com.bbn.openmap.omGraphics
Class OMGraphicList

java.lang.Object
  extended by com.bbn.openmap.omGraphics.geom.BasicGeometry
      extended by com.bbn.openmap.omGraphics.OMGraphicAdapter
          extended by com.bbn.openmap.omGraphics.OMList<OMGraphic>
              extended by com.bbn.openmap.omGraphics.OMGraphicList
All Implemented Interfaces:
OMGeometry, OMGraphic, OMGraphicConstants, java.io.Serializable, java.lang.Cloneable, java.lang.Iterable<OMGraphic>, java.util.Collection<OMGraphic>, java.util.List<OMGraphic>
Direct Known Subclasses:
CustomGraphic, DTEDCoverageManager, EsriGraphicList, FeatureCacheGraphicList, LinkOMGraphicList, OMGraphicHash, OMGrid, RpfCoverage, RpfCoverage.RpfCoverageControl, TemporalOMGraphicList, TimelineLayer.CurrentTimeMarker, TimelineLayer.PlayFilter, TimelineLayer.TimeHashMarks

public class OMGraphicList
extends OMList<OMGraphic>
implements java.io.Serializable

This class encapsulates a List of OMGraphics.

There are several things that this list does that make it better that any ol' List. You can make several common OMGraphic modification calls on the list, and the list handles the iteration and changing of all the graphics while taking into account a travese order.

An additional benefit is that because the OMGraphicList extends OMGraphic it can contain other instances of OMGraphicList. This way you can manage groupings of graphics, (for instance, an OMGraphicList of OMGraphicLists which each have an OMRaster and OMText).

Many methods, such as generate() and findClosest() traverse the items in the GraphicsList recursively. The direction that the list is traversed is controlled by then traverseMode variable. The traverseMode mode lets you set whether the first or last object added to the list (FIRST_ADDED_ON_TOP or LAST_ADDED_ON_TOP) is drawn on top of the list and considered first for searches.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class com.bbn.openmap.omGraphics.OMList
OMList.OMDist<T>
 
Field Summary
 
Fields inherited from class com.bbn.openmap.omGraphics.OMList
allowDuplicates, FIRST_ADDED_ON_TOP, graphics, LAST_ADDED_ON_TOP, NONE, processAllGeometries, traverseMode, vague
 
Fields inherited from class com.bbn.openmap.omGraphics.OMGraphicAdapter
declutterType, displayPaint, edgeMatchesFill, fillPaint, hasLabel, linePaint, matted, mattingPaint, renderType, selected, selectPaint, showEditablePalette, stroke, textureMask
 
Fields inherited from class com.bbn.openmap.omGraphics.geom.BasicGeometry
attributes, lineType, needToRegenerate, shape, visible
 
Fields inherited from interface com.bbn.openmap.omGraphics.OMGraphicConstants
ADD_GRAPHIC_MASK, APP_OBJECT, BASIC_STROKE, CHANGE_APPEARANCE, clear, DECIMAL_DEGREES, DECLUTTERTYPE_LINE, DECLUTTERTYPE_MOVE, DECLUTTERTYPE_NONE, DECLUTTERTYPE_SPACE, DEFAULT_ROTATIONANGLE, DELETE_GRAPHIC_MASK, DESELECT_GRAPHIC_MASK, DESELECTALL_GRAPHIC_MASK, GRAPHICTYPE_ARC, GRAPHICTYPE_BITMAP, GRAPHICTYPE_CIRCLE, GRAPHICTYPE_ELLIPSE, GRAPHICTYPE_GRAPHIC, GRAPHICTYPE_GRID, GRAPHICTYPE_LINE, GRAPHICTYPE_POINT, GRAPHICTYPE_POLY, GRAPHICTYPE_RASTER, GRAPHICTYPE_RECTANGLE, GRAPHICTYPE_TEXT, INDEX, INFOLINE, LABEL, LINETYPE_GREATCIRCLE, LINETYPE_RHUMB, LINETYPE_STRAIGHT, LINETYPE_UNKNOWN, LOWER_GRAPHIC_MASK, LOWER_TO_BOTTOM_GRAPHIC_MASK, NO_ROTATE, OMGRAPHIC_ELT, OMGRAPHIC_TYPE_ATTR, RADIANS, RAISE_GRAPHIC_MASK, RAISE_TO_TOP_GRAPHIC_MASK, REMOVABLE, RENDERTYPE_LATLON, RENDERTYPE_OFFSET, RENDERTYPE_UNKNOWN, RENDERTYPE_XY, SELECT_GRAPHIC_MASK, SORT_GRAPHICS_MASK, TOOLTIP, UPDATE_GRAPHIC_MASK, UPDATED
 
Constructor Summary
OMGraphicList()
          Construct an OMGraphicList.
OMGraphicList(java.util.Collection<OMGraphic> c)
          Construct an OMGraphicList to include a Collection of OMGraphics.
OMGraphicList(int initialCapacity)
          Construct an OMGraphicList with an initial capacity.
 
Method Summary
 void add(int index, OMGraphic element)
           
 boolean add(OMGraphic g)
          Add an OMGraphic to the list.
 boolean addAll(java.util.Collection<? extends OMGraphic> c)
           
 boolean addAll(int index, java.util.Collection<? extends OMGraphic> c)
           
 java.lang.Object clone()
          Generic return of SinkGraphic for subclasses that don't implement clone properly.
 OMList<OMGraphic> create()
           
protected  OMList.OMDist<OMGraphic> createDist()
           
 OMGraphic get(int location)
          Get the geometry at the location number on the list.
 OMGraphic getOMGraphicAt(int index)
           
 java.util.List<OMGraphic> getTargets()
          Get a reference to the graphics vector.
 java.util.Iterator<OMGraphic> iteratorCopy()
          Returns a iterator of a shallow copy of the current list, to avoid concurrent modification exceptions if the list is being generated or rendered while the list is being reviewed for other reasons.
 java.util.ListIterator<OMGraphic> listIteratorCopy()
          Returns a iterator of a shallow copy of the current list, to avoid concurrent modification exceptions if the list is being generated or rendered while the list is being reviewed for other reasons.
 java.util.ListIterator<OMGraphic> listIteratorCopy(int size)
          Returns a iterator of a shallow copy of the current list, to avoid concurrent modification exceptions if the list is being generated or rendered while the list is being reviewed for other reasons.
protected  OMGraphic objectToOMGraphic(java.lang.Object obj)
          Convenience method to cast an object to an OMGraphic if it is one.
 void readGraphics(java.io.ObjectInputStream objstream)
          Read a cache of OMGraphics, given a ObjectInputStream.
 void readGraphics(java.net.URL cacheURL)
          Read a cache of OMGraphics, given an URL.
 OMGraphic remove(int location)
          Remove the geometry at the location number.
 OMGraphic set(int index, OMGraphic element)
           
 void setFillPaint(java.awt.Paint paint)
          Set the fill paint for all the objects on the list.
 void setGridGenerator(OMGridGenerator generator, Projection proj)
          Goes through the list, finds the OMGrid objects, and sets the generator for all of them.
 void setLinePaint(java.awt.Paint paint)
          Set the line paint for all the objects on the list.
 void setMatted(boolean value)
          Set the matting flag for all the objects on the list.
 void setMattingPaint(java.awt.Paint paint)
          Set the matting paint for all the objects on the list.
 void setOMGraphicAt(OMGraphic graphic, int index)
          Set the graphic at the specified location.
 void setSelectPaint(java.awt.Paint paint)
          Set the selection paint for all the objects on the list.
 void setStroke(java.awt.Stroke stroke)
          Set the stroke of all the graphics on the list.
 void setTargets(java.util.List<OMGraphic> list)
          Set the List used to hold the OMGraphics.
 void setTextureMask(java.awt.TexturePaint texture)
          Set the texture mask for the OMGraphics on the list.
 void sort()
          This sort method is a place-holder for OMGraphicList extensions to implement their own particular criteria for sorting an OMGraphicList.
 void writeGraphics(java.io.ObjectOutputStream objectstream)
          Write the graphics out to a ObjectOutputStream
 void writeGraphics(java.lang.String graphicsSaveFile)
          Write the graphics out to a file
 
Methods inherited from class com.bbn.openmap.omGraphics.OMList
checkForDuplicate, clear, contains, contains, containsAll, deselect, distance, doAction, findAll, findAll, findAllTest, findClosest, findClosest, findClosest, findClosestTest, findIndexOfClosest, findIndexOfClosest, generate, generate, getAllowDuplicates, getContains, getCopy, getDescription, getDescription, getProcessAllGeometries, getTraverseMode, indexOf, isEmpty, isVague, isVisible, iterator, lastIndexOf, listIterator, listIterator, moveIndexedOneToBack, moveIndexedOneToBottom, moveIndexedOneToFront, moveIndexedOneToTop, moveIndexedToBottom, moveIndexedToFirst, moveIndexedToLast, moveIndexedToTop, project, project, remove, removeAll, render, renderAllAsSelected, restore, retainAll, select, selectClosest, selectClosest, selectClosestTest, setAllowDuplicates, setProcessAllGeometries, setTraverseMode, setVague, setVisible, shouldProcess, size, subList, toArray, toArray
 
Methods inherited from class com.bbn.openmap.omGraphics.OMGraphicAdapter
getDeclutterType, getDisplayColor, getDisplayPaint, getEdgeMatchesFill, getFillColor, getFillPaint, getHasLabel, getLineColor, getLinePaint, getMattingPaint, getRenderType, getSelectColor, getSelectPaint, getShowEditablePalette, getStroke, getTextureMask, hasLineTypeChoice, initLabelingDuringGenerate, isClear, isMatted, isSelected, normalizeDistanceForLineWidth, readStroke, readTextureMask, regenerate, renderLabel, renderShape, setDeclutterType, setEdgeMatchesFill, setFillColor, setGraphicsColor, setGraphicsForEdge, setGraphicsForFill, setHasLabel, setLabelLocation, setLabelLocation, setLabelLocation, setLabelLocation, setLabelLocation, setLabelLocation, setLabelLocation, setLabelLocation, setLineColor, setRenderType, setSelectColor, setSelected, setShowEditablePalette, shouldRenderEdge, shouldRenderFill, writeStroke, writeTextureMask
 
Methods inherited from class com.bbn.openmap.omGraphics.geom.BasicGeometry
_distance, appendShapeEdge, appendShapeEdge, appendShapeEdge, appendShapeEdge, clearAttributes, contains, createAttributeMap, createBoxShape, createShape, createShape, describeShapeDetail, describeShapeDetail, distanceToEdge, distanceToEdge, draw, draw, fill, fill, getAppObject, getAttribute, getAttributes, getLineType, getNeedToRegenerate, getShape, isRenderable, isRenderable, putAttribute, removeAttribute, setAppObject, setAttributes, setLineType, setNeedToRegenerate, setShape
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.List
equals, hashCode
 
Methods inherited from interface com.bbn.openmap.omGraphics.OMGraphic
getDeclutterType, getDisplayColor, getDisplayPaint, getFillColor, getFillPaint, getLineColor, getLinePaint, getMattingPaint, getRenderType, getSelectColor, getSelectPaint, getShowEditablePalette, getStroke, getTextureMask, hasLineTypeChoice, isMatted, isSelected, normalizeDistanceForLineWidth, regenerate, renderLabel, setDeclutterType, setGraphicsColor, setGraphicsForEdge, setGraphicsForFill, setLabelLocation, setLabelLocation, setLabelLocation, setRenderType, setSelected, setShowEditablePalette, shouldRenderEdge, shouldRenderFill
 
Methods inherited from interface com.bbn.openmap.omGraphics.OMGeometry
clearAttributes, contains, distanceToEdge, draw, draw, fill, fill, getAppObject, getAttribute, getAttributes, getLineType, getNeedToRegenerate, getShape, isRenderable, isRenderable, putAttribute, removeAttribute, setAppObject, setAttributes, setLineType, setNeedToRegenerate, setShape
 

Constructor Detail

OMGraphicList

public OMGraphicList()
Construct an OMGraphicList.


OMGraphicList

public OMGraphicList(int initialCapacity)
Construct an OMGraphicList with an initial capacity.

Parameters:
initialCapacity - the initial capacity of the list

OMGraphicList

public OMGraphicList(java.util.Collection<OMGraphic> c)
Construct an OMGraphicList to include a Collection of OMGraphics.

Parameters:
c - Collection of OMGraphics.
Method Detail

iteratorCopy

public java.util.Iterator<OMGraphic> iteratorCopy()
Returns a iterator of a shallow copy of the current list, to avoid concurrent modification exceptions if the list is being generated or rendered while the list is being reviewed for other reasons.


listIteratorCopy

public java.util.ListIterator<OMGraphic> listIteratorCopy()
Returns a iterator of a shallow copy of the current list, to avoid concurrent modification exceptions if the list is being generated or rendered while the list is being reviewed for other reasons.


listIteratorCopy

public java.util.ListIterator<OMGraphic> listIteratorCopy(int size)
Returns a iterator of a shallow copy of the current list, to avoid concurrent modification exceptions if the list is being generated or rendered while the list is being reviewed for other reasons.


add

public boolean add(OMGraphic g)
Add an OMGraphic to the list.

Specified by:
add in interface java.util.Collection<OMGraphic>
Specified by:
add in interface java.util.List<OMGraphic>
Overrides:
add in class OMList<OMGraphic>

setOMGraphicAt

public void setOMGraphicAt(OMGraphic graphic,
                           int index)
Set the graphic at the specified location. The OMGraphic must not be null.

Parameters:
graphic - OMGraphic
index - index of the OMGraphic to return
Throws:
java.lang.ArrayIndexOutOfBoundsException - if index is out-of-bounds

getOMGraphicAt

public OMGraphic getOMGraphicAt(int index)

get

public OMGraphic get(int location)
Get the geometry at the location number on the list.

Specified by:
get in interface java.util.List<OMGraphic>
Parameters:
location - the location of the OMGraphic to return
Returns:
OMGraphic or null if location > list size
Throws:
java.lang.ArrayIndexOutOfBoundsException - if location < 0 or location >= this.size()

setStroke

public void setStroke(java.awt.Stroke stroke)
Set the stroke of all the graphics on the list.

Specified by:
setStroke in interface OMGraphic
Overrides:
setStroke in class OMGraphicAdapter
Parameters:
stroke - the stroke object to use.
See Also:
Stroke, BasicStroke

setFillPaint

public void setFillPaint(java.awt.Paint paint)
Set the fill paint for all the objects on the list.

Specified by:
setFillPaint in interface OMGraphic
Overrides:
setFillPaint in class OMGraphicAdapter
Parameters:
paint - java.awt.Paint

setTextureMask

public void setTextureMask(java.awt.TexturePaint texture)
Set the texture mask for the OMGraphics on the list. If not null, then it will be rendered on top of the fill paint. If the fill paint is clear, the texture mask will not be used. If you just want to render the texture mask as is, set the fill paint of the graphic instead. This is really to be used to have a texture added to the graphic, with the fill paint still influencing appearance.

Specified by:
setTextureMask in interface OMGraphic
Overrides:
setTextureMask in class OMGraphicAdapter

setLinePaint

public void setLinePaint(java.awt.Paint paint)
Set the line paint for all the objects on the list.

Specified by:
setLinePaint in interface OMGraphic
Overrides:
setLinePaint in class OMGraphicAdapter
Parameters:
paint - java.awt.Paint

setSelectPaint

public void setSelectPaint(java.awt.Paint paint)
Set the selection paint for all the objects on the list.

Specified by:
setSelectPaint in interface OMGraphic
Overrides:
setSelectPaint in class OMGraphicAdapter
Parameters:
paint - java.awt.Paint

setMattingPaint

public void setMattingPaint(java.awt.Paint paint)
Set the matting paint for all the objects on the list.

Specified by:
setMattingPaint in interface OMGraphic
Overrides:
setMattingPaint in class OMGraphicAdapter
Parameters:
paint - java.awt.Paint

setMatted

public void setMatted(boolean value)
Set the matting flag for all the objects on the list.

Specified by:
setMatted in interface OMGraphic
Overrides:
setMatted in class OMGraphicAdapter

setGridGenerator

public void setGridGenerator(OMGridGenerator generator,
                             Projection proj)
Goes through the list, finds the OMGrid objects, and sets the generator for all of them. If a projection is passed in, the generator will be used to create a displayable graphic within the grid.

Parameters:
generator - an OMGridGenerator to create a renderable graphic from the OMGrid.
proj - a projection to use to generate the graphic. If null, the generator will create a renderable graphic the next time a projection is handed to the list.

getTargets

public java.util.List<OMGraphic> getTargets()
Get a reference to the graphics vector. This method is meant for use by methods that need to iterate over the graphics vector, or make at least two invocations on the graphics vector.

HACK this method should either return a clone of the graphics list or a quick reference. Currently it returns the latter for simplicity and minor speed improvement. We should allow a way for the user to set the desired behavior, depending on whether they want responsibility for list synchronization. Right now, the user is responsible for synchronizing the OMGraphicList if it's being used in two or more threads...

Returns:
a reference of the graphics List.

setTargets

public void setTargets(java.util.List<OMGraphic> list)
Set the List used to hold the OMGraphics. The OMGraphicList assumes that this list contains OMGraphics. Make *SURE* this is the case. The OMGraphicList will behave badly if there are non-OMGraphics on the list.


readGraphics

public void readGraphics(java.net.URL cacheURL)
                  throws java.io.IOException
Read a cache of OMGraphics, given an URL.

Parameters:
cacheURL - URL of serialized graphic list.
Throws:
java.io.IOException

readGraphics

public void readGraphics(java.io.ObjectInputStream objstream)
                  throws java.io.IOException
Read a cache of OMGraphics, given a ObjectInputStream.

Parameters:
objstream - ObjectInputStream of graphic list.
Throws:
java.io.IOException

writeGraphics

public void writeGraphics(java.lang.String graphicsSaveFile)
                   throws java.io.IOException
Write the graphics out to a file

Parameters:
graphicsSaveFile -
Throws:
java.io.IOException

writeGraphics

public void writeGraphics(java.io.ObjectOutputStream objectstream)
                   throws java.io.IOException
Write the graphics out to a ObjectOutputStream

Parameters:
objectstream - ObjectOutputStream
Throws:
java.io.IOException

sort

public void sort()
This sort method is a place-holder for OMGraphicList extensions to implement their own particular criteria for sorting an OMGraphicList. Does nothing for a generic OMGraphicList.

Overrides:
sort in class OMList<OMGraphic>

objectToOMGraphic

protected OMGraphic objectToOMGraphic(java.lang.Object obj)
Convenience method to cast an object to an OMGraphic if it is one. Returns null if it isn't.

Overrides:
objectToOMGraphic in class OMList<OMGraphic>

clone

public java.lang.Object clone()
Description copied from class: OMGraphicAdapter
Generic return of SinkGraphic for subclasses that don't implement clone properly.

Specified by:
clone in interface OMGraphic
Overrides:
clone in class OMGraphicAdapter
Returns:
a duplicate list full of shallow copies of each of the OMGraphics contained on the list.

create

public OMList<OMGraphic> create()
Specified by:
create in class OMList<OMGraphic>

createDist

protected OMList.OMDist<OMGraphic> createDist()
Specified by:
createDist in class OMList<OMGraphic>

add

public void add(int index,
                OMGraphic element)
Specified by:
add in interface java.util.List<OMGraphic>
Overrides:
add in class OMList<OMGraphic>

addAll

public boolean addAll(java.util.Collection<? extends OMGraphic> c)
Specified by:
addAll in interface java.util.Collection<OMGraphic>
Specified by:
addAll in interface java.util.List<OMGraphic>

addAll

public boolean addAll(int index,
                      java.util.Collection<? extends OMGraphic> c)
Specified by:
addAll in interface java.util.List<OMGraphic>

set

public OMGraphic set(int index,
                     OMGraphic element)
Specified by:
set in interface java.util.List<OMGraphic>

remove

public OMGraphic remove(int location)
Remove the geometry at the location number.

Specified by:
remove in interface java.util.List<OMGraphic>
Overrides:
remove in class OMList<OMGraphic>
Parameters:
location - the location of the OMGeometry to remove


Copyright (C) BBNT Solutions LLC; See http://openmap.bbn.com/ for details