Class ColoredOverlayCollection
Object
ColoredOverlayCollection
Like a
OverlayCollection but additionally associates a color with each overlay.- Author:
- Owen Feehan
-
Constructor Summary
ConstructorsConstructorDescriptionCreate an empty collection.ColoredOverlayCollection(OverlayCollection overlays, ColorList colors) Creates a newColoredOverlayCollectioninstance. -
Method Summary
Modifier and TypeMethodDescriptionvoidAppend an overlay and its respective color to the end of the list..getColor(int index) Access a particular color in the collection by index.The list of colors, each element corresponding tooverlays.getOverlay(int index) Access a particularOverlayin the collection by index.The collection of overlays, each element corresponding tocolors.iterator()intsize()The total number of elements in the list.subsetWhereBoxIntersects(Dimensions scene, DrawOverlay drawOverlay, List<BoundingBox> toIntersectWith) Find overlays whose bounding-boxes intersect with any of the boxes intoIntersectWith.toString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
ColoredOverlayCollection
public ColoredOverlayCollection()Create an empty collection. -
ColoredOverlayCollection
Creates a newColoredOverlayCollectioninstance.- Parameters:
overlays- The collection of overlays, each element corresponding tocolors.colors- The list of colors, each element corresponding tooverlays.
-
-
Method Details
-
add
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
-
size
public int size()The total number of elements in the list.- Returns:
- the total number of elements.
-
getOverlay
Access a particularOverlayin 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 < 0 || index >= size())
-
getColor
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 < 0 || index >= size())
-
toString
-
subsetWhereBoxIntersects
public ColoredOverlayCollection subsetWhereBoxIntersects(Dimensions scene, DrawOverlay drawOverlay, List<BoundingBox> toIntersectWith) Find overlays whose bounding-boxes intersect with any of the boxes intoIntersectWith.- 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
ColoredOverlayCollectioncontaining the elements (uncopied) which match the criteria. This may be empty if no elements match the criteria.
-
getOverlays
The collection of overlays, each element corresponding tocolors. -
getColors
The list of colors, each element corresponding tooverlays.
-