NASA World Wind

gov.nasa.worldwindx.applications.worldwindow.util.measuretool
Class WWOMeasureTool

java.lang.Object
  extended by gov.nasa.worldwind.avlist.AVListImpl
      extended by gov.nasa.worldwindx.applications.worldwindow.util.measuretool.WWOMeasureTool
All Implemented Interfaces:
AVList, Disposable, PositionListener, RenderingListener, SelectListener, MouseListener, MouseMotionListener, EventListener

public class WWOMeasureTool
extends AVListImpl
implements Disposable, MouseListener, MouseMotionListener, SelectListener, PositionListener, RenderingListener


Nested Class Summary
static interface WWOMeasureTool.ControlPoint
           
static interface WWOMeasureTool.ControlPointList
           
static interface WWOMeasureTool.MeasureDisplay
           
 
Field Summary
protected  boolean active
           
protected  boolean armed
           
protected  WWOMeasureTool.ControlPointList controlPoints
           
protected  RenderableLayer controlPointsLayer
           
protected  BasicDragger dragger
           
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  EventListenerList eventListeners
           
protected  boolean freeHand
           
protected  double freeHandMinSpacing
           
protected  WWOMeasureTool.ControlPoint lastPickedObject
           
protected  WWOMeasureTool.MeasureDisplay measureDisplay
           
protected  String measureShapeType
           
protected  boolean moving
           
protected  WWOMeasureTool.ControlPoint movingTarget
           
protected  ArrayList<Position> positions
           
protected  boolean regularShape
           
protected  WWOMeasureTool.ControlPoint rubberBandTarget
           
protected  Renderable shape
           
protected  Position shapeCenterPosition
           
protected  int shapeIntervals
           
protected  Angle shapeOrientation
           
protected  Rectangle2D.Double shapeRectangle
           
protected  boolean showAnnotation
           
protected  boolean showControlPoints
           
protected  UnitsFormat unitsFormat
           
protected  boolean useRubberBand
           
protected  WorldWindow wwd
           
 
Constructor Summary
WWOMeasureTool(WorldWindow wwd, Renderable shape, String lineType, RenderableLayer controlPointsLayer)
           
 
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)
           
 void addSelectListener(SelectListener listener)
           
protected  void autoDisarm()
           
protected  void callSelectListeners(SelectEvent event)
           
 void clear()
           
protected  Position computeSurfacePosition(LatLon latLon)
           
protected  WWOMeasureTool.ControlPoint createControlPoint(Position position)
           
protected  WWOMeasureTool.ControlPointList createControlPoints()
           
protected  WWOMeasureTool.MeasureDisplay createMeasureDisplay()
           
 void dispose()
          Disposes of any internal resources allocated by the object.
protected  void doMoved()
           
protected  void doSelected(SelectEvent event)
           
protected  void dragSelected(SelectEvent event)
           
 double getArea()
           
 Position getCenterPosition()
           
protected  WWOMeasureTool.ControlPointList getControlPoints()
           
 double getFreeHandMinSpacing()
           
 double getHeight()
           
 String getLabel(String labelName)
           
 double getLength()
           
 String getMeasureShapeType()
           
 Angle getOrientation()
           
 ArrayList<? extends Position> getPositions()
           
 Renderable getShape()
           
 Rectangle2D.Double getShapeRectangle()
           
 UnitsFormat getUnitsFormat()
           
 double getWidth()
           
 WorldWindow getWwd()
           
protected  void highlight(Object o)
           
protected  boolean isActive()
           
 boolean isArmed()
           
 boolean isFreeHand()
           
protected  boolean isMoving()
           
protected  boolean isRegularShape()
           
 boolean isShowAnnotation()
           
 boolean isShowControlPoints()
           
 boolean isUseRubberBand()
           
 void mouseClicked(MouseEvent mouseEvent)
           
 void mouseDragged(MouseEvent mouseEvent)
           
 void mouseEntered(MouseEvent e)
           
 void mouseExited(MouseEvent e)
           
 void mouseMoved(MouseEvent mouseEvent)
           
 void mousePressed(MouseEvent mouseEvent)
           
 void mouseReleased(MouseEvent mouseEvent)
           
 void moveControlPoint(WWOMeasureTool.ControlPoint point)
          Update the current measure shape according to a given control point position.
 void moved(PositionEvent event)
           
 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  void moveToPosition(Position oldPosition, Position newPosition)
           
 void removeControlPoint()
          Remove the last control point from the current measure shape.
 void selected(SelectEvent event)
           
protected  void setActive(boolean state)
           
 void setArmed(boolean armed)
          Arms and disarms the measure tool controller.
 void setFreeHand(boolean state)
           
 void setFreeHandMinSpacing(double distance)
           
 void setLabel(String labelName, String label)
           
protected  void setMeasureShape(Polyline line, String shapeType)
           
protected  void setMeasureShape(SurfaceShape newShape)
           
protected  void setMoving(boolean state)
           
 void setShowAnnotation(boolean state)
           
 void setShowControlPoints(boolean state)
           
 void setUnitsFormat(UnitsFormat unitsFormat)
           
 void setUseRubberBand(boolean state)
           
 void stageChanged(RenderingEvent event)
           
protected  void updateMeasureShape()
           
protected  void updatePositionsFromShape()
           
protected  void updateShapeControlPoints()
           
protected  void updateShapeProperties(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

active

protected boolean active

armed

protected boolean armed

controlPoints

protected WWOMeasureTool.ControlPointList controlPoints

controlPointsLayer

protected RenderableLayer controlPointsLayer

dragger

protected BasicDragger dragger

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

eventListeners

protected EventListenerList eventListeners

freeHand

protected boolean freeHand

freeHandMinSpacing

protected double freeHandMinSpacing

lastPickedObject

protected WWOMeasureTool.ControlPoint lastPickedObject

measureDisplay

protected WWOMeasureTool.MeasureDisplay measureDisplay

measureShapeType

protected String measureShapeType

moving

protected boolean moving

movingTarget

protected WWOMeasureTool.ControlPoint movingTarget

positions

protected ArrayList<Position> positions

regularShape

protected boolean regularShape

rubberBandTarget

protected WWOMeasureTool.ControlPoint rubberBandTarget

shape

protected Renderable shape

shapeCenterPosition

protected Position shapeCenterPosition

shapeIntervals

protected int shapeIntervals

shapeOrientation

protected Angle shapeOrientation

shapeRectangle

protected Rectangle2D.Double shapeRectangle

showAnnotation

protected boolean showAnnotation

showControlPoints

protected boolean showControlPoints

unitsFormat

protected UnitsFormat unitsFormat

useRubberBand

protected boolean useRubberBand

wwd

protected final WorldWindow wwd
Constructor Detail

WWOMeasureTool

public WWOMeasureTool(WorldWindow wwd,
                      Renderable shape,
                      String lineType,
                      RenderableLayer controlPointsLayer)
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)

addSelectListener

public void addSelectListener(SelectListener listener)

autoDisarm

protected void autoDisarm()

callSelectListeners

protected void callSelectListeners(SelectEvent event)

clear

public void clear()

computeSurfacePosition

protected Position computeSurfacePosition(LatLon latLon)

createControlPoint

protected WWOMeasureTool.ControlPoint createControlPoint(Position position)

createControlPoints

protected WWOMeasureTool.ControlPointList createControlPoints()

createMeasureDisplay

protected WWOMeasureTool.MeasureDisplay createMeasureDisplay()

dispose

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

Specified by:
dispose in interface Disposable

doMoved

protected void doMoved()

doSelected

protected void doSelected(SelectEvent event)

dragSelected

protected void dragSelected(SelectEvent event)

getArea

public double getArea()

getCenterPosition

public Position getCenterPosition()

getControlPoints

protected WWOMeasureTool.ControlPointList getControlPoints()

getFreeHandMinSpacing

public double getFreeHandMinSpacing()

getHeight

public double getHeight()

getLabel

public String getLabel(String labelName)

getLength

public double getLength()

getMeasureShapeType

public String getMeasureShapeType()

getOrientation

public Angle getOrientation()

getPositions

public ArrayList<? extends Position> getPositions()

getShape

public Renderable getShape()

getShapeRectangle

public Rectangle2D.Double getShapeRectangle()

getUnitsFormat

public UnitsFormat getUnitsFormat()

getWidth

public double getWidth()

getWwd

public WorldWindow getWwd()

highlight

protected void highlight(Object o)

isActive

protected boolean isActive()

isArmed

public boolean isArmed()

isFreeHand

public boolean isFreeHand()

isMoving

protected boolean isMoving()

isRegularShape

protected boolean isRegularShape()

isShowAnnotation

public boolean isShowAnnotation()

isShowControlPoints

public boolean isShowControlPoints()

isUseRubberBand

public boolean isUseRubberBand()

mouseClicked

public void mouseClicked(MouseEvent mouseEvent)
Specified by:
mouseClicked in interface MouseListener

mouseDragged

public void mouseDragged(MouseEvent mouseEvent)
Specified by:
mouseDragged in interface MouseMotionListener

mouseEntered

public void mouseEntered(MouseEvent e)
Specified by:
mouseEntered in interface MouseListener

mouseExited

public void mouseExited(MouseEvent e)
Specified by:
mouseExited in interface MouseListener

mouseMoved

public void mouseMoved(MouseEvent mouseEvent)
Specified by:
mouseMoved in interface MouseMotionListener

mousePressed

public void mousePressed(MouseEvent mouseEvent)
Specified by:
mousePressed in interface MouseListener

mouseReleased

public void mouseReleased(MouseEvent mouseEvent)
Specified by:
mouseReleased in interface MouseListener

moveControlPoint

public void moveControlPoint(WWOMeasureTool.ControlPoint point)
Update the current measure shape according to a given control point position.

Parameters:
point - one of the shape control points.

moved

public void moved(PositionEvent event)
Specified by:
moved in interface PositionListener

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.

moveToPosition

protected void moveToPosition(Position oldPosition,
                              Position newPosition)

removeControlPoint

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


selected

public void selected(SelectEvent event)
Specified by:
selected in interface SelectListener

setActive

protected void setActive(boolean state)

setArmed

public void setArmed(boolean armed)
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:
armed - true to arm the controller, false to disarm it.

setFreeHand

public void setFreeHand(boolean state)

setFreeHandMinSpacing

public void setFreeHandMinSpacing(double distance)

setLabel

public void setLabel(String labelName,
                     String label)

setMeasureShape

protected void setMeasureShape(Polyline line,
                               String shapeType)

setMeasureShape

protected void setMeasureShape(SurfaceShape newShape)

setMoving

protected void setMoving(boolean state)

setShowAnnotation

public void setShowAnnotation(boolean state)

setShowControlPoints

public void setShowControlPoints(boolean state)

setUnitsFormat

public void setUnitsFormat(UnitsFormat unitsFormat)

setUseRubberBand

public void setUseRubberBand(boolean state)

stageChanged

public void stageChanged(RenderingEvent event)
Specified by:
stageChanged in interface RenderingListener

updateMeasureShape

protected void updateMeasureShape()

updatePositionsFromShape

protected void updatePositionsFromShape()

updateShapeControlPoints

protected void updateShapeControlPoints()

updateShapeProperties

protected void updateShapeProperties(String control,
                                     Position newPosition)

NASA World Wind