|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.bbn.openmap.omGraphics.geom.BasicGeometry
public abstract class 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 information 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 java.util.Map<java.lang.Object,java.lang.Object> |
attributes
Attribute Map for this Geometry/OMGraphic. |
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 re-projected. |
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(double x,
double y)
Return the shortest distance from the graphic to an XY-point. |
static java.awt.geom.GeneralPath |
appendShapeEdge(java.awt.geom.GeneralPath toShape,
float[] xpoints,
float[] ypoints)
Convenience method to add the coordinates to the given GeneralPath. |
static java.awt.geom.GeneralPath |
appendShapeEdge(java.awt.geom.GeneralPath toShape,
float[] xpoints,
float[] ypoints,
int startIndex,
int length)
Convenience method to add the coordinates to the given GeneralPath. |
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. |
void |
clearAttributes()
Removes all of the objects stored in a Map stored in the appObject. |
boolean |
contains(double x,
double y)
Answers the question whether or not the OMGeometry contains the given pixel point. |
protected java.util.Map<java.lang.Object,java.lang.Object> |
createAttributeMap()
Method to extend if you don't like Hashtables used for attribute table. |
static java.awt.geom.GeneralPath |
createBoxShape(float x,
float y,
int width,
int height)
Create a general path from a point plus a height and width; |
static java.awt.geom.GeneralPath |
createShape(float[] xpoints,
float[] ypoints,
boolean isPolygon)
Create a Shape object given an array of x points and y points. |
static java.awt.geom.GeneralPath |
createShape(float[] xpoints,
float[] 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(double x,
double y)
Return the shortest distance from the graphic to an XY-point. |
float |
distanceToEdge(double x,
double y)
Return the shortest distance from the edge of a graphic to an XY-point. |
static float |
distanceToEdge(double x,
double y,
java.awt.Shape shape)
Return the shortest distance from the edge of a Shape object to an XY-point. |
void |
draw(java.awt.Graphics g)
Paint the graphic, as an outlined shape. |
void |
draw(java.awt.Graphics g,
java.awt.Shape s)
Paint the graphic, as an outlined shape. |
void |
fill(java.awt.Graphics g)
Paints the graphic, as a filled shape. |
void |
fill(java.awt.Graphics g,
java.awt.Shape s)
Paint the graphic, as a filled shape. |
abstract boolean |
generate(Projection proj)
Prepare the geometry for rendering. |
java.lang.Object |
getAppObject()
For backward compatibility, now returns whatever is saved under the OMGraphic.APP_OBJECT key. |
java.lang.Object |
getAttribute(java.lang.Object key)
Returns the object stored in a Map stored in the appObject. |
java.util.Map<java.lang.Object,java.lang.Object> |
getAttributes()
Returns the 'official' attribute Map. |
java.lang.String |
getDescription()
OMGeometry method for returning a simple description of the OMGraphic. |
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()
A check to see if the OMGeometry is ready for rendering. |
boolean |
isRenderable(java.awt.Shape shape)
A check to see if the OMGeometry is ready for rendering. |
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. |
void |
render(java.awt.Graphics g)
Sure it renders, but not with any controllable rendering attributes - the colors and strokes are what are set in the Graphics. |
void |
restore(OMGeometry source)
Replace the member variables of this OMGraphic with copies of member variables from another one. |
void |
select()
Let the geometry object know it's selected. |
void |
setAppObject(java.lang.Object obj)
For backward compatibility, puts object in attribute table under OMGraphic.APP_OBJECT. |
void |
setAttributes(java.util.Map<java.lang.Object,java.lang.Object> 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 transient boolean needToRegenerate
protected java.util.Map<java.lang.Object,java.lang.Object> attributes
protected boolean visible
protected transient java.awt.geom.GeneralPath shape
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
protected java.util.Map<java.lang.Object,java.lang.Object> 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<java.lang.Object,java.lang.Object> getAttributes()
getAttributes
in interface OMGeometry
public void setAttributes(java.util.Map<java.lang.Object,java.lang.Object> atts)
setAttributes
in interface OMGeometry
public void setAppObject(java.lang.Object obj)
setAppObject
in interface OMGeometry
obj
- any objectpublic java.lang.Object getAppObject()
getAppObject
in interface OMGeometry
public java.lang.String getDescription()
getDescription
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 boolean isRenderable(java.awt.Shape shape)
isRenderable
in interface OMGeometry
shape
- the projected shape of the OMGraphic
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 fill(java.awt.Graphics g, java.awt.Shape s)
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.s
- Shape object to fill for rendering.public void draw(java.awt.Graphics g, java.awt.Shape s)
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.s
- Shape object to render.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 void render(java.awt.Graphics g)
render
in interface OMGeometry
g
- Graphics2D context to render into.public float distanceToEdge(double x, double y)
distanceToEdge
in interface OMGeometry
x
- X coordinate of the point.y
- Y coordinate of the point.
public static float distanceToEdge(double x, double y, java.awt.Shape shape)
Method taken and adapted from
distanceToEdge(double, double)
x
- X coordinate of the point.y
- Y coordinate of the point.shape
- Shape object to test.
public float distance(double x, double 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(double x, double 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(double x, double 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 occurring 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(float[] xpoints, float[] 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(float[] xpoints, float[] 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, float[] xpoints, float[] ypoints)
toShape
- the GeneralPath Shape object to add the coordinates to.xpoints
- horizontal pixel coordinates.ypoints
- vertical pixel coordinates.
public static java.awt.geom.GeneralPath appendShapeEdge(java.awt.geom.GeneralPath toShape, float[] xpoints, float[] ypoints, int startIndex, int length)
toShape
- the GeneralPath Shape object to add the coordinates to.xpoints
- horizontal pixel coordinates.ypoints
- vertical pixel coordinates.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(float x, float y, int width, int height)
public void restore(OMGeometry source)
OMGeometry
restore
in interface OMGeometry
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |