NASA World Wind

gov.nasa.worldwind.util.measure
Class MeasureTool

java.lang.Object
  extended by gov.nasa.worldwind.avlist.AVListImpl
      extended by 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 of SHAPE_LINE, SHAPE_PATH, SHAPE_POLYGON, SHAPE_CIRCLE, SHAPE_ELLIPSE, SHAPE_SQUARE or SHAPE_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 a MeasureToolController.

The interaction sequence for drawing a shape and measuring is as follows:

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 MeasureTool is armed, pressing and immediately releasing mouse button one while also pressing the control key (Ctl) removes the last point entered.

Arming and disarming the MeasureTool does 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 responsability.

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 to SHAPE_LINE. If more then two positions are provided, the measure shape will be set to SHAPE_PATH if the last position differs from the first (open path), or SHAPE_POLYGON if 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 of SHAPE_CIRCLE, SHAPE_ELLIPSE, SHAPE_SQUARE or SHAPE_QUAD), a center position, a wdth, a height (in meters) and a heading angle.

Finally, the application can use an existing Polyline or SurfaceShape by using setMeasureShape(Polyline) or setMeasureShape(SurfaceShape). The surface shape can be one of SurfacePolygon, SurfaceQuad, SurfaceSquare, SurfaceEllipse or SurfaceCircle.

Measuring

The application can read the measured length or area by calling the MeasureTool getLength() or getArea() 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() and getOrientation() methods.

The measurements are dislayed in units specified in the measure tool's UnitsFormat object. Access to the units format is via the method getUnitsFormat().

Events

The MeasureTool will send events on several occasions: when the position list has changed - EVENT_POSITION_ADD, EVENT_POSITION_REMOVE or EVENT_POSITION_REPLACE, when metrics has changed EVENT_METRIC_CHANGED or when the tool is armed or disarmed EVENT_ARMED.

Events will also be fired at the start and end of a rubber band operation during shape creation: EVENT_RUBBERBAND_START and EVENT_RUBBERBAND_STOP.

See MeasureToolPanel for 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
static class MeasureTool.ControlPoint
           
protected static class MeasureTool.ControlPointWithLeader
           
protected static class MeasureTool.CustomRenderableLayer
           
 
Field Summary
static String ACCUMULATED_LABEL
           
static String ANGLE_LABEL
           
protected  ScreenAnnotation annotation
           
protected  AnnotationAttributes annotationAttributes
           
protected  RenderableLayer applicationLayer
           
static String AREA_LABEL
           
static String CENTER_LATITUDE_LABEL
           
static String CENTER_LONGITUDE_LABEL
           
static String CONTROL_TYPE_LEADER_ORIGIN
           
static String CONTROL_TYPE_LOCATION_INDEX
           
static String CONTROL_TYPE_REGULAR_SHAPE
           
protected  MeasureToolController controller
           
protected  ArrayList<Renderable> controlPoints
           
protected  AnnotationAttributes controlPointsAttributes
           
protected  MeasureTool.CustomRenderableLayer controlPointsLayer
           
protected  AnnotationAttributes controlPointWithLeaderAttributes
           
static String EVENT_ARMED
           
static String EVENT_METRIC_CHANGED
           
static String EVENT_POSITION_ADD
           
static String EVENT_POSITION_REMOVE
           
static String EVENT_POSITION_REPLACE
           
static String EVENT_RUBBERBAND_START
           
static String EVENT_RUBBERBAND_STOP
           
protected  Color fillColor
           
protected  boolean followTerrain
           
static String HEADING_LABEL
           
static String HEIGHT_LABEL
           
static String LATITUDE_LABEL
           
protected  MeasureTool.CustomRenderableLayer layer
           
protected  ShapeAttributes leaderAttributes
           
static String LENGTH_LABEL
           
protected  Polyline line
           
protected  Color lineColor
           
protected  double lineWidth
           
static String LONGITUDE_LABEL
           
static String MAJOR_AXIS_LABEL
           
protected static int MAX_SHAPE_MOVE_ITERATIONS
           
protected  String measureShapeType
           
static String MINOR_AXIS_LABEL
           
protected  String pathType
           
static String PERIMETER_LABEL
           
protected  ArrayList<Position> positions
           
static String RADIUS_LABEL
           
static String SHAPE_CIRCLE
           
protected static double SHAPE_CONTROL_EPSILON_METERS
           
static String SHAPE_ELLIPSE
           
static String SHAPE_LINE
           
protected static double SHAPE_MIN_HEIGHT_METERS
           
protected static double SHAPE_MIN_WIDTH_METERS
           
static String SHAPE_PATH
           
static String SHAPE_POLYGON
           
static String SHAPE_QUAD
           
static String SHAPE_SQUARE
           
protected  Position shapeCenterPosition
           
protected  int shapeIntervals
           
protected  MeasureTool.CustomRenderableLayer shapeLayer
           
protected  Angle shapeOrientation
           
protected  Rectangle2D.Double shapeRectangle
           
protected  boolean showAnnotation
           
protected  boolean showControlPoints
           
protected  SurfaceShape surfaceShape
           
protected  UnitsFormat unitsFormat
           
static String WIDTH_LABEL
           
protected  WorldWindow wwd
           
 
Constructor Summary
MeasureTool(WorldWindow wwd)
          Construct a new measure tool drawing events from the specified WorldWindow.
MeasureTool(WorldWindow wwd, RenderableLayer applicationLayer)
          Construct a new measure tool drawing events from the specified WorldWindow and using the given RenderableLayer.
 
Method Summary
 void addControlPoint()
          Add a control point to the current measure shape at the cuurrent WorldWindow position.
protected  void addControlPoint(Position position, String key, Object value)
           
protected  void addControlPointWithLeader(Position position, String controlKey, Object control, String leaderKey, Object leader)
           
protected  boolean areLocationsRedundant(LatLon locA, LatLon locB)
           
 void clear()
          Removes all positions from the shape, clear attributes.
protected  Double computeAccumulatedLength(LatLon pos)
           
protected  Angle computeAngleBetween(LatLon a, LatLon b, LatLon c)
           
protected  Vec4 computeAnnotationPosition(Position pos)
           
protected  Angle computeControlPointAzimuth(String control, double width, double height)
           
protected  Angle computeControlPointAzimuthInShapeCoordinates(String control, Angle azimuth)
           
protected  LatLon computeControlPointLocation(String control, Globe globe, Angle heading, LatLon center, double width, double height)
           
protected  Angle computeControlPointPathLength(String control, double width, double height, double globeRadius)
           
protected  String computeCornerControl(Position position)
           
protected static Angle computeNormalizedHeading(Angle heading)
           
protected  double computePathLength()
           
protected  LatLon computeQuadEdgeMidpointLocation(String control, Globe globe, Angle heading, LatLon center, double width, double height)
           
protected  Position computeSurfacePosition(LatLon latLon)
           
protected  MeasureTool.CustomRenderableLayer createCustomRenderableLayer()
           
 void dispose()
          Disposes of any internal resources allocated by the object.
protected  void doAddControlPoint(MeasureTool.ControlPoint controlPoint)
           
protected  String formatCircleMeasurements(Position pos)
           
protected  String formatEllipseMeasurements(Position pos)
           
protected  String formatLineMeasurements(Position pos)
           
protected  String formatPolygonMeasurements(Position pos)
           
protected  String formatQuadMeasurements(Position pos)
           
protected  String formatSquareMeasurements(Position pos)
           
 AnnotationAttributes getAnnotationAttributes()
          Get the attributes associated with the tool tip annotation.
 RenderableLayer getApplicationLayer()
          Returns the applilcation layer passed to the constructor.
 double getArea()
           
 Position getCenterPosition()
           
 MeasureToolController getController()
          Get the MeasureToolController for this measure tool.
 MeasureTool.ControlPoint getControlPoint(String control)
           
 ArrayList<Renderable> getControlPoints()
          Get the list of control points associated with the current measure shape.
 AnnotationAttributes getControlPointsAttributes()
          Get the attributes associated with the control points.
protected  String getDisplayString(Position pos)
           
 Color getFillColor()
           
 double getHeight()
           
 String getLabel(String labelName)
           
 RenderableLayer getLayer()
          Returns the measure tool layer.
 double getLength()
           
 Polyline getLine()
          Returns the polyline currently used to display lines and path.
 Color getLineColor()
           
 double getLineWidth()
           
 String getMeasureShapeType()
          Get the measure shape type.
protected  MeasureTool.ControlPoint getOppositeControl(String control)
           
 Angle getOrientation()
           
 String getPathType()
           
protected  String getPathType(List<? extends Position> positions)
           
 ArrayList<? extends Position> getPositions()
          Get the list of positions that define the current measure shape.
 String getShapeInitialControl(Position position)
           
protected  Angle getShapeInitialHeading()
           
 SurfaceShape getSurfaceShape()
          Returns the surface shape currently used to display polygons.
 UnitsFormat getUnitsFormat()
          Return the UnitsFormat instance governing the measurement value display units and format.
 double getWidth()
           
 WorldWindow getWwd()
           
 boolean isArmed()
          Identifies whether the measure tool controller is armed.
 boolean isCenterControl(MeasureTool.ControlPoint controlPoint)
           
 boolean isCornerControl(MeasureTool.ControlPoint controlPoint)
           
 boolean isFollowTerrain()
           
 boolean isMeasureShape(Object o)
           
 boolean isRegularShape()
           
protected  boolean isRegularShape(String shape)
           
 boolean isShowAnnotation()
           
 boolean isShowControlPoints()
           
 boolean isSideControl(MeasureTool.ControlPoint controlPoint)
           
protected static String keyFromPolylinePathType(int type)
           
protected  boolean lengthsEssentiallyEqual(Double l1, Double l2)
           
 void moveControlPoint(MeasureTool.ControlPoint point)
          Update the current measure shape according to a given control point position.
 void moveControlPoint(MeasureTool.ControlPoint point, String mode)
          Update the current measure shape according to a given control point position and shape edition mode.
 void moveMeasureShape(Angle azimuth, Angle distance)
          Move the current measure shape along a great circle arc at a given azimuth Angle for a given distance Angle.
protected  LatLon moveShapeByControlPoint(MeasureTool.ControlPoint controlPoint, Globe globe, Angle heading, LatLon center, double width, double height)
           
protected static int polylinePathTypeFromKey(String type)
           
 void removeControlPoint()
          Remove the last control point from the current measure shape.
 void setArmed(boolean state)
          Arms and disarms the measure tool controller.
 void setController(MeasureToolController controller)
          Set the controller object for this measure tool - can be null.
 void setFillColor(Color color)
           
 void setFollowTerrain(boolean followTerrain)
           
protected  void setInitialLabels()
           
 void setLabel(String labelName, String label)
           
 void setLineColor(Color color)
           
 void setLineWidth(double width)
           
 void setMeasureShape(Polyline line)
          Set the measure shape to an existing Polyline.
 void setMeasureShape(SurfaceShape surfaceShape)
          Set the measure shape to an existing SurfaceShape.
 void setMeasureShapeType(String shape)
          Set the measure shape type.
 void setMeasureShapeType(String shapeType, Position centerPosition, double radius)
          Set and initialize the measure shape to one of the regular shapes SHAPE_CIRCLE, SHAPE_ELLIPSE, SHAPE_SQUARE or SHAPE_QUAD.
 void setMeasureShapeType(String shapeType, Position centerPosition, double width, double height, Angle orientation)
          Set and initialize the measure shape to one of the regular shapes SHAPE_CIRCLE, SHAPE_ELLIPSE, SHAPE_SQUARE or SHAPE_QUAD.
 void setPathType(String type)
           
 void setPositions(ArrayList<? extends Position> newPositions)
          Set the measure shape to an arbitrary list of positions.
 void setShowAnnotation(boolean state)
           
 void setShowControlPoints(boolean state)
           
 void setUnitsFormat(UnitsFormat unitsFormat)
          Set the measure tool's @{link UnitsFormat} instance that governs measurement value display units and format.
protected  void swapCornerControls(String control, Position position)
           
protected  void swapEdgeControls(String control, Position position)
           
 void updateAnnotation(Position pos)
           
protected  void updateControlPointWithLeader(MeasureTool.ControlPointWithLeader cp, LatLon controlLocation)
           
protected  void updateMeasureShape()
           
protected  void updatePositionsFromShape()
           
protected  void updateShapeCenter(String control, Position newPosition)
           
protected  void updateShapeControlPoints()
           
protected  void updateShapeOrientation(String control, Position newPosition)
           
protected  void updateShapeProperties(String control, Position newPosition, String mode)
           
protected  void updateShapeSize(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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ACCUMULATED_LABEL

public static final String ACCUMULATED_LABEL
See Also:
Constant Field Values

ANGLE_LABEL

public static final String ANGLE_LABEL
See Also:
Constant Field Values

annotation

protected ScreenAnnotation annotation

annotationAttributes

protected AnnotationAttributes annotationAttributes

applicationLayer

protected RenderableLayer applicationLayer

AREA_LABEL

public static final String AREA_LABEL
See Also:
Constant Field Values

CENTER_LATITUDE_LABEL

public static final String CENTER_LATITUDE_LABEL
See Also:
Constant Field Values

CENTER_LONGITUDE_LABEL

public static final String CENTER_LONGITUDE_LABEL
See Also:
Constant Field Values

CONTROL_TYPE_LEADER_ORIGIN

public static final String CONTROL_TYPE_LEADER_ORIGIN
See Also:
Constant Field Values

CONTROL_TYPE_LOCATION_INDEX

public static final String CONTROL_TYPE_LOCATION_INDEX
See Also:
Constant Field Values

CONTROL_TYPE_REGULAR_SHAPE

public static final String CONTROL_TYPE_REGULAR_SHAPE
See Also:
Constant Field Values

controller

protected MeasureToolController controller

controlPoints

protected ArrayList<Renderable> controlPoints

controlPointsAttributes

protected AnnotationAttributes controlPointsAttributes

controlPointsLayer

protected MeasureTool.CustomRenderableLayer controlPointsLayer

controlPointWithLeaderAttributes

protected AnnotationAttributes controlPointWithLeaderAttributes

EVENT_ARMED

public static final String EVENT_ARMED
See Also:
Constant Field Values

EVENT_METRIC_CHANGED

public static final String EVENT_METRIC_CHANGED
See Also:
Constant Field Values

EVENT_POSITION_ADD

public static final String EVENT_POSITION_ADD
See Also:
Constant Field Values

EVENT_POSITION_REMOVE

public static final String EVENT_POSITION_REMOVE
See Also:
Constant Field Values

EVENT_POSITION_REPLACE

public static final String EVENT_POSITION_REPLACE
See Also:
Constant Field Values

EVENT_RUBBERBAND_START

public static final String EVENT_RUBBERBAND_START
See Also:
Constant Field Values

EVENT_RUBBERBAND_STOP

public static final String EVENT_RUBBERBAND_STOP
See Also:
Constant Field Values

fillColor

protected Color fillColor

followTerrain

protected boolean followTerrain

HEADING_LABEL

public static final String HEADING_LABEL
See Also:
Constant Field Values

HEIGHT_LABEL

public static final String HEIGHT_LABEL
See Also:
Constant Field Values

LATITUDE_LABEL

public static final String LATITUDE_LABEL
See Also:
Constant Field Values

layer

protected MeasureTool.CustomRenderableLayer layer

leaderAttributes

protected ShapeAttributes leaderAttributes

LENGTH_LABEL

public static final String LENGTH_LABEL
See Also:
Constant Field Values

line

protected Polyline line

lineColor

protected Color lineColor

lineWidth

protected double lineWidth

LONGITUDE_LABEL

public static final String LONGITUDE_LABEL
See Also:
Constant Field Values

MAJOR_AXIS_LABEL

public static final String MAJOR_AXIS_LABEL
See Also:
Constant Field Values

MAX_SHAPE_MOVE_ITERATIONS

protected static final int MAX_SHAPE_MOVE_ITERATIONS
See Also:
Constant Field Values

measureShapeType

protected String measureShapeType

MINOR_AXIS_LABEL

public static final String MINOR_AXIS_LABEL
See Also:
Constant Field Values

pathType

protected String pathType

PERIMETER_LABEL

public static final String PERIMETER_LABEL
See Also:
Constant Field Values

positions

protected ArrayList<Position> positions

RADIUS_LABEL

public static final String RADIUS_LABEL
See Also:
Constant Field Values

SHAPE_CIRCLE

public static final String SHAPE_CIRCLE
See Also:
Constant Field Values

SHAPE_CONTROL_EPSILON_METERS

protected static final double SHAPE_CONTROL_EPSILON_METERS
See Also:
Constant Field Values

SHAPE_ELLIPSE

public static final String SHAPE_ELLIPSE
See Also:
Constant Field Values

SHAPE_LINE

public static final String SHAPE_LINE
See Also:
Constant Field Values

SHAPE_MIN_HEIGHT_METERS

protected static final double SHAPE_MIN_HEIGHT_METERS
See Also:
Constant Field Values

SHAPE_MIN_WIDTH_METERS

protected static final double SHAPE_MIN_WIDTH_METERS
See Also:
Constant Field Values

SHAPE_PATH

public static final String SHAPE_PATH
See Also:
Constant Field Values

SHAPE_POLYGON

public static final String SHAPE_POLYGON
See Also:
Constant Field Values

SHAPE_QUAD

public static final String SHAPE_QUAD
See Also:
Constant Field Values

SHAPE_SQUARE

public static final String SHAPE_SQUARE
See Also:
Constant Field Values

shapeCenterPosition

protected Position shapeCenterPosition

shapeIntervals

protected int shapeIntervals

shapeLayer

protected MeasureTool.CustomRenderableLayer shapeLayer

shapeOrientation

protected Angle shapeOrientation

shapeRectangle

protected Rectangle2D.Double shapeRectangle

showAnnotation

protected boolean showAnnotation

showControlPoints

protected boolean showControlPoints

surfaceShape

protected SurfaceShape surfaceShape

unitsFormat

protected UnitsFormat unitsFormat

WIDTH_LABEL

public static final String WIDTH_LABEL
See Also:
Constant Field Values

wwd

protected final WorldWindow wwd
Constructor Detail

MeasureTool

public MeasureTool(WorldWindow wwd)
Construct a new measure tool drawing events from the specified WorldWindow.

Parameters:
wwd - the WorldWindow to draw events from.

MeasureTool

public MeasureTool(WorldWindow wwd,
                   RenderableLayer applicationLayer)
Construct a new measure tool drawing events from the specified WorldWindow and using the given RenderableLayer.

Parameters:
wwd - the WorldWindow to draw events from.
applicationLayer - the RenderableLayer to use. May be null. If specified, the caller is responsible for adding the layer to the model and enabling it.
Method Detail

addControlPoint

public void addControlPoint()
Add a control point to the current measure shape at the cuurrent WorldWindow position.


addControlPoint

protected void addControlPoint(Position position,
                               String key,
                               Object value)

addControlPointWithLeader

protected void addControlPointWithLeader(Position position,
                                         String controlKey,
                                         Object control,
                                         String leaderKey,
                                         Object leader)

areLocationsRedundant

protected boolean areLocationsRedundant(LatLon locA,
                                        LatLon locB)

clear

public void clear()
Removes all positions from the shape, clear attributes.


computeAccumulatedLength

protected Double computeAccumulatedLength(LatLon pos)

computeAngleBetween

protected Angle computeAngleBetween(LatLon a,
                                    LatLon b,
                                    LatLon c)

computeAnnotationPosition

protected Vec4 computeAnnotationPosition(Position pos)

computeControlPointAzimuth

protected Angle computeControlPointAzimuth(String control,
                                           double width,
                                           double height)

computeControlPointAzimuthInShapeCoordinates

protected Angle computeControlPointAzimuthInShapeCoordinates(String control,
                                                             Angle azimuth)

computeControlPointLocation

protected LatLon computeControlPointLocation(String control,
                                             Globe globe,
                                             Angle heading,
                                             LatLon center,
                                             double width,
                                             double height)

computeControlPointPathLength

protected Angle computeControlPointPathLength(String control,
                                              double width,
                                              double height,
                                              double globeRadius)

computeCornerControl

protected String computeCornerControl(Position position)

computeNormalizedHeading

protected static Angle computeNormalizedHeading(Angle heading)

computePathLength

protected double computePathLength()

computeQuadEdgeMidpointLocation

protected LatLon computeQuadEdgeMidpointLocation(String control,
                                                 Globe globe,
                                                 Angle heading,
                                                 LatLon center,
                                                 double width,
                                                 double height)

computeSurfacePosition

protected Position computeSurfacePosition(LatLon latLon)

createCustomRenderableLayer

protected MeasureTool.CustomRenderableLayer createCustomRenderableLayer()
Returns:
Instance of the custom renderable layer to use of our internal layers

dispose

public void dispose()
Description copied from interface: Disposable
Disposes of any internal resources allocated by the object.

Specified by:
dispose in interface Disposable

doAddControlPoint

protected void doAddControlPoint(MeasureTool.ControlPoint controlPoint)

formatCircleMeasurements

protected String formatCircleMeasurements(Position pos)

formatEllipseMeasurements

protected String formatEllipseMeasurements(Position pos)

formatLineMeasurements

protected String formatLineMeasurements(Position pos)

formatPolygonMeasurements

protected String formatPolygonMeasurements(Position pos)

formatQuadMeasurements

protected String formatQuadMeasurements(Position pos)

formatSquareMeasurements

protected String formatSquareMeasurements(Position pos)

getAnnotationAttributes

public AnnotationAttributes getAnnotationAttributes()
Get the attributes associated with the tool tip annotation.

Returns:
the attributes associated with the tool tip annotation.

getApplicationLayer

public RenderableLayer getApplicationLayer()
Returns the applilcation layer passed to the constructor.

Returns:
the layer containing the measure shape and control points.

getArea

public double getArea()

getCenterPosition

public Position getCenterPosition()

getController

public MeasureToolController getController()
Get the MeasureToolController for this measure tool.

Returns:
the MeasureToolController for this measure tool.

getControlPoint

public MeasureTool.ControlPoint getControlPoint(String control)

getControlPoints

public 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.

getDisplayString

protected String getDisplayString(Position pos)

getFillColor

public Color getFillColor()

getHeight

public double getHeight()

getLabel

public String getLabel(String labelName)

getLayer

public RenderableLayer getLayer()
Returns the measure tool layer.

Returns:
the layer containing the measure shape and control points.

getLength

public double getLength()

getLine

public Polyline getLine()
Returns the polyline currently used to display lines and path.

Returns:
the polyline currently used to display lines and path.

getLineColor

public Color getLineColor()

getLineWidth

public double getLineWidth()

getMeasureShapeType

public String getMeasureShapeType()
Get the measure shape type. can be one of SHAPE_LINE, SHAPE_PATH, SHAPE_POLYGON, SHAPE_CIRCLE, SHAPE_ELLIPSE, SHAPE_SQUARE or SHAPE_QUAD.

Returns:
the measure shape type.

getOppositeControl

protected MeasureTool.ControlPoint getOppositeControl(String control)

getOrientation

public Angle getOrientation()

getPathType

public String getPathType()

getPathType

protected String getPathType(List<? extends Position> positions)

getPositions

public 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.

getShapeInitialControl

public String getShapeInitialControl(Position position)

getShapeInitialHeading

protected Angle getShapeInitialHeading()

getSurfaceShape

public SurfaceShape getSurfaceShape()
Returns the surface shape currently used to display polygons.

Returns:
the surface shape currently used to display polygons.

getUnitsFormat

public UnitsFormat getUnitsFormat()
Return the UnitsFormat instance governing the measurement value display units and format.

Returns:
the tool's units format instance.

getWidth

public double getWidth()

getWwd

public WorldWindow getWwd()

isArmed

public boolean isArmed()
Identifies whether the measure tool controller is armed.

Returns:
true if armed, false if not armed.

isCenterControl

public boolean isCenterControl(MeasureTool.ControlPoint controlPoint)

isCornerControl

public boolean isCornerControl(MeasureTool.ControlPoint controlPoint)

isFollowTerrain

public boolean isFollowTerrain()

isMeasureShape

public boolean isMeasureShape(Object o)

isRegularShape

public boolean isRegularShape()

isRegularShape

protected boolean isRegularShape(String shape)

isShowAnnotation

public boolean isShowAnnotation()

isShowControlPoints

public boolean isShowControlPoints()

isSideControl

public boolean isSideControl(MeasureTool.ControlPoint controlPoint)

keyFromPolylinePathType

protected static String keyFromPolylinePathType(int type)

lengthsEssentiallyEqual

protected boolean lengthsEssentiallyEqual(Double l1,
                                          Double l2)

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,
                             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 azimuth Angle for a given distance Angle.

Parameters:
azimuth - the azimuth Angle.
distance - the distance Angle.

moveShapeByControlPoint

protected LatLon moveShapeByControlPoint(MeasureTool.ControlPoint controlPoint,
                                         Globe globe,
                                         Angle heading,
                                         LatLon center,
                                         double width,
                                         double height)

polylinePathTypeFromKey

protected static int polylinePathTypeFromKey(String type)

removeControlPoint

public void removeControlPoint()
Remove the last control point from the current measure shape.


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.

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.

setFillColor

public void setFillColor(Color color)

setFollowTerrain

public void setFollowTerrain(boolean followTerrain)

setInitialLabels

protected void setInitialLabels()

setLabel

public void setLabel(String labelName,
                     String label)

setLineColor

public void setLineColor(Color color)

setLineWidth

public void setLineWidth(double width)

setMeasureShape

public void setMeasureShape(Polyline line)
Set the measure shape to an existing Polyline.

Parameters:
line - a Polyline instance.

setMeasureShape

public void setMeasureShape(SurfaceShape surfaceShape)
Set the measure shape to an existing SurfaceShape. Can be one of SurfacePolygon, SurfaceQuad, SurfaceSquare, SurfaceEllipse or SurfaceCircle.

Parameters:
surfaceShape - a SurfaceShape instance.

setMeasureShapeType

public void setMeasureShapeType(String shape)
Set the measure shape type. can be one of SHAPE_LINE, SHAPE_PATH, SHAPE_POLYGON, SHAPE_CIRCLE, SHAPE_ELLIPSE, SHAPE_SQUARE or SHAPE_QUAD. This will reset the measure tool and clear the current measure shape.

Parameters:
shape - the measure shape type.

setMeasureShapeType

public void setMeasureShapeType(String shapeType,
                                Position centerPosition,
                                double radius)
Set and initialize the measure shape to one of the regular shapes SHAPE_CIRCLE, SHAPE_ELLIPSE, SHAPE_SQUARE or SHAPE_QUAD.

Parameters:
shapeType - the shape type.
centerPosition - ther shape center position.
radius - the shape radius of half width/height.

setMeasureShapeType

public void setMeasureShapeType(String shapeType,
                                Position centerPosition,
                                double width,
                                double height,
                                Angle orientation)
Set and initialize the measure shape to one of the regular shapes SHAPE_CIRCLE, SHAPE_ELLIPSE, SHAPE_SQUARE or SHAPE_QUAD.

Parameters:
shapeType - the shape type.
centerPosition - ther shape center position.
width - the shape width.
height - the shape height.
orientation - the shape orientation or azimuth angle - clockwise from north.

setPathType

public void setPathType(String type)

setPositions

public void setPositions(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 to SHAPE_LINE. If more then two positions are provided, the measure shape will be set to SHAPE_PATH if the last position differs from the first (open path), or SHAPE_POLYGON if the path is closed.

Parameters:
newPositions - the shape position list.

setShowAnnotation

public void setShowAnnotation(boolean state)

setShowControlPoints

public void setShowControlPoints(boolean state)

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:
IllegalArgumentException - if the units format instance is null.

swapCornerControls

protected void swapCornerControls(String control,
                                  Position position)

swapEdgeControls

protected void swapEdgeControls(String control,
                                Position position)

updateAnnotation

public void updateAnnotation(Position pos)

updateControlPointWithLeader

protected void updateControlPointWithLeader(MeasureTool.ControlPointWithLeader cp,
                                            LatLon controlLocation)

updateMeasureShape

protected void updateMeasureShape()

updatePositionsFromShape

protected void updatePositionsFromShape()

updateShapeCenter

protected void updateShapeCenter(String control,
                                 Position newPosition)

updateShapeControlPoints

protected void updateShapeControlPoints()

updateShapeOrientation

protected void updateShapeOrientation(String control,
                                      Position newPosition)

updateShapeProperties

protected void updateShapeProperties(String control,
                                     Position newPosition,
                                     String mode)

updateShapeSize

protected void updateShapeSize(String control,
                               Position newPosition)

NASA World Wind