Class JaxoObjectList<E extends JaxoObject>

  • 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
    • Field Summary

      • Fields inherited from class java.util.AbstractList

        modCount
    • 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.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.lang.Iterable

        forEach
      • 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

      • 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 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​(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 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​(java.awt.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 java.awt.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 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 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 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 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()