## com.bbn.openmap.omGraphics.geom
Class PolygonGeometry

    java.lang.Object
      com.bbn.openmap.omGraphics.geom.BasicGeometry
          com.bbn.openmap.omGraphics.geom.PolygonGeometry

All Implemented Interfaces:
  OMGeometry, OMGraphicConstants, java.io.Serializable

Direct Known Subclasses:
  PolygonGeometry.LL, PolygonGeometry.XY, PolylineGeometry

public abstract class PolygonGeometry
extends BasicGeometry
implements java.io.Serializable, OMGeometry

Graphic object that represents a polygon.

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.

### NOTES:

- See the RESTRICTIONS on Lat/Lon polygons/polylines. Not following the guidelines listed may result in ambiguous/undefined shapes! Similar assumptions apply to the other vector graphics that we define: circles, ellipses, rects, lines.
- LatLon OMPolys store latlon coordinates internally in radian format for efficiency in projecting. Subclasses should follow this model.
- Holes in the poly are not supported. If you want holes, use multiple PolyGeometrys in a OMGeometryList.

### TODO:

- Polar filled-polygon correction for Cylindrical projections (like OMCircle).

See Also:
  Serialized Form

Nested Class Summary
`static class` `PolygonGeometry.LL`
`static class` `PolygonGeometry.Offset`
`static class` `PolygonGeometry.XY`

Field Summary
`protected boolean` `doShapes` Flag for telling the PolygonGeometry to use the Shape objects to represent itself internally.
`protected boolean` `isPolygon` Whether it is a polygon, as opposed to a polyline.
`protected int[][]` `xpoints` Internal array of projected x coordinate arrays.
`protected int[][]` `ypoints` Internal array of projected y coordinate arrays.

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
`protected` `PolygonGeometry()`

Method Summary
`protected abstract void` `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(int x, int y)` Return the shortest distance from the graphic to an XY-point.
`boolean` `getDoShapes()`
`boolean` `getIsPolygon()`
`java.awt.geom.GeneralPath` `getShape()` Get the array of java.awt.Shape objects that represent the projected graphic.
`void` `setDoShapes(boolean set)`
`protected void` `setIsPolygon(boolean set)`

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, deselect, distanceToEdge, draw, fill, generate, getAppObject, getAppObject, getAttribute, getAttributeMap, getAttributes, getLineType, getNeedToRegenerate, getRenderType, isRenderable, isVisible, putAttribute, regenerate, removeAttribute, replaceAppObjectWithAttributeMap, select, setAppObject, setAppObject, setAttributes, setLineType, setNeedToRegenerate, setShape, setVisible`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Methods inherited from interface com.bbn.openmap.omGraphics.OMGeometry
`clearAttributes, contains, deselect, draw, fill, generate, getAppObject, getAttribute, getAttributes, getLineType, getNeedToRegenerate, getRenderType, isRenderable, isVisible, putAttribute, regenerate, removeAttribute, select, setAppObject, setAttributes, setLineType, setNeedToRegenerate, setShape, setVisible`

Field Detail

### xpoints

    protected int[][] xpoints

  Internal array of projected x coordinate arrays.

### ypoints

    protected int[][] ypoints

  Internal array of projected y coordinate arrays.

### isPolygon

    protected boolean isPolygon

  Whether it is a polygon, as opposed to a polyline. Should be a polygon, since that is what is being created. The PolylineGeometry subclasses set this to false.

### doShapes

    protected boolean doShapes

  Flag for telling the PolygonGeometry to use the Shape objects to represent itself internally. See intro for more info.

Constructor Detail

### PolygonGeometry

    protected PolygonGeometry()

Method Detail

### setDoShapes

    public void setDoShapes(boolean set)

### getDoShapes

    public boolean getDoShapes()

### setIsPolygon

    protected void setIsPolygon(boolean set)

### getIsPolygon

    public boolean getIsPolygon()

### createShape

    protected abstract void createShape()

  Since OMPoly has the option to not create a Shape, this method is here to create it if it is asked for. The OMPoly needs to be generated.

### distance

    public float distance(int x,
                          int y)

  Return the shortest distance from the graphic to an XY-point. This works if generate() has been successful.

  Specified by:
    `distance` in interface `OMGeometry`
  Overrides:
    `distance` in class `BasicGeometry`
  Parameters:
    `x` - horizontal pixel location.
    `y` - vertical pixel location.
  Returns:
    the distance of the object to the location given.

### getShape

    public java.awt.geom.GeneralPath getShape()

  Get the array of java.awt.Shape objects that represent the projected graphic. The array will contain more than one Shape object of the object wraps around the earth and needs to show up in more than one place on the map.

  The java.awt.Shape object gives you the ability to do a little spatial analysis on the graphics.

  Specified by:
    `getShape` in interface `OMGeometry`
  Overrides:
    `getShape` in class `BasicGeometry`
  Returns:
    java.awt.Shape[], or null if the graphic needs to be generated with the current map projection, or null if the OMGeometry hasn't been updated to use Shape objects for its internal representation.

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