net.sf.jaxodraw.object
Class JaxoObjectList<E extends JaxoObject>

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<E>
          extended by java.util.ArrayList<E>
              extended by net.sf.jaxodraw.object.JaxoObjectList<E>
Type Parameters:
E - the element type of this list.
All Implemented Interfaces:
Serializable, Cloneable, Iterable<E>, Collection<E>, List<E>, RandomAccess, JaxoList<E>

public class JaxoObjectList<E extends JaxoObject>
extends ArrayList<E>
implements JaxoList<E>

Implementation of JaxoList. This should ensure that only JaxoObjects are added as elements.

Since:
2.0
See Also:
Serialized Form

Field Summary
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
JaxoObjectList()
          Just calls super().
JaxoObjectList(Collection<? extends E> c)
          Add all elements of c to this List.
JaxoObjectList(int initialCapacity)
          Just calls super(initialCapacity).
 
Method Summary
 JaxoList<E> copyOf()
          Returns a copy of this JaxoList, i.e., a new JaxoList with copies of equal JaxoObjects at equal positions.
 Rectangle getBounds()
          Returns the smallest bounding box that contains all the JaxoObjects of this JaxoList.
 Rectangle getBoundsExcept(Collection<? extends E> excludes)
          Returns the smallest bounding box that contains all the JaxoObjects of this JaxoList except the ones contained in 'except'.
 Rectangle intersection(Rectangle inside)
          Intersection of the bounding box of this JaxoList with the given Rectangle.
 boolean isCopy(JaxoList<E> list)
          Determines if this JaxoList is a copy of the specified one.
 void move(int index, int newIndex)
          Move the object at 'index' to 'newIndex', leaving all other elements in order.
 void moveAllObjects(int deltaX, int deltaY)
          Displaces all JaxoObjects by the same amount.
 void paint(JaxoGraphics2D g)
          Call paint(g) on all elements of JaxoObjects.
 void paintClipped(JaxoGraphics2D g)
          Call paint on all elements of JaxoObjects if they intersect the current clipping area of the given graphics context.
 void paintClippedExcept(Collection<? extends E> excludes, JaxoGraphics2D g)
          Call paint on all elements of JaxoObjects that are not contained in 'excludes' and that intersect the current clipping area of the given graphics context.
 void paintExcept(Collection<? extends E> excludes, JaxoGraphics2D g)
          Call paint on all elements of JaxoObjects that are not contained in 'excludes'.
 boolean removeMarkedObjects()
          Removes all marked JaxoObjects from this list.
 void setColor(Color c)
          Sets the color of all JaxoObjects in this list.
 boolean toEnd(E object)
          Moves the specified JaxoObject to the last position in this list.
 boolean toFront(E object)
          Moves the specified JaxoObject to the first position in this list.
 
Methods inherited from class java.util.ArrayList
add, add, addAll, addAll, clear, clone, contains, ensureCapacity, get, indexOf, isEmpty, lastIndexOf, remove, remove, removeRange, set, size, toArray, toArray, trimToSize
 
Methods inherited from class java.util.AbstractList
equals, hashCode, iterator, listIterator, listIterator, subList
 
Methods inherited from class java.util.AbstractCollection
containsAll, removeAll, retainAll, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
add, add, addAll, addAll, clear, contains, containsAll, equals, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, retainAll, set, size, subList, toArray, toArray
 

Constructor Detail

JaxoObjectList

public JaxoObjectList()
Just calls super().


JaxoObjectList

public JaxoObjectList(Collection<? extends E> c)
Add all elements of c to this List.

Parameters:
c - the collection whose elements are to be placed into this list.

JaxoObjectList

public JaxoObjectList(int initialCapacity)
Just calls super(initialCapacity).

Parameters:
initialCapacity - the initial capacity of the list.
Method Detail

paint

public void paint(JaxoGraphics2D g)
Call paint(g) on all elements of JaxoObjects.

Specified by:
paint in interface JaxoList<E extends JaxoObject>
Parameters:
g - The graphics context to paint to.
See Also:
JaxoObject.paint(JaxoGraphics2D)

paintClipped

public void paintClipped(JaxoGraphics2D g)
Call paint on all elements of JaxoObjects if they intersect the current clipping area of the given graphics context.

Specified by:
paintClipped in interface JaxoList<E extends JaxoObject>
Parameters:
g - The graphics context to paint to.
See Also:
JaxoObject.paint(JaxoGraphics2D), Graphics.hitClip(int,int,int,int)

paintExcept

public void paintExcept(Collection<? extends E> excludes,
                        JaxoGraphics2D g)
Call paint on all elements of JaxoObjects that are not contained in 'excludes'.

Specified by:
paintExcept in interface JaxoList<E extends JaxoObject>
Parameters:
excludes - The JaxoObjects to exlude.
g - The graphics context to paint to.
See Also:
JaxoObject.paint(JaxoGraphics2D)

paintClippedExcept

public void paintClippedExcept(Collection<? extends E> excludes,
                               JaxoGraphics2D g)
Call paint on all elements of JaxoObjects that are not contained in 'excludes' and that intersect the current clipping area of the given graphics context.

Specified by:
paintClippedExcept in interface JaxoList<E extends JaxoObject>
Parameters:
excludes - The JaxoObjects to exlude.
g - The graphics context to paint to.
See Also:
JaxoObject.paint(JaxoGraphics2D), Graphics.hitClip(int,int,int,int)

copyOf

public JaxoList<E> copyOf()
Returns a copy of this JaxoList, i.e., a new JaxoList with copies of equal JaxoObjects at equal positions.

Specified by:
copyOf in interface JaxoList<E extends JaxoObject>
Returns:
A copy of this JaxoList.

isCopy

public boolean isCopy(JaxoList<E> list)
Determines if this JaxoList is a copy of the specified one.

Specified by:
isCopy in interface JaxoList<E extends JaxoObject>
Parameters:
list - The JaxoList to compare against.
Returns:
True if the JaxoLists contain identical JaxoObjects at equal positions.

moveAllObjects

public void moveAllObjects(int deltaX,
                           int deltaY)
Displaces all JaxoObjects by the same amount.

Specified by:
moveAllObjects in interface JaxoList<E extends JaxoObject>
Parameters:
deltaX - The displacement in x direction
deltaY - The displacement in y direction

setColor

public void setColor(Color c)
Sets the color of all JaxoObjects in this list.

Specified by:
setColor in interface JaxoList<E extends JaxoObject>
Parameters:
c - The color to set.

move

public void move(int index,
                 int newIndex)
Move the object at 'index' to 'newIndex', leaving all other elements in order.

Specified by:
move in interface JaxoList<E extends JaxoObject>
Parameters:
index - The index of the object to move.
newIndex - The new index of the object.

toEnd

public boolean toEnd(E object)
Moves the specified JaxoObject to the last position in this list.

Specified by:
toEnd in interface JaxoList<E extends JaxoObject>
Parameters:
object - The JaxoObject to move.
Returns:
True if the object was already in the last position, i.e., the JaxoList has not been modified.

toFront

public boolean toFront(E object)
Moves the specified JaxoObject to the first position in this list.

Specified by:
toFront in interface JaxoList<E extends JaxoObject>
Parameters:
object - The JaxoObject to move.
Returns:
True if the JaxoObject was already in the first position, i.e., the JaxoList has not been modified.

removeMarkedObjects

public boolean removeMarkedObjects()
Removes all marked JaxoObjects from this list.

Specified by:
removeMarkedObjects in interface JaxoList<E extends JaxoObject>
Returns:
True if the list was modified by this operation, i.e., there were marked objects in the list.

getBounds

public Rectangle getBounds()
Returns the smallest bounding box that contains all the JaxoObjects of this JaxoList.

Specified by:
getBounds in interface JaxoList<E extends JaxoObject>
Returns:
A Rectangle holding the bounds of this JaxoList, or null if the List is empty (ie contains no objects).

getBoundsExcept

public Rectangle getBoundsExcept(Collection<? extends E> excludes)
Returns the smallest bounding box that contains all the JaxoObjects of this JaxoList except the ones contained in 'except'.

Specified by:
getBoundsExcept in interface JaxoList<E extends JaxoObject>
Parameters:
excludes - objects to exclude, may be null.
Returns:
A Rectangle holding the bounds of the current JaxoList, or null if the List is empty (ie contains no objects).

intersection

public Rectangle intersection(Rectangle inside)
Intersection of the bounding box of this JaxoList with the given Rectangle. This returns null if either any of the two rectangles are null, or if they do not intersect.

Specified by:
intersection in interface JaxoList<E extends JaxoObject>
Parameters:
inside - The Rectangle to intersect with.
Returns:
The intersection, or null if either any of the two rectangles are null, or if they do not intersect.
See Also:
JaxoList.getBounds()


Copyright © 2003-2011 The JaxoDraw team. All Rights Reserved.