Package gov.nasa.worldwindx.examples.kml
Class KMLViewController
- java.lang.Object
-
- gov.nasa.worldwindx.examples.kml.KMLViewController
-
- Direct Known Subclasses:
KMLFlyViewController,KMLOrbitViewController
public abstract class KMLViewController extends java.lang.ObjectBase class for controllers to animate the view to look at KML features. Each controller includes logic to animate to aLookAtorCameraview, 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 ofView, for exampleOrbitView.An application that provides a custom View implementation can extend this base class to provide a KML controller for the custom view.
-
-
Field Summary
Fields Modifier and Type Field Description static doubleDEFAULT_VIEW_ALTITUDEDefault altitude from which to view a KML feature.protected doubleviewAltitudeDefault altitude from which to view a KML feature.protected WorldWindowwwdWorldWindow that holds the view to animate.
-
Constructor Summary
Constructors Modifier Constructor Description protectedKMLViewController(WorldWindow wwd)Create the view controller.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static KMLViewControllercreate(WorldWindow wwd)Convenience method to create a new view controller appropriate for theWorldWindow's currentView.protected doublefindMaxAltitude(java.util.List<? extends Position> positions)Get the maximum altitude in a list of positions.doublegetViewAltitude()Get the default altitude for viewing a KML placemark when the globe flies to a placemark.voidgoTo(KMLAbstractFeature feature)Animate the view to look at a KML feature.voidgoTo(KMLAbstractView view)Animates theViewattached to this controller's WorldWindow to look at the specified KMLview.protected abstract voidgoTo(KMLCamera camera)Animate the view to the position described by a KMLCamera.protected abstract voidgoTo(KMLLookAt lookAt)Animate the view to the position described by a KMLLookAt.protected voidgoToDefaultGroundOverlayView(KMLGroundOverlay overlay)Go to a default view of GroundOverlay.protected voidgoToDefaultPlacemarkView(KMLPlacemark placemark)Go to a default view of a Placemark.voidgoToDefaultView(KMLAbstractFeature feature)Move the view to look at a KML feature.protected voidgoToDefaultView(java.util.List<? extends Position> positions)Go to a view of a list of positions.voidsetViewAltitude(double viewAltitude)Set the default altitude for viewing a KML placemark when the globe flies to a placemark.
-
-
-
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 theWorldWindow's currentView. Accepted view types are as follows: . If theViewis not one of the recognized types, this returnsnulland logs a warning.- Parameters:
wwd- theWorldWindowto create a view controller for.- Returns:
- A new view controller, or
nullif theWorldWindow'sViewtype is not one of the recognized types.
-
goTo
public void goTo(KMLAbstractFeature feature)
Animate the view to look at a KML feature. If the feature defines aLookAtorCamera, 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 theViewattached to this controller's WorldWindow to look at the specified KMLview. Theviewmay be one of the following types: If theviewis notnulland is not one of the recognized types, this logs a warning but otherwise does nothing.- Parameters:
view- the KML view to animate to.- Throws:
java.lang.IllegalArgumentException- ifviewisnull.
-
goTo
protected abstract void goTo(KMLLookAt lookAt)
Animate the view to the position described by a KMLLookAt.- Parameters:
lookAt- KML LookAt that describes the desired view.
-
goTo
protected abstract void goTo(KMLCamera camera)
Animate the view to the position described by a KMLCamera.- Parameters:
camera- KML Camera that describes the desired view.
-
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.
-
goToDefaultPlacemarkView
protected void goToDefaultPlacemarkView(KMLPlacemark placemark)
Go to a default view of a Placemark.- Parameters:
placemark- Placemark to look at
-
goToDefaultGroundOverlayView
protected void goToDefaultGroundOverlayView(KMLGroundOverlay overlay)
Go to a default view of GroundOverlay.- Parameters:
overlay- Overlay to look at
-
goToDefaultView
protected void goToDefaultView(java.util.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
-
findMaxAltitude
protected double findMaxAltitude(java.util.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_VALUEifpositionsis 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.
-
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.
-
-