|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.bbn.openmap.omGraphics.geom.BasicGeometry
Base class implementation of OpenMap OMGeometry, the super class for all OMGraphics.
The geometry classes are intended to pull the object location data out of the OMGraphics. If you have a bunch of OMGraphics that are all rendered with common attributes, you can create a bunch of OMGeometry objects to plavce in a OMGeometryList that will render them all alike.
The BasicGeometry can hold attributes. Traditionally, there has been an appObject (Application Object) that could be set in the OMGeometry/OMGraphic to maintain a pointer for additional infomration about the shape. This has been modified so that an attribute Map can be maintained for the BasicGeometry to let it hold on to a bunch of organized attributes. To maintain backward compatibility, the setAppObject() and getAppObject() methods have been modified to manage a java.util.Map along with any Objects stored in the appObject. Using the setAppObject() and getAppObject() methods in conjunction with other attributes will cause that object to be stored in the attribute Map under the APP_OBJECT_KEY Map key.
PolygonGeometry
,
PolylineGeometry
,
OMGeometryList
,
Projection
,
Serialized FormField Summary | |
protected static java.lang.String |
APP_OBJECT_KEY
|
protected java.lang.Object |
appObject
Space for an application to associate geometry with an application object. |
protected static java.lang.String |
ATT_MAP_KEY
|
protected int |
lineType
The lineType describes the way a line will be drawn between points. |
protected boolean |
needToRegenerate
Flag to indicate that the object needs to be reprojected. |
protected java.awt.geom.GeneralPath |
shape
The Java 2D containing the Shape of the Graphic. |
protected boolean |
visible
A flag to render this geometry visible. |
Constructor Summary | |
BasicGeometry()
|
Method Summary | |
protected float |
_distance(int x,
int y)
Return the shortest distance from the graphic to an XY-point. |
static java.awt.geom.GeneralPath |
appendShapeEdge(java.awt.geom.GeneralPath toShape,
java.awt.geom.GeneralPath addShape)
Convenience method to append the edge of a GeneralPath Shape to another GeneralPath Shape. |
static java.awt.geom.GeneralPath |
appendShapeEdge(java.awt.geom.GeneralPath toShape,
java.awt.geom.GeneralPath addShape,
boolean lineTo)
Convenience method to append the edge of a GeneralPath Shape to another GeneralPath Shape. |
static java.awt.geom.GeneralPath |
appendShapeEdge(java.awt.geom.GeneralPath toShape,
int[] xpoints,
int[] ypoints)
Convenience method to add the coordinates to the given GeneralPath. |
static java.awt.geom.GeneralPath |
appendShapeEdge(java.awt.geom.GeneralPath toShape,
int[] xpoints,
int[] ypoints,
int startIndex,
int length)
Convenience method to add the coordinates to the given GeneralPath. |
protected boolean |
checkAttributeMap()
Returns true if the appObject is a Map and if it's the attribute Map, false if the appObject is something different or null. |
protected boolean |
checkAttributeMap(java.lang.Object obj)
Returns true of the Object is a Map and is pointing to itself in the Map under the ATT_MAP_KEY. |
void |
clearAttributes()
Removes all of the objects stored in a Map stored in the appObject. |
boolean |
contains(int x,
int y)
Answsers the question whether or not the OMGeometry contains the given pixel point. |
protected java.util.Map |
createAttributeMap()
Method to extend if you don't like Hashtables used for attribute table. |
static java.awt.geom.GeneralPath |
createBoxShape(int x,
int y,
int width,
int height)
Create a general path from a point plus a height and width; |
static java.awt.geom.GeneralPath |
createShape(int[] xpoints,
int[] ypoints,
boolean isPolygon)
Create a Shape object given an array of x points and y points. |
static java.awt.geom.GeneralPath |
createShape(int[] xpoints,
int[] ypoints,
int startIndex,
int length,
boolean isPolygon)
Create a Shape object given an array of x points and y points. |
static void |
describeShapeDetail(java.awt.Shape shape)
Utility method that iterates over a Shape object and prints out the points. |
static void |
describeShapeDetail(java.awt.Shape shape,
double flattening)
Utility method that iterates over a Shape object and prints out the points. |
void |
deselect()
Let the geometry object know it's deselected. |
float |
distance(int x,
int y)
Return the shortest distance from the graphic to an XY-point. |
float |
distanceToEdge(int x,
int y)
Return the shortest distance from the edge of a graphic to an XY-point. |
void |
draw(java.awt.Graphics g)
Paint the graphic, as an outlined shape. |
void |
fill(java.awt.Graphics g)
Paint the graphic, as a filled shape. |
abstract boolean |
generate(Projection proj)
Prepare the geometry for rendering. |
java.lang.Object |
getAppObject()
Gets the application's object pointer. |
protected java.lang.Object |
getAppObject(boolean checkForObjOnMap)
Same as getAppObject, with the option of disabling the attribute Map management. |
java.lang.Object |
getAttribute(java.lang.Object key)
Returns the object stored in a Map stored in the appObject. |
protected java.util.Map |
getAttributeMap()
Returns a Map that is being used as an attribute holder. |
java.util.Map |
getAttributes()
Returns the 'official' attribute Map, null if it hasn't been set. |
int |
getLineType()
Return the line type. |
boolean |
getNeedToRegenerate()
Return the regeneration status. |
abstract int |
getRenderType()
Return the render type. |
java.awt.geom.GeneralPath |
getShape()
Get the java.awt.Shape object that represents the projected graphic. |
boolean |
isRenderable()
|
boolean |
isVisible()
Get the visibility variable. |
void |
putAttribute(java.lang.Object key,
java.lang.Object value)
Adds a key-value pair to the attribute Map. |
boolean |
regenerate(Projection proj)
Invoke this to regenerate a "dirty" graphic. |
java.lang.Object |
removeAttribute(java.lang.Object key)
Removes the object stored in a Map stored in the appObject. |
protected void |
replaceAppObjectWithAttributeMap()
A call used by the BasicGeometry to replace a current appication object with an Object Map while also adding that application object to the Map under the APP_OBJECT_KEY key value. |
void |
select()
Let the geometry object know it's selected. |
void |
setAppObject(java.lang.Object obj)
Holds an application specific object for later access. |
protected void |
setAppObject(java.lang.Object obj,
boolean checkToReplaceObjWithMap)
Same as setAppObject with the option for disabling the attribute Map management. |
void |
setAttributes(java.util.Map atts)
Sets the 'official' attribute Map, moving any appObject that isn't currently the 'official' attribute Map into the map under the APP_OBJECT_KEY. |
void |
setLineType(int value)
Set the line type for the graphic, which will affect how the lines will be drawn. |
void |
setNeedToRegenerate(boolean value)
Sets the regenerate flag for the graphic. |
void |
setShape(java.awt.geom.GeneralPath gp)
Set the java.awt.Shape object that represents the projected graphic. |
void |
setVisible(boolean visible)
Set the visibility variable. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected int lineType
protected boolean needToRegenerate
protected java.lang.Object appObject
setAppObject(java.lang.Object)
,
getAppObject()
protected boolean visible
protected transient java.awt.geom.GeneralPath shape
protected static final java.lang.String APP_OBJECT_KEY
protected static final java.lang.String ATT_MAP_KEY
Constructor Detail |
public BasicGeometry()
Method Detail |
public void setLineType(int value)
setLineType
in interface OMGeometry
value
- the line type of the graphic.public int getLineType()
getLineType
in interface OMGeometry
public abstract int getRenderType()
getRenderType
in interface OMGeometry
public void setNeedToRegenerate(boolean value)
setNeedToRegenerate
in interface OMGeometry
value
- booleanpublic boolean getNeedToRegenerate()
getNeedToRegenerate
in interface OMGeometry
public void setVisible(boolean visible)
setVisible
in interface OMGeometry
visible
- booleanpublic boolean isVisible()
isVisible
in interface OMGeometry
public void select()
select
in interface OMGeometry
public void deselect()
deselect
in interface OMGeometry
public void setAppObject(java.lang.Object obj)
The BasicGeometry has been updated to use an attribute Object Map to hold multiple attributes. If no attributes have been added, then the appObject will just hold any object passed in here. If attributes have already been added, then calling this method will add the object to the Map under the APP_OBJECT_KEY key. getAppObject() will return the object set in this method.
setAppObject
in interface OMGeometry
obj
- Objectprotected void setAppObject(java.lang.Object obj, boolean checkToReplaceObjWithMap)
checkToReplaceObjWithMap
- if false, just sets obj to
appObject.public java.lang.Object getAppObject()
getAppObject
in interface OMGeometry
protected java.lang.Object getAppObject(boolean checkForObjOnMap)
checkForObjOnMap
- if false, just returns the appObject.protected void replaceAppObjectWithAttributeMap()
protected boolean checkAttributeMap()
protected boolean checkAttributeMap(java.lang.Object obj)
protected java.util.Map getAttributeMap()
protected java.util.Map createAttributeMap()
public void putAttribute(java.lang.Object key, java.lang.Object value)
putAttribute
in interface OMGeometry
public java.lang.Object getAttribute(java.lang.Object key)
getAttribute
in interface OMGeometry
public java.lang.Object removeAttribute(java.lang.Object key)
removeAttribute
in interface OMGeometry
public void clearAttributes()
clearAttributes
in interface OMGeometry
public java.util.Map getAttributes()
getAttributes
in interface OMGeometry
public void setAttributes(java.util.Map atts)
setAttributes
in interface OMGeometry
public abstract boolean generate(Projection proj)
render()
! If a vector graphic has
lat-lon components, then we project these vertices into x-y
space. For raster graphics we prepare in a different fashion.
If the generate is unsuccessful, it's usually because of some
oversight, (for instance if proj
is null), and
if debugging is enabled, a message may be output to the
controlling terminal.
generate
in interface OMGeometry
proj
- Projection
regenerate(com.bbn.openmap.proj.Projection)
public boolean isRenderable()
isRenderable
in interface OMGeometry
public void fill(java.awt.Graphics g)
This paints the graphic into the Graphics context. This is
similar to paint()
function of
java.awt.Components. Note that if the graphic has not been
generated or if it isn't visible, it will not be rendered.
This method used to be abstract, but with the conversion of OMGeometrys to internally represent themselves as java.awt.Shape objects, it's a more generic method. If the OMGeometry hasn't been updated to use Shape objects, it should have its own render method.
fill
in interface OMGeometry
g
- Graphics2D context to render into.public void draw(java.awt.Graphics g)
This paints the graphic into the Graphics context. This is
similar to paint()
function of
java.awt.Components. Note that if the graphic has not been
generated or if it isn't visible, it will not be rendered.
This method used to be abstract, but with the conversion of OMGeometrys to internally represent themselves as java.awt.Shape objects, it's a more generic method. If the OMGeometry hasn't been updated to use Shape objects, it should have its own render method.
draw
in interface OMGeometry
g
- Graphics2D context to render into.public float distanceToEdge(int x, int y)
x
- X coordinate of the point.y
- Y coordinate of the point.
public float distance(int x, int y)
This method used to be abstract, but with the conversion of OMGeometrys to internally represent themselves as java.awt.Shape objects, it's a more generic method. If the OMGeometry hasn't been updated to use Shape objects, it should have its own distance method.
Calls _distance(x, y);
distance
in interface OMGeometry
x
- X coordinate of the point.y
- Y coordinate of the point.
protected float _distance(int x, int y)
_distance was added so subclasses could make this call if their geometries/attributes require this action (when fill color doesn't matter).
x
- X coordinate of the point.y
- Y coordinate of the point.
public boolean contains(int x, int y)
This method used to be abstract, but with the conversion of OMGeometrys to internally represent themselves as java.awt.Shape objects, it's a more generic method. If the OMGeometry hasn't been updated to use Shape objects, it should have its own contains method.
This method duplicates a java.awt.Shape method, with some protection wrapped around it. If you have other queries for the internal Shape object, just ask for it and then ask it directly. This method is provided because it is the most useful, used when determining if a mouse event is occuring over an object on the map.
contains
in interface OMGeometry
x
- X pixel coordinate of the point.y
- Y pixel coordinate of the point.
public boolean regenerate(Projection proj)
generate()
method. It invokes
generate()
only if needToRegenerate()
on the graphic returns true. To force a graphic to be
generated, call generate()
directly.
regenerate
in interface OMGeometry
proj
- the Projection
generate(com.bbn.openmap.proj.Projection)
public java.awt.geom.GeneralPath getShape()
The java.awt.Shape object gives you the ability to do a little spatial analysis on the graphics.
getShape
in interface OMGeometry
public void setShape(java.awt.geom.GeneralPath gp)
The java.awt.Shape object gives you the ability to do a little spatial analysis on the graphics.
setShape
in interface OMGeometry
gp
- java.awt.geom.GeneralPath, or null if the graphic
needs to be generated with the current map projection or
to clear out the object being held by the OMGeometry.public static java.awt.geom.GeneralPath createShape(int[] xpoints, int[] ypoints, boolean isPolygon)
xpoints
- projected x coordinatesypoints
- projected y coordinatesisPolygon
- whether the points make up a polygon, or a
polyline. If it's true, the Shape object returned is a
Polygon. If false, the Shape returned is a GeneralPath
object.
public static java.awt.geom.GeneralPath createShape(int[] xpoints, int[] ypoints, int startIndex, int length, boolean isPolygon)
xpoints
- projected x coordinatesypoints
- projected y coordinatesstartIndex
- the starting coordinate index in the array.length
- the number of points to use from the array for
the shape.isPolygon
- whether the points make up a polygon, or a
polyline. If it's true, the Shape object returned is a
Polygon. If false, the Shape returned is a GeneralPath
object.
public static void describeShapeDetail(java.awt.Shape shape)
public static void describeShapeDetail(java.awt.Shape shape, double flattening)
public static java.awt.geom.GeneralPath appendShapeEdge(java.awt.geom.GeneralPath toShape, int[] xpoints, int[] ypoints)
toShape
- the GeneralPath Shape object to add the
coordinates to.xpoints
- horizontal pixel coordiantes.ypoints
- vertical pixel coordiantes.
public static java.awt.geom.GeneralPath appendShapeEdge(java.awt.geom.GeneralPath toShape, int[] xpoints, int[] ypoints, int startIndex, int length)
toShape
- the GeneralPath Shape object to add the
coordinates to.xpoints
- horizontal pixel coordiantes.ypoints
- vertical pixel coordiantes.startIndex
- the index into pixel coordinate array to
start reading from.length
- the number of coordinates to add.
public static java.awt.geom.GeneralPath appendShapeEdge(java.awt.geom.GeneralPath toShape, java.awt.geom.GeneralPath addShape)
toShape
- the GeneralPath Shape object to add the edge to.addShape
- the GeneralPath Shape to add to the toShape.
public static java.awt.geom.GeneralPath appendShapeEdge(java.awt.geom.GeneralPath toShape, java.awt.geom.GeneralPath addShape, boolean lineTo)
toShape
- the GeneralPath Shape object to add the edge to.addShape
- the GeneralPath Shape to add to the toShape.lineTo
- specify whether the first point of the appended
path is connected to the original path. True to connect.
public static java.awt.geom.GeneralPath createBoxShape(int x, int y, int width, int height)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |