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.Object
Base class for controllers to animate the view to look at KML features. Each controller includes logic to animate to aLookAt
orCamera
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 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 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
Constructors Modifier Constructor Description protected
KMLViewController(WorldWindow wwd)
Create the view controller.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static KMLViewController
create(WorldWindow wwd)
Convenience method to create a new view controller appropriate for theWorldWindow
's currentView
.protected double
findMaxAltitude(java.util.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 theView
attached to this controller's WorldWindow to look at the specified KMLview
.protected abstract void
goTo(KMLCamera camera)
Animate the view to the position described by a KMLCamera
.protected abstract void
goTo(KMLLookAt lookAt)
Animate the view to the position described by a KMLLookAt
.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(java.util.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.
-
-
-
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 theView
is not one of the recognized types, this returnsnull
and logs a warning.- Parameters:
wwd
- theWorldWindow
to create a view controller for.- Returns:
- A new view controller, or
null
if theWorldWindow
'sView
type 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 aLookAt
orCamera
, 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 theView
attached to this controller's WorldWindow to look at the specified KMLview
. Theview
may be one of the following types: If theview
is notnull
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:
java.lang.IllegalArgumentException
- ifview
isnull
.
-
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_VALUE
ifpositions
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.
-
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.
-
-