Package gov.nasa.worldwindx.examples.kml
Class KMLApplicationController
- java.lang.Object
-
- gov.nasa.worldwindx.examples.kml.KMLApplicationController
-
- All Implemented Interfaces:
SelectListener,java.beans.PropertyChangeListener,java.util.EventListener
public class KMLApplicationController extends java.lang.Object implements SelectListener, java.beans.PropertyChangeListener
A controller that maps KML events to changes in a WorldWind 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
Fields Modifier and Type Field Description protected BalloonControllerballoonControllerController to open balloons when KML features are selected.protected TreeNodehighlightedNodeIndicates theTreeNodecurrently under the cursor.protected WorldWindowwwdIndicates theWorldWindowthis controller listens to for select events and property change events.
-
Constructor Summary
Constructors Constructor Description KMLApplicationController(WorldWindow wwd)Creates a newKMLApplicationControllerwith the specifiedWorldWindow.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected booleancanMoveTo(KMLAbstractFeature feature)Determines if the view can be moved to look at a KML feature.protected booleancanSelect(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 booleancanShowBalloon(KMLAbstractFeature feature)Determines if a balloon can be opened for a KML feature.BalloonControllergetBalloonController()Indicates the BalloonController associated with this controller.protected voidmoveTo(KMLAbstractFeature feature)Smoothly moves theWorldWindow'sViewto the specifiedKMLAbstractFeature.protected voidmoveTo(KMLAbstractView view)Smoothly moves theWorldWindow'sViewto the specifiedKMLAbstractView.protected voidonFeatureSelected(KMLAbstractFeature feature)Invoked when a feature is selected in the KML feature tree.protected voidonNetworkLinkRefreshed(KMLNetworkLink networkLink)Called frompropertyChangewhen aKMLNetworkLinksends aproperty change event.AVKey.RETRIEVAL_STATE_SUCCESSFULvoidpropertyChange(java.beans.PropertyChangeEvent event)Handles property change events sent fromKMLNetworkLinkobjects to theSceneController.voidselected(SelectEvent event)Animate the globe to a KML feature when the feature is clicked in the tree.voidsetBalloonController(BalloonController balloonController)Specifies a BalloonController that this controller can use to open balloons when KML features are selected.protected voidsetCursor(java.awt.Cursor cursor)Set the mouse cursor.
-
-
-
Field Detail
-
wwd
protected WorldWindow wwd
Indicates theWorldWindowthis controller listens to for select events and property change events. Initialized during construction.
-
highlightedNode
protected TreeNode highlightedNode
Indicates theTreeNodecurrently under the cursor. Initiallynull.
-
balloonController
protected BalloonController balloonController
Controller to open balloons when KML features are selected.
-
-
Constructor Detail
-
KMLApplicationController
public KMLApplicationController(WorldWindow wwd)
Creates a newKMLApplicationControllerwith the specifiedWorldWindow. The newKMLApplicationControllerlistens KML tree node select events, andKMLNetworkLinkrefresh property change events.- Parameters:
wwd- theWorldWindowthis listens to, and who'sViewis moved upon a refresh event.- Throws:
java.lang.IllegalArgumentException- if thewwdisnull.
-
-
Method Detail
-
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
nullif no BalloonController is set.
-
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 benullto unset the balloon controller.
-
selected
public void selected(SelectEvent event)
Animate the globe to a KML feature when the feature is clicked in the tree.- Specified by:
selectedin interfaceSelectListener- Parameters:
event- Select event.
-
propertyChange
public void propertyChange(java.beans.PropertyChangeEvent event)
Handles property change events sent fromKMLNetworkLinkobjects to theSceneController. Upon receiving aevent from aAVKey.RETRIEVAL_STATE_SUCCESSFULKMLNetworkLink, this attempts to fly to aKMLAbstractViewassociated with the link's KML resource.If the
KMLNetworkLink'sflyToViewproperty is0orfalse, this ignores the event. Otherwise, this attempts to get aKMLAbstractViewfrom features in the link's KML resource as follows:NetworkLinkControlchild of link's KML resource.AbstractFeaturechild of link's KML resource.
WorldWindow'sViewto fly to the feature'sKMLAbstractViewusing aKMLViewController- Specified by:
propertyChangein interfacejava.beans.PropertyChangeListener- Parameters:
event- a property change event from theSceneController.
-
onNetworkLinkRefreshed
protected void onNetworkLinkRefreshed(KMLNetworkLink networkLink)
Called frompropertyChangewhen aKMLNetworkLinksends aproperty change event. This attempts to fly to a view associated with the link's KML resource.AVKey.RETRIEVAL_STATE_SUCCESSFULThis does nothing if the
networkLinkisnull.- Parameters:
networkLink- theKMLNetworkLinkthat has been refreshed.
-
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.
-
moveTo
protected void moveTo(KMLAbstractFeature feature)
Smoothly moves theWorldWindow'sViewto the specifiedKMLAbstractFeature.- Parameters:
feature- theKMLAbstractFeatureto move to.
-
moveTo
protected void moveTo(KMLAbstractView view)
Smoothly moves theWorldWindow'sViewto the specifiedKMLAbstractView.- Parameters:
view- theKMLAbstractViewto move to.
-
setCursor
protected void setCursor(java.awt.Cursor cursor)
Set the mouse cursor.- Parameters:
cursor- New cursor. Passnullto reset the default cursor.
-
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:
trueif the controller can either animate the view or open a balloon for the feature.
-
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:
trueif 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.
-
canShowBalloon
protected boolean canShowBalloon(KMLAbstractFeature feature)
Determines if a balloon can be opened for a KML feature.- Parameters:
feature- KML feature to test.- Returns:
trueif the feature has a balloon.
-
-