Class ColoredOverlayCollection

Object
ColoredOverlayCollection
All Implemented Interfaces:
Iterable<Overlay>

public class ColoredOverlayCollection extends Object implements Iterable<Overlay>
Like a OverlayCollection but additionally associates a color with each overlay.
Author:
Owen Feehan
  • Constructor Details

    • ColoredOverlayCollection

      public ColoredOverlayCollection()
      Create an empty collection.
    • ColoredOverlayCollection

      public ColoredOverlayCollection(OverlayCollection overlays, ColorList colors)
      Creates a new ColoredOverlayCollection instance.
      Parameters:
      overlays - The collection of overlays, each element corresponding to colors.
      colors - The list of colors, each element corresponding to overlays.
  • Method Details

    • add

      public void add(Overlay overlay, RGBColor color)
      Append an overlay and its respective color to the end of the list..
      Parameters:
      overlay - the overlay to append.
      color - the corresponding color of the overlay.
    • iterator

      public Iterator<Overlay> iterator()
      Specified by:
      iterator in interface Iterable<Overlay>
    • size

      public int size()
      The total number of elements in the list.
      Returns:
      the total number of elements.
    • getOverlay

      public Overlay getOverlay(int index)
      Access a particular Overlay in the collection by index.
      Parameters:
      index - the index (starting at 0).
      Returns:
      the respective element at index index.
      Throws:
      IndexOutOfBoundsException - if the index is out of range (index &lt; 0 || index &gt;= size())
    • getColor

      public RGBColor getColor(int index)
      Access a particular color in the collection by index.
      Parameters:
      index - the index (starting at 0).
      Returns:
      the respective element at index index.
      Throws:
      IndexOutOfBoundsException - if the index is out of range (index &lt; 0 || index &gt;= size())
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • subsetWhereBoxIntersects

      public ColoredOverlayCollection subsetWhereBoxIntersects(Dimensions scene, DrawOverlay drawOverlay, List<BoundingBox> toIntersectWith)
      Find overlays whose bounding-boxes intersect with any of the boxes in toIntersectWith.
      Parameters:
      scene - the size of the image in which all bounding-boxes must fully fit inside.
      drawOverlay - what draws the overlays on the image, and thus determines the bounding-box of an overlay.
      toIntersectWith - the list of boxes against which elements are searched for any intersection.
      Returns:
      a newly created ColoredOverlayCollection containing the elements (uncopied) which match the criteria. This may be empty if no elements match the criteria.
    • getOverlays

      public OverlayCollection getOverlays()
      The collection of overlays, each element corresponding to colors.
    • getColors

      public ColorList getColors()
      The list of colors, each element corresponding to overlays.