com.bbn.openmap.omGraphics.labeled
Class LabeledOMPoly

java.lang.Object
  extended by com.bbn.openmap.omGraphics.geom.BasicGeometry
      extended by com.bbn.openmap.omGraphics.OMGraphicAdapter
          extended by com.bbn.openmap.omGraphics.OMAbstractLine
              extended by com.bbn.openmap.omGraphics.OMPoly
                  extended by com.bbn.openmap.omGraphics.labeled.LabeledOMPoly
All Implemented Interfaces:
LabeledOMGraphic, OMGeometry, OMGraphic, OMGraphicConstants, java.io.Serializable, java.lang.Cloneable

public class LabeledOMPoly
extends OMPoly
implements LabeledOMGraphic

This is an OMPoly that has been extended to manage a text label.

See Also:
Serialized Form

Field Summary
protected  int index
           
protected  OMText label
           
protected  boolean locateAtCenter
           
protected  java.awt.Point offset
           
 
Fields inherited from class com.bbn.openmap.omGraphics.OMPoly
coordMode, COORDMODE_ORIGIN, COORDMODE_PREVIOUS, doShapes, geometryClosed, isPolygon, lat, lon, rawllpts, units, xs, ys
 
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
 
Fields inherited from interface com.bbn.openmap.omGraphics.OMGraphicConstants
ADD_GRAPHIC_MASK, APP_OBJECT, 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, INDEX, INFOLINE, LABEL, LINETYPE_GREATCIRCLE, LINETYPE_RHUMB, LINETYPE_STRAIGHT, LINETYPE_UNKNOWN, LOWER_GRAPHIC_MASK, LOWER_TO_BOTTOM_GRAPHIC_MASK, NO_ROTATE, OMGRAPHIC_ELT, OMGRAPHIC_TYPE_ATTR, 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, UPDATED
 
Constructor Summary
LabeledOMPoly()
           
LabeledOMPoly(double[] llPoints, int units, int lType)
          Create an LabeledOMPoly from a list of float lat/lon pairs.
LabeledOMPoly(double[] llPoints, int units, int lType, int nsegs)
          Create an LabeledOMPoly from a list of float lat/lon pairs.
LabeledOMPoly(double latPoint, double lonPoint, int[] xypoints, int cMode)
          Create an x/y LabeledOMPoly at an offset from lat/lon.
LabeledOMPoly(double latPoint, double lonPoint, int[] xPoints, int[] yPoints, int cMode)
          Create an x/y LabeledOMPoly at an offset from lat/lon.
LabeledOMPoly(int[] xypoints)
          Create an LabeledOMPoly from a list of xy pairs.
LabeledOMPoly(int[] xPoints, int[] yPoints)
          Create an x/y LabeledOMPoly.
 
Method Summary
protected  double calculateProjectedArea()
          Calculate the projected area of the poly.
 boolean generate(Projection proj)
          Prepare the poly for rendering.
 java.awt.Point getCenter()
          Get the calculated center where the label string is drawn.
 java.awt.Font getFont()
          Get the Font for the label.
 int getIndex()
          Get the index of the OMGraphic where the String will be rendered.
 int getJustify()
          Get the justification setting for the label.
protected  OMText getLabel()
           
 java.awt.Point getOffset()
          Get the x, y pixel offsets set for the rendering of the point.
 double getRotationAngle()
          Get the current rotation of the text.
 java.lang.String getText()
          Get the String for the label.
protected  java.awt.Point getTextPoint(Projection proj)
          Calculate where the text point ought to go.
 boolean isLocateAtCenter()
          Get whether the LabeledOMGraphic is placing the label String in the center of the OMGraphic.
 void render(java.awt.Graphics g)
          Paint the poly.
 void setFont(java.awt.Font f)
          Set the Font for the label.
 void setIndex(int index)
          Set the index of the OMGraphic coordinates where the drawing point of the label should be attached.
 void setJustify(int just)
          Set the justification setting for the label.
 void setLinePaint(java.awt.Paint paint)
          Set the line paint for the polygon.
 void setLocateAtCenter(boolean set)
          Tell the LabeledOMGraphic to calculate the location of the String that would put it in the middle of the OMGraphic.
 void setOffset(java.awt.Point p)
          Set the x, y pixel offsets where the String should be rendered, from the location determined from the index point, or from the calculated center point.
 void setRotationAngle(double angle)
          Set the angle by which the text is to rotated.
 void setText(java.lang.String label)
          Set the String for the label.
 void setTextPaint(java.awt.Paint paint)
          If not set to null, the text will be painted in a different color.
 
Methods inherited from class com.bbn.openmap.omGraphics.OMPoly
checkPoints, createShape, distance, getCoordMode, getDoShapes, getIndexOfFirstNodeOfSegIntersect, getLat, getLatLonArray, getLatLonArrayCopy, getLon, getNumSegs, getRawllpts, getShape, getUnits, getXs, getYs, insertRadians, isGeometryClosed, isPolygon, main, restore, setCoordMode, setDoShapes, setFillPaint, setIsPolygon, setLat, setLocation, setLocation, setLocation, setLocation, setLocation, setLon, setNumSegs, setXs, setYs, shouldRenderFill
 
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.OMGraphicAdapter
clone, deselect, getDeclutterType, getDisplayColor, getDisplayPaint, getEdgeMatchesFill, getFillColor, getFillPaint, getHasLabel, getLineColor, getLinePaint, getMattingPaint, getRenderType, getSelectColor, getSelectPaint, getShowEditablePalette, getStroke, getTextureMask, hasLineTypeChoice, initLabelingDuringGenerate, isClear, isMatted, isSelected, normalizeDistanceForLineWidth, readStroke, readTextureMask, regenerate, renderLabel, renderShape, select, setDeclutterType, setEdgeMatchesFill, setFillColor, setGraphicsColor, setGraphicsForEdge, setGraphicsForFill, setHasLabel, setLabelLocation, setLabelLocation, setLabelLocation, setLabelLocation, setLabelLocation, setLabelLocation, setLabelLocation, setLabelLocation, setLineColor, setMatted, setMattingPaint, setRenderType, setSelectColor, setSelected, setSelectPaint, setShowEditablePalette, setStroke, setTextureMask, shouldRenderEdge, writeStroke, writeTextureMask
 
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.OMGraphic
clone, deselect, getDeclutterType, getDisplayColor, getDisplayPaint, getFillColor, getFillPaint, getLineColor, getLinePaint, getMattingPaint, getRenderType, getSelectColor, getSelectPaint, getShowEditablePalette, getStroke, getTextureMask, hasLineTypeChoice, isMatted, isSelected, normalizeDistanceForLineWidth, regenerate, renderLabel, select, setDeclutterType, setGraphicsColor, setGraphicsForEdge, setGraphicsForFill, setLabelLocation, setLabelLocation, setLabelLocation, setMatted, setMattingPaint, setRenderType, setSelected, setSelectPaint, setShowEditablePalette, setStroke, setTextureMask, shouldRenderEdge
 
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

label

protected OMText label

offset

protected java.awt.Point offset

locateAtCenter

protected boolean locateAtCenter

index

protected int index
Constructor Detail

LabeledOMPoly

public LabeledOMPoly()

LabeledOMPoly

public LabeledOMPoly(double[] llPoints,
                     int units,
                     int lType)
Create an LabeledOMPoly from a list of float lat/lon pairs.

See Also:
OMPoly.OMPoly(double[], int, int)

LabeledOMPoly

public LabeledOMPoly(double[] llPoints,
                     int units,
                     int lType,
                     int nsegs)
Create an LabeledOMPoly from a list of float lat/lon pairs.

See Also:
OMPoly.OMPoly(double[], int, int, int)

LabeledOMPoly

public LabeledOMPoly(int[] xypoints)
Create an LabeledOMPoly from a list of xy pairs.

See Also:
OMPoly.OMPoly(int[])

LabeledOMPoly

public LabeledOMPoly(int[] xPoints,
                     int[] yPoints)
Create an x/y LabeledOMPoly.

See Also:
OMPoly.OMPoly(int[], int[])

LabeledOMPoly

public LabeledOMPoly(double latPoint,
                     double lonPoint,
                     int[] xypoints,
                     int cMode)
Create an x/y LabeledOMPoly at an offset from lat/lon.

See Also:
OMPoly.OMPoly(double, double, int[], int)

LabeledOMPoly

public LabeledOMPoly(double latPoint,
                     double lonPoint,
                     int[] xPoints,
                     int[] yPoints,
                     int cMode)
Create an x/y LabeledOMPoly at an offset from lat/lon.

See Also:
OMPoly.OMPoly(double, double, int[], int[], int)
Method Detail

setText

public void setText(java.lang.String label)
Set the String for the label.

Specified by:
setText in interface LabeledOMGraphic

getText

public java.lang.String getText()
Get the String for the label.

Specified by:
getText in interface LabeledOMGraphic

getLabel

protected OMText getLabel()

setFont

public void setFont(java.awt.Font f)
Set the Font for the label.

Specified by:
setFont in interface LabeledOMGraphic

getFont

public java.awt.Font getFont()
Get the Font for the label.

Specified by:
getFont in interface LabeledOMGraphic

setJustify

public void setJustify(int just)
Set the justification setting for the label.

Specified by:
setJustify in interface LabeledOMGraphic
See Also:
OMText.JUSTIFY_LEFT, OMText.JUSTIFY_CENTER, OMText.JUSTIFY_RIGHT

getJustify

public int getJustify()
Get the justification setting for the label.

Specified by:
getJustify in interface LabeledOMGraphic
See Also:
OMText.JUSTIFY_LEFT, OMText.JUSTIFY_CENTER, OMText.JUSTIFY_RIGHT

setLocateAtCenter

public void setLocateAtCenter(boolean set)
Tell the LabeledOMGraphic to calculate the location of the String that would put it in the middle of the OMGraphic.

Specified by:
setLocateAtCenter in interface LabeledOMGraphic

isLocateAtCenter

public boolean isLocateAtCenter()
Get whether the LabeledOMGraphic is placing the label String in the center of the OMGraphic.

Specified by:
isLocateAtCenter in interface LabeledOMGraphic

calculateProjectedArea

protected double calculateProjectedArea()
Calculate the projected area of the poly. Algorithm used is from some australian astronomy website =) http://astronomy.swin.edu.au/~pbourke/geometry/polyarea


getCenter

public java.awt.Point getCenter()
Get the calculated center where the label string is drawn. Algorithm used is from some australian astronomy website =) http://astronomy.swin.edu.au/~pbourke/geometry/polyarea

Specified by:
getCenter in interface LabeledOMGraphic

setIndex

public void setIndex(int index)
Set the index of the OMGraphic coordinates where the drawing point of the label should be attached. The meaning of the point differs between OMGraphic types.

Specified by:
setIndex in interface LabeledOMGraphic

getIndex

public int getIndex()
Get the index of the OMGraphic where the String will be rendered. The meaning of the index differs from OMGraphic type to OMGraphic type.

Specified by:
getIndex in interface LabeledOMGraphic

setOffset

public void setOffset(java.awt.Point p)
Set the x, y pixel offsets where the String should be rendered, from the location determined from the index point, or from the calculated center point. Point.x is the horizontal offset, Point.y is the vertical offset.

Specified by:
setOffset in interface LabeledOMGraphic

getOffset

public java.awt.Point getOffset()
Get the x, y pixel offsets set for the rendering of the point.

Specified by:
getOffset in interface LabeledOMGraphic

setRotationAngle

public void setRotationAngle(double angle)
Set the angle by which the text is to rotated.

Specified by:
setRotationAngle in interface LabeledOMGraphic
Parameters:
angle - the number of radians the text is to be rotated. Measured clockwise from horizontal. Positive numbers move the positive x axis toward the positive y axis.

getRotationAngle

public double getRotationAngle()
Get the current rotation of the text.

Specified by:
getRotationAngle in interface LabeledOMGraphic
Returns:
the text rotation.

setLinePaint

public void setLinePaint(java.awt.Paint paint)
Set the line paint for the polygon. If the text paint hasn't been explicitly set, then the text paint will be set to this paint, too.

Specified by:
setLinePaint in interface OMGraphic
Overrides:
setLinePaint in class OMGraphicAdapter
Parameters:
paint - the real line Paint

setTextPaint

public void setTextPaint(java.awt.Paint paint)
If not set to null, the text will be painted in a different color. If set to null, the text paint will match the poly edge paint.

Parameters:
paint - the Paint object for the text

getTextPoint

protected java.awt.Point getTextPoint(Projection proj)
Calculate where the text point ought to go.


generate

public boolean generate(Projection proj)
Description copied from class: OMPoly
Prepare the poly for rendering.

Specified by:
generate in interface OMGeometry
Overrides:
generate in class OMPoly
Parameters:
proj - Projection
Returns:
true if generate was successful
See Also:
OMGraphicAdapter.regenerate(com.bbn.openmap.proj.Projection)

render

public void render(java.awt.Graphics g)
Description copied from class: OMPoly
Paint the poly. This works if generate() has been successful.

Specified by:
render in interface OMGeometry
Overrides:
render in class OMPoly
Parameters:
g - java.awt.Graphics to paint the poly onto.


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