|
||||||||||
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 com.bbn.openmap.omGraphics.OMGraphicAdapter com.bbn.openmap.omGraphics.OMAbstractLine com.bbn.openmap.omGraphics.OMPoly
public class OMPoly
Graphic object that represents a polygon or polyline (multi-line-segment-object).
The differentiators between polygons and polylines is the fill color. If the fillPaint is equal to OMColor.clear, then the poly will be considered a polyline. There are methods to override this in the OMPoly class, but they do play around with the fillPaint, depending on the order in which the methods are called. If you know it's a polyline, call setIsPolygon(false) if you think that the fillPaint could be set to anything other than the default, OMColor.clear.
All of the OMGraphics are moving to having their internal representation as java.awt.Shape objects. Unfortunately, this has the side effect of slowing OMPolys down, because the way that the projection classes handle transformations cause more objects to be allocated and more loops to be run through. So, by default, the OMPoly does NOT use Shape objects internally, to keep layers that throw down many, many polys running quickly. If you want to do some spatial analysis on an OMPoly, call setDoShapes(true) on it, then generate(Projection), and then call getShapes() to get the java.awt.Shape objects for the poly. You can then run the different Shape spatial analysis methods on the Shape objects.
OMCircle
,
OMRect
,
OMLine
,
Serialized FormField Summary | |
---|---|
protected int |
coordMode
For RENDERTYPE_OFFSET, type of offset. |
static int |
COORDMODE_ORIGIN
Translation offsets. |
static int |
COORDMODE_PREVIOUS
Delta offsets. |
protected boolean |
doShapes
Flag for telling the OMPoly to use the Shape objects to represent itself internally. |
protected boolean |
geometryClosed
|
protected boolean |
isPolygon
Poly is a polygon or a polyline. |
protected double |
lat
For RENDERTYPE_OFFSET, the latitude of the starting point of the poly. |
protected double |
lon
For RENDERTYPE_OFFSET, the longitude of the starting point of the poly. |
protected double[] |
rawllpts
raw float lats and lons stored internally in radians. |
protected int |
units
Radians or decimal degrees. |
protected int[] |
xs
The x array of ints, representing pixels, used for x/y or offset polys. |
protected int[] |
ys
The y array of ints, representing pixels, used for x/y or offset polys. |
Fields inherited from class com.bbn.openmap.omGraphics.OMAbstractLine |
---|
arrowhead, nsegs, xpoints, ypoints |
Fields inherited from class com.bbn.openmap.omGraphics.OMGraphicAdapter |
---|
declutterType, displayPaint, edgeMatchesFill, fillPaint, hasLabel, linePaint, matted, mattingPaint, renderType, selected, selectPaint, showEditablePalette, stroke, textureMask |
Fields inherited from class com.bbn.openmap.omGraphics.geom.BasicGeometry |
---|
attributes, lineType, needToRegenerate, shape, visible |
Constructor Summary | |
---|---|
OMPoly()
Construct a default OMPoly. |
|
OMPoly(double[] llPoints,
int units,
int lType)
Create an OMPoly from a list of float lat/lon pairs. |
|
OMPoly(double[] llPoints,
int units,
int lType,
int nsegs)
Create an OMPoly from a list of float lat/lon pairs. |
|
OMPoly(double latPoint,
double lonPoint,
int[] xypoints,
int cMode)
Create an x/y OMPoly at an offset from lat/lon. |
|
OMPoly(double latPoint,
double lonPoint,
int[] xPoints,
int[] yPoints,
int cMode)
Create an x/y OMPoly at an offset from lat/lon. |
|
OMPoly(int[] xypoints)
Create an OMPoly from a list of xy pairs. |
|
OMPoly(int[] xPoints,
int[] yPoints)
Create an x/y OMPoly. |
Method Summary | |
---|---|
protected boolean |
checkPoints(float[][] xpoints2,
float[][] ypoints2)
Return true if the xpoints and ypoints are not null and contain coordinates. |
protected java.awt.geom.GeneralPath |
createShape()
Since OMPoly has the option to not create a Shape, this method is here to create it if it is asked for. |
float |
distance(double x,
double y)
Return the shortest distance from the graphic to an XY-point. |
boolean |
generate(Projection proj)
Prepare the poly for rendering. |
int |
getCoordMode()
For RENDERTYPE_OFFSET, type of offset. |
boolean |
getDoShapes()
|
int |
getIndexOfFirstNodeOfSegIntersect(double x,
double y,
double maxDist)
Get the index of the leading node of an edge that is intersecting the given location. |
double |
getLat()
Get the latitude of the offset point, in decimal degrees. |
double[] |
getLatLonArray()
Return the rawllpts array. |
double[] |
getLatLonArrayCopy()
Use this if you want to play around with the values without messing with the OMPoly. |
double |
getLon()
Get the longitude of the offset point, in decimal degrees. |
int |
getNumSegs()
Get the number of subsegments for each segment in the poly. |
double[] |
getRawllpts()
For XMLEncoder |
java.awt.geom.GeneralPath |
getShape()
Get the array of java.awt.Shape objects that represent the projected graphic. |
int |
getUnits()
For XMLEncoder |
int[] |
getXs()
Get the array of x points. |
int[] |
getYs()
Get the array of y points. |
void |
insertRadians(double[] latlons,
int coordPairIndex,
boolean replaceEndsOfInsertedAtJoin)
Convenience function for adding some coordinates to the polygon, for lat/lon polygons. |
protected boolean |
isGeometryClosed()
Is the geometry closed ? |
boolean |
isPolygon()
Check if this is a polygon or a polyline. |
static void |
main(java.lang.String[] argv)
|
void |
render(java.awt.Graphics g)
Paint the poly. |
void |
restore(OMGeometry source)
Takes the generic OMGraphic settings from another OMGraphic and pushes them to this one. |
void |
setCoordMode(int coordMode)
For RENDERTYPE_OFFSET, type of offset. |
void |
setDoShapes(boolean set)
|
void |
setFillPaint(java.awt.Paint paint)
Set the fill Paint of the poly. |
void |
setIsPolygon(boolean set)
Set the Polyline/Polygon setting, if you know better. |
void |
setLat(double lat)
Set the latitude of the offset point, in decimal degrees. |
void |
setLocation(double[] llPoints,
int units)
Set an OMPoly from a list of float lat/lon pairs. |
void |
setLocation(double latPoint,
double lonPoint,
int units,
int[] xypoints)
Set the location based on a latitude, longitude, and some xy points. |
void |
setLocation(double latPoint,
double lonPoint,
int units,
int[] xPoints,
int[] yPoints)
Set the location based on a latitude, longitude, and some xy points. |
void |
setLocation(int[] xypoints)
Set an OMPoly from a list of xy pixel pairs. |
void |
setLocation(int[] xPoints,
int[] yPoints)
Set an OMPoly from a x/y coordinates. |
void |
setLon(double lon)
Set the longitude of the offset point, in decimal degrees. |
void |
setNumSegs(int nsegs)
Set the number of subsegments for each segment in the poly. |
void |
setXs(int[] x)
Set the array of x points. |
void |
setYs(int[] y)
Set the array of y points. |
boolean |
shouldRenderFill()
Return true of the fill color/paint should be rendered (not clear). |
Methods inherited from class com.bbn.openmap.omGraphics.OMAbstractLine |
---|
addArrowHead, addArrowHead, addArrowHead, addArrowHead, createArrowHeads, getArrowDirectionType, getArrowHead, getArrowLocation, getWingLength, getWingTip, hasArrowHead, restore, setArrowHead |
Methods inherited from class com.bbn.openmap.omGraphics.geom.BasicGeometry |
---|
_distance, appendShapeEdge, appendShapeEdge, appendShapeEdge, appendShapeEdge, clearAttributes, contains, createAttributeMap, createBoxShape, createShape, createShape, describeShapeDetail, describeShapeDetail, distanceToEdge, distanceToEdge, draw, draw, fill, fill, getAppObject, getAttribute, getAttributes, getDescription, getLineType, getNeedToRegenerate, isRenderable, isRenderable, isVisible, putAttribute, removeAttribute, setAppObject, setAttributes, setLineType, setNeedToRegenerate, setShape, setVisible |
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, distanceToEdge, draw, draw, fill, fill, getAppObject, getAttribute, getAttributes, getDescription, getLineType, getNeedToRegenerate, isRenderable, isRenderable, isVisible, putAttribute, removeAttribute, setAppObject, setAttributes, setLineType, setNeedToRegenerate, setShape, setVisible |
Field Detail |
---|
public static final int COORDMODE_ORIGIN
public static final int COORDMODE_PREVIOUS
protected int units
protected double lat
protected double lon
protected int coordMode
COORDMODE_ORIGIN
,
COORDMODE_PREVIOUS
protected int[] xs
protected int[] ys
protected boolean isPolygon
protected double[] rawllpts
protected boolean doShapes
protected boolean geometryClosed
Constructor Detail |
---|
public OMPoly()
public OMPoly(double[] llPoints, int units, int lType)
NOTES:
llPoints
- array of lat/lon points, arranged lat, lon, lat, lon,
etc.units
- radians or decimal degrees. Use OMGraphic.RADIANS or
OMGraphic.DECIMAL_DEGREESlType
- line type, from a list defined in OMGraphic.public OMPoly(double[] llPoints, int units, int lType, int nsegs)
NOTES:
llPoints
- array of lat/lon points, arranged lat, lon, lat, lon,
etc.units
- radians or decimal degrees. Use OMGraphic.RADIANS or
OMGraphic.DECIMAL_DEGREESlType
- line type, from a list defined in OMGraphic.nsegs
- number of segment points (only for LINETYPE_GREATCIRCLE or
LINETYPE_RHUMB line types, and if < 1, this value is generated
internally)public OMPoly(int[] xypoints)
xypoints
- array of x/y points, arranged x, y, x, y, etc.public OMPoly(int[] xPoints, int[] yPoints)
xPoints
- float[] of x coordinatesyPoints
- float[] of y coordinatespublic OMPoly(double latPoint, double lonPoint, int[] xypoints, int cMode)
latPoint
- latitude in decimal degreeslonPoint
- longitude in decimal degreesxypoints
- float[] of x,y pairscMode
- offset coordinate modepublic OMPoly(double latPoint, double lonPoint, int[] xPoints, int[] yPoints, int cMode)
latPoint
- latitude in decimal degreeslonPoint
- longitude in decimal degreesxPoints
- float[] of x coordinatesyPoints
- float[] of y coordinatescMode
- offset coordinate modeMethod Detail |
---|
public void setLocation(double[] llPoints, int units)
NOTES:
llPoints
- array of lat/lon points, arranged lat, lon, lat, lon,
etc.units
- radians or decimal degrees. Use OMGraphic.RADIANS or
OMGraphic.DECIMAL_DEGREESpublic void setLocation(int[] xypoints)
xypoints
- array of x/y points, arranged x, y, x, y, etc.public void setLocation(int[] xPoints, int[] yPoints)
xPoints
- float[] of x coordinatesyPoints
- float[] of y coordinatespublic void setLocation(double latPoint, double lonPoint, int units, int[] xypoints)
latPoint
- latitude in decimal degreeslonPoint
- longitude in decimal degreesunits
- radians or decimal degrees. Use OMGraphic.RADIANS or
OMGraphic.DECIMAL_DEGREESxypoints
- array of x/y points, arranged x, y, x, y, etc.public void setLocation(double latPoint, double lonPoint, int units, int[] xPoints, int[] yPoints)
latPoint
- latitude in decimal degreeslonPoint
- longitude in decimal degreesunits
- radians or decimal degrees. Use OMGraphic.RADIANS or
OMGraphic.DECIMAL_DEGREESxPoints
- float[] of x coordinatesyPoints
- float[] of y coordinatespublic double[] getLatLonArray()
public double[] getLatLonArrayCopy()
public void setLat(double lat)
public double getLat()
public void setLon(double lon)
public double getLon()
public void setXs(int[] x)
public int[] getXs()
public void setYs(int[] y)
public int[] getYs()
public void setFillPaint(java.awt.Paint paint)
setFillPaint
in interface OMGraphic
setFillPaint
in class OMGraphicAdapter
paint
- value Colorpublic boolean isPolygon()
public void setIsPolygon(boolean set)
public void setNumSegs(int nsegs)
nsegs
- number of segment pointspublic int getNumSegs()
public void setCoordMode(int coordMode)
COORDMODE_ORIGIN
,
COORDMODE_PREVIOUS
public int getCoordMode()
COORDMODE_ORIGIN
,
COORDMODE_PREVIOUS
public void setDoShapes(boolean set)
public boolean getDoShapes()
public boolean generate(Projection proj)
generate
in interface OMGeometry
generate
in class OMGraphicAdapter
proj
- Projection
OMGraphicAdapter.regenerate(com.bbn.openmap.proj.Projection)
protected boolean checkPoints(float[][] xpoints2, float[][] ypoints2)
xpoints2
- ypoints2
- public boolean shouldRenderFill()
shouldRenderFill
in interface OMGraphic
shouldRenderFill
in class OMGraphicAdapter
public void render(java.awt.Graphics g)
render
in interface OMGeometry
render
in class OMGraphicAdapter
g
- java.awt.Graphics to paint the poly onto.public float distance(double x, double y)
distance
in interface OMGeometry
distance
in class OMGraphicAdapter
x
- horizontal pixel location.y
- vertical pixel location.
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
getShape
in class BasicGeometry
protected java.awt.geom.GeneralPath createShape()
protected boolean isGeometryClosed()
public double[] getRawllpts()
public int getUnits()
public void insertRadians(double[] latlons, int coordPairIndex, boolean replaceEndsOfInsertedAtJoin)
latlons
- the set of coordinates to add, in radians. Use
ProjMath.arrayDegToRad() if you need to convert decimal degrees.coordPairIndex
- index of the coordinate pair to insert coordinates.
0 is the start of the polygon, 1 means the latlons will be
inserted after the first original coordinate pair, etc.replaceEndsOfInsertedAtJoin
- flad to indicate whether the
coordinates at the end of the inserted latlons array should be
removed before insertion. If the coordinate list is being added to
the start or end of the polygon, only the coordinate pair
connecting to the original poly will be removed.public int getIndexOfFirstNodeOfSegIntersect(double x, double y, double maxDist)
x
- horizontal coordinatey
- vertical coordinatemaxDist
- maximum pixel distance from segment to be considered an
intersect.
public static void main(java.lang.String[] argv)
public void restore(OMGeometry source)
OMGraphicAdapter
restore
in interface OMGeometry
restore
in class OMGraphicAdapter
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |