Class 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 Detail

      • wwd

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

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

        protected BalloonController balloonController
        Controller to open balloons when KML features are selected.
    • 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:
        java.lang.IllegalArgumentException - if the wwd is null.
    • 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 be null 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 interface SelectListener
        Parameters:
        event - Select event.
      • propertyChange

        public void propertyChange​(java.beans.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 java.beans.PropertyChangeListener
        Parameters:
        event - a property change event from the SceneController.
      • 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.
      • 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 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.
      • setCursor

        protected void setCursor​(java.awt.Cursor cursor)
        Set the mouse cursor.
        Parameters:
        cursor - New cursor. Pass null 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.