NASA World Wind

gov.nasa.worldwindx.examples.kml
Class KMLApplicationController

java.lang.Object
  extended by gov.nasa.worldwindx.examples.kml.KMLApplicationController
All Implemented Interfaces:
SelectListener, PropertyChangeListener, EventListener

public class KMLApplicationController
extends Object
implements SelectListener, PropertyChangeListener

A controller that maps KML events to changes in a World Wind application. This controller animates the view to a KML feature when the feature is clicked in the feature tree, and animates the view to KML network links when they are refreshed.

This controller may optionally be associated with a BalloonController. If a BalloonController is set, this controller will open the description balloon for a KML feature when the feature is clicked in the feature tree.


Field Summary
protected  BalloonController balloonController
          Controller to open balloons when KML features are selected.
protected  TreeNode highlightedNode
          Indicates the TreeNode currently under the cursor.
protected  WorldWindow wwd
          Indicates the WorldWindow this controller listens to for select events and property change events.
 
Constructor Summary
KMLApplicationController(WorldWindow wwd)
          Creates a new KMLApplicationController with the specified WorldWindow.
 
Method Summary
protected  boolean canMoveTo(KMLAbstractFeature feature)
          Determines if the view can be moved to look at a KML feature.
protected  boolean canSelect(KMLAbstractFeature feature)
          Determines if there is a some action (fly to and/or open description balloon) to take when the user selects a KML feature in the tree.
protected  boolean canShowBalloon(KMLAbstractFeature feature)
          Determines if a balloon can be opened for a KML feature.
 BalloonController getBalloonController()
          Indicates the BalloonController associated with this controller.
protected  void moveTo(KMLAbstractFeature feature)
          Smoothly moves the WorldWindow's View to the specified KMLAbstractFeature.
protected  void moveTo(KMLAbstractView view)
          Smoothly moves the WorldWindow's View to the specified KMLAbstractView.
protected  void onFeatureSelected(KMLAbstractFeature feature)
          Invoked when a feature is selected in the KML feature tree.
protected  void onNetworkLinkRefreshed(KMLNetworkLink networkLink)
          Called from propertyChange when a KMLNetworkLink sends a AVKey.RETRIEVAL_STATE_SUCCESSFUL property change event.
 void propertyChange(PropertyChangeEvent event)
          Handles property change events sent from KMLNetworkLink objects to the SceneController.
 void selected(SelectEvent event)
          Animate the globe to a KML feature when the feature is clicked in the tree.
 void setBalloonController(BalloonController balloonController)
          Specifies a BalloonController that this controller can use to open balloons when KML features are selected.
protected  void setCursor(Cursor cursor)
          Set the mouse cursor.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

balloonController

protected BalloonController balloonController
Controller to open balloons when KML features are selected.


highlightedNode

protected TreeNode highlightedNode
Indicates the TreeNode currently under the cursor. Initially null.


wwd

protected WorldWindow wwd
Indicates the WorldWindow this controller listens to for select events and property change events. Initialized during construction.

Constructor Detail

KMLApplicationController

public KMLApplicationController(WorldWindow wwd)
Creates a new KMLApplicationController with the specified WorldWindow. The new KMLApplicationController listens KML tree node select events, and KMLNetworkLink refresh property change events.

Parameters:
wwd - the WorldWindow this listens to, and who's View is moved upon a refresh event.
Throws:
IllegalArgumentException - if the wwd is null.
Method Detail

canMoveTo

protected boolean canMoveTo(KMLAbstractFeature feature)
Determines if the view can be moved to look at a KML feature.

Parameters:
feature - KML feature to test.
Returns:
true if the feature has a view associated with it. This can be an explicit Camera or LookAt, or a default view for a geographic feature. Not all features have a default view. For example, features attached to screen (ScreenOverlay) and container features (Document and Folder) do not have default views.

canSelect

protected boolean canSelect(KMLAbstractFeature feature)
Determines if there is a some action (fly to and/or open description balloon) to take when the user selects a KML feature in the tree. The controller displays a hand cursor when the mouse is over a feature if the feature can be flown to, or if the has a balloon that can be opened.

Parameters:
feature - KML feature to test.
Returns:
true if the controller can either animate the view or open a balloon for the feature.

canShowBalloon

protected boolean canShowBalloon(KMLAbstractFeature feature)
Determines if a balloon can be opened for a KML feature.

Parameters:
feature - KML feature to test.
Returns:
true if the feature has a balloon.

getBalloonController

public BalloonController getBalloonController()
Indicates the BalloonController associated with this controller. The BalloonController is used to open balloons for KML features when the feature is selected.

Returns:
Active BalloonController. May return null if no BalloonController is set.

moveTo

protected void moveTo(KMLAbstractFeature feature)
Smoothly moves the WorldWindow's View to the specified KMLAbstractFeature.

Parameters:
feature - the KMLAbstractFeature to move to.

moveTo

protected void moveTo(KMLAbstractView view)
Smoothly moves the WorldWindow's View to the specified KMLAbstractView.

Parameters:
view - the KMLAbstractView to move to.

onFeatureSelected

protected void onFeatureSelected(KMLAbstractFeature feature)
Invoked when a feature is selected in the KML feature tree. This implementation animates the view to look at the feature, and opens the feature's balloon.

Parameters:
feature - Feature that was selected.

onNetworkLinkRefreshed

protected void onNetworkLinkRefreshed(KMLNetworkLink networkLink)
Called from propertyChange when a KMLNetworkLink sends a AVKey.RETRIEVAL_STATE_SUCCESSFUL property change event. This attempts to fly to a view associated with the link's KML resource.

This does nothing if the networkLink is null.

Parameters:
networkLink - the KMLNetworkLink that has been refreshed.

propertyChange

public void propertyChange(PropertyChangeEvent event)
Handles property change events sent from KMLNetworkLink objects to the SceneController. Upon receiving a AVKey.RETRIEVAL_STATE_SUCCESSFUL event from a KMLNetworkLink, this attempts to fly to a KMLAbstractView associated with the link's KML resource.

If the KMLNetworkLink's flyToView property is 0 or false, this ignores the event. Otherwise, this attempts to get a KMLAbstractView from features in the link's KML resource as follows:

  1. NetworkLinkControl child of link's KML resource.
  2. AbstractFeature child of link's KML resource.
If neither of the above features contain a view, this ignores the event. Otherwise, this causes the WorldWindow's View to fly to the feature's KMLAbstractView using a KMLViewController

Specified by:
propertyChange in interface PropertyChangeListener
Parameters:
event - a property change event from the SceneController.

selected

public void selected(SelectEvent event)
Animate the globe to a KML feature when the feature is clicked in the tree.

Specified by:
selected in interface SelectListener
Parameters:
event - Select event.

setBalloonController

public void setBalloonController(BalloonController balloonController)
Specifies a BalloonController that this controller can use to open balloons when KML features are selected.

Parameters:
balloonController - New BalloonController. May be null to unset the balloon controller.

setCursor

protected void setCursor(Cursor cursor)
Set the mouse cursor.

Parameters:
cursor - New cursor. Pass null to reset the default cursor.

NASA World Wind