NASA World Wind

gov.nasa.worldwindx.examples.kml
Class KMLViewController

java.lang.Object
  extended by gov.nasa.worldwindx.examples.kml.KMLViewController
Direct Known Subclasses:
KMLFlyViewController, KMLOrbitViewController

public abstract class KMLViewController
extends Object

Base class for controllers to animate the view to look at KML features. Each controller includes logic to animate to a LookAt or Camera view, or to animate to a default view a KML feature that does not define a view. Subclasses of this base class implement animator logic for particular types of View, for example OrbitView.

An application that provides a custom View implementation can extend this base class to provide a KML controller for the custom view.


Field Summary
static double DEFAULT_VIEW_ALTITUDE
          Default altitude from which to view a KML feature.
protected  double viewAltitude
          Default altitude from which to view a KML feature.
protected  WorldWindow wwd
          WorldWindow that holds the view to animate.
 
Constructor Summary
protected KMLViewController(WorldWindow wwd)
          Create the view controller.
 
Method Summary
static KMLViewController create(WorldWindow wwd)
          Convenience method to create a new view controller appropriate for the WorldWindow's current View.
protected  double findMaxAltitude(List<? extends Position> positions)
          Get the maximum altitude in a list of positions.
 double getViewAltitude()
          Get the default altitude for viewing a KML placemark when the globe flies to a placemark.
 void goTo(KMLAbstractFeature feature)
          Animate the view to look at a KML feature.
 void goTo(KMLAbstractView view)
          Animates the View attached to this controller's WorldWindow to look at the specified KML view.
protected abstract  void goTo(KMLCamera camera)
          Animate the view to the position described by a KML Camera.
protected abstract  void goTo(KMLLookAt lookAt)
          Animate the view to the position described by a KML LookAt.
protected  void goToDefaultGroundOverlayView(KMLGroundOverlay overlay)
          Go to a default view of GroundOverlay.
protected  void goToDefaultPlacemarkView(KMLPlacemark placemark)
          Go to a default view of a Placemark.
 void goToDefaultView(KMLAbstractFeature feature)
          Move the view to look at a KML feature.
protected  void goToDefaultView(List<? extends Position> positions)
          Go to a view of a list of positions.
 void setViewAltitude(double viewAltitude)
          Set the default altitude for viewing a KML placemark when the globe flies to a placemark.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_VIEW_ALTITUDE

public static final double DEFAULT_VIEW_ALTITUDE
Default altitude from which to view a KML feature.

See Also:
Constant Field Values

viewAltitude

protected double viewAltitude
Default altitude from which to view a KML feature.


wwd

protected WorldWindow wwd
WorldWindow that holds the view to animate.

Constructor Detail

KMLViewController

protected KMLViewController(WorldWindow wwd)
Create the view controller.

Parameters:
wwd - WorldWindow that holds the view to animate.
Method Detail

create

public static KMLViewController create(WorldWindow wwd)
Convenience method to create a new view controller appropriate for the WorldWindow's current View. Accepted view types are as follows: . If the View is not one of the recognized types, this returns null and logs a warning.

Parameters:
wwd - the WorldWindow to create a view controller for.
Returns:
A new view controller, or null if the WorldWindow's View type is not one of the recognized types.

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.MIN_VALUE if positions is empty.

getViewAltitude

public double getViewAltitude()
Get the default altitude for viewing a KML placemark when the globe flies to a placemark. This setting is only used if the placemark does not specify a view.

Returns:
Default altitude from which to view a placemark.

goTo

public void goTo(KMLAbstractFeature feature)
Animate the view to look at a KML feature. If the feature defines a LookAt or Camera, the view will animate to the view specified in KML. Otherwise the view will animate to a default position looking straight down at the feature from an altitude that brings the entire feature into view.

Parameters:
feature - Feature to look at.

goTo

public void goTo(KMLAbstractView view)
Animates the View attached to this controller's WorldWindow to look at the specified KML view. The view may be one of the following types: If the view is not null and is not one of the recognized types, this logs a warning but otherwise does nothing.

Parameters:
view - the KML view to animate to.
Throws:
IllegalArgumentException - if view is null.

goTo

protected abstract void goTo(KMLCamera camera)
Animate the view to the position described by a KML Camera.

Parameters:
camera - KML Camera that describes the desired view.

goTo

protected abstract void goTo(KMLLookAt lookAt)
Animate the view to the position described by a KML LookAt.

Parameters:
lookAt - KML LookAt that describes the desired view.

goToDefaultGroundOverlayView

protected void goToDefaultGroundOverlayView(KMLGroundOverlay overlay)
Go to a default view of GroundOverlay.

Parameters:
overlay - Overlay to look at

goToDefaultPlacemarkView

protected void goToDefaultPlacemarkView(KMLPlacemark placemark)
Go to a default view of a Placemark.

Parameters:
placemark - Placemark to look at

goToDefaultView

public void goToDefaultView(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.

goToDefaultView

protected void goToDefaultView(List<? extends Position> positions)
Go to a view of a list of positions. This method computes a view looking straight down from an altitude that brings all of the positions into view.

Parameters:
positions - List of positions to bring into view

setViewAltitude

public void setViewAltitude(double viewAltitude)
Set the default altitude for viewing a KML placemark when the globe flies to a placemark. This setting is only used if the placemark does not specify a view.

Parameters:
viewAltitude - Default altitude from which to view a placemark.

NASA World Wind