Class MeasureTool
- java.lang.Object
-
- gov.nasa.worldwind.avlist.AVListImpl
-
- gov.nasa.worldwind.util.measure.MeasureTool
-
- All Implemented Interfaces:
AVList,Disposable
public class MeasureTool extends AVListImpl implements Disposable
A utility class to interactively draw shapes and measure distance and area across the terrain. When armed, the class monitors mouse events to allow the definition of a measure shape that can be one ofSHAPE_LINE,SHAPE_PATH,SHAPE_POLYGON,SHAPE_CIRCLE,SHAPE_ELLIPSE,SHAPE_SQUAREorSHAPE_QUAD.In order to allow user interaction with the measuring shape, a controller must be set by calling
setController(MeasureToolController)with a new instance of aMeasureToolController.The interaction sequence for drawing a shape and measuring is as follows:
- Set the measure shape.
- Arm the
MeasureToolobject by calling itssetArmed(boolean)method with an argument of true. - Click on the terrain to add points.
- Disarm the
MeasureToolobject by calling itssetArmed(boolean)method with an argument of false. - Read the measured length or area by calling
the
MeasureToolgetLength()orgetArea()method. Note that the length and area can be queried at any time during or after the process.
While entering points or after the measure tool has been disarmed, dragging the control points allow to change the initial points positions and alter the measure shape.
While the
MeasureToolis armed, pressing and immediately releasing mouse button one while also pressing the control key (Ctl) removes the last point entered. Once theMeasureToolis disarmed, a measure shape of type SHAPE_POLYGON can be moved by dragging a control point while pressing the alt/option key.Arming and disarming the
MeasureTooldoes not change the contents or attributes of the measure tool's layer. Note that the measure tool will NOT disarm itself after the second point of a line or a regular shape has been entered - the MeasureToolController has that responsibility.Setting the measure shape from the application
The application can set the measure shape to an arbitrary list of positions using
setPositions(java.util.ArrayList). If the provided list contains two positions, the measure shape will be set toSHAPE_LINE. If more then two positions are provided, the measure shape will be set toSHAPE_PATHif the last position differs from the first (open path), orSHAPE_POLYGONif the path is closed.The application can also set the measure shape to a predefined regular shape by calling
setMeasureShapeType(String, Position, double, double, Angle), providing a shape type (one ofSHAPE_CIRCLE,SHAPE_ELLIPSE,SHAPE_SQUAREorSHAPE_QUAD), a center position, a width, a height (in meters) and a heading angle.Finally, the application can use an existing
PathorSurfaceShapeby usingsetMeasureShape(Path)orsetMeasureShape(SurfaceShape). The surface shape can be one ofSurfacePolyline,SurfacePolygon,SurfaceQuad,SurfaceSquare,SurfaceEllipseorSurfaceCircle.Measuring
The application can read the measured length or area by calling the
MeasureToolgetLength()orgetArea()method. These methods will return -1 when no value is available.Regular shapes are defined by a center position, a width a height and a heading angle. Those attributes can be accessed by calling the
getCenterPosition(),getWidth(),getHeight()andgetOrientation()methods.The measurements are displayed in units specified in the measure tool's
UnitsFormatobject. Access to the units format is via the methodgetUnitsFormat().Events
The
MeasureToolwill send events on several occasions: when the position list has changed -EVENT_POSITION_ADD,EVENT_POSITION_REMOVEorEVENT_POSITION_REPLACE, when metrics has changedEVENT_METRIC_CHANGEDor when the tool is armed or disarmedEVENT_ARMED.Events will also be fired at the start and end of a rubber band operation during shape creation:
EVENT_RUBBERBAND_STARTandEVENT_RUBBERBAND_STOP.See
MeasureToolPanelfor some events usage.Several instances of this class can be used simultaneously. However, each instance should be disposed of after usage by calling the
dispose()method.- See Also:
MeasureToolController
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classMeasureTool.ControlPointprotected static classMeasureTool.ControlPointWithLeaderprotected static classMeasureTool.CustomRenderableLayer
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringACCUMULATED_LABELstatic java.lang.StringANGLE_LABELprotected ScreenAnnotationannotationprotected AnnotationAttributesannotationAttributesprotected RenderableLayerapplicationLayerstatic java.lang.StringAREA_LABELstatic java.lang.StringCENTER_LATITUDE_LABELstatic java.lang.StringCENTER_LONGITUDE_LABELstatic java.lang.StringCONTROL_TYPE_LEADER_ORIGINstatic java.lang.StringCONTROL_TYPE_LOCATION_INDEXstatic java.lang.StringCONTROL_TYPE_REGULAR_SHAPEprotected MeasureToolControllercontrollerprotected java.util.ArrayList<Renderable>controlPointsprotected AnnotationAttributescontrolPointsAttributesprotected MeasureTool.CustomRenderableLayercontrolPointsLayerprotected AnnotationAttributescontrolPointWithLeaderAttributesstatic java.lang.StringEVENT_ARMEDstatic java.lang.StringEVENT_METRIC_CHANGEDstatic java.lang.StringEVENT_POSITION_ADDstatic java.lang.StringEVENT_POSITION_REMOVEstatic java.lang.StringEVENT_POSITION_REPLACEstatic java.lang.StringEVENT_RUBBERBAND_STARTstatic java.lang.StringEVENT_RUBBERBAND_STOPprotected java.awt.ColorfillColorprotected booleanfollowTerrainstatic java.lang.StringHEADING_LABELstatic java.lang.StringHEIGHT_LABELstatic java.lang.StringLATITUDE_LABELprotected MeasureTool.CustomRenderableLayerlayerprotected ShapeAttributesleaderAttributesstatic java.lang.StringLENGTH_LABELprotected Pathlineprotected java.awt.ColorlineColorprotected doublelineWidthstatic java.lang.StringLONGITUDE_LABELstatic java.lang.StringMAJOR_AXIS_LABELprotected static intMAX_SHAPE_MOVE_ITERATIONSprotected java.lang.StringmeasureShapeTypestatic java.lang.StringMINOR_AXIS_LABELprotected java.lang.StringpathTypestatic java.lang.StringPERIMETER_LABELprotected java.util.ArrayList<Position>positionsstatic java.lang.StringRADIUS_LABELstatic java.lang.StringSHAPE_CIRCLEprotected static doubleSHAPE_CONTROL_EPSILON_METERSstatic java.lang.StringSHAPE_ELLIPSEstatic java.lang.StringSHAPE_LINEprotected static doubleSHAPE_MIN_HEIGHT_METERSprotected static doubleSHAPE_MIN_WIDTH_METERSstatic java.lang.StringSHAPE_PATHstatic java.lang.StringSHAPE_POLYGONstatic java.lang.StringSHAPE_QUADstatic java.lang.StringSHAPE_SQUAREprotected PositionshapeCenterPositionprotected intshapeIntervalsprotected MeasureTool.CustomRenderableLayershapeLayerprotected AngleshapeOrientationprotected java.awt.geom.Rectangle2D.DoubleshapeRectangleprotected booleanshowAnnotationprotected booleanshowControlPointsprotected SurfaceShapesurfaceShapeprotected UnitsFormatunitsFormatstatic java.lang.StringWIDTH_LABELprotected WorldWindowwwd
-
Constructor Summary
Constructors Constructor Description MeasureTool(WorldWindow wwd)Construct a new measure tool drawing events from the specifiedWorldWindow.MeasureTool(WorldWindow wwd, RenderableLayer applicationLayer)Construct a new measure tool drawing events from the specifiedWorldWindowand using the givenRenderableLayer.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description PositionaddControlPoint()Add a control point to the current measure shape at the current WorldWindow position.protected voidaddControlPoint(Position position, java.lang.String key, java.lang.Object value)protected voidaddControlPointWithLeader(Position position, java.lang.String controlKey, java.lang.Object control, java.lang.String leaderKey, java.lang.Object leader)protected booleanareLocationsRedundant(LatLon locA, LatLon locB)voidclear()Removes all positions from the shape, clear attributes.protected java.lang.DoublecomputeAccumulatedLength(LatLon pos)protected AnglecomputeAngleBetween(LatLon a, LatLon b, LatLon c)protected AnglecomputeControlPointAzimuth(java.lang.String control, double width, double height)protected AnglecomputeControlPointAzimuthInShapeCoordinates(java.lang.String control, Angle azimuth)protected LatLoncomputeControlPointLocation(java.lang.String control, Globe globe, Angle heading, LatLon center, double width, double height)protected AnglecomputeControlPointPathLength(java.lang.String control, double width, double height, double globeRadius)protected java.lang.StringcomputeCornerControl(Position position)protected static AnglecomputeNormalizedHeading(Angle heading)protected doublecomputePathLength()protected LatLoncomputeQuadEdgeMidpointLocation(java.lang.String control, Globe globe, Angle heading, LatLon center, double width, double height)protected PositioncomputeSurfacePosition(LatLon latLon)protected MeasureTool.CustomRenderableLayercreateCustomRenderableLayer()voiddispose()Disposes of any internal resources allocated by the object.protected voiddoAddControlPoint(MeasureTool.ControlPoint controlPoint)protected java.lang.StringformatCircleMeasurements(Position pos)protected java.lang.StringformatEllipseMeasurements(Position pos)protected java.lang.StringformatLineMeasurements(Position pos)protected java.lang.StringformatPolygonMeasurements(Position pos)protected java.lang.StringformatQuadMeasurements(Position pos)protected java.lang.StringformatSquareMeasurements(Position pos)AnnotationAttributesgetAnnotationAttributes()Get the attributes associated with the tool tip annotation.RenderableLayergetApplicationLayer()Returns the application layer passed to the constructor.doublegetArea()PositiongetCenterPosition()MeasureToolControllergetController()Get theMeasureToolControllerfor this measure tool.MeasureTool.ControlPointgetControlPoint(java.lang.String control)java.util.ArrayList<Renderable>getControlPoints()Get the list of control points associated with the current measure shape.AnnotationAttributesgetControlPointsAttributes()Get the attributes associated with the control points.protected java.lang.StringgetDisplayString(Position pos)java.awt.ColorgetFillColor()doublegetHeight()java.lang.StringgetLabel(java.lang.String labelName)RenderableLayergetLayer()Returns the measure tool layer.doublegetLength()PathgetLine()Returns the path currently used to display lines and path.java.awt.ColorgetLineColor()doublegetLineWidth()java.lang.StringgetMeasureShapeType()Get the measure shape type.protected MeasureTool.ControlPointgetOppositeControl(java.lang.String control)AnglegetOrientation()java.lang.StringgetPathType()protected java.lang.StringgetPathType(java.util.List<? extends Position> positions)java.util.ArrayList<? extends Position>getPositions()Get the list of positions that define the current measure shape.java.lang.StringgetShapeInitialControl(Position position)protected AnglegetShapeInitialHeading()SurfaceShapegetSurfaceShape()Returns the surface shape currently used to display polygons.UnitsFormatgetUnitsFormat()Return theUnitsFormatinstance governing the measurement value display units and format.doublegetWidth()WorldWindowgetWwd()booleanisArmed()Identifies whether the measure tool controller is armed.booleanisCenterControl(MeasureTool.ControlPoint controlPoint)booleanisCornerControl(MeasureTool.ControlPoint controlPoint)booleanisFollowTerrain()booleanisMeasureShape(java.lang.Object o)booleanisRegularShape()protected booleanisRegularShape(java.lang.String shape)booleanisShowAnnotation()booleanisShowControlPoints()booleanisSideControl(MeasureTool.ControlPoint controlPoint)protected booleanlengthsEssentiallyEqual(java.lang.Double l1, java.lang.Double l2)voidmoveControlPoint(MeasureTool.ControlPoint point)Update the current measure shape according to a given control point position.voidmoveControlPoint(MeasureTool.ControlPoint point, java.lang.String mode)Update the current measure shape according to a given control point position and shape edition mode.voidmoveMeasureShape(Angle azimuth, Angle distance)Move the current measure shape along a great circle arc at a given azimuthAnglefor a given distanceAngle.protected LatLonmoveShapeByControlPoint(MeasureTool.ControlPoint controlPoint, Globe globe, Angle heading, LatLon center, double width, double height)voidremoveControlPoint()Remove the last control point from the current measure shape.voidsetArmed(boolean state)Arms and disarms the measure tool controller.voidsetController(MeasureToolController controller)Set the controller object for this measure tool - can be null.voidsetFillColor(java.awt.Color color)voidsetFollowTerrain(boolean followTerrain)protected voidsetInitialLabels()voidsetLabel(java.lang.String labelName, java.lang.String label)voidsetLineColor(java.awt.Color color)voidsetLineWidth(double width)voidsetMeasureShape(Path line)Set the measure shape to an existingPath.voidsetMeasureShape(SurfaceShape surfaceShape)Set the measure shape to an existingSurfaceShape.voidsetMeasureShapeType(java.lang.String shape)Set the measure shape type.voidsetMeasureShapeType(java.lang.String shapeType, Position centerPosition, double radius)Set and initialize the measure shape to one of the regular shapesSHAPE_CIRCLE,SHAPE_ELLIPSE,SHAPE_SQUAREorSHAPE_QUAD.voidsetMeasureShapeType(java.lang.String shapeType, Position centerPosition, double width, double height, Angle orientation)Set and initialize the measure shape to one of the regular shapesSHAPE_CIRCLE,SHAPE_ELLIPSE,SHAPE_SQUAREorSHAPE_QUAD.voidsetPathType(java.lang.String type)voidsetPositions(java.util.ArrayList<? extends Position> newPositions)Set the measure shape to an arbitrary list of positions.voidsetShowAnnotation(boolean state)voidsetShowControlPoints(boolean state)voidsetUnitsFormat(UnitsFormat unitsFormat)Set the measure tool's @{link UnitsFormat} instance that governs measurement value display units and format.protected voidswapCornerControls(java.lang.String control, Position position)protected voidswapEdgeControls(java.lang.String control, Position position)voidupdateAnnotation(Position pos)protected voidupdateControlPointWithLeader(MeasureTool.ControlPointWithLeader cp, LatLon controlLocation)protected voidupdateMeasureShape()protected voidupdatePositionsFromShape()protected voidupdateShapeCenter(java.lang.String control, Position newPosition)protected voidupdateShapeControlPoints()protected voidupdateShapeOrientation(java.lang.String control, Position newPosition)protected voidupdateShapeProperties(java.lang.String control, Position newPosition, java.lang.String mode)protected voidupdateShapeSize(java.lang.String control, Position newPosition)-
Methods inherited from class gov.nasa.worldwind.avlist.AVListImpl
addPropertyChangeListener, addPropertyChangeListener, clearList, copy, firePropertyChange, firePropertyChange, getBooleanValue, getBooleanValue, getChangeSupport, getDoubleValue, getDoubleValue, getEntries, getIntegerValue, getIntegerValue, getLongValue, getLongValue, getRestorableStateForAVPair, getStringValue, getStringValue, getStringValue, getValue, getValues, hasKey, removeKey, removePropertyChangeListener, removePropertyChangeListener, setValue, setValues
-
-
-
-
Field Detail
-
SHAPE_LINE
public static final java.lang.String SHAPE_LINE
- See Also:
- Constant Field Values
-
SHAPE_PATH
public static final java.lang.String SHAPE_PATH
- See Also:
- Constant Field Values
-
SHAPE_POLYGON
public static final java.lang.String SHAPE_POLYGON
- See Also:
- Constant Field Values
-
SHAPE_CIRCLE
public static final java.lang.String SHAPE_CIRCLE
- See Also:
- Constant Field Values
-
SHAPE_ELLIPSE
public static final java.lang.String SHAPE_ELLIPSE
- See Also:
- Constant Field Values
-
SHAPE_QUAD
public static final java.lang.String SHAPE_QUAD
- See Also:
- Constant Field Values
-
SHAPE_SQUARE
public static final java.lang.String SHAPE_SQUARE
- See Also:
- Constant Field Values
-
EVENT_POSITION_ADD
public static final java.lang.String EVENT_POSITION_ADD
- See Also:
- Constant Field Values
-
EVENT_POSITION_REMOVE
public static final java.lang.String EVENT_POSITION_REMOVE
- See Also:
- Constant Field Values
-
EVENT_POSITION_REPLACE
public static final java.lang.String EVENT_POSITION_REPLACE
- See Also:
- Constant Field Values
-
EVENT_METRIC_CHANGED
public static final java.lang.String EVENT_METRIC_CHANGED
- See Also:
- Constant Field Values
-
EVENT_ARMED
public static final java.lang.String EVENT_ARMED
- See Also:
- Constant Field Values
-
EVENT_RUBBERBAND_START
public static final java.lang.String EVENT_RUBBERBAND_START
- See Also:
- Constant Field Values
-
EVENT_RUBBERBAND_STOP
public static final java.lang.String EVENT_RUBBERBAND_STOP
- See Also:
- Constant Field Values
-
ANGLE_LABEL
public static final java.lang.String ANGLE_LABEL
- See Also:
- Constant Field Values
-
AREA_LABEL
public static final java.lang.String AREA_LABEL
- See Also:
- Constant Field Values
-
LENGTH_LABEL
public static final java.lang.String LENGTH_LABEL
- See Also:
- Constant Field Values
-
PERIMETER_LABEL
public static final java.lang.String PERIMETER_LABEL
- See Also:
- Constant Field Values
-
RADIUS_LABEL
public static final java.lang.String RADIUS_LABEL
- See Also:
- Constant Field Values
-
HEIGHT_LABEL
public static final java.lang.String HEIGHT_LABEL
- See Also:
- Constant Field Values
-
WIDTH_LABEL
public static final java.lang.String WIDTH_LABEL
- See Also:
- Constant Field Values
-
HEADING_LABEL
public static final java.lang.String HEADING_LABEL
- See Also:
- Constant Field Values
-
CENTER_LATITUDE_LABEL
public static final java.lang.String CENTER_LATITUDE_LABEL
- See Also:
- Constant Field Values
-
CENTER_LONGITUDE_LABEL
public static final java.lang.String CENTER_LONGITUDE_LABEL
- See Also:
- Constant Field Values
-
LATITUDE_LABEL
public static final java.lang.String LATITUDE_LABEL
- See Also:
- Constant Field Values
-
LONGITUDE_LABEL
public static final java.lang.String LONGITUDE_LABEL
- See Also:
- Constant Field Values
-
ACCUMULATED_LABEL
public static final java.lang.String ACCUMULATED_LABEL
- See Also:
- Constant Field Values
-
MAJOR_AXIS_LABEL
public static final java.lang.String MAJOR_AXIS_LABEL
- See Also:
- Constant Field Values
-
MINOR_AXIS_LABEL
public static final java.lang.String MINOR_AXIS_LABEL
- See Also:
- Constant Field Values
-
CONTROL_TYPE_LOCATION_INDEX
public static final java.lang.String CONTROL_TYPE_LOCATION_INDEX
- See Also:
- Constant Field Values
-
CONTROL_TYPE_REGULAR_SHAPE
public static final java.lang.String CONTROL_TYPE_REGULAR_SHAPE
- See Also:
- Constant Field Values
-
CONTROL_TYPE_LEADER_ORIGIN
public static final java.lang.String CONTROL_TYPE_LEADER_ORIGIN
- See Also:
- Constant Field Values
-
SHAPE_MIN_WIDTH_METERS
protected static final double SHAPE_MIN_WIDTH_METERS
- See Also:
- Constant Field Values
-
SHAPE_MIN_HEIGHT_METERS
protected static final double SHAPE_MIN_HEIGHT_METERS
- See Also:
- Constant Field Values
-
MAX_SHAPE_MOVE_ITERATIONS
protected static final int MAX_SHAPE_MOVE_ITERATIONS
- See Also:
- Constant Field Values
-
SHAPE_CONTROL_EPSILON_METERS
protected static final double SHAPE_CONTROL_EPSILON_METERS
- See Also:
- Constant Field Values
-
wwd
protected final WorldWindow wwd
-
controller
protected MeasureToolController controller
-
positions
protected java.util.ArrayList<Position> positions
-
controlPoints
protected java.util.ArrayList<Renderable> controlPoints
-
applicationLayer
protected RenderableLayer applicationLayer
-
layer
protected MeasureTool.CustomRenderableLayer layer
-
controlPointsLayer
protected MeasureTool.CustomRenderableLayer controlPointsLayer
-
shapeLayer
protected MeasureTool.CustomRenderableLayer shapeLayer
-
line
protected Path line
-
surfaceShape
protected SurfaceShape surfaceShape
-
annotation
protected ScreenAnnotation annotation
-
lineColor
protected java.awt.Color lineColor
-
fillColor
protected java.awt.Color fillColor
-
lineWidth
protected double lineWidth
-
pathType
protected java.lang.String pathType
-
controlPointsAttributes
protected AnnotationAttributes controlPointsAttributes
-
controlPointWithLeaderAttributes
protected AnnotationAttributes controlPointWithLeaderAttributes
-
leaderAttributes
protected ShapeAttributes leaderAttributes
-
annotationAttributes
protected AnnotationAttributes annotationAttributes
-
measureShapeType
protected java.lang.String measureShapeType
-
followTerrain
protected boolean followTerrain
-
showControlPoints
protected boolean showControlPoints
-
showAnnotation
protected boolean showAnnotation
-
unitsFormat
protected UnitsFormat unitsFormat
-
shapeRectangle
protected java.awt.geom.Rectangle2D.Double shapeRectangle
-
shapeCenterPosition
protected Position shapeCenterPosition
-
shapeOrientation
protected Angle shapeOrientation
-
shapeIntervals
protected int shapeIntervals
-
-
Constructor Detail
-
MeasureTool
public MeasureTool(WorldWindow wwd)
Construct a new measure tool drawing events from the specifiedWorldWindow.- Parameters:
wwd- theWorldWindowto draw events from.
-
MeasureTool
public MeasureTool(WorldWindow wwd, RenderableLayer applicationLayer)
Construct a new measure tool drawing events from the specifiedWorldWindowand using the givenRenderableLayer.- Parameters:
wwd- theWorldWindowto draw events from.applicationLayer- theRenderableLayerto use. May be null. If specified, the caller is responsible for adding the layer to the model and enabling it.
-
-
Method Detail
-
setInitialLabels
protected void setInitialLabels()
-
getWwd
public WorldWindow getWwd()
-
getUnitsFormat
public UnitsFormat getUnitsFormat()
Return theUnitsFormatinstance governing the measurement value display units and format.- Returns:
- the tool's units format instance.
-
setUnitsFormat
public void setUnitsFormat(UnitsFormat unitsFormat)
Set the measure tool's @{link UnitsFormat} instance that governs measurement value display units and format.- Parameters:
unitsFormat- the units format instance.- Throws:
java.lang.IllegalArgumentException- if the units format instance is null.
-
createCustomRenderableLayer
protected MeasureTool.CustomRenderableLayer createCustomRenderableLayer()
- Returns:
- Instance of the custom renderable layer to use of our internal layers
-
setController
public void setController(MeasureToolController controller)
Set the controller object for this measure tool - can be null.- Parameters:
controller- the controller object for this measure tool.
-
setLabel
public void setLabel(java.lang.String labelName, java.lang.String label)
-
getLabel
public java.lang.String getLabel(java.lang.String labelName)
-
getController
public MeasureToolController getController()
Get theMeasureToolControllerfor this measure tool.- Returns:
- the
MeasureToolControllerfor this measure tool.
-
setArmed
public void setArmed(boolean state)
Arms and disarms the measure tool controller. When armed, the controller monitors user input and builds the shape in response to user actions. When disarmed, the controller ignores all user input.- Parameters:
state- true to arm the controller, false to disarm it.
-
isArmed
public boolean isArmed()
Identifies whether the measure tool controller is armed.- Returns:
- true if armed, false if not armed.
-
getLayer
public RenderableLayer getLayer()
Returns the measure tool layer.- Returns:
- the layer containing the measure shape and control points.
-
getApplicationLayer
public RenderableLayer getApplicationLayer()
Returns the application layer passed to the constructor.- Returns:
- the layer containing the measure shape and control points.
-
getLine
public Path getLine()
Returns the path currently used to display lines and path.- Returns:
- the path currently used to display lines and path.
-
getSurfaceShape
public SurfaceShape getSurfaceShape()
Returns the surface shape currently used to display polygons.- Returns:
- the surface shape currently used to display polygons.
-
getPositions
public java.util.ArrayList<? extends Position> getPositions()
Get the list of positions that define the current measure shape.- Returns:
- the list of positions that define the current measure shape.
-
setPositions
public void setPositions(java.util.ArrayList<? extends Position> newPositions)
Set the measure shape to an arbitrary list of positions. If the provided list contains two positions, the measure shape will be set toSHAPE_LINE. If more then two positions are provided, the measure shape will be set toSHAPE_PATHif the last position differs from the first (open path), orSHAPE_POLYGONif the path is closed.- Parameters:
newPositions- the shape position list.
-
getControlPoints
public java.util.ArrayList<Renderable> getControlPoints()
Get the list of control points associated with the current measure shape.- Returns:
- the list of control points associated with the current measure shape.
-
getControlPointsAttributes
public AnnotationAttributes getControlPointsAttributes()
Get the attributes associated with the control points.- Returns:
- the attributes associated with the control points.
-
getAnnotationAttributes
public AnnotationAttributes getAnnotationAttributes()
Get the attributes associated with the tool tip annotation.- Returns:
- the attributes associated with the tool tip annotation.
-
setLineColor
public void setLineColor(java.awt.Color color)
-
getLineColor
public java.awt.Color getLineColor()
-
setFillColor
public void setFillColor(java.awt.Color color)
-
getFillColor
public java.awt.Color getFillColor()
-
setLineWidth
public void setLineWidth(double width)
-
getLineWidth
public double getLineWidth()
-
getPathType
public java.lang.String getPathType()
-
setPathType
public void setPathType(java.lang.String type)
-
isShowControlPoints
public boolean isShowControlPoints()
-
setShowControlPoints
public void setShowControlPoints(boolean state)
-
isShowAnnotation
public boolean isShowAnnotation()
-
setShowAnnotation
public void setShowAnnotation(boolean state)
-
clear
public void clear()
Removes all positions from the shape, clear attributes.
-
isMeasureShape
public boolean isMeasureShape(java.lang.Object o)
-
getMeasureShapeType
public java.lang.String getMeasureShapeType()
Get the measure shape type. can be one ofSHAPE_LINE,SHAPE_PATH,SHAPE_POLYGON,SHAPE_CIRCLE,SHAPE_ELLIPSE,SHAPE_SQUAREorSHAPE_QUAD.- Returns:
- the measure shape type.
-
setMeasureShapeType
public void setMeasureShapeType(java.lang.String shape)
Set the measure shape type. can be one ofSHAPE_LINE,SHAPE_PATH,SHAPE_POLYGON,SHAPE_CIRCLE,SHAPE_ELLIPSE,SHAPE_SQUAREorSHAPE_QUAD. This will reset the measure tool and clear the current measure shape.- Parameters:
shape- the measure shape type.
-
setMeasureShapeType
public void setMeasureShapeType(java.lang.String shapeType, Position centerPosition, double radius)Set and initialize the measure shape to one of the regular shapesSHAPE_CIRCLE,SHAPE_ELLIPSE,SHAPE_SQUAREorSHAPE_QUAD.- Parameters:
shapeType- the shape type.centerPosition- the shape center position.radius- the shape radius of half width/height.
-
setMeasureShapeType
public void setMeasureShapeType(java.lang.String shapeType, Position centerPosition, double width, double height, Angle orientation)Set and initialize the measure shape to one of the regular shapesSHAPE_CIRCLE,SHAPE_ELLIPSE,SHAPE_SQUAREorSHAPE_QUAD.- Parameters:
shapeType- the shape type.centerPosition- the shape center position.width- the shape width.height- the shape height.orientation- the shape orientation or azimuth angle - clockwise from north.
-
setMeasureShape
public void setMeasureShape(Path line)
Set the measure shape to an existingPath.- Parameters:
line- aPathinstance.
-
getPathType
protected java.lang.String getPathType(java.util.List<? extends Position> positions)
-
setMeasureShape
public void setMeasureShape(SurfaceShape surfaceShape)
Set the measure shape to an existingSurfaceShape. Can be one ofSurfacePolygon,SurfaceQuad,SurfaceSquare,SurfaceEllipseorSurfaceCircle.- Parameters:
surfaceShape- aSurfaceShapeinstance.
-
isRegularShape
public boolean isRegularShape()
-
isRegularShape
protected boolean isRegularShape(java.lang.String shape)
-
isFollowTerrain
public boolean isFollowTerrain()
-
setFollowTerrain
public void setFollowTerrain(boolean followTerrain)
-
isCenterControl
public boolean isCenterControl(MeasureTool.ControlPoint controlPoint)
-
isSideControl
public boolean isSideControl(MeasureTool.ControlPoint controlPoint)
-
isCornerControl
public boolean isCornerControl(MeasureTool.ControlPoint controlPoint)
-
getLength
public double getLength()
-
getArea
public double getArea()
-
getWidth
public double getWidth()
-
getHeight
public double getHeight()
-
getOrientation
public Angle getOrientation()
-
getCenterPosition
public Position getCenterPosition()
-
addControlPoint
public Position addControlPoint()
Add a control point to the current measure shape at the current WorldWindow position.- Returns:
- The position of the new control point, or null if the control point could not be added.
-
removeControlPoint
public void removeControlPoint()
Remove the last control point from the current measure shape.
-
moveControlPoint
public void moveControlPoint(MeasureTool.ControlPoint point)
Update the current measure shape according to a given control point position.- Parameters:
point- one of the shape control points.
-
moveControlPoint
public void moveControlPoint(MeasureTool.ControlPoint point, java.lang.String mode)
Update the current measure shape according to a given control point position and shape edition mode.- Parameters:
point- one of the shape control points.mode- the shape edition mode.
-
moveMeasureShape
public void moveMeasureShape(Angle azimuth, Angle distance)
Move the current measure shape along a great circle arc at a given azimuthAnglefor a given distanceAngle.- Parameters:
azimuth- the azimuthAngle.distance- the distanceAngle.
-
getShapeInitialControl
public java.lang.String getShapeInitialControl(Position position)
-
getShapeInitialHeading
protected Angle getShapeInitialHeading()
-
updateShapeProperties
protected void updateShapeProperties(java.lang.String control, Position newPosition, java.lang.String mode)
-
updateShapeCenter
protected void updateShapeCenter(java.lang.String control, Position newPosition)
-
updateShapeOrientation
protected void updateShapeOrientation(java.lang.String control, Position newPosition)
-
updateShapeSize
protected void updateShapeSize(java.lang.String control, Position newPosition)
-
getControlPoint
public MeasureTool.ControlPoint getControlPoint(java.lang.String control)
-
computeCornerControl
protected java.lang.String computeCornerControl(Position position)
-
getOppositeControl
protected MeasureTool.ControlPoint getOppositeControl(java.lang.String control)
-
moveShapeByControlPoint
protected LatLon moveShapeByControlPoint(MeasureTool.ControlPoint controlPoint, Globe globe, Angle heading, LatLon center, double width, double height)
-
swapEdgeControls
protected void swapEdgeControls(java.lang.String control, Position position)
-
swapCornerControls
protected void swapCornerControls(java.lang.String control, Position position)
-
computeControlPointLocation
protected LatLon computeControlPointLocation(java.lang.String control, Globe globe, Angle heading, LatLon center, double width, double height)
-
computeQuadEdgeMidpointLocation
protected LatLon computeQuadEdgeMidpointLocation(java.lang.String control, Globe globe, Angle heading, LatLon center, double width, double height)
-
computeControlPointAzimuth
protected Angle computeControlPointAzimuth(java.lang.String control, double width, double height)
-
computeControlPointAzimuthInShapeCoordinates
protected Angle computeControlPointAzimuthInShapeCoordinates(java.lang.String control, Angle azimuth)
-
computeControlPointPathLength
protected Angle computeControlPointPathLength(java.lang.String control, double width, double height, double globeRadius)
-
updateShapeControlPoints
protected void updateShapeControlPoints()
-
updateControlPointWithLeader
protected void updateControlPointWithLeader(MeasureTool.ControlPointWithLeader cp, LatLon controlLocation)
-
updateMeasureShape
protected void updateMeasureShape()
-
updatePositionsFromShape
protected void updatePositionsFromShape()
-
dispose
public void dispose()
Description copied from interface:DisposableDisposes of any internal resources allocated by the object.- Specified by:
disposein interfaceDisposable
-
addControlPoint
protected void addControlPoint(Position position, java.lang.String key, java.lang.Object value)
-
addControlPointWithLeader
protected void addControlPointWithLeader(Position position, java.lang.String controlKey, java.lang.Object control, java.lang.String leaderKey, java.lang.Object leader)
-
doAddControlPoint
protected void doAddControlPoint(MeasureTool.ControlPoint controlPoint)
-
updateAnnotation
public void updateAnnotation(Position pos)
-
getDisplayString
protected java.lang.String getDisplayString(Position pos)
-
formatCircleMeasurements
protected java.lang.String formatCircleMeasurements(Position pos)
-
formatEllipseMeasurements
protected java.lang.String formatEllipseMeasurements(Position pos)
-
formatSquareMeasurements
protected java.lang.String formatSquareMeasurements(Position pos)
-
formatQuadMeasurements
protected java.lang.String formatQuadMeasurements(Position pos)
-
formatPolygonMeasurements
protected java.lang.String formatPolygonMeasurements(Position pos)
-
formatLineMeasurements
protected java.lang.String formatLineMeasurements(Position pos)
-
computeAccumulatedLength
protected java.lang.Double computeAccumulatedLength(LatLon pos)
-
computePathLength
protected double computePathLength()
-
lengthsEssentiallyEqual
protected boolean lengthsEssentiallyEqual(java.lang.Double l1, java.lang.Double l2)
-
-