com.bbn.openmap.omGraphics
Class OMGraphicList

java.lang.Object
  extended bycom.bbn.openmap.omGraphics.geom.BasicGeometry
      extended bycom.bbn.openmap.omGraphics.OMGraphic
          extended bycom.bbn.openmap.omGraphics.OMGraphicList
All Implemented Interfaces:
java.lang.Cloneable, GraphicList, OMGeometry, OMGraphicConstants, java.io.Serializable
Direct Known Subclasses:
CustomGraphic, EsriGraphicList, FeatureCacheGraphicList, LinkOMGraphicList, OMGeometryList, OMGraphicHash, OMGrid, ScenarioGraphicLoader.ScenarioGraphicList

public class OMGraphicList
extends OMGraphic
implements GraphicList, 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
protected static class OMGraphicList.OMDist
          RetVal for closest object/distance calculations.
 
Field Summary
protected  boolean allowDuplicates
          Flag used to allow duplicates in the OMGraphicList.
static int FIRST_ADDED_ON_TOP
          Used to set the order in which the list is traversed to draw or search the objects.
protected  java.util.List graphics
          The list of graphics.
static int LAST_ADDED_ON_TOP
          Used to set the order in which the list is traversed to draw or search the objects.
static int NONE
          Used for searches, when OMDist doesn't have a graphic.
protected  boolean processAllGeometries
          Override flag for shouldProcess method.
protected  int traverseMode
          List traversal mode.
protected  boolean vague
          Flag to adjust behavior of OMGraphicList for certain queries.
 
Fields inherited from class com.bbn.openmap.omGraphics.OMGraphic
declutterType, displayPaint, edgeMatchesFill, fillPaint, hasLabel, linePaint, matted, mattingPaint, renderType, selected, selectPaint, showEditablePalette, stroke, textureMask
 
Fields inherited from class com.bbn.openmap.omGraphics.geom.BasicGeometry
APP_OBJECT_KEY, appObject, ATT_MAP_KEY, lineType, needToRegenerate, shape, visible
 
Fields inherited from interface com.bbn.openmap.omGraphics.OMGraphicConstants
ADD_GRAPHIC_MASK, 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, INFOLINE, LABEL, LINETYPE_GREATCIRCLE, LINETYPE_RHUMB, LINETYPE_STRAIGHT, LINETYPE_UNKNOWN, LOWER_GRAPHIC_MASK, LOWER_TO_BOTTOM_GRAPHIC_MASK, 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
 
Constructor Summary
OMGraphicList()
          Construct an OMGraphicList.
OMGraphicList(int initialCapacity)
          Construct an OMGraphicList with an initial capacity.
OMGraphicList(int initialCapacity, int capacityIncrement)
          Deprecated. capacityIncrement no longer used.
OMGraphicList(java.util.List list)
          Construct an OMGraphicList around a List of OMGraphics.
 
Method Summary
protected  void _add(OMGeometry g)
          Add an OMGeometry to the list.
protected  void _doAction(OMGeometry graphic, OMAction action)
          Perform an action on the provided geometry.
protected  OMGraphicList.OMDist _findClosest(int x, int y, float limit)
          Calls _findClosest(x, y, limit, false);
protected  OMGraphicList.OMDist _findClosest(int x, int y, float limit, boolean resetSelect)
          Find the closest Object and its distance.
protected  OMGeometry _getAt(int location)
          Get the geometry at the location number on the list.
protected  OMGeometry _getContains(int x, int y)
          Finds the first OMGeometry (the one on top) that is under this pixel.
protected  OMGeometry _getWithAppObject(java.lang.Object appObj)
          Get the graphic with the appObject.
protected  int _indexOf(OMGeometry geometry)
          Return the index of the OMGeometry in the list.
protected  void _insert(OMGeometry geometry, int location)
          Insert the geometry at the location number.
protected  java.lang.Object _remove(int location)
          Remove the graphic at a location in the list.
protected  boolean _remove(OMGeometry geometry)
          Remove the graphic.
protected  OMGeometry _selectClosest(int x, int y, float limit)
          Finds the object located the closest to the point, if the object distance away is within the limit, and sets the paint of that graphic to its select paint.
protected  void _setAt(OMGeometry graphic, int index)
          Set the geometry at the specified location.
 void add(OMGraphic g)
          Add an OMGraphic to the list.
 void addOMGraphic(OMGraphic g)
          Add an OMGraphic to the GraphicList.
protected  void checkForDuplicate(OMGeometry g)
          Convenience function for methods that may add a OMGeometry.
 void clear()
          Remove all elements from the graphic list.
 java.lang.Object clone()
          Generic return of SinkGraphic for subclasses that don't implement clone properly for some reason.
 boolean contains(OMGeometry g)
          Checks if an OMGeometry is on this list.
 void deselect()
          If you call deselect() on an OMGraphicList, it deselects all the graphics it contains.
 void deselectAll()
          Deselects all the items on the graphic list.
 float distance(int x, int y)
          Finds the distance to the closest OMGeometry.
 void doAction(OMGraphic graphic, OMAction action)
          Perform an action on the provided graphic.
 OMGraphicList findAll(int x, int y, float limit)
          Find all of the OMGraphics on this list that are located within the pixel limit of the x, y pixel location.
protected  OMGraphicList findAll(int x, int y, float limit, boolean resetSelect, OMGraphicList addTo)
          Find all of the OMGraphics on this list that are located within the pixel limit of the x, y pixel location.
protected  boolean findAllTest(int x, int y, float limit, boolean resetSelect, OMGraphicList addTo, OMGeometry omg, OMGraphicList.OMDist omd)
          Test to find out if an OMGeometry is located within the pixel limit of the x, y pixel location.
 OMGraphic findClosest(int x, int y)
          Finds the object located the closest to the point, regardless of how far away it is.
 OMGraphic findClosest(int x, int y, float limit)
          Finds the object located the closest to the point, if the object distance away is within the limit.
protected  OMGraphicList.OMDist findClosestTest(OMGraphicList.OMDist current, int index, OMGeometry graphic, int x, int y, float limit, boolean resetSelect)
          Test the omgraphic distance away from the x, y point, and compare it to the current OMDist passed in.
 int findIndexOfClosest(int x, int y)
          Finds the object located the closest to the point, regardless of how far away it is.
 int findIndexOfClosest(int x, int y, float limit)
          Finds the object located the closest to the point, if the object distance away is within the limit.
 boolean generate(Projection p)
          Prepare the graphics for rendering.
 void generate(Projection p, boolean forceProjectAll)
          Prepare the graphics for rendering.
 boolean getAllowDuplicates()
          Get whether the list will allow duplicate entries added.
 java.lang.String getDescription()
          OMGraphic method for returning a simple description of the list.
 java.lang.String getDescription(int level)
          OMGraphic method, for returning a simple description if the contents of the list.
 OMGraphic getOMGraphicAt(int location)
          Get the graphic at the location number on the list.
 OMGraphic getOMGraphicThatContains(int x, int y)
          Finds the first OMGraphic (the one on top) that is under this pixel.
 OMGraphic getOMGraphicWithAppObject(java.lang.Object appObj)
          Get the graphic with the appObject.
 boolean getProcessAllGeometries()
          Get the settings for the programmatic override for shouldProcess method to always process geometries.
 java.util.List getTargets()
          Get a reference to the graphics vector.
 int getTraverseMode()
          Get the order in which the list is traversed to draw or search the objects.
 int indexOf(OMGraphic graphic)
          Return the index of the OMGraphic in the list.
 void insertOMGraphicAt(OMGraphic graphic, int location)
          Insert the graphic at the location number.
 boolean isEmpty()
          Find out if the list is empty.
 boolean isVague()
          Get whether the list returns the specific OMGraphic in response to a query, or itself.
 boolean isVisible()
          Get the visibility variable.
 java.util.Iterator iterator()
          Get an Iterator containing the OMGeometrys.
 void moveIndexedOneToBack(int location)
          Moves the graphic at the given index toward the back of the list by one spot, sliding the other graphic up on in the list in order.
 void moveIndexedOneToBottom(int location)
          Moves the graphic at the given index to the part of the list where it will be drawn under one of the other graphics, its neighbor on the list.
 void moveIndexedOneToFront(int location)
          Moves the graphic at the given index toward the front of the list by one spot, sliding the other graphic back on in the list in order.
 void moveIndexedOneToTop(int location)
          Moves the graphic at the given index to the part of the list where it will be drawn on top of one of the other graphics which is its neighbor on the list.
 void moveIndexedToBottom(int location)
          Moves the graphic at the given index to the part of the list where it will be drawn under all of the other graphics.
 void moveIndexedToFirst(int location)
          Moves the graphic at the given index to the front of the list, sliding the other graphics back on in the list in order.
 void moveIndexedToLast(int location)
          Moves the graphic at the given index to the end of the list, sliding the other graphics up on in the list in order.
 void moveIndexedToTop(int location)
          Moves the graphic at the given index to the part of the list where it will be drawn on top of the other graphics.
protected  OMGraphic objectToOMGraphic(java.lang.Object obj)
          Convenience method to cast an object to an OMGraphic if it is one.
 void project(Projection p)
          Projects any graphics needing projection.
 void project(Projection p, boolean forceProjectAll)
          Projects the OMGeometrys on the list.
 void readGraphics(java.io.ObjectInputStream objstream)
          Read a cache of OMGraphics, given a ObjectInputStream.
 void readGraphics(java.net.URL cacheURL)
          Read a cache of OMGeometrys, given an URL.
 boolean remove(OMGraphic graphic)
          Remove the graphic.
 void removeOMGraphicAt(int location)
          Remove the graphic at the location number.
 void render(java.awt.Graphics gr)
          Renders all the objects in the list a graphics context.
 void renderAllAsSelected(java.awt.Graphics gr)
          Renders all the objects in the list a graphics context, in their 'selected' mode.
 void select()
          If you call select() on an OMGraphicList, it selects all the graphics it contains.
 void selectAll()
          Selects all the items on the graphic list.
 OMGraphic selectClosest(int x, int y)
          Finds the object located the closest to the coordinates, regardless of how far away it is.
 OMGraphic selectClosest(int x, int y, float limit)
          Finds the object located the closest to the point, if the object distance away is within the limit, and sets the paint of that graphic to its select paint.
protected  OMGraphicList.OMDist selectClosestTest(OMGraphicList.OMDist current, int index, OMGeometry graphic, int x, int y, float limit)
          A variation on findClosestTest, manages select() and deselect().
 void setAllowDuplicates(boolean set)
          Set whether the list will allow duplicate entries added.
 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 setProcessAllGeometries(boolean set)
          Set the programmatic override for shouldProcess method to always process geometries.
 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 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 setTraverseMode(int mode)
          Set the order in which the list is traversed to draw or search the objects.
 void setVague(boolean value)
          Set whether the list returns the specific OMGraphic in response to a query, or itself.
 void setVisible(boolean visible)
          Set the visibility variable.
protected  boolean shouldProcess(OMGeometry omg)
          This method is called internally for those methods where skipping invisible OMGeometries would save processing time and effort.
 int size()
          Find out the number of graphics in the list.
 void sort()
          This sort method is a placeholder 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.OMGraphic
getDeclutterType, getDisplayColor, getDisplayPaint, getEdgeMatchesFill, getFillColor, getFillPaint, getHasLabel, getLineColor, getLinePaint, getMattingPaint, getRenderType, getSelectColor, getSelectPaint, getShowEditablePalette, getStroke, getTextureMask, hasLineTypeChoice, initLabelingDuringGenerate, isClear, isMatted, isSelected, normalizeDistanceForLineWidth, regenerate, renderLabel, setDeclutterType, setEdgeMatchesFill, setFillColor, setGraphicsColor, setGraphicsForEdge, setGraphicsForFill, setHasLabel, setLabelLocation, setLabelLocation, setLabelLocation, setLineColor, setRenderType, setSelectColor, setSelected, setShape, setShowEditablePalette, shouldRenderEdge, shouldRenderFill
 
Methods inherited from class com.bbn.openmap.omGraphics.geom.BasicGeometry
_distance, appendShapeEdge, appendShapeEdge, appendShapeEdge, appendShapeEdge, checkAttributeMap, checkAttributeMap, clearAttributes, contains, createAttributeMap, createBoxShape, createShape, createShape, describeShapeDetail, describeShapeDetail, distanceToEdge, draw, fill, getAppObject, getAppObject, getAttribute, getAttributeMap, getAttributes, getLineType, getNeedToRegenerate, getShape, isRenderable, putAttribute, removeAttribute, replaceAppObjectWithAttributeMap, setAppObject, setAppObject, setAttributes, setLineType, setNeedToRegenerate
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.bbn.openmap.omGraphics.OMGeometry
clearAttributes, contains, draw, fill, getAppObject, getAttribute, getAttributes, getLineType, getNeedToRegenerate, getShape, isRenderable, putAttribute, removeAttribute, setAppObject, setAttributes, setLineType, setNeedToRegenerate
 

Field Detail

LAST_ADDED_ON_TOP

public static final transient int LAST_ADDED_ON_TOP
Used to set the order in which the list is traversed to draw or search the objects. This means that the last things on the list will be on top of the map because they are drawn last, on top of everything else. For searches, objects added last to the list will be considered first for a search match.

See Also:
Constant Field Values

FIRST_ADDED_ON_TOP

public static final transient int FIRST_ADDED_ON_TOP
Used to set the order in which the list is traversed to draw or search the objects. This means that the first things on the list will appear on top because they are drawn last, on top of everything else. For searches, objects added first to the list will be considered first for a search match. This is the default mode for the list.

See Also:
Constant Field Values

NONE

public static final int NONE
Used for searches, when OMDist doesn't have a graphic. The index of a null graphic is NONE. If you try to remove or insert a graphic at NONE, an exception will be thrown. If you try to get a graphic at NONE, you'll get null;

See Also:
Constant Field Values

traverseMode

protected int traverseMode
List traversal mode. The default is FIRST_ADDED_ON_TOP.


vague

protected boolean vague
Flag to adjust behavior of OMGraphicList for certain queries. If OMGraphicList should act as OMGraphic, the entire list will be treated as one object. Otherwise, the list will act as a pass-through container, and internal OMGraphics will be returned. This applies to distance(), selectClosest(), findClosest(), getOMGraphicThatContains(), etc. This flag becomes really helpful for embedded OMGraphicLists, not so much for top-level OMGraphicLists.


graphics

protected java.util.List graphics
The list of graphics. Once an OMGraphicList is constructed, this variable should never be null.


allowDuplicates

protected boolean allowDuplicates
Flag used to allow duplicates in the OMGraphicList. True by default - this prevents the list from doing the extra work for checking for duplicates at addition time.


processAllGeometries

protected boolean processAllGeometries
Override flag for shouldProcess method. The setting will override the OMGraphicList from using the OMGraphic's visibility settings in determining which OMGraphics should be used in different distance, generate and render methods.

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(int initialCapacity,
                     int capacityIncrement)
Deprecated. capacityIncrement no longer used.

Construct an OMGraphicList with an initial capacity and a standard increment value.

Parameters:
initialCapacity - the initial capacity of the list
capacityIncrement - the capacityIncrement for resizing

OMGraphicList

public OMGraphicList(java.util.List list)
Construct an OMGraphicList around a List of OMGraphics. The OMGraphicList assumes that all the objects on the list are OMGraphics, and never does checking. Live with the consequences if you put other stuff in there.

Parameters:
list - List of OMGraphics.
Method Detail

getDescription

public java.lang.String getDescription()
OMGraphic method for returning a simple description of the list. This is really a debugging method.

Overrides:
getDescription in class OMGraphic

getDescription

public java.lang.String getDescription(int level)
OMGraphic method, for returning a simple description if the contents of the list. This method handles the spacing of sub-member descriptions. This is really a debugging method.

Overrides:
getDescription in class OMGraphic
Parameters:
level - used by OMGraphicLists to provide an offset, or a notion of embedding.
Returns:
String that represents the structure of the OMGraphicList.

setVague

public void setVague(boolean value)
Set whether the list returns the specific OMGraphic in response to a query, or itself.


isVague

public boolean isVague()
Get whether the list returns the specific OMGraphic in response to a query, or itself.


addOMGraphic

public void addOMGraphic(OMGraphic g)
Add an OMGraphic to the GraphicList. The OMGraphic must not be null.

Parameters:
g - the non-null OMGraphic to add
Throws:
java.lang.IllegalArgumentException - if OMGraphic is null

add

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


_add

protected void _add(OMGeometry g)
Add an OMGeometry to the list.


setTraverseMode

public void setTraverseMode(int mode)
Set the order in which the list is traversed to draw or search the objects. The possible modes for the list are FIRST_ADDED_ON_TOP or LAST_ADDED_ON_TOP.

Parameters:
mode - traversal mode

getTraverseMode

public int getTraverseMode()
Get the order in which the list is traversed to draw or search the objects. The possible modes for the list are FIRST_ADDED_ON_TOP or LAST_ADDED_ON_TOP.

Returns:
int traversal mode

clear

public void clear()
Remove all elements from the graphic list.


isEmpty

public boolean isEmpty()
Find out if the list is empty.

Returns:
boolean true if the list is empty, false if not

size

public int size()
Find out the number of graphics in the list.

Returns:
int the number of graphics on the list.

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 location)
Get the graphic at the location number on the list.

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()

_getAt

protected OMGeometry _getAt(int location)
Get the geometry at the location number on the list.

Parameters:
location - the location of the OMGeometry to return
Returns:
OMGraphic or null if location > list size
Throws:
java.lang.ArrayIndexOutOfBoundsException - if location < 0 or location >= this.size()

_setAt

protected void _setAt(OMGeometry graphic,
                      int index)
Set the geometry at the specified location. The OMGeometry must not be null.

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

getOMGraphicWithAppObject

public OMGraphic getOMGraphicWithAppObject(java.lang.Object appObj)
Get the graphic with the appObject. Traverse mode doesn't matter. Tests object identity first, then tries equality.

Parameters:
appObj - appObject of the wanted graphic.
Returns:
OMGraphic or null if not found
See Also:
Object.equals(java.lang.Object), OMGeometry.setAppObject(java.lang.Object), OMGeometry.getAppObject()

_getWithAppObject

protected OMGeometry _getWithAppObject(java.lang.Object appObj)
Get the graphic with the appObject. Traverse mode doesn't matter. Tests object identity first, then tries equality.

If this list contains OMGraphicLists that are not vague, and the those lists' appObject doesn't match, the object will be passed to those lists as well for a check, with their OMGraphic being passed back with a successful search.

Parameters:
appObj - appObject of the wanted graphic.
Returns:
OMGraphic or null if not found
See Also:
Object.equals(java.lang.Object), OMGeometry.setAppObject(java.lang.Object), OMGeometry.getAppObject()

removeOMGraphicAt

public void removeOMGraphicAt(int location)
Remove the graphic at the location number.

Parameters:
location - the location of the OMGraphic to remove.

remove

public boolean remove(OMGraphic graphic)
Remove the graphic.

Parameters:
graphic - the OMGraphic object to remove.
Returns:
true if graphic was on the list, false if otherwise.

_remove

protected java.lang.Object _remove(int location)
Remove the graphic at a location in the list.

Parameters:
location - the OMGraphic object to remove.
Returns:
true if graphic was on the list, false if otherwise.

_remove

protected boolean _remove(OMGeometry geometry)
Remove the graphic. If this list is not vague, it will also ask sub-OMGraphicLists to remove it if the geometry isn't found on this OMGraphicList.

Parameters:
geometry - the OMGeometry object to remove.
Returns:
true if geometry was on the list, false if otherwise.

indexOf

public int indexOf(OMGraphic graphic)
Return the index of the OMGraphic in the list.

Parameters:
graphic - the graphic to look for
Returns:
the index in the list of the graphic, -1 if the object is not found.

_indexOf

protected int _indexOf(OMGeometry geometry)
Return the index of the OMGeometry in the list.

Parameters:
geometry - the geometry to look for
Returns:
the index in the list of the geometry, -1 if the object is not found.

insertOMGraphicAt

public void insertOMGraphicAt(OMGraphic graphic,
                              int location)
Insert the graphic at the location number. The OMGraphic must not be null.

Parameters:
graphic - the OMGraphic to insert.
location - the location of the OMGraphic to insert
Throws:
java.lang.IllegalArgumentException - if OMGraphic is null
java.lang.ArrayIndexOutOfBoundsException - if index is out-of-bounds

_insert

protected void _insert(OMGeometry geometry,
                       int location)
Insert the geometry at the location number. The OMGeometry must not be null.

Parameters:
geometry - the OMGeometry to insert.
location - the location of the OMGeometry to insert
Throws:
java.lang.IllegalArgumentException - if OMGeometry is null
java.lang.ArrayIndexOutOfBoundsException - if index is out-of-bounds

moveIndexedOneToTop

public void moveIndexedOneToTop(int location)
Moves the graphic at the given index to the part of the list where it will be drawn on top of one of the other graphics which is its neighbor on the list. This method does check to see what the traverseMode of the list is, and calls either moveIndexedToLast or moveIndexedToFirst, depending on what is appropriate.

Parameters:
location - the index location of the graphic to move.
See Also:
moveIndexedOneToFront(int), moveIndexedOneToBack(int)

moveIndexedToTop

public void moveIndexedToTop(int location)
Moves the graphic at the given index to the part of the list where it will be drawn on top of the other graphics. This method does check to see what the traverseMode of the list is, and calls either moveIndexedToLast or moveIndexedToFirst, depending on what is appropriate.

Parameters:
location - the index location of the graphic to move.

moveIndexedOneToBottom

public void moveIndexedOneToBottom(int location)
Moves the graphic at the given index to the part of the list where it will be drawn under one of the other graphics, its neighbor on the list. This method does check to see what the traverseMode of the list is, and calls either moveIndexedOneToBack or moveIndexedOneToFront, depending on what is appropriate.

Parameters:
location - the index location of the graphic to move.
See Also:
moveIndexedOneToFront(int), moveIndexedOneToBack(int)

moveIndexedToBottom

public void moveIndexedToBottom(int location)
Moves the graphic at the given index to the part of the list where it will be drawn under all of the other graphics. This method does check to see what the traverseMode of the list is, and calls either moveIndexedToLast or moveIndexedToFirst, depending on what is appropriate.

Parameters:
location - the index location of the graphic to move.

moveIndexedToFirst

public void moveIndexedToFirst(int location)
Moves the graphic at the given index to the front of the list, sliding the other graphics back on in the list in order. If the location is already at the beginning or beyond the end, nothing happens.

Parameters:
location - the index of the graphic to move.
See Also:
moveIndexedToBottom(int), moveIndexedToTop(int)

moveIndexedOneToFront

public void moveIndexedOneToFront(int location)
Moves the graphic at the given index toward the front of the list by one spot, sliding the other graphic back on in the list in order. If the location is already at the beginning or beyond the end, nothing happens.

Parameters:
location - the index of the graphic to move.

moveIndexedToLast

public void moveIndexedToLast(int location)
Moves the graphic at the given index to the end of the list, sliding the other graphics up on in the list in order. If the location is already at the end or less than zero, nothing happens.

Parameters:
location - the index of the graphic to move.
See Also:
moveIndexedToBottom(int), moveIndexedToTop(int)

moveIndexedOneToBack

public void moveIndexedOneToBack(int location)
Moves the graphic at the given index toward the back of the list by one spot, sliding the other graphic up on in the list in order. If the location is already at the end or less than zero, nothing happens.

Parameters:
location - the index of the graphic to move.

setStroke

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

Overrides:
setStroke in class OMGraphic
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.

Overrides:
setFillPaint in class OMGraphic
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.

Overrides:
setTextureMask in class OMGraphic

setLinePaint

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

Overrides:
setLinePaint in class OMGraphic
Parameters:
paint - java.awt.Paint

setSelectPaint

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

Overrides:
setSelectPaint in class OMGraphic
Parameters:
paint - java.awt.Paint

setMattingPaint

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

Overrides:
setMattingPaint in class OMGraphic
Parameters:
paint - java.awt.Paint

setMatted

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

Overrides:
setMatted in class OMGraphic

project

public void project(Projection p)
Projects any graphics needing projection. Use this method to project any new or changed OMGeometrys before painting. to re-project the whole list, use generate(Projection, boolean) with forceProjectAll set to true. This is the same as calling generate(p, false)

Parameters:
p - a Projection
See Also:
generate(Projection, boolean)

project

public void project(Projection p,
                    boolean forceProjectAll)
Projects the OMGeometrys on the list. This is the same as calling generate(p, forceProjectAll).

Parameters:
p - a Projection
forceProjectAll - if true, all the graphics on the list are generated with the new projection. If false they are only generated if getNeedToRegenerate() returns true
See Also:
generate(Projection, boolean)

generate

public boolean generate(Projection p)
Prepare the graphics for rendering. This is the same as calling project(p, true).

Specified by:
generate in interface OMGeometry
Specified by:
generate in class OMGraphic
Parameters:
p - a Projection
Returns:
boolean true
See Also:
generate(Projection, boolean)

generate

public void generate(Projection p,
                     boolean forceProjectAll)
Prepare the graphics for rendering. This must be done before calling render()! This recursively calls generate() on the OMGraphics on the list.

Parameters:
p - a Projection
forceProjectAll - if true, all the graphics on the list are generated with the new projection. If false they are only generated if getNeedToRegenerate() returns true
See Also:
OMGraphic.generate(com.bbn.openmap.proj.Projection), OMGraphic.regenerate(com.bbn.openmap.proj.Projection)

render

public void render(java.awt.Graphics gr)
Renders all the objects in the list a graphics context. This is the same as paint() for AWT components. The graphics are rendered in the order of traverseMode. Any graphics where isVisible() returns false are not rendered.

Overrides:
render in class OMGraphic
Parameters:
gr - the AWT Graphics context

renderAllAsSelected

public void renderAllAsSelected(java.awt.Graphics gr)
Renders all the objects in the list a graphics context, in their 'selected' mode. This is the same as paint() for AWT components. The graphics are rendered in the order of traverseMode. Any graphics where isVisible() returns false are not rendered. All of the graphics on the list are returned to their deselected state.

Parameters:
gr - the AWT Graphics context

shouldProcess

protected boolean shouldProcess(OMGeometry omg)
This method is called internally for those methods where skipping invisible OMGeometries would save processing time and effort. If you don't want visiblilty to be considered when processing OMGeometries/OMGraphics, override this method and return true.


setProcessAllGeometries

public void setProcessAllGeometries(boolean set)
Set the programmatic override for shouldProcess method to always process geometries.


getProcessAllGeometries

public boolean getProcessAllGeometries()
Get the settings for the programmatic override for shouldProcess method to always process geometries.


distance

public float distance(int x,
                      int y)
Finds the distance to the closest OMGeometry.

Specified by:
distance in interface OMGeometry
Overrides:
distance in class OMGraphic
Parameters:
x - x coord
y - y coord
Returns:
float distance
See Also:
findClosest(int, int, float)

_findClosest

protected OMGraphicList.OMDist _findClosest(int x,
                                            int y,
                                            float limit,
                                            boolean resetSelect)
Find the closest Object and its distance. The search is always conducted from the topmost graphic to the bottommost, depending on the traverseMode.

Parameters:
x - x coord
y - y coord
limit - the max distance that a graphic has to be within to be returned, in pixels.
resetSelect - deselect any OMGraphic touched.
Returns:
OMDist

findClosestTest

protected OMGraphicList.OMDist findClosestTest(OMGraphicList.OMDist current,
                                               int index,
                                               OMGeometry graphic,
                                               int x,
                                               int y,
                                               float limit,
                                               boolean resetSelect)
Test the omgraphic distance away from the x, y point, and compare it to the current OMDist passed in. If the graphic is the new closest, return the same OMDist object filled in with the new value. Otherwise, return null.

Parameters:
current - the OMDist that contains the current best result of a search.
index - the index in the graphic list of the provied OMGeometry
graphic - the OMGeometry to test
x - the window horiontal pixel value.
y - the window vertical pixel value.
resetSelect - flag to call deselect on any OMGeometry contacted. Used here to pass on in case the OMGeometry provided is an OMGraphicList, and to use to decide if deselect should be called on the provided graphic.
Returns:
OMDist with an OMGraphic if the graphic passed in is the current closest. OMDist.graphic could be null, OMDist.d could be Infinity.

findClosest

public OMGraphic findClosest(int x,
                             int y,
                             float limit)
Finds the object located the closest to the point, if the object distance away is within the limit. The search is always conducted from the topmost graphic to the bottommost, depending on the traverseMode. Any graphics where isVisible() returns false are not considered.

Parameters:
x - the x coordinate on the component the graphics are displayed on.
y - the y coordinate on the component the graphics are displayed on.
limit - the max distance that a graphic has to be within to be returned, in pixels.
Returns:
OMGraphic the closest on the list within the limit, or null if not found.

findAll

public OMGraphicList findAll(int x,
                             int y,
                             float limit)
Find all of the OMGraphics on this list that are located within the pixel limit of the x, y pixel location.

Parameters:
x - the x coordinate on the component the graphics are displayed on.
y - the y coordinate on the component the graphics are displayed on.
limit - the max distance that a graphic has to be within to be returned, in pixels.
Returns:
OMGraphicList containing all of the OMGraphics within the limit.

findAll

protected OMGraphicList findAll(int x,
                                int y,
                                float limit,
                                boolean resetSelect,
                                OMGraphicList addTo)
Find all of the OMGraphics on this list that are located within the pixel limit of the x, y pixel location.

Parameters:
x - the x coordinate on the component the graphics are displayed on.
y - the y coordinate on the component the graphics are displayed on.
limit - the max distance that a graphic has to be within to be returned, in pixels.
resetSelect - call deselect on OMGraphics not within limit.
addTo - OMGraphicList to add found OMGraphics to, if null a list will be created.
Returns:
OMGraphicList containing all of the OMGraphics within the limit, empty if none are found.

findAllTest

protected boolean findAllTest(int x,
                              int y,
                              float limit,
                              boolean resetSelect,
                              OMGraphicList addTo,
                              OMGeometry omg,
                              OMGraphicList.OMDist omd)
Test to find out if an OMGeometry is located within the pixel limit of the x, y pixel location.

Parameters:
x - the x coordinate on the component the graphics are displayed on.
y - the y coordinate on the component the graphics are displayed on.
limit - the max distance that a graphic has to be within to be returned, in pixels.
resetSelect - call deselect on OMGeometry not within limit.
addTo - OMGraphicList to add found OMGeometries to, if null a list will be created.
omg - OMGeometry to test.
omd - OMDist to use for test, provided to avoid recurring memory allocations for loops.
Returns:
true of this method should still be called again in a loop, false of this list is vague and we have a hit.

findClosest

public OMGraphic findClosest(int x,
                             int y)
Finds the object located the closest to the point, regardless of how far away it is. This method returns null if the list is not valid. The search starts at the first-added graphic.
This is the same as calling findClosest(x, y, Float.MAX_VALUE).

Parameters:
x - the horizontal pixel position of the window, from the left of the window.
y - the vertical pixel position of the window, from the top of the window.
Returns:
the closest graphic to the xy window point.
See Also:
findClosest(int, int, float)

findIndexOfClosest

public int findIndexOfClosest(int x,
                              int y,
                              float limit)
Finds the object located the closest to the point, if the object distance away is within the limit. The search is always conducted from the topmost graphic to the bottommost, depending on the traverseMode. Any graphics where isVisible() returns false are not considered.

Parameters:
x - the x coordinate on the component the graphics are displayed on.
y - the y coordinate on the component the graphics are displayed on.
limit - the max distance that a graphic has to be within to be returned, in pixels.
Returns:
index of the closest on the list within the limit, or OMGeometryList.NONE if not found.

findIndexOfClosest

public int findIndexOfClosest(int x,
                              int y)
Finds the object located the closest to the point, regardless of how far away it is. This method returns null if the list is not valid. The search starts at the first-added graphic.
This is the same as calling findClosest(x, y, Float.MAX_VALUE).

Parameters:
x - the horizontal pixel position of the window, from the left of the window.
y - the vertical pixel position of the window, from the top of the window.
Returns:
index of the closest graphic to the xy window point, or OMGeometryList.NONE if not found.
See Also:
findIndexOfClosest(int, int, float)

_findClosest

protected OMGraphicList.OMDist _findClosest(int x,
                                            int y,
                                            float limit)
Calls _findClosest(x, y, limit, false);


selectClosest

public OMGraphic selectClosest(int x,
                               int y)
Finds the object located the closest to the coordinates, regardless of how far away it is. Sets the select paint of that object, and resets the paint of all the other objects. The search starts at the first-added graphic.

Parameters:
x - the x coordinate on the component the graphics are displayed on.
y - the y coordinate on the component the graphics are displayed on.
Returns:
the closest OMGraphic on the list, with selected having been called on that OMGraphics. This OMGraphic will be within the limit or null if none found. Will return this list if this list is set to be vague.

selectClosest

public OMGraphic selectClosest(int x,
                               int y,
                               float limit)
Finds the object located the closest to the point, if the object distance away is within the limit, and sets the paint of that graphic to its select paint. It sets the paints to all the other objects to the regular paint. The search starts at the first-added graphic. Any graphics where isVisible() returns false are not considered.

Parameters:
x - the horizontal pixel position of the window, from the left of the window.
y - the vertical pixel position of the window, from the top of the window.
limit - the max distance that a graphic has to be within to be returned, in pixels.
Returns:
the closest OMGraphic on the list, with selected having been called on that OMGraphics. This OMGraphic will be within the limit or null if none found. Will return this list if this list is set to be vague.

_selectClosest

protected OMGeometry _selectClosest(int x,
                                    int y,
                                    float limit)
Finds the object located the closest to the point, if the object distance away is within the limit, and sets the paint of that graphic to its select paint. It sets the paints to all the other objects to the regular paint. The search starts at the first-added graphic. Any graphics where isVisible() returns false are not considered.

Parameters:
x - the horizontal pixel position of the window, from the left of the window.
y - the vertical pixel position of the window, from the top of the window.
limit - the max distance that a graphic has to be within to be returned, in pixels.
Returns:
the closest OMGraphic on the list, with selected having been called on that OMGraphics. This OMGraphic will be within the limit or null if none found. Will return this list if this list is set to be vague.

selectClosestTest

protected OMGraphicList.OMDist selectClosestTest(OMGraphicList.OMDist current,
                                                 int index,
                                                 OMGeometry graphic,
                                                 int x,
                                                 int y,
                                                 float limit)
A variation on findClosestTest, manages select() and deselect().

Parameters:
current - the OMDist that contains the current best result of a search.
index - the index in the graphic list of the provied OMGeometry
graphic - the OMGeometry to test
x - the window horiontal pixel value.
y - the window vertical pixel value.
Returns:
OMDist if the graphic passed in is the current closest. OMGeometry will be set in OMDist and selected(). OMGeometry will be deselected if not the closest, and the OMDist will be null. This method will return this list if it is set to be vague and one of its children meet the criteria.

select

public void select()
If you call select() on an OMGraphicList, it selects all the graphics it contains. This is really an OMGraphic method, but it makes OMGraphicLists embedded in other OMGraphicLists act correctly.

Specified by:
select in interface OMGeometry
Overrides:
select in class OMGraphic

getOMGraphicThatContains

public OMGraphic getOMGraphicThatContains(int x,
                                          int y)
Finds the first OMGraphic (the one on top) that is under this pixel.

Parameters:
x - the horizontal pixel position of the window, from the left of the window.
y - the vertical pixel position of the window, from the top of the window.
Returns:
the graphic that contains the pixel, NONE (null) if none are found.

_getContains

protected OMGeometry _getContains(int x,
                                  int y)
Finds the first OMGeometry (the one on top) that is under this pixel. If an OMGeometry is an OMGraphicList, its contents will be checked. If that check is successful and OMGraphicList is not vague, its OMGeometry will be returned - otherwise the list will be returned.

Parameters:
x - the horizontal pixel position of the window, from the left of the window.
y - the vertical pixel position of the window, from the top of the window.
Returns:
the graphic that contains the pixel, NONE (null) if none are found.

deselect

public void deselect()
If you call deselect() on an OMGraphicList, it deselects all the graphics it contains. This is really an OMGraphic method, but it makes OMGraphicLists embedded in other OMGraphicLists act correctly.

Specified by:
deselect in interface OMGeometry
Overrides:
deselect in class OMGraphic

deselectAll

public void deselectAll()
Deselects all the items on the graphic list.


selectAll

public void selectAll()
Selects all the items on the graphic list.


doAction

public void doAction(OMGraphic graphic,
                     OMAction action)
Perform an action on the provided graphic. If the graphic is not currently on the list, it is added (if the action doesn't say to delete it). If the graphic is null, the list checks for an action to take on the list (deselectAll).


_doAction

protected void _doAction(OMGeometry graphic,
                         OMAction action)
Perform an action on the provided geometry. If the geometry is not currently on the list, it is added (if the action doesn't say to delete it). If the geometry is null, the list checks for an action to take on the list (deselectAll).


setVisible

public void setVisible(boolean visible)
Set the visibility variable. NOTE:
This is checked by the OMGeometryList when it iterates through its list for render and gesturing. It is not checked by the internal OMGeometry methods, although maybe it should be...

Specified by:
setVisible in interface OMGeometry
Overrides:
setVisible in class BasicGeometry
Parameters:
visible - boolean

isVisible

public boolean isVisible()
Get the visibility variable. For the OMGeometryList, if any part of it is visible, then it is considered visible.

Specified by:
isVisible in interface OMGeometry
Overrides:
isVisible in class BasicGeometry
Returns:
boolean

setAllowDuplicates

public void setAllowDuplicates(boolean set)
Set whether the list will allow duplicate entries added. If not, then the copy will be added, and the previous version removed.


getAllowDuplicates

public boolean getAllowDuplicates()
Get whether the list will allow duplicate entries added. If not, then the copy will be added, and the previous version removed.


checkForDuplicate

protected void checkForDuplicate(OMGeometry g)
Convenience function for methods that may add a OMGeometry. Method checks to see if duplicates are allowed, and if they are not, it will remove the OMGeometry from the list. The calling method can be confident that it will be adding a unqiue OMGeometry. Internal methods that call this method should be synchronized on the graphics list.


contains

public boolean contains(OMGeometry g)
Checks if an OMGeometry is on this list. Checks sublists, too.


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 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 OMGeometryList if it's being used in two or more threads...

Returns:
a reference of the graphics List.

setTargets

public void setTargets(java.util.List 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.


iterator

public java.util.Iterator iterator()
Get an Iterator containing the OMGeometrys.


readGraphics

public void readGraphics(java.net.URL cacheURL)
                  throws java.io.IOException
Read a cache of OMGeometrys, 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 placeholder for OMGraphicList extensions to implement their own particular criteria for sorting an OMGraphicList. Does nothing for a generic OMGraphicList.


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.


clone

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

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


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