Package net.sf.jaxodraw.object
Class JaxoObjectList<E extends JaxoObject>
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractList<E>
-
- java.util.ArrayList<E>
-
- net.sf.jaxodraw.object.JaxoObjectList<E>
-
- Type Parameters:
E
- the element type of this list.
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
,java.lang.Iterable<E>
,java.util.Collection<E>
,java.util.List<E>
,java.util.RandomAccess
,JaxoList<E>
public class JaxoObjectList<E extends JaxoObject> extends java.util.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
-
-
Constructor Summary
Constructors Constructor Description JaxoObjectList()
Just calls super().JaxoObjectList(int initialCapacity)
Just calls super(initialCapacity).JaxoObjectList(java.util.Collection<? extends E> c)
Add all elements of c to this List.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description JaxoList<E>
copyOf()
Returns a copy of this JaxoList, i.e., a new JaxoList with copies of equal JaxoObjects at equal positions.java.awt.Rectangle
getBounds()
Returns the smallest bounding box that contains all the JaxoObjects of this JaxoList.java.awt.Rectangle
getBoundsExcept(java.util.Collection<? extends E> excludes)
Returns the smallest bounding box that contains all the JaxoObjects of this JaxoList except the ones contained in 'except'.java.awt.Rectangle
intersection(java.awt.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(java.util.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(java.util.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(java.awt.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, equals, forEach, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeIf, removeRange, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray, trimToSize
-
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, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray
-
-
-
-
Constructor Detail
-
JaxoObjectList
public JaxoObjectList()
Just calls super().
-
JaxoObjectList
public JaxoObjectList(java.util.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 interfaceJaxoList<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 interfaceJaxoList<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(java.util.Collection<? extends E> excludes, JaxoGraphics2D g)
Call paint on all elements of JaxoObjects that are not contained in 'excludes'.- Specified by:
paintExcept
in interfaceJaxoList<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(java.util.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 interfaceJaxoList<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 interfaceJaxoList<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 interfaceJaxoList<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 interfaceJaxoList<E extends JaxoObject>
- Parameters:
deltaX
- The displacement in x directiondeltaY
- The displacement in y direction
-
setColor
public void setColor(java.awt.Color c)
Sets the color of all JaxoObjects in this list.- Specified by:
setColor
in interfaceJaxoList<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 interfaceJaxoList<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 interfaceJaxoList<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 interfaceJaxoList<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 interfaceJaxoList<E extends JaxoObject>
- Returns:
- True if the list was modified by this operation, i.e., there were marked objects in the list.
-
getBounds
public java.awt.Rectangle getBounds()
Returns the smallest bounding box that contains all the JaxoObjects of this JaxoList.- Specified by:
getBounds
in interfaceJaxoList<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 java.awt.Rectangle getBoundsExcept(java.util.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 interfaceJaxoList<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 java.awt.Rectangle intersection(java.awt.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 interfaceJaxoList<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()
-
-