NASA World Wind

gov.nasa.worldwind.view.orbit
Class BasicOrbitView

java.lang.Object
  extended by gov.nasa.worldwind.avlist.AVListImpl
      extended by gov.nasa.worldwind.WWObjectImpl
          extended by gov.nasa.worldwind.view.BasicView
              extended by gov.nasa.worldwind.view.orbit.BasicOrbitView
All Implemented Interfaces:
AVList, Restorable, View, OrbitView, WWObject, java.beans.PropertyChangeListener, java.util.EventListener
Direct Known Subclasses:
FlatOrbitView

public class BasicOrbitView
extends BasicView
implements OrbitView


Field Summary
protected  Position center
           
protected  OrbitViewCollisionSupport collisionSupport
           
protected  double zoom
           
 
Fields inherited from class gov.nasa.worldwind.view.BasicView
COLLISION_NUM_ITERATIONS, COLLISION_THRESHOLD, dc, detectCollisions, eyePosition, farClipDistance, fieldOfView, frustum, globe, hadCollisions, heading, lastEyePoint, lastEyePosition, lastForwardVector, lastFrustumInModelCoords, lastUpVector, MINIMUM_FAR_DISTANCE, MINIMUM_NEAR_DISTANCE, modelview, modelviewInv, nearClipDistance, pitch, projection, roll, viewInputHandler, viewLimits, viewport
 
Fields inherited from class gov.nasa.worldwind.avlist.AVListImpl
changeSupport
 
Fields inherited from interface gov.nasa.worldwind.view.orbit.OrbitView
CENTER_STOPPED
 
Fields inherited from interface gov.nasa.worldwind.View
VIEW_STOPPED
 
Constructor Summary
BasicOrbitView()
           
 
Method Summary
 void addCenterAnimator(Position begin, Position end, boolean smoothed)
           
 void addCenterAnimator(Position begin, Position end, long lengthMillis, boolean smoothed)
           
 void addEyePositionAnimator(long timeToIterate, Position beginPosition, Position endPosition)
           
 void addFlyToZoomAnimator(Angle heading, Angle pitch, double zoomAmount)
           
 void addHeadingAnimator(Angle begin, Angle end)
           
 void addHeadingPitchAnimator(Angle beginHeading, Angle endHeading, Angle beginPitch, Angle endPitch)
           
 void addPanToAnimator(Position centerPos, Angle heading, Angle pitch, double zoom)
           
 void addPanToAnimator(Position centerPos, Angle heading, Angle pitch, double zoom, boolean endCenterOnSurface)
           
 void addPanToAnimator(Position centerPos, Angle heading, Angle pitch, double zoom, long timeToMove, boolean endCenterOnSurface)
           
 void addPanToAnimator(Position beginCenterPos, Position endCenterPos, Angle beginHeading, Angle endHeading, Angle beginPitch, Angle endPitch, double beginZoom, double endZoom, boolean endCenterOnSurface)
           
 void addPanToAnimator(Position beginCenterPos, Position endCenterPos, Angle beginHeading, Angle endHeading, Angle beginPitch, Angle endPitch, double beginZoom, double endZoom, long timeToMove, boolean endCenterOnSurface)
           
 void addPitchAnimator(Angle begin, Angle end)
           
 void addZoomAnimator(double zoomStart, double zoomEnd)
           
protected  void afterDoApply()
           
 boolean canFocusOnTerrainCenter()
           
 boolean canFocusOnViewportCenter()
          Determines if the BasicOrbitView can be focused on the viewport center focusOnViewportCenter().
 void computeAndSetViewCenter()
          computes and sets the center of rotation for heading and pitch changes.
 void computeAndSetViewCenterIfNeeded()
          computes and sets the center of rotation for heading and pitch changes, if it is needed.
protected  Position computeEyePositionFromModelview()
           
 double computeHorizonDistance()
          Gets the distance from the View's eye point to the horizon point on the last rendered Globe.
protected  double computeHorizonDistance(Position eyePosition)
           
 double computePixelSizeAtDistance(double distance)
          Computes the dimension (in meters) that a screen pixel would cover at a given distance from the eye point (also in meters).
 Position computePositionFromScreenPoint(double x, double y)
          Computes the intersection of a line originating from the eye point (passing throught (x, y)) with the last rendered SectorGeometry, or the last analytical Globe if no rendered geometry exists.
 Line computeRayFromScreenPoint(double x, double y)
          Computes a line, in model coordinates, originating from the eye point, and passing throught the point contained by (x, y) on the View's projection plane (or after projection into model space).
 void copyViewState(View view)
          Copy the state of the given View.
protected  void doApply(DrawContext dc)
           
protected  void doGetRestorableState(RestorableSupport rs, RestorableSupport.StateObject context)
           
protected  void doRestoreState(RestorableSupport rs, RestorableSupport.StateObject context)
           
protected  void flagHadCollisions()
           
 void focusOnTerrainCenter()
           
 void focusOnViewportCenter()
          sets the point of rotation for heading and pitch changes to the surface position at the viewport center.
 Vec4 getCenterPoint()
          Gets the center point of the view.
 Position getCenterPosition()
          Get the center position of the OrbitView.
 Vec4 getCurrentEyePoint()
          Returns the most up-to-date location of the eye in cartesian coordinates.
 Position getCurrentEyePosition()
          Returns the most up-to-date location of the eye in geographic coordintes.
 Position getEyePosition()
          Returns the location of the eye in geographic coordinates.
 OrbitViewLimits getOrbitViewLimits()
          Returns the OrbitViewLimits that apply to this OrbitView.
 double getZoom()
          Get the zoom value for the OrbitView.
 void goTo(Position position, double distance)
          Animate to the specified position.
protected  void legacyRestoreState(RestorableSupport rs, RestorableSupport.StateObject context)
          Restores state values from previous versions of the BasicObitView state XML.
static Position normalizedCenterPosition(Position unnormalizedPosition)
           
static Angle normalizedHeading(Angle unnormalizedHeading)
           
static Angle normalizedPitch(Angle unnormalizedPitch)
           
 Vec4 project(Vec4 modelPoint)
          Maps a Point in model (cartesian) coordinates to a Point in screen coordinates.
protected  void resolveCollisionsWithPitch()
           
 void setCenterPosition(Position center)
          Sets the center position of the OrbitView.
 void setEyePosition(Position eyePosition)
          Sets the location of the eye in geographic coordinates.
 void setHeading(Angle heading)
          Sets the heading of the view.
protected  void setModelCoordinates(OrbitViewInputSupport.OrbitViewState modelCoords)
           
 void setOrbitViewLimits(OrbitViewLimits viewLimits)
          Sets the OrbitViewLimits that will apply to this OrbitView.
 void setOrientation(Position eyePosition, Position centerPosition)
          Sets the location of the eye, and the center of the screen in geographic coordinates.
 void setPitch(Angle pitch)
          Sets the pitch of the view.
 void setViewOutOfFocus(boolean b)
          Alerts the BasicOrbitView that the view requires the point of rotation for heading and pitch changes to be' recalculate.
 void setZoom(double zoom)
          Set the zoom value for the OrbitVeiw.
 void stopMovementOnCenter()
          Stop any changes to the center position.
 Vec4 unProject(Vec4 windowPoint)
          Maps a Point in screen coordinates to a Point in model coordinates.
protected  boolean validateModelCoordinates(OrbitViewInputSupport.OrbitViewState modelCoords)
           
 
Methods inherited from class gov.nasa.worldwind.view.BasicView
addAnimator, apply, computeFarClipDistance, computeFarDistance, computeNearClipDistance, computeNearDistance, getDC, getEyePoint, getFarClipDistance, getFieldOfView, getForwardVector, getFrustum, getFrustumInModelCoordinates, getGlobe, getHeading, getModelviewMatrix, getNearClipDistance, getPitch, getProjectionMatrix, getRestorableState, getUpVector, getViewInputHandler, getViewport, getViewPropertyLimits, hadCollisions, isAnimating, isDetectCollisions, loadGLViewState, popReferenceCenter, project, pushReferenceCenter, restoreState, setDetectCollisions, setFarClipDistance, setFieldOfView, setNearClipDistance, setViewInputHandler, setViewState, stopAnimations, stopMovement, unProject
 
Methods inherited from class gov.nasa.worldwind.WWObjectImpl
propertyChange
 
Methods inherited from class gov.nasa.worldwind.avlist.AVListImpl
addPropertyChangeListener, addPropertyChangeListener, clearList, copy, firePropertyChange, firePropertyChange, getDoubleValue, getDoubleValue, getEntries, getIntegerValue, getIntegerValue, getLongValue, getLongValue, getStringValue, getStringValue, getStringValue, getValue, getValues, hasKey, removeKey, removePropertyChangeListener, removePropertyChangeListener, setValue, setValues
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface gov.nasa.worldwind.view.orbit.OrbitView
hadCollisions, isDetectCollisions, setDetectCollisions
 
Methods inherited from interface gov.nasa.worldwind.View
addAnimator, apply, getEyePoint, getFarClipDistance, getFieldOfView, getForwardVector, getFrustum, getFrustumInModelCoordinates, getGlobe, getHeading, getModelviewMatrix, getNearClipDistance, getPitch, getProjectionMatrix, getUpVector, getViewInputHandler, getViewport, getViewPropertyLimits, isAnimating, popReferenceCenter, pushReferenceCenter, setFieldOfView, stopAnimations, stopMovement
 
Methods inherited from interface gov.nasa.worldwind.avlist.AVList
addPropertyChangeListener, addPropertyChangeListener, clearList, copy, firePropertyChange, firePropertyChange, getEntries, getStringValue, getValue, getValues, hasKey, removeKey, removePropertyChangeListener, removePropertyChangeListener, setValue, setValues
 
Methods inherited from interface java.beans.PropertyChangeListener
propertyChange
 
Methods inherited from interface gov.nasa.worldwind.Restorable
getRestorableState, restoreState
 

Field Detail

center

protected Position center

collisionSupport

protected final OrbitViewCollisionSupport collisionSupport

zoom

protected double zoom
Constructor Detail

BasicOrbitView

public BasicOrbitView()
Method Detail

addCenterAnimator

public void addCenterAnimator(Position begin,
                              Position end,
                              boolean smoothed)

addCenterAnimator

public void addCenterAnimator(Position begin,
                              Position end,
                              long lengthMillis,
                              boolean smoothed)

addEyePositionAnimator

public void addEyePositionAnimator(long timeToIterate,
                                   Position beginPosition,
                                   Position endPosition)

addFlyToZoomAnimator

public void addFlyToZoomAnimator(Angle heading,
                                 Angle pitch,
                                 double zoomAmount)

addHeadingAnimator

public void addHeadingAnimator(Angle begin,
                               Angle end)

addHeadingPitchAnimator

public void addHeadingPitchAnimator(Angle beginHeading,
                                    Angle endHeading,
                                    Angle beginPitch,
                                    Angle endPitch)

addPanToAnimator

public void addPanToAnimator(Position centerPos,
                             Angle heading,
                             Angle pitch,
                             double zoom)

addPanToAnimator

public void addPanToAnimator(Position centerPos,
                             Angle heading,
                             Angle pitch,
                             double zoom,
                             boolean endCenterOnSurface)

addPanToAnimator

public void addPanToAnimator(Position centerPos,
                             Angle heading,
                             Angle pitch,
                             double zoom,
                             long timeToMove,
                             boolean endCenterOnSurface)

addPanToAnimator

public void addPanToAnimator(Position beginCenterPos,
                             Position endCenterPos,
                             Angle beginHeading,
                             Angle endHeading,
                             Angle beginPitch,
                             Angle endPitch,
                             double beginZoom,
                             double endZoom,
                             boolean endCenterOnSurface)

addPanToAnimator

public void addPanToAnimator(Position beginCenterPos,
                             Position endCenterPos,
                             Angle beginHeading,
                             Angle endHeading,
                             Angle beginPitch,
                             Angle endPitch,
                             double beginZoom,
                             double endZoom,
                             long timeToMove,
                             boolean endCenterOnSurface)

addPitchAnimator

public void addPitchAnimator(Angle begin,
                             Angle end)

addZoomAnimator

public void addZoomAnimator(double zoomStart,
                            double zoomEnd)

afterDoApply

protected void afterDoApply()

canFocusOnTerrainCenter

public boolean canFocusOnTerrainCenter()

canFocusOnViewportCenter

public boolean canFocusOnViewportCenter()
Determines if the BasicOrbitView can be focused on the viewport center focusOnViewportCenter(). Focusing on the viewport center requires a non-null Globe, a non-null DrawContext, and the viewport center is on the terrain.

Specified by:
canFocusOnViewportCenter in interface OrbitView
Returns:
true if the BasicOrbitView can focus on the viewport center.

computeAndSetViewCenter

public void computeAndSetViewCenter()
computes and sets the center of rotation for heading and pitch changes.


computeAndSetViewCenterIfNeeded

public void computeAndSetViewCenterIfNeeded()
computes and sets the center of rotation for heading and pitch changes, if it is needed.


computeEyePositionFromModelview

protected Position computeEyePositionFromModelview()
Overrides:
computeEyePositionFromModelview in class BasicView

computeHorizonDistance

public double computeHorizonDistance()
Description copied from interface: View
Gets the distance from the View's eye point to the horizon point on the last rendered Globe.

Specified by:
computeHorizonDistance in interface View
Overrides:
computeHorizonDistance in class BasicView
Returns:
the distance from the eye point to the horizon.

computeHorizonDistance

protected double computeHorizonDistance(Position eyePosition)
Overrides:
computeHorizonDistance in class BasicView

computePixelSizeAtDistance

public double computePixelSizeAtDistance(double distance)
Description copied from interface: View
Computes the dimension (in meters) that a screen pixel would cover at a given distance from the eye point (also in meters). The distance is interpreted as the linear distance between the eye point and the world point in question. This computation assumes that pixels dimensions are square, and therefore returns a single dimension.

Specified by:
computePixelSizeAtDistance in interface View
Overrides:
computePixelSizeAtDistance in class BasicView
Parameters:
distance - the distance in meters from the eye point. This value must be positive but is otherwise unbounded.
Returns:
the dimension of a pixel in meters at the given distance.

computePositionFromScreenPoint

public Position computePositionFromScreenPoint(double x,
                                               double y)
Description copied from interface: View
Computes the intersection of a line originating from the eye point (passing throught (x, y)) with the last rendered SectorGeometry, or the last analytical Globe if no rendered geometry exists.

Specified by:
computePositionFromScreenPoint in interface View
Overrides:
computePositionFromScreenPoint in class BasicView
Parameters:
x - the horizontal coordinate originating from the left side of View's projection plane.
y - the vertical coordinate originating from the top of View's projection plane.
Returns:
the point on the surface in polar coordiantes.

computeRayFromScreenPoint

public Line computeRayFromScreenPoint(double x,
                                      double y)
Description copied from interface: View
Computes a line, in model coordinates, originating from the eye point, and passing throught the point contained by (x, y) on the View's projection plane (or after projection into model space).

Specified by:
computeRayFromScreenPoint in interface View
Overrides:
computeRayFromScreenPoint in class BasicView
Parameters:
x - the horizontal coordinate originating from the left side of View's projection plane.
y - the vertical coordinate originating from the top of View's projection plane.
Returns:
a line beginning at the View's eye point and passing throught (x, y) transformed into model space.

copyViewState

public void copyViewState(View view)
Description copied from interface: View
Copy the state of the given View.

Specified by:
copyViewState in interface View
Overrides:
copyViewState in class BasicView
Parameters:
view - The View whose state is to be copied.

doApply

protected void doApply(DrawContext dc)
Overrides:
doApply in class BasicView

doGetRestorableState

protected void doGetRestorableState(RestorableSupport rs,
                                    RestorableSupport.StateObject context)
Overrides:
doGetRestorableState in class BasicView

doRestoreState

protected void doRestoreState(RestorableSupport rs,
                              RestorableSupport.StateObject context)
Overrides:
doRestoreState in class BasicView

flagHadCollisions

protected void flagHadCollisions()

focusOnTerrainCenter

public void focusOnTerrainCenter()

focusOnViewportCenter

public void focusOnViewportCenter()
sets the point of rotation for heading and pitch changes to the surface position at the viewport center.

Specified by:
focusOnViewportCenter in interface OrbitView

getCenterPoint

public Vec4 getCenterPoint()
Description copied from interface: View
Gets the center point of the view.

Specified by:
getCenterPoint in interface View
Overrides:
getCenterPoint in class BasicView
Returns:
the center point of the view if that point is on the globe, otherwise, return null

getCenterPosition

public Position getCenterPosition()
Description copied from interface: OrbitView
Get the center position of the OrbitView. The center position is used as the point about which the heading and pitch rotate. It is defined by the intersection of a ray from the eye position through the center of the viewport with the surface of the globe.

Specified by:
getCenterPosition in interface OrbitView
Overrides:
getCenterPosition in class BasicView
Returns:
the center position.

getCurrentEyePoint

public Vec4 getCurrentEyePoint()
Description copied from interface: View
Returns the most up-to-date location of the eye in cartesian coordinates. Unlike View.getEyePosition() and View.getEyePoint(), getCurrentEyePoint will return the View's immediate position.

Specified by:
getCurrentEyePoint in interface View
Overrides:
getCurrentEyePoint in class BasicView
Returns:
Vec4 of the eye.

getCurrentEyePosition

public Position getCurrentEyePosition()
Description copied from interface: View
Returns the most up-to-date location of the eye in geographic coordintes. Unlike View.getEyePosition() and View.getEyePoint(), getCurrentEyePosition will return the View's immediate position.

Specified by:
getCurrentEyePosition in interface View
Overrides:
getCurrentEyePosition in class BasicView
Returns:
Position of the eye.

getEyePosition

public Position getEyePosition()
Description copied from interface: View
Returns the location of the eye in geographic coordinates. This value is computed in the most recent call to apply.

Specified by:
getEyePosition in interface View
Overrides:
getEyePosition in class BasicView
Returns:
Position of the eye.

getOrbitViewLimits

public OrbitViewLimits getOrbitViewLimits()
Returns the OrbitViewLimits that apply to this OrbitView. Incoming parameters to the methods setCenterPosition, setHeading, setPitch, or setZoom are be limited by the parameters defined in this OrbitViewLimits.

Specified by:
getOrbitViewLimits in interface OrbitView
Returns:
the OrbitViewLimits that apply to this OrbitView

getZoom

public double getZoom()
Description copied from interface: OrbitView
Get the zoom value for the OrbitView. The zoom value is the distance between the eye position and the center position.

Specified by:
getZoom in interface OrbitView
Returns:
the zoom value

goTo

public void goTo(Position position,
                 double distance)
Description copied from interface: View
Animate to the specified position. The implementation is expected to animate the View to look at the given position from the given elevation.

Specified by:
goTo in interface View
Overrides:
goTo in class BasicView
Parameters:
position - The position to animate to.
distance - The elevation to look at the position from.

legacyRestoreState

protected void legacyRestoreState(RestorableSupport rs,
                                  RestorableSupport.StateObject context)
Restores state values from previous versions of the BasicObitView state XML. These values are stored or named differently than the current implementation. Those values which have not changed are ignored here, and are restored in doRestoreState(gov.nasa.worldwind.util.RestorableSupport, gov.nasa.worldwind.util.RestorableSupport.StateObject).

Parameters:
rs - RestorableSupport object which contains the state value properties.
context - active context in the RestorableSupport to read state from.

normalizedCenterPosition

public static Position normalizedCenterPosition(Position unnormalizedPosition)

normalizedHeading

public static Angle normalizedHeading(Angle unnormalizedHeading)

normalizedPitch

public static Angle normalizedPitch(Angle unnormalizedPitch)

project

public Vec4 project(Vec4 modelPoint)
Description copied from interface: View
Maps a Point in model (cartesian) coordinates to a Point in screen coordinates. The returned x and y are relative to the lower left hand screen corner, while z is the screen depth-coordinate. If the model point cannot be sucessfully mapped, this will return null.

Specified by:
project in interface View
Overrides:
project in class BasicView
Parameters:
modelPoint - the model coordinate Point to project.
Returns:
the mapped screen coordinate Point.

resolveCollisionsWithPitch

protected void resolveCollisionsWithPitch()

setCenterPosition

public void setCenterPosition(Position center)
Description copied from interface: OrbitView
Sets the center position of the OrbitView. The center position is used as the point about which the heading and pitch rotate. It is defined by the intersection of a ray from the eye position through the center of the viewport with the surface of the globe.

Specified by:
setCenterPosition in interface OrbitView

setEyePosition

public void setEyePosition(Position eyePosition)
Description copied from interface: View
Sets the location of the eye in geographic coordinates. The implementation may interpret this command in whatever way it chooses, so long as the eye is placed at the specified eyePosition.

Specified by:
setEyePosition in interface View
Overrides:
setEyePosition in class BasicView
Parameters:
eyePosition - Position of the eye.

setHeading

public void setHeading(Angle heading)
Description copied from interface: View
Sets the heading of the view. The implementation may interpret this command in whatever way it chooses.

Specified by:
setHeading in interface View
Overrides:
setHeading in class BasicView
Parameters:
heading - The direction to aim the view in degrees

setModelCoordinates

protected void setModelCoordinates(OrbitViewInputSupport.OrbitViewState modelCoords)

setOrbitViewLimits

public void setOrbitViewLimits(OrbitViewLimits viewLimits)
Sets the OrbitViewLimits that will apply to this OrbitView. Incoming parameters to the methods setCenterPosition, setHeading, setPitch, or setZoom will be limited by the parameters defined in viewLimits.

Specified by:
setOrbitViewLimits in interface OrbitView
Parameters:
viewLimits - the OrbitViewLimits that will apply to this OrbitView.
Throws:
java.lang.IllegalArgumentException - if viewLimits is null.

setOrientation

public void setOrientation(Position eyePosition,
                           Position centerPosition)
Description copied from interface: View
Sets the location of the eye, and the center of the screen in geographic coordinates. The implementation may interpret this command in whatever way it choooses, so long as the eye is placed at the specified eyePosition, and the center of the screen is the specified centerPositoin. Specifically, implementations must determine what the up direction will be given these parameters, and apply these parameters in a meaningful way.

Specified by:
setOrientation in interface View
Overrides:
setOrientation in class BasicView
Parameters:
eyePosition - Position of they eye.
centerPosition - Position of the screen center.

setPitch

public void setPitch(Angle pitch)
Description copied from interface: View
Sets the pitch of the view. The implemenation may interepret pitch as it chooses

Specified by:
setPitch in interface View
Overrides:
setPitch in class BasicView
Parameters:
pitch - The pitch of the view.

setViewOutOfFocus

public void setViewOutOfFocus(boolean b)
Alerts the BasicOrbitView that the view requires the point of rotation for heading and pitch changes to be' recalculate.

Parameters:
b - true if the point of rotation needs recalculation, false if it does not.

setZoom

public void setZoom(double zoom)
Description copied from interface: OrbitView
Set the zoom value for the OrbitVeiw. The zoom value is the distance between the eye position and the center position.

Specified by:
setZoom in interface OrbitView

stopMovementOnCenter

public void stopMovementOnCenter()
Description copied from interface: OrbitView
Stop any changes to the center position.

Specified by:
stopMovementOnCenter in interface OrbitView

unProject

public Vec4 unProject(Vec4 windowPoint)
Description copied from interface: View
Maps a Point in screen coordinates to a Point in model coordinates. The input x and y are relative to the lower left hand screen corner, while z is the screen depth-coordinate. If the screen point cannot be sucessfully mapped, this will return null.

Specified by:
unProject in interface View
Overrides:
unProject in class BasicView
Parameters:
windowPoint - the window coordinate Point to project.
Returns:
the mapped screen coordinate Point.

validateModelCoordinates

protected boolean validateModelCoordinates(OrbitViewInputSupport.OrbitViewState modelCoords)

NASA World Wind