NASA World Wind

gov.nasa.worldwind.examples
Class LineBuilder

java.lang.Object
  extended by gov.nasa.worldwind.avlist.AVListImpl
      extended by gov.nasa.worldwind.examples.LineBuilder
All Implemented Interfaces:
AVList, PropertyChangeListener, EventListener

public class LineBuilder
extends AVListImpl

A utility class to interactively build a polyline. When armed, the class monitors mouse events and adds new postions to a polyline as the user identifies them. The interaction sequence for creating a line is as follows:

While the line builder is armed, pressing and immediately releasing mouse button one while also pressing the control key (Ctl) removes the last position from the polyline.

Mouse events the line builder acts on while armed are marked as consumed. These events are mouse pressed, released, clicked and dragged. These events are not acted on while the line builder is not armed. The builder can be continuously armed and rearmed to allow intervening maneuvering of the globe while building a polyline. A user can add positions, pause entry, maneuver the view, then continue entering positions.

Arming and disarming the line builder does not change the contents or attributes of the line builder's layer.

The polyline and a layer contatining it may be specified when a LineBuilder is constructed.

This class contains a main method implementing an example program illustrating use of LineBuilder.


Field Summary
 
Fields inherited from class gov.nasa.worldwind.avlist.AVListImpl
changeSupport
 
Constructor Summary
LineBuilder(WorldWindow wwd, RenderableLayer lineLayer, Polyline polyline)
          Construct a new line builder using the specified polyline and layer and drawing events from the specified world window.
 
Method Summary
 void clear()
          Removes all positions from the polyline.
 RenderableLayer getLayer()
          Returns the layer holding the polyline being created.
 Polyline getLine()
          Returns the layer currently used to display the polyline.
 boolean isArmed()
          Identifies whether the line builder is armed.
 void setArmed(boolean armed)
          Arms and disarms the line builder.
 
Methods inherited from class gov.nasa.worldwind.avlist.AVListImpl
addPropertyChangeListener, addPropertyChangeListener, clearList, copy, firePropertyChange, firePropertyChange, getDoubleValue, getDoubleValue, getEntries, getIntegerValue, getIntegerValue, getLongValue, getLongValue, getStringValue, getStringValue, getStringValue, getValue, getValues, hasKey, propertyChange, removeKey, removePropertyChangeListener, removePropertyChangeListener, setValue, setValues
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LineBuilder

public LineBuilder(WorldWindow wwd,
                   RenderableLayer lineLayer,
                   Polyline polyline)
Construct a new line builder using the specified polyline and layer and drawing events from the specified world window. Either or both the polyline and the layer may be null, in which case the necessary object is created.

Parameters:
wwd - the world window to draw events from.
lineLayer - the layer holding the polyline. May be null, in which case a new layer is created.
polyline - the polyline object to build. May be null, in which case a new polyline is created.
Method Detail

clear

public void clear()
Removes all positions from the polyline.


getLayer

public RenderableLayer getLayer()
Returns the layer holding the polyline being created.

Returns:
the layer containing the polyline.

getLine

public Polyline getLine()
Returns the layer currently used to display the polyline.

Returns:
the layer holding the polyline.

isArmed

public boolean isArmed()
Identifies whether the line builder is armed.

Returns:
true if armed, false if not armed.

setArmed

public void setArmed(boolean armed)
Arms and disarms the line builder. When armed, the line builder monitors user input and builds the polyline in response to the actions mentioned in the overview above. When disarmed, the line builder ignores all user input.

Parameters:
armed - true to arm the line builder, false to disarm it.

NASA World Wind