NASA World Wind

gov.nasa.worldwind.util.measure
Class MeasureToolController

java.lang.Object
  extended by java.awt.event.MouseAdapter
      extended by gov.nasa.worldwind.util.measure.MeasureToolController
All Implemented Interfaces:
PositionListener, RenderingListener, SelectListener, MouseListener, MouseMotionListener, EventListener

public class MeasureToolController
extends MouseAdapter
implements MouseListener, MouseMotionListener, SelectListener, PositionListener, RenderingListener

Generic controller for the MeasureTool.

See Also:
MeasureTool

Field Summary
protected  boolean active
           
protected  boolean armed
           
protected  BasicDragger dragger
           
protected  boolean freeHand
           
protected  double freeHandMinSpacing
           
protected  MeasureTool.ControlPoint lastPickedObject
           
protected  MeasureTool measureTool
           
protected  boolean moving
           
protected  MeasureTool.ControlPoint movingTarget
           
protected  MeasureTool.ControlPoint rubberBandTarget
           
protected  boolean useRubberBand
           
 
Constructor Summary
MeasureToolController()
           
 
Method Summary
protected  void autoDisarm()
           
protected  void doMoved(PositionEvent event)
           
protected  void doSelected(SelectEvent event)
           
protected  void dragSelected(SelectEvent event)
           
 double getFreeHandMinSpacing()
          Get the minimum distance in meters between two control points for free hand drawing.
 MeasureTool getMeasureTool()
          Get the MeasureTool that this controller is operating on.
protected  void highlight(Object o)
           
 boolean isActive()
          Returns true if the controller is in the middle of a rubber band operation.
 boolean isArmed()
          Identifies whether the measure tool controller is armed.
 boolean isFreeHand()
          Get whether this controller allows free hand drawing of path and polygons while using rubber band mode.
 boolean isMoving()
          Returns true if the controller is moving the measure shape as a whole.
 boolean isUseRubberBand()
          Returns true if this controller is using rubber band during shape creation.
 void mouseClicked(MouseEvent mouseEvent)
           
 void mouseDragged(MouseEvent mouseEvent)
           
 void mouseMoved(MouseEvent mouseEvent)
           
 void mousePressed(MouseEvent mouseEvent)
           
 void mouseReleased(MouseEvent mouseEvent)
           
 void moved(PositionEvent event)
           
protected  void moveToPosition(Position oldPosition, Position newPosition)
          Move the shape to the specified new position
 void selected(SelectEvent event)
           
protected  void setActive(boolean state)
           
 void setArmed(boolean armed)
          Arms and disarms the measure tool controller.
 void setFreeHand(boolean state)
          Set whether this controller allows free hand drawing of path and polygons while using rubber band mode.
 void setFreeHandMinSpacing(double distance)
          Set the minimum distance in meters between two control points for free hand drawing.
 void setMeasureTool(MeasureTool measureTool)
          Set the MeasureTool that this controller will be operating on.
protected  void setMoving(boolean state)
           
 void setUseRubberBand(boolean state)
          Set whether this controller should use rubber band during shape creation.
 void stageChanged(RenderingEvent event)
           
 
Methods inherited from class java.awt.event.MouseAdapter
mouseEntered, mouseExited
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.awt.event.MouseListener
mouseEntered, mouseExited
 

Field Detail

active

protected boolean active

armed

protected boolean armed

dragger

protected BasicDragger dragger

freeHand

protected boolean freeHand

freeHandMinSpacing

protected double freeHandMinSpacing

lastPickedObject

protected MeasureTool.ControlPoint lastPickedObject

measureTool

protected MeasureTool measureTool

moving

protected boolean moving

movingTarget

protected MeasureTool.ControlPoint movingTarget

rubberBandTarget

protected MeasureTool.ControlPoint rubberBandTarget

useRubberBand

protected boolean useRubberBand
Constructor Detail

MeasureToolController

public MeasureToolController()
Method Detail

autoDisarm

protected void autoDisarm()

doMoved

protected void doMoved(PositionEvent event)

doSelected

protected void doSelected(SelectEvent event)

dragSelected

protected void dragSelected(SelectEvent event)

getFreeHandMinSpacing

public double getFreeHandMinSpacing()
Get the minimum distance in meters between two control points for free hand drawing.

Returns:
the minimum distance in meters between two control points for free hand drawing.

getMeasureTool

public MeasureTool getMeasureTool()
Get the MeasureTool that this controller is operating on.

Returns:
the MeasureTool that this controller is operating on.

highlight

protected void highlight(Object o)

isActive

public boolean isActive()
Returns true if the controller is in the middle of a rubber band operation.

Returns:
true if the controller is in the middle of a rubber band operation.

isArmed

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

Returns:
true if armed, false if not armed.

isFreeHand

public boolean isFreeHand()
Get whether this controller allows free hand drawing of path and polygons while using rubber band mode.

Returns:
true if free hand drawing of path and polygons in rubber band mode.

isMoving

public boolean isMoving()
Returns true if the controller is moving the measure shape as a whole.

Returns:
true if the controller is moving the measure shape as a whole.

isUseRubberBand

public boolean isUseRubberBand()
Returns true if this controller is using rubber band during shape creation. When using rubber band, new control points are added by first pressing the left mouse button, then dragging the mouse toward the proper position, then releasing the mouse button. Otherwise new control point are added for each new click of the mouse.

Returns:
true if this controller is using rubber band during shape creation.

mouseClicked

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

mouseDragged

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

mouseMoved

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

mousePressed

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

mouseReleased

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

moved

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

moveToPosition

protected void moveToPosition(Position oldPosition,
                              Position newPosition)
Move the shape to the specified new position

Parameters:
oldPosition - Previous position of shape
newPosition - New position for 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)
Set whether this controller allows free hand drawing of path and polygons while using rubber band mode.

Parameters:
state - true to allow free hand drawing of path and polygons in rubber band mode.

setFreeHandMinSpacing

public void setFreeHandMinSpacing(double distance)
Set the minimum distance in meters between two control points for free hand drawing.

Parameters:
distance - the minimum distance in meters between two control points for free hand drawing.

setMeasureTool

public void setMeasureTool(MeasureTool measureTool)
Set the MeasureTool that this controller will be operating on.

Parameters:
measureTool - the MeasureTool that this controller will be operating on.

setMoving

protected void setMoving(boolean state)

setUseRubberBand

public void setUseRubberBand(boolean state)
Set whether this controller should use rubber band during shape creation. When using rubber band, new control points are added by first pressing the left mouse button, then dragging the mouse toward the proper position, then releasing the mouse button. Otherwise new control point are added for each new click of the mouse.

Parameters:
state - true if this controller should use rubber band during shape creation.

stageChanged

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

NASA World Wind