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:
Serializable
,Cloneable
,Iterable<E>
,Collection<E>
,List<E>
,RandomAccess
,SequencedCollection<E>
,JaxoList<E>
Implementation of JaxoList.
This should ensure that only JaxoObjects are added as elements.
- Since:
- 2.0
- See Also:
-
Field Summary
Fields inherited from class java.util.AbstractList
modCount
-
Constructor Summary
ConstructorsConstructorDescriptionJust calls super().JaxoObjectList
(int initialCapacity) Just calls super(initialCapacity).JaxoObjectList
(Collection<? extends E> c) Add all elements of c to this List. -
Method Summary
Modifier and TypeMethodDescriptioncopyOf()
Returns a copy of this JaxoList, i.e., a new JaxoList with copies of equal JaxoObjects at equal positions.Returns the smallest bounding box that contains all the JaxoObjects of this JaxoList.getBoundsExcept
(Collection<? extends E> excludes) Returns the smallest bounding box that contains all the JaxoObjects of this JaxoList except the ones contained in 'except'.intersection
(Rectangle inside) Intersection of the bounding box of this JaxoList with the given Rectangle.boolean
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
Call paint(g) on all elements of JaxoObjects.void
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
Removes all marked JaxoObjects from this list.void
Sets the color of all JaxoObjects in this list.boolean
Moves the specified JaxoObject to the last position in this list.boolean
Moves the specified JaxoObject to the first position in this list.Methods inherited from class java.util.ArrayList
add, add, addAll, addAll, addFirst, addLast, clear, clone, contains, ensureCapacity, equals, forEach, get, getFirst, getLast, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeFirst, removeIf, removeLast, removeRange, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray, trimToSize
Methods inherited from class java.util.AbstractCollection
containsAll, toString
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
Methods inherited from interface java.util.List
add, add, addAll, addAll, addFirst, addLast, clear, contains, containsAll, equals, get, getFirst, getLast, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeFirst, removeLast, replaceAll, retainAll, reversed, set, size, sort, spliterator, subList, toArray, toArray
-
Constructor Details
-
JaxoObjectList
public JaxoObjectList()Just calls super(). -
JaxoObjectList
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 Details
-
paint
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:
-
paintClipped
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:
-
paintExcept
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:
-
paintClippedExcept
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:
-
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
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
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
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
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
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
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
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:
-