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 BalloonController
balloonController
Controller to open balloons when KML features are selected.protected TreeNode
highlightedNode
Indicates theTreeNode
currently under the cursor.protected WorldWindow
wwd
Indicates theWorldWindow
this controller listens to for select events and property change events.
-
Constructor Summary
Constructors Constructor Description KMLApplicationController(WorldWindow wwd)
Creates a newKMLApplicationController
with the specifiedWorldWindow
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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 theWorldWindow
'sView
to the specifiedKMLAbstractFeature
.protected void
moveTo(KMLAbstractView view)
Smoothly moves theWorldWindow
'sView
to the specifiedKMLAbstractView
.protected void
onFeatureSelected(KMLAbstractFeature feature)
Invoked when a feature is selected in the KML feature tree.protected void
onNetworkLinkRefreshed(KMLNetworkLink networkLink)
Called frompropertyChange
when aKMLNetworkLink
sends a
property change event.AVKey.RETRIEVAL_STATE_SUCCESSFUL
void
propertyChange(java.beans.PropertyChangeEvent event)
Handles property change events sent fromKMLNetworkLink
objects to theSceneController
.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(java.awt.Cursor cursor)
Set the mouse cursor.
-
-
-
Field Detail
-
wwd
protected WorldWindow wwd
Indicates theWorldWindow
this controller listens to for select events and property change events. Initialized during construction.
-
highlightedNode
protected TreeNode highlightedNode
Indicates theTreeNode
currently 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 newKMLApplicationController
with the specifiedWorldWindow
. The newKMLApplicationController
listens KML tree node select events, andKMLNetworkLink
refresh property change events.- Parameters:
wwd
- theWorldWindow
this listens to, and who'sView
is moved upon a refresh event.- Throws:
java.lang.IllegalArgumentException
- if thewwd
isnull
.
-
-
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
null
if 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 benull
to 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:
selected
in interfaceSelectListener
- Parameters:
event
- Select event.
-
propertyChange
public void propertyChange(java.beans.PropertyChangeEvent event)
Handles property change events sent fromKMLNetworkLink
objects to theSceneController
. Upon receiving a
event from aAVKey.RETRIEVAL_STATE_SUCCESSFUL
KMLNetworkLink
, this attempts to fly to aKMLAbstractView
associated with the link's KML resource.If the
KMLNetworkLink
'sflyToView
property is0
orfalse
, this ignores the event. Otherwise, this attempts to get aKMLAbstractView
from features in the link's KML resource as follows:NetworkLinkControl
child of link's KML resource.AbstractFeature
child of link's KML resource.
WorldWindow
'sView
to fly to the feature'sKMLAbstractView
using aKMLViewController
- Specified by:
propertyChange
in interfacejava.beans.PropertyChangeListener
- Parameters:
event
- a property change event from theSceneController
.
-
onNetworkLinkRefreshed
protected void onNetworkLinkRefreshed(KMLNetworkLink networkLink)
Called frompropertyChange
when aKMLNetworkLink
sends a
property change event. This attempts to fly to a view associated with the link's KML resource.AVKey.RETRIEVAL_STATE_SUCCESSFUL
This does nothing if the
networkLink
isnull
.- Parameters:
networkLink
- theKMLNetworkLink
that 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
'sView
to the specifiedKMLAbstractFeature
.- Parameters:
feature
- theKMLAbstractFeature
to move to.
-
moveTo
protected void moveTo(KMLAbstractView view)
Smoothly moves theWorldWindow
'sView
to the specifiedKMLAbstractView
.- Parameters:
view
- theKMLAbstractView
to move to.
-
setCursor
protected void setCursor(java.awt.Cursor cursor)
Set the mouse cursor.- Parameters:
cursor
- New cursor. Passnull
to 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:
true
if 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:
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.
-
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.
-
-