NASA World Wind

gov.nasa.worldwindx.examples.util
Class BalloonController

java.lang.Object
  extended by java.awt.event.MouseAdapter
      extended by gov.nasa.worldwindx.examples.util.BalloonController
All Implemented Interfaces:
SelectListener, MouseListener, MouseMotionListener, MouseWheelListener, EventListener

public class BalloonController
extends MouseAdapter
implements SelectListener

Controller to display a Balloon and handle balloon events. The controller does the following:

Displaying a balloon for a selected object

When a object is clicked, the controller looks for a Balloon attached to the object. The controller includes special logic for handling balloons attached to KML features.

KML Features

The KMLAbstractFeature is attached to the top PickedObject under AVKey.CONTEXT. The controller looks for the balloon in the KMLAbstractFeature under key AVKey.BALLOON.

Other objects

If the top object is an instance of AVList, the controller looks for a Balloon under AVKey.BALLOON.

URL events

The controller looks for a value under AVKey.URL attached to either the top PickedObject. If the URL refers to a KML or KMZ document, the document is loaded into a new layer. If the link includes a reference to a KML feature, controller will animate the view to that feature and/or open the feature balloon.

If the link should open in a new window (determined by an AVKey.TARGET of "_blank"), the controller will launch the system web browser and navigate to the link. Otherwise it will allow the BrowserBalloon to navigate to the link.

Consuming a SelectEvent in the BalloonController will prevent the balloon from taking action on that event. For example, a BrowserBalloon will navigate in place when a link is clicked, but it will not if the balloon controller consumes the left press and left click select events. This allows the balloon controller to override the default action for certain URLs.

BrowserBalloon control events

AbstractBrowserBalloon identifies its controls by attaching a value to the PickedObject's AVList under AVKey.ACTION. The controller reads this value and performs the appropriate action. The possible actions are AVKey.RESIZE, AVKey.BACK, AVKey.FORWARD, and AVKey.CLOSE.


Nested Class Summary
protected  class BalloonController.DocumentRetrievalTask
          A TimerTask that will request a resource from the FileStore until it becomes available, or until a timeout is exceeded.
 
Field Summary
protected  Balloon balloon
           
static String BALLOON
           
static String BALLOON_FLY_TO
           
protected  int balloonOffset
          Vertical offset, in pixels, between the balloon and the point that the leader shape points to.
static int DEFAULT_BALLOON_OFFSET
           
static String FLY_TO
           
protected  Object lastSelectedObject
           
protected  BalloonResizeController resizeController
          A resize controller is created when the mouse enters a resize control on the balloon.
protected  long retrievalPollInterval
          Interval between periodic checks for completion of asynchronous document retrieval (in milliseconds).
protected  long retrievalTimeout
          Timeout to use when requesting remote documents.
protected  WorldWindow wwd
           
 
Constructor Summary
BalloonController(WorldWindow wwd)
          Create a new balloon controller.
 
Method Summary
protected  void addDocumentLayer(KMLRoot document)
          Adds the specified document to this controller's WorldWindow as a new Layer.
protected  void adjustPosition(Balloon balloon, Point screenPoint)
          Adjust the position of a balloon so that the entire balloon is visible on screen.
 boolean canShowBalloon(KMLAbstractFeature feature)
          Determines whether or not a balloon must be created for a KML feature.
protected  Position computeIntersection(AbstractShape shape, Point screenPoint)
          Compute the intersection of a line through a screen point and a shape.
protected  void configureBalloon(Balloon balloon, KMLAbstractFeature feature)
          Configure a new balloon for a KML feature.
protected  Balloon createBalloon(KMLAbstractFeature feature)
          Create a balloon for a KML feature and attach the balloon to the feature.
protected  void createResizeController(Balloon balloon)
          Create a resize controller and attach it to the WorldWindow.
protected  void destroyResizeController(SelectEvent event)
          Destroy the active resize controller.
protected  void doFeatureLinkActivated(KMLAbstractFeature feature, String directive)
          Handle activation of a KML feature link.
protected  double findMaxAltitude(List<? extends Position> positions)
          Get the maximum altitude in a list of positions.
protected  KMLRoot findOpenKmlDocument(String url)
          Search for a KML document that has already been opened.
protected  String getAttachmentMode(KMLAbstractFeature feature)
          Get the attachment mode of a KML feature: AVKey.GLOBE or AVKey.SCREEN.
protected  Balloon getBalloon(PickedObject pickedObject)
          Get the balloon attached to a PickedObject.
protected  int getBalloonAltitudeMode(Object balloonObject)
          Get the appropriate altitude mode for a GlobeBalloon, depending on the object that has been selected.
 int getBalloonOffset()
          Indicates the vertical distance, in pixels, between the balloon and the point that the leader points to.
protected  Point getBalloonPoint(KMLAbstractFeature feature)
          Get the screen point for a balloon for a KML feature attached to the screen.
protected  Point getBalloonPointForScreenOverlay(KMLScreenOverlay overlay)
          Get the screen point for a balloon for a ScreenOverlay.
protected  Position getBalloonPosition(KMLAbstractFeature feature)
          Get the position of the balloon for a KML feature attached to the globe.
protected  Position getBalloonPosition(List<? extends Position> positions)
          Get the position of the balloon for a list of positions that bound a feature.
protected  Position getBalloonPosition(Object topObject, Point pickPoint)
          Get the position of the balloon for a picked object with an attached balloon.
protected  Position getBalloonPositionForGroundOverlay(KMLGroundOverlay overlay)
          Get the position of the balloon for a KML GroundOverlay.
protected  Position getBalloonPositionForPlacemark(KMLPlacemark placemark)
          Get the position of the balloon for a KML placemark.
protected  KMLAbstractFeature getContext(PickedObject pickedObject)
          Get the KML feature that is the context of a picked object.
protected  String getUrl(PickedObject pickedObject)
          Get the URL attached to a PickedObject.
protected  void hideBalloon()
          Hide the active balloon.
protected  boolean isBalloonTrigger(MouseEvent e)
          Inspect a mouse event to see if it should make a balloon visible.
protected  boolean isKmlUrl(String url, String contentType)
          Does a URL refer to a KML or KMZ document?
protected  boolean isLinkActivationTrigger(SelectEvent event)
          Determines if a SelectEvent is an event that activates a hyperlink.
protected  boolean isResizeControl(PickedObject po)
           
protected  boolean isUseBrowserBalloon()
          Indicates if the controller will create Balloons of type AbstractBrowserBalloon.
 void mouseClicked(MouseEvent e)
          Handle a mouse click.
 void mouseMoved(MouseEvent e)
           
protected  void moveToFeature(KMLAbstractFeature feature)
          Move the view to look at a KML feature.
protected  boolean mustAdjustPosition(Balloon balloon)
          Determines if a balloon position must be adjusted to make the balloon visible in the viewport.
protected  void onBalloonAction(AbstractBrowserBalloon browserBalloon, String action)
          Called when a AbstractBrowserBalloon control is activated (Close, Back, or Forward).
protected  void onDocumentFailed(String url, Exception e)
          Called when a KML file fails to load due to a network timeout or parsing error.
protected  void onDocumentLoaded(String url, KMLRoot document, String featureRef)
          Called when a KML document has been loaded.
protected  boolean onFeatureLinkActivated(KMLRoot doc, String linkFragment, SelectEvent event)
          Called when a link to a KML feature is activated.
protected  void onLinkActivated(SelectEvent event, String url)
          Called when a URL in a balloon is activated.
protected  void openInNewBrowser(SelectEvent event, String url)
          Open a URL in a new web browser.
protected  void requestDocument(String url, KMLRoot context, String featureRef)
          Asynchronously load a KML document.
 void selected(SelectEvent event)
           
 void setBalloonOffset(int balloonOffset)
          Sets the vertical distance, in pixels, between the balloon and the point that the leader points to.
protected  void showBalloon(Balloon balloon, Object balloonObject, Point point)
          Show a balloon at a screen point.
protected  void showBalloon(Balloon balloon, Position position)
          Show a balloon at a globe position.
 void showBalloon(KMLAbstractFeature feature)
          Show a balloon for a KML feature.
 
Methods inherited from class java.awt.event.MouseAdapter
mouseDragged, mouseEntered, mouseExited, mousePressed, mouseReleased, mouseWheelMoved
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

balloon

protected Balloon balloon

BALLOON

public static final String BALLOON
See Also:
Constant Field Values

BALLOON_FLY_TO

public static final String BALLOON_FLY_TO
See Also:
Constant Field Values

balloonOffset

protected int balloonOffset
Vertical offset, in pixels, between the balloon and the point that the leader shape points to.


DEFAULT_BALLOON_OFFSET

public static final int DEFAULT_BALLOON_OFFSET
See Also:
Constant Field Values

FLY_TO

public static final String FLY_TO
See Also:
Constant Field Values

lastSelectedObject

protected Object lastSelectedObject

resizeController

protected BalloonResizeController resizeController
A resize controller is created when the mouse enters a resize control on the balloon. The controller is destroyed when the mouse exits the resize control.


retrievalPollInterval

protected long retrievalPollInterval
Interval between periodic checks for completion of asynchronous document retrieval (in milliseconds).


retrievalTimeout

protected long retrievalTimeout
Timeout to use when requesting remote documents. If the document does not load within this many milliseconds the controller will stop trying and report an error.


wwd

protected WorldWindow wwd
Constructor Detail

BalloonController

public BalloonController(WorldWindow wwd)
Create a new balloon controller.

Parameters:
wwd - WorldWindow to attach to.
Method Detail

addDocumentLayer

protected void addDocumentLayer(KMLRoot document)
Adds the specified document to this controller's WorldWindow as a new Layer.

This expects the kmlRoot's AVKey.DISPLAY_NAME field to contain a display name suitable for use as a layer name.

Parameters:
document - the KML document to add a Layer for.

adjustPosition

protected void adjustPosition(Balloon balloon,
                              Point screenPoint)
Adjust the position of a balloon so that the entire balloon is visible on screen.

Parameters:
balloon - Balloon to adjust the position of.
screenPoint - Screen point to which the balloon leader points.

canShowBalloon

public boolean canShowBalloon(KMLAbstractFeature feature)
Determines whether or not a balloon must be created for a KML feature. A balloon is created for any feature with a balloon style or a non-empty description. No balloon is created for a feature with no balloon style and no description.

Parameters:
feature - KML feature to test.
Returns:
true if a balloon must be created for the feature. Otherwise false.

computeIntersection

protected Position computeIntersection(AbstractShape shape,
                                       Point screenPoint)
Compute the intersection of a line through a screen point and a shape.

Parameters:
shape - Shape with which to compute intersection.
screenPoint - Compute the intersection of a line through this screen point and the shape.
Returns:
The intersection position, or null if there is no intersection, or if the computation is interrupted.

configureBalloon

protected void configureBalloon(Balloon balloon,
                                KMLAbstractFeature feature)
Configure a new balloon for a KML feature.

Parameters:
balloon - Balloon to configure.
feature - Feature that owns the Balloon.

createBalloon

protected Balloon createBalloon(KMLAbstractFeature feature)
Create a balloon for a KML feature and attach the balloon to the feature. The type of balloon created depends on the type of feature and the result of isUseBrowserBalloon(). If the feature is attached to a point on the globe, this method creates a GlobeBalloon. If the feature is attached to the screen, a ScreenBalloon is created. If isUseBrowserBalloon() returns true, the balloon will be a descendant of AbstractBrowserBalloon. Otherwise it will be a descendant of AbstractAnnotationBalloon.

Parameters:
feature - Feature to create balloon for.
Returns:
New balloon. May return null if the feature should not have a balloon.

createResizeController

protected void createResizeController(Balloon balloon)
Create a resize controller and attach it to the WorldWindow. Has no effect if there is already an active resize controller.

Parameters:
balloon - Balloon to resize.

destroyResizeController

protected void destroyResizeController(SelectEvent event)
Destroy the active resize controller.

Parameters:
event - Event that triggered the controller to be destroyed.

doFeatureLinkActivated

protected void doFeatureLinkActivated(KMLAbstractFeature feature,
                                      String directive)
Handle activation of a KML feature link. Depending on the display directive, this method will either move the view to the feature, open the balloon for the feature, or both. See the KML specification for details on links to features in the KML description balloon.

Parameters:
feature - Feature to navigate to.
directive - Display directive, one of FLY_TO, BALLOON, or BALLOON_FLY_TO.

findMaxAltitude

protected double findMaxAltitude(List<? extends Position> positions)
Get the maximum altitude in a list of positions.

Parameters:
positions - List of positions to search for max altitude.
Returns:
The maximum elevation in the list of positions. Returns -Double.MAX_VALUE if positions is empty.

findOpenKmlDocument

protected KMLRoot findOpenKmlDocument(String url)
Search for a KML document that has already been opened. This method looks in the session cache for a parsed KMLRoot.

Parameters:
url - URL of the KML document.
Returns:
KMLRoot for an already-parsed document, or null if the document was not found in the cache.

getAttachmentMode

protected String getAttachmentMode(KMLAbstractFeature feature)
Get the attachment mode of a KML feature: AVKey.GLOBE or AVKey.SCREEN. Some features, such as a PointPlacemark, are attached to a point on the globe. Others, such as a ScreenImage, are attached to the screen.

Parameters:
feature - KML feature to test.
Returns:
AVKey.GLOBE if the feature is attached to a geographic location. Otherwise AVKey.SCREEN. Container features (Document and Folder) are considered screen features.

getBalloon

protected Balloon getBalloon(PickedObject pickedObject)
Get the balloon attached to a PickedObject. If the PickedObject represents a KML feature, then the balloon will be retrieved from the feature. Otherwise, the balloon will be retrieved from the user object's field AVKey.BALLOON.

If a KML feature is picked, and the feature does not have a balloon, a new balloon may be created and attached to the feature. canShowBalloon determines if a balloon will be created for the feature.

Parameters:
pickedObject - PickedObject to inspect. May not be null.
Returns:
The balloon attached to the picked object, or null if there is no balloon. Returns null if pickedObject is null.

getBalloonAltitudeMode

protected int getBalloonAltitudeMode(Object balloonObject)
Get the appropriate altitude mode for a GlobeBalloon, depending on the object that has been selected. If the balloon object is an instance of PointPlacemark, this implementation returns the altitude mode of the placemark. Otherwise it returns WorldWind.ABSOLUTE.

Parameters:
balloonObject - The object that the balloon is attached to.
Returns:
The altitude mode that should be applied to the balloon, one of WorldWind.ABSOLUTE, WorldWind.CLAMP_TO_GROUND, or WorldWind.RELATIVE_TO_GROUND.

getBalloonOffset

public int getBalloonOffset()
Indicates the vertical distance, in pixels, between the balloon and the point that the leader points to.

Returns:
Vertical offset, in pixels.

getBalloonPoint

protected Point getBalloonPoint(KMLAbstractFeature feature)
Get the screen point for a balloon for a KML feature attached to the screen. This method applies only to KML features that area attached to the screen, rather than to the globe (for example, ScreenOverlay, but not GroundOverlay). This method determines the type of feature, and then calls a more specific method to handle features of that type.

Parameters:
feature - Feature for which to find a balloon point.
Returns:
Point for the balloon, or null if a point cannot be determined.
See Also:
getBalloonPointForScreenOverlay(gov.nasa.worldwind.ogc.kml.KMLScreenOverlay), getBalloonPosition(gov.nasa.worldwind.ogc.kml.KMLAbstractFeature)

getBalloonPointForScreenOverlay

protected Point getBalloonPointForScreenOverlay(KMLScreenOverlay overlay)
Get the screen point for a balloon for a ScreenOverlay.

Parameters:
overlay - ScreenOverlay for which to find a balloon position.
Returns:
Point for the balloon, or null if a point cannot be determined.
See Also:
getBalloonPoint(gov.nasa.worldwind.ogc.kml.KMLAbstractFeature)

getBalloonPosition

protected Position getBalloonPosition(KMLAbstractFeature feature)
Get the position of the balloon for a KML feature attached to the globe. This method applies to KML features that area attached to the globe, rather than to the screen (for example, this method applies to GroundOverlay, but not to ScreenOverlay). This method determines the type of feature, and calls a more specific method to handle features of that type.

Parameters:
feature - Feature to find balloon position for.
Returns:
Position at which to place the Placemark balloon.
See Also:
getBalloonPositionForPlacemark(gov.nasa.worldwind.ogc.kml.KMLPlacemark), getBalloonPositionForGroundOverlay(gov.nasa.worldwind.ogc.kml.KMLGroundOverlay), getBalloonPoint(gov.nasa.worldwind.ogc.kml.KMLAbstractFeature)

getBalloonPosition

protected Position getBalloonPosition(List<? extends Position> positions)
Get the position of the balloon for a list of positions that bound a feature. This method returns a position at the centroid of the sector that bounds all of the points in the list, and at the maximum altitude of the points in the list.

Parameters:
positions - List of positions to find a balloon position.
Returns:
Position for the balloon, or null if a position cannot be determined.

getBalloonPosition

protected Position getBalloonPosition(Object topObject,
                                      Point pickPoint)
Get the position of the balloon for a picked object with an attached balloon. If the top object is an instance of Locatable, this method returns the position of the Locatable. If the object is an instance of AbstractShape, the method performs an intersection calculation between a ray through the pick point and the shape. If neither of the previous conditions are true, or if the object is null, this method returns the intersection position of a ray through the pick point and the globe.

Parameters:
topObject - Object that was picked. May be null.
pickPoint - The point at which the mouse event occurred.
Returns:
Position at which to place the balloon, or null if a position cannot be determined.

getBalloonPositionForGroundOverlay

protected Position getBalloonPositionForGroundOverlay(KMLGroundOverlay overlay)
Get the position of the balloon for a KML GroundOverlay. This method returns the centroid of the sector that bounds all of the points in the overlay.

Parameters:
overlay - Ground overlay for which to find a balloon position.
Returns:
Position for the balloon, or null if a position cannot be determined.
See Also:
getBalloonPosition(gov.nasa.worldwind.ogc.kml.KMLAbstractFeature)

getBalloonPositionForPlacemark

protected Position getBalloonPositionForPlacemark(KMLPlacemark placemark)
Get the position of the balloon for a KML placemark. For a point placemark, this method returns the placemark point. For all other placemarks, this method returns the centroid of the sector that bounds all of the points in the placemark. Note that the centroid of the sector may not actually fall on the visible area of the shape.

Parameters:
placemark - Placemark for which to find a balloon position.
Returns:
Position for the balloon, or null if a position cannot be determined.
See Also:
getBalloonPosition(gov.nasa.worldwind.ogc.kml.KMLAbstractFeature)

getContext

protected KMLAbstractFeature getContext(PickedObject pickedObject)
Get the KML feature that is the context of a picked object. The context is associated with either the PickedObject or the user object under the key AVKey.CONTEXT.

Parameters:
pickedObject - PickedObject to inspect for context. May not be null.
Returns:
The KML feature associated with the picked object, or null if no KML feature is found.

getUrl

protected String getUrl(PickedObject pickedObject)
Get the URL attached to a PickedObject. This method looks for a URL attached to the PickedObject under AVKey.URL.

Parameters:
pickedObject - PickedObject to inspect. May not be null.
Returns:
The URL attached to the PickedObject, or null if there is no URL.

hideBalloon

protected void hideBalloon()
Hide the active balloon. Does nothing if there is no active balloon.


isBalloonTrigger

protected boolean isBalloonTrigger(MouseEvent e)
Inspect a mouse event to see if it should make a balloon visible.

Parameters:
e - Event to inspect.
Returns:
true if the event is a balloon trigger. This implementation returns true if the event is a left click.

isKmlUrl

protected boolean isKmlUrl(String url,
                           String contentType)
Does a URL refer to a KML or KMZ document?

Parameters:
url - URL to test.
contentType - Mime type of the URL content. May be null.
Returns:
Return true if the URL refers to a file with a ".kml" or ".kmz" extension, or if the contentType is the KML or KMZ mime type.

isLinkActivationTrigger

protected boolean isLinkActivationTrigger(SelectEvent event)
Determines if a SelectEvent is an event that activates a hyperlink.

Parameters:
event - Event to test. May not be null.
Returns:
true if the event actives hyperlinks. This implementation returns true for left click events.

isResizeControl

protected boolean isResizeControl(PickedObject po)

isUseBrowserBalloon

protected boolean isUseBrowserBalloon()
Indicates if the controller will create Balloons of type AbstractBrowserBalloon. BrowserBalloons are used on platforms that support them (currently Windows and Mac). AbstractAnnotationBalloon is used on other platforms.

Returns:
true if the controller will create BrowserBalloons.

mouseClicked

public void mouseClicked(MouseEvent e)
Handle a mouse click. If the top picked object has a balloon attached to it the balloon will be made visible. A balloon may be attached to a KML feature, or to any picked object though AVKey.BALLOON.

Specified by:
mouseClicked in interface MouseListener
Overrides:
mouseClicked in class MouseAdapter
Parameters:
e - Mouse event

mouseMoved

public void mouseMoved(MouseEvent e)
Specified by:
mouseMoved in interface MouseMotionListener
Overrides:
mouseMoved in class MouseAdapter

moveToFeature

protected void moveToFeature(KMLAbstractFeature feature)
Move the view to look at a KML feature. The view will be adjusted to look at the bounding sector that contains all of the feature's points.

Parameters:
feature - Feature to look at.

mustAdjustPosition

protected boolean mustAdjustPosition(Balloon balloon)
Determines if a balloon position must be adjusted to make the balloon visible in the viewport.

Parameters:
balloon - Balloon to inspect.
Returns:
true if the balloon position must be adjusted to make the balloon visible.

onBalloonAction

protected void onBalloonAction(AbstractBrowserBalloon browserBalloon,
                               String action)
Called when a AbstractBrowserBalloon control is activated (Close, Back, or Forward).

Parameters:
browserBalloon - Balloon involved in action.
action - Identifier for the action that occurred.

onDocumentFailed

protected void onDocumentFailed(String url,
                                Exception e)
Called when a KML file fails to load due to a network timeout or parsing error. This implementation simply logs a warning.

Parameters:
url - URL of the document that failed to load.
e - Exception that caused the failure.

onDocumentLoaded

protected void onDocumentLoaded(String url,
                                KMLRoot document,
                                String featureRef)
Called when a KML document has been loaded. This implementation creates a new layer and adds the new document to the layer.

Parameters:
url - URL of the document that has been loaded.
document - Parsed document.
featureRef - Reference to a feature that must be activated (fly to or open balloon).

onFeatureLinkActivated

protected boolean onFeatureLinkActivated(KMLRoot doc,
                                         String linkFragment,
                                         SelectEvent event)
Called when a link to a KML feature is activated.

Parameters:
doc - Document to search for the feature.
linkFragment - Reference to the feature. The fragment may contain a display directive. For example "#myPlacemark", or "#myPlacemark;balloon".
event - The select event that activated the link. This event will be consumed if a KML feature is found that matches the link fragment. However, the controller only moves to the feature or opens a balloon if the event is a link activation event, or null. Other events are consumed to prevent the balloon from handling events for a link that the controller wants handle. This parameter may be null.
Returns:
True if a feature matching the reference was found and some action was taken.

onLinkActivated

protected void onLinkActivated(SelectEvent event,
                               String url)
Called when a URL in a balloon is activated. This method handles links to KML documents, features in KML documents, and links that target a new browser window.

The possible cases are:

KML/KMZ document - Load the document in a new layer.
Feature in KML/KMZ document - Load the document, navigate to the feature and/or open feature balloon.
Feature in currently open KML/KMZ document - Navigate to the feature and/or open feature balloon.
HTML document, target current window - No action, let the BrowserBalloon navigate to the URL.
HTML document, target new window - Launch the system web browser and navigate to the URL.

If the URL matches one of the cases defined above, the SelectEvent will be marked as consumed. Marking the event as consumed prevents BrowserBalloon from handling the event. However, the controller will only take action on the event if the event is a link activation trigger.

For example, if a left click event (a link activation event) occurs on a link to a KML document, the event will be marked as consumed and the document will be opened. If a left press event (not a link activation event) occurs with the same URL, the event will be consumed but the document will not be opened (if the press is followed by a click, the click will cause the document to be opened). Consuming the left press prevents the balloon from processing the event.

Parameters:
event - SelectEvent for the URL activation. If the event is a link activation trigger the controller will take action on the event (by opening a KML document, etc). If the event is not a link activation trigger, but the URL is a URL that the balloon controller would normally handle, the event is consumed to prevent the balloon itself from trying to handle the event, but no further action is taken.
url - URL that was activated.
See Also:
isLinkActivationTrigger(gov.nasa.worldwind.event.SelectEvent)

openInNewBrowser

protected void openInNewBrowser(SelectEvent event,
                                String url)
Open a URL in a new web browser. Launch the system web browser and navigate to the URL.

Parameters:
event - SelectEvent that triggered navigation. The event is consumed if URL can be parsed.
url - URL to open.

requestDocument

protected void requestDocument(String url,
                               KMLRoot context,
                               String featureRef)
Asynchronously load a KML document. When the document is available, onDocumentLoaded will be called on the Event Dispatch Thread (EDT). If the document fails to load, onDocumentFailed will be called. Failure will be reported if the document does not load within retrievalTimeout milliseconds.

Parameters:
url - URL of KML doc to open.
context - Context of the URL, used to resolve local references.
featureRef - A reference to a feature in the remote file to animate the globe to once the file is available.
See Also:
onDocumentLoaded(String, gov.nasa.worldwind.ogc.kml.KMLRoot, String), onDocumentFailed(String, Exception)

selected

public void selected(SelectEvent event)
Specified by:
selected in interface SelectListener

setBalloonOffset

public void setBalloonOffset(int balloonOffset)
Sets the vertical distance, in pixels, between the balloon and the point that the leader points to.

Parameters:
balloonOffset - Vertical offset, in pixels.

showBalloon

protected void showBalloon(Balloon balloon,
                           Object balloonObject,
                           Point point)
Show a balloon at a screen point.

Parameters:
balloon - Balloon to make visible.
balloonObject - The picked object that owns the balloon. May be null.
point - Point where mouse was clicked.

showBalloon

protected void showBalloon(Balloon balloon,
                           Position position)
Show a balloon at a globe position.

Parameters:
balloon - Balloon to make visible.
position - Position on the globe to locate the balloon. If the balloon is attached to the screen, it will be position at the screen point currently over this position.

showBalloon

public void showBalloon(KMLAbstractFeature feature)
Show a balloon for a KML feature. The balloon will be positioned over the feature on the globe. If the feature does not have a balloon, a balloon may be created. canShowBalloon determines if a balloon will be created.

Parameters:
feature - KML feature for which to show a balloon.

NASA World Wind