com.bbn.openmap.omGraphics
Class OMGeometryList

java.lang.Object
  extended bycom.bbn.openmap.omGraphics.geom.BasicGeometry
      extended bycom.bbn.openmap.omGraphics.OMGraphic
          extended bycom.bbn.openmap.omGraphics.OMGraphicList
              extended bycom.bbn.openmap.omGraphics.OMGeometryList
All Implemented Interfaces:
java.lang.Cloneable, GraphicList, OMGeometry, OMGraphicConstants, java.io.Serializable
Direct Known Subclasses:
OMAreaList

public class OMGeometryList
extends OMGraphicList
implements GraphicList, java.io.Serializable

This class encapsulates a List of OMGeometries. It's an OMGraphic, so it contains information on how to draw them. It's also a subclass to the OMGraphicList, and relies on many OMGraphicList methods.

The OMGeometryList assumes that all OMGeometries on it should be rendered the same - same fill color, same edge color and stroke, and will create one java.awt.Shape object from all the projected OMGeometries for more efficient rendering. If your individual OMGeometries have independing rendering characteristics, use the OMGraphicList and OMGraphics.

Because the OMGeometryList creates a single java.awt.Shape object for all of its contents, it needs to be generated() if an OMGeometry is added or removed from the list. If you don't regenerate the OMGeometryList, the list will iterate through its contents and render each piece separately.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class com.bbn.openmap.omGraphics.OMGraphicList
OMGraphicList.OMDist
 
Field Summary
protected  boolean connectParts
          Flag to mark that the parts should be connected, making this OMGeometryList a combination OMGraphic that sums disparate parts.
 
Fields inherited from class com.bbn.openmap.omGraphics.OMGraphicList
allowDuplicates, FIRST_ADDED_ON_TOP, graphics, LAST_ADDED_ON_TOP, NONE, processAllGeometries, traverseMode, vague
 
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
OMGeometryList()
          Construct an OMGeometryList.
OMGeometryList(int initialCapacity)
          Construct an OMGeometryList with an initial capacity.
OMGeometryList(java.util.List list)
          Construct an OMGeometryList around a List of OMGeometries.
 
Method Summary
protected  float _distance(int x, int y)
          Return the shortest distance from the graphic to an XY-point.
protected  OMGraphicList.OMDist _findClosest(int x, int y, float limit, boolean resetSelect)
          Find the closest Object and its distance.
 void add(OMGeometry g)
          Add an OMGeometry to the GraphicList.
 void doAction(OMGeometry geometry, OMAction action)
          Perform an action on the provided geometry.
 OMGraphic findClosest(int x, int y, float limit)
          This method returns an OMGraphic if the thing that is found closest to the coordinates is an OMGraphic.
 OMGeometry findClosestGeometry(int x, int y)
          Finds the object located the closest to the point, regardless of how far away it is.
 OMGeometry findClosestGeometry(int x, int y, float limit)
          Finds the object located the closest to the point, if the object distance away is within the limit.
 void generate(Projection p, boolean forceProjectAll)
          Prepare the geometries for rendering.
 OMGeometry getAt(int location)
          Get the geometry at the location number on the list.
 boolean getConnectParts()
          Get whether the OMGeometries on the list should be connected to make a one-part shape object (if true), or a multi-part shape object (if false).
 OMGeometry getContains(int x, int y)
          Finds the first OMGeometry (the one on top) that is under this pixel.
 OMGraphic getOMGraphicThatContains(int x, int y)
          Returns this list if x, y is inside the bounds of the contents of this list.
 OMGeometry getWithAppObject(java.lang.Object appObj)
          Get the geometry with the appObject.
 int indexOf(OMGeometry geometry)
          Return the index of the OMGeometry in the list.
 void insertAt(OMGeometry geometry, int location)
          Insert the geometry at the location number.
 void readGraphics(java.io.ObjectInputStream objstream)
          Read a cache of OMGeometries, given a ObjectInputStream.
 boolean remove(OMGeometry geometry)
          Remove the geometry from the list.
 java.lang.Object removeAt(int location)
          Remove the geometry at the location number.
 void render(java.awt.Graphics gr)
          Renders all the objects in the list a geometries context.
 void renderAllAsSelected(java.awt.Graphics gr)
          Renders all the objects in the list a geometry's context, in their 'selected' mode.
protected  void renderGeometry(OMGeometry geometry, java.awt.Graphics gr)
           
 OMGraphic selectClosest(int x, int y, float limit)
          This method returns an OMGraphic if the thing that is found closest to the coordinates is an OMGraphic.
 OMGeometry selectClosestGeometry(int x, int y)
          Finds the object located the closest to the coordinates, regardless of how far away it is.
 OMGeometry selectClosestGeometry(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 geometry to its select paint.
 void setAt(OMGeometry geometry, int index)
          Set the geometry at the specified location.
 void setConnectParts(boolean value)
          Set whether the OMGeometries on the list should be connected to make a one-part shape object (if true), or a multi-part shape object (if false).
 void setFillPaint(java.awt.Paint paint)
          Set the fill paint for this list object.
 void setLinePaint(java.awt.Paint paint)
          Set the line paint for this list object.
 void setMatted(boolean value)
          Set the matting flag for all the list.
 void setMattingPaint(java.awt.Paint paint)
          Set the matting paint for all the objects on the list.
 void setSelectPaint(java.awt.Paint paint)
          Set the select paint for this list object.
 void setStroke(java.awt.Stroke s)
          Set the stroke for this list object.
 void setTextureMask(java.awt.TexturePaint texture)
          Set the texture mask for the OMGeometries on the list.
protected  void updateShape(OMGeometry geometry, Projection p, boolean forceProject)
          Given a OMGeometry, it calls generate/regenerate on it, and then adds the GeneralPath shape within it to the OMGeometryList shape object.
 
Methods inherited from class com.bbn.openmap.omGraphics.OMGraphicList
_add, _doAction, _findClosest, _getAt, _getContains, _getWithAppObject, _indexOf, _insert, _remove, _remove, _selectClosest, _setAt, add, addOMGraphic, checkForDuplicate, clear, clone, contains, deselect, deselectAll, distance, doAction, findAll, findAll, findAllTest, findClosest, findClosestTest, findIndexOfClosest, findIndexOfClosest, generate, getAllowDuplicates, getDescription, getDescription, getOMGraphicAt, getOMGraphicWithAppObject, getProcessAllGeometries, getTargets, getTraverseMode, indexOf, insertOMGraphicAt, isEmpty, isVague, isVisible, iterator, moveIndexedOneToBack, moveIndexedOneToBottom, moveIndexedOneToFront, moveIndexedOneToTop, moveIndexedToBottom, moveIndexedToFirst, moveIndexedToLast, moveIndexedToTop, objectToOMGraphic, project, project, readGraphics, remove, removeOMGraphicAt, select, selectAll, selectClosest, selectClosestTest, setAllowDuplicates, setGridGenerator, setOMGraphicAt, setProcessAllGeometries, setTargets, setTraverseMode, setVague, setVisible, shouldProcess, size, sort, writeGraphics, writeGraphics
 
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
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

connectParts

protected boolean connectParts
Flag to mark that the parts should be connected, making this OMGeometryList a combination OMGraphic that sums disparate parts. False by default.

Constructor Detail

OMGeometryList

public OMGeometryList()
Construct an OMGeometryList.


OMGeometryList

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

Parameters:
initialCapacity - the initial capacity of the list

OMGeometryList

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

Parameters:
list - List of OMGeometries.
Method Detail

add

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

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

remove

public boolean remove(OMGeometry geometry)
Remove the geometry from the list.

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

indexOf

public 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.

setAt

public void setAt(OMGeometry geometry,
                  int index)
Set the geometry at the specified location. The OMGeometry must not be null.

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

getAt

public OMGeometry getAt(int location)
Get the geometry at the location number on the list.

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

getWithAppObject

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

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

removeAt

public java.lang.Object removeAt(int location)
Remove the geometry at the location number.

Parameters:
location - the location of the OMGeometry to remove

insertAt

public void insertAt(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.ArrayIndexOutOfBoundsException - if index is out-of-bounds

setStroke

public void setStroke(java.awt.Stroke s)
Set the stroke for this list object. All geometries will be rendered with this stroke.

Overrides:
setStroke in class OMGraphicList
Parameters:
s - the stroke object to use.

setFillPaint

public void setFillPaint(java.awt.Paint paint)
Set the fill paint for this list object. All the geometries will be rendered with this fill paint.

Overrides:
setFillPaint in class OMGraphicList
Parameters:
paint - java.awt.Paint

setTextureMask

public void setTextureMask(java.awt.TexturePaint texture)
Set the texture mask for the OMGeometries 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 graphics, with the fill paint still influencing appearance.

Overrides:
setTextureMask in class OMGraphicList

setLinePaint

public void setLinePaint(java.awt.Paint paint)
Set the line paint for this list object. All the geometries will be rendered with this fill paint.

Overrides:
setLinePaint in class OMGraphicList
Parameters:
paint - Set the line paint for all the objects on the list.

setSelectPaint

public void setSelectPaint(java.awt.Paint paint)
Set the select paint for this list object. All the geometries will be rendered with this fill paint.

Overrides:
setSelectPaint in class OMGraphicList
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 OMGraphicList
Parameters:
paint - java.awt.Paint

setMatted

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

Overrides:
setMatted in class OMGraphicList

render

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

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

renderGeometry

protected void renderGeometry(OMGeometry geometry,
                              java.awt.Graphics gr)

renderAllAsSelected

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

Overrides:
renderAllAsSelected in class OMGraphicList
Parameters:
gr - the AWT Graphics context

generate

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

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

updateShape

protected void updateShape(OMGeometry geometry,
                           Projection p,
                           boolean forceProject)
Given a OMGeometry, it calls generate/regenerate on it, and then adds the GeneralPath shape within it to the OMGeometryList shape object.


_distance

protected float _distance(int x,
                          int y)
Return the shortest distance from the graphic to an XY-point. Checks to see of the point is contained within the OMGraphic, which may, or may not be the right thing for clear OMGraphics or lines.

_distance was added so subclasses could make this call if their geometries/attributes require this action (when fill color doesn't matter).

Overrides:
_distance in class BasicGeometry
Parameters:
x - X coordinate of the point.
y - Y coordinate of the point.
Returns:
float distance, in pixels, from graphic to the point. Returns Float.POSITIVE_INFINITY if the graphic isn't ready (ungenerated).

_findClosest

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

Overrides:
_findClosest in class OMGraphicList
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

findClosestGeometry

public OMGeometry findClosestGeometry(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 geometry to the bottommost, depending on the traverseMode. Any geometries where isVisible() returns false are not considered.

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

findClosest

public OMGraphic findClosest(int x,
                             int y,
                             float limit)
This method returns an OMGraphic if the thing that is found closest to the coordinates is an OMGraphic. It mose likely is an OMGeometry, so it can return null if it found something close to the coordinates that isn't an OMGraphic.

Overrides:
findClosest in class OMGraphicList
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.

selectClosest

public OMGraphic selectClosest(int x,
                               int y,
                               float limit)
This method returns an OMGraphic if the thing that is found closest to the coordinates is an OMGraphic. It mose likely is an OMGeometry, so it can return null if it found something close to the coordinates that isn't an OMGraphic. It will tell anything it finds to be selected, however, whether it is an OMGraphic or OMGeometry.

Overrides:
selectClosest in class OMGraphicList
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.

findClosestGeometry

public OMGeometry findClosestGeometry(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 geometry.
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 geometry to the xy window point.
See Also:
findClosest(int, int, float)

selectClosestGeometry

public OMGeometry selectClosestGeometry(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.

selectClosestGeometry

public OMGeometry selectClosestGeometry(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 geometry to its select paint. It sets the paints to all the other objects to the regular paint. The search starts at the first-added geometry. Any geometries 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 geometry has to be within to be returned, in pixels.
Returns:
the closest OMGeometry on the list, within the limit or null if none found.

getContains

public OMGeometry getContains(int x,
                              int y)
Finds the first OMGeometry (the one on top) that is under this pixel. This method will return the particular OMGeometry that may fall around the pixel location. If you want to know if the pixel touches any part of this list, call contains(x, y) instead.

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 geometry that contains the pixel, NONE (null) if none are found.

getOMGraphicThatContains

public OMGraphic getOMGraphicThatContains(int x,
                                          int y)
Returns this list if x, y is inside the bounds of the contents of this list.

Overrides:
getOMGraphicThatContains in class OMGraphicList
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.

doAction

public void doAction(OMGeometry geometry,
                     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).


readGraphics

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

Overrides:
readGraphics in class OMGraphicList
Parameters:
objstream - ObjectInputStream of geometry list.
Throws:
java.io.IOException

setConnectParts

public void setConnectParts(boolean value)
Set whether the OMGeometries on the list should be connected to make a one-part shape object (if true), or a multi-part shape object (if false).


getConnectParts

public boolean getConnectParts()
Get whether the OMGeometries on the list should be connected to make a one-part shape object (if true), or a multi-part shape object (if false).



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