Package gov.nasa.worldwind
Interface View
-
- All Superinterfaces:
AVList,java.util.EventListener,MessageListener,java.beans.PropertyChangeListener,Restorable,WWObject
- All Known Subinterfaces:
OrbitView
- All Known Implementing Classes:
BasicFlyView,BasicOrbitView,BasicView
public interface View extends WWObject, Restorable
TheViewinterface provides a coordinate transformation from model coordinates to eye coordinates. This follows the OpenGL convention of a right-handed coordinate system with the origin at the eye point and looking down the negative Z axis.Viewalso provides a transformation from eye coordinates to screen coordinates, following the OpenGL convention of an origin in the lower left hand screen corner.Most of the accessor and computation methods on
Viewwill use viewing state computed in the last call toapply.The following methods return state values updated in the most recent call to apply.
- getEyePosition
- getEyePoint
- getUpVector
- getForwardVector
- getModelviewMatrix
- getViewport
- getFrustum
- getFrustumInModelCoordinates
- getProjectionMatrix
The following methods return computed values using state that was updated in the most recent call to
apply.- project
- unproject
- computeRayFromScreenPoint
- computePositionFromScreenPoint
- computePixelSizeAtDistance
- computeHorizonDistance
- See Also:
OrbitView
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringVIEW_STOPPED
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidaddAnimator(Animator animator)Add an animator to theView.voidapply(DrawContext dc)Calculates and applies thisView'sinternal state to the graphics context in the specifieddc.doublecomputePixelSizeAtDistance(double distance)Computes the dimension (in meters) that a screen pixel would cover at a given distance from the eye point (also in meters).PositioncomputePositionFromScreenPoint(double x, double y)Computes the intersection of a line originating from the eye point and passing through (x, y) with theGlobe.LinecomputeRayFromScreenPoint(double x, double y)Computes a line, in model coordinates, originating from the eye point, and passing through the point contained by (x, y) on theView'sprojection plane (or after projection into model space).voidcopyViewState(View view)Copy the state of the givenView.Vec4getCenterPoint()Gets the center point of the view.Vec4getCurrentEyePoint()Returns the most up-to-date location of the eye in cartesian coordinates.PositiongetCurrentEyePosition()Returns the current geographic coordinates of this view's eye position, as determined from this view's current parameters.Vec4getEyePoint()Returns the location of the eye in cartesian coordinates.PositiongetEyePosition()Returns the current geographic coordinates of this view's eye position, as computed for the most recent model traversal.doublegetFarClipDistance()Returns the far clipping plane distance, in eye coordinates.AnglegetFieldOfView()Returns the horizontal field-of-view angle (the angle of visibility), or null if the implementation does not support a field-of-view.Vec4getForwardVector()Returns the forward axis in cartesian coordinates.FrustumgetFrustum()Returns the viewingFrustumin eye coordinates.FrustumgetFrustumInModelCoordinates()Returns the viewingFrustumin model coordinates.GlobegetGlobe()Gets the globe associated with this view.AnglegetHeading()Returns the view's current heading.doublegetHorizonDistance()Returns the horizon distance for this view's most recently used eye position.MatrixgetModelviewMatrix()Returns the modelview matrix.doublegetNearClipDistance()Returns the near clipping plane distance, in eye coordinates.AnglegetPitch()Returns the view's current pitch.MatrixgetProjectionMatrix()Gets the projection matrix.AnglegetRoll()Returns this View's current roll.Vec4getUpVector()Returns the up axis in cartesian coordinates.ViewInputHandlergetViewInputHandler()Gets theViewInputHandlerbeing used to map input events toViewcontrols.java.awt.RectanglegetViewport()Returns the bounds (x, y, width, height) of the viewport.ViewPropertyLimitsgetViewPropertyLimits()Get theViewPropertyLimitsfor this view.longgetViewStateID()Get an identifier for the current state of the modelview matrix.voidgoTo(Position position, double elevation)Animate to the specified position.booleanisAnimating()Determine if there are any animations active in theView.voidpopReferenceCenter(DrawContext dc)Removes the model-view matrix on top of the matrix stack, and restores the original matrix.Vec4project(Vec4 modelPoint)Maps aPointin model (cartesian) coordinates to aPointin screen coordinates.MatrixpushReferenceCenter(DrawContext dc, Vec4 referenceCenter)Defines and applies a new model-view matrix in which the world origin is located atreferenceCenter.voidsetEyePosition(Position eyePosition)Sets the geographic position of the eye.voidsetFieldOfView(Angle fieldOfView)Sets the horizontal field-of-view angle (the angle of visibility) to the specifiedfieldOfView.voidsetHeading(Angle heading)Sets the heading of the view.voidsetOrientation(Position eyePosition, Position centerPosition)Sets the location of the eye, and the center of the screen in geographic coordinates.voidsetPitch(Angle pitch)Sets the pitch of the view.MatrixsetReferenceCenter(DrawContext dc, Vec4 referenceCenter)Sets the reference center matrix without pushing the stack.voidsetRoll(Angle roll)Set the roll of the view.voidstopAnimations()Stops any animations that are active in thisViewvoidstopMovement()Stops any movement associated with thisView.Vec4unProject(Vec4 windowPoint)Maps aPointin screen coordinates to aPointin model coordinates.-
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 gov.nasa.worldwind.event.MessageListener
onMessage
-
Methods inherited from interface gov.nasa.worldwind.Restorable
getRestorableState, restoreState
-
-
-
-
Field Detail
-
VIEW_STOPPED
static final java.lang.String VIEW_STOPPED
- See Also:
- Constant Field Values
-
-
Method Detail
-
stopMovement
void stopMovement()
Stops any movement associated with thisView.
-
getEyePosition
Position getEyePosition()
Returns the current geographic coordinates of this view's eye position, as computed for the most recent model traversal.Note: The value returned is not necessarily the value specified to
setEyePosition(gov.nasa.worldwind.geom.Position)but is the eye position corresponding to this view's most recently applied state.- Returns:
- the position of the eye corresponding to the most recent application of this view, or null if the view has not yet been applied.
-
setEyePosition
void setEyePosition(Position eyePosition)
Sets the geographic position of the eye.- Parameters:
eyePosition- the eye position.- Throws:
java.lang.IllegalArgumentException- IfeyePositionis null.
-
getCurrentEyePosition
Position getCurrentEyePosition()
Returns the current geographic coordinates of this view's eye position, as determined from this view's current parameters.Note: The value returned is not necessarily the value specified to
setEyePosition(gov.nasa.worldwind.geom.Position)but is the eye position corresponding to this view's current parameters.- Returns:
- the position of the eye corresponding to the current parameters of this view.
-
setOrientation
void setOrientation(Position eyePosition, Position centerPosition)
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 chooses, so long as the eye is placed at the specifiedeyePosition, and the center of the screen is the specifiedcenterPosition. Specifically, implementations must determine what the up direction will be given these parameters, and apply these parameters in a meaningful way.- Parameters:
eyePosition- Position of they eye.centerPosition- Position of the screen center.
-
setHeading
void setHeading(Angle heading)
Sets the heading of the view. The implementation may interpret this command in whatever way it chooses.- Parameters:
heading- The direction to aim the view in degrees
-
setPitch
void setPitch(Angle pitch)
Sets the pitch of the view. The implementation may interpret pitch as it chooses- Parameters:
pitch- The pitch of the view.
-
getHeading
Angle getHeading()
Returns the view's current heading.- Returns:
- Angle of the view's heading.
-
getPitch
Angle getPitch()
Returns the view's current pitch.- Returns:
- Angle of the view's pitch.
-
getRoll
Angle getRoll()
Returns this View's current roll.- Returns:
- Angle of the view's roll.
-
setRoll
void setRoll(Angle roll)
Set the roll of the view. The implementation may interpret roll as it chooses.- Parameters:
roll- New roll. May not be null.
-
getEyePoint
Vec4 getEyePoint()
Returns the location of the eye in cartesian coordinates. This value is computed in the most recent call toapply.- Returns:
- Vec4 of the eye.
-
getCurrentEyePoint
Vec4 getCurrentEyePoint()
Returns the most up-to-date location of the eye in cartesian coordinates. UnlikegetEyePosition()andgetEyePoint(), getCurrentEyePoint will return the View's immediate position.- Returns:
- Vec4 of the eye.
-
getUpVector
Vec4 getUpVector()
Returns the up axis in cartesian coordinates. This value is computed in the most recent call toapply.- Returns:
- Vec4 of the up axis.
-
getForwardVector
Vec4 getForwardVector()
Returns the forward axis in cartesian coordinates. This value is computed in the most recent call toapply.- Returns:
- Vec4 of the forward axis.
-
getModelviewMatrix
Matrix getModelviewMatrix()
Returns the modelview matrix. The modelview matrix transforms model coordinates to eye coordinates. This matrix is constructed using the model space translation and orientation specific to each the implementation. This value is computed in the most recent call toapply.- Returns:
- the current model-view matrix.
-
getViewStateID
long getViewStateID()
Get an identifier for the current state of the modelview matrix. The modelview matrix transforms model coordinates to eye coordinates. This identifier can be used to determine if the view has changed state since a previous frame.- Returns:
- an identifier for the current modelview matrix state.
-
getFieldOfView
Angle getFieldOfView()
Returns the horizontal field-of-view angle (the angle of visibility), or null if the implementation does not support a field-of-view.- Returns:
- Angle of the horizontal field-of-view, or null if none exists.
-
setFieldOfView
void setFieldOfView(Angle fieldOfView)
Sets the horizontal field-of-view angle (the angle of visibility) to the specifiedfieldOfView. This may be ignored if the implementation that do not support a field-of-view.- Parameters:
fieldOfView- the horizontal field-of-view angle.- Throws:
java.lang.IllegalArgumentException- If the implementation supports field-of-view, andfieldOfViewis null.
-
getViewport
java.awt.Rectangle getViewport()
Returns the bounds (x, y, width, height) of the viewport. The implementation will configure itself to render in this viewport. This value is computed in the most recent call toapply.- Returns:
- the Rectangle of the viewport.
-
getNearClipDistance
double getNearClipDistance()
Returns the near clipping plane distance, in eye coordinates. Implementations of theViewinterface are not required to have a method for setting the near and far distance. Applications that need to control the near and far clipping distances can derive fromBasicOrbitVieworBasicFlyView- Returns:
- near clipping plane distance, in eye coordinates.
-
getFarClipDistance
double getFarClipDistance()
Returns the far clipping plane distance, in eye coordinates. Implementations of theViewinterface are not required to have a method for setting the near and far distance. Applications that need to control the near and far clipping distances can derive fromBasicOrbitVieworBasicFlyView- Returns:
- far clipping plane distance, in eye coordinates.
-
getFrustum
Frustum getFrustum()
Returns the viewingFrustumin eye coordinates. TheFrustumis the portion of viewable space defined by three sets of parallel 'clipping' planes. This value is computed in the most recent call toapply.- Returns:
- viewing Frustum in eye coordinates.
-
getFrustumInModelCoordinates
Frustum getFrustumInModelCoordinates()
Returns the viewingFrustumin model coordinates. Model coordinate frustums are useful for performing visibility tests against world geometry. This frustum has the same shape as the frustum returned ingetFrustum, but it has been transformed into model space. This value is computed in the most recent call toapply.- Returns:
- viewing Frustum in model coordinates.
-
getProjectionMatrix
Matrix getProjectionMatrix()
Gets the projection matrix. The projection matrix transforms eye coordinates to screen coordinates. This matrix is constructed using the projection parameters specific to each implementation ofView. The methodgetFrustum()returns the geometry corresponding to this matrix. This value is computed in the most recent call toapply.- Returns:
- the current projection matrix.
-
apply
void apply(DrawContext dc)
Calculates and applies thisView'sinternal state to the graphics context in the specifieddc. All subsequently rendered objects use this new state. Upon return, the OpenGL graphics context reflects the values of this view, as do any computed values of the view, such as the modelview matrix, projection matrix and viewing frustum.- Parameters:
dc- the current WorldWind DrawContext on whichViewwill apply its state.- Throws:
java.lang.IllegalArgumentException- Ifdcis null, or if theGlobeorGLinstances indcare null.
-
project
Vec4 project(Vec4 modelPoint)
Maps aPointin model (cartesian) coordinates to aPointin 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 successfully mapped, this will return null.- Parameters:
modelPoint- the model coordinatePointto project.- Returns:
- the mapped screen coordinate
Point. - Throws:
java.lang.IllegalArgumentException- ifmodelPointis null.
-
unProject
Vec4 unProject(Vec4 windowPoint)
Maps aPointin screen coordinates to aPointin 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 successfully mapped, this will return null.- Parameters:
windowPoint- the window coordinatePointto project.- Returns:
- the mapped screen coordinate
Point. - Throws:
java.lang.IllegalArgumentException- ifwindowPointis null.
-
pushReferenceCenter
Matrix pushReferenceCenter(DrawContext dc, Vec4 referenceCenter)
Defines and applies a new model-view matrix in which the world origin is located atreferenceCenter. Geometry rendered after a call topushReferenceCentershould be transformed with respect toreferenceCenter, rather than the canonical origin (0, 0, 0). Calls topushReferenceCentermust be followed bypopReferenceCenterafter rendering is complete. Note that calls togetModelviewMatrix()will not return reference-center model-view matrix, but the original matrix.- Parameters:
dc- the current WorldWind drawing context on which new model-view state will be applied.referenceCenter- the location to become the new world origin.- Returns:
- a new model-view matrix with origin is at
referenceCenter, or null if this method failed. - Throws:
java.lang.IllegalArgumentException- ifreferenceCenteris null, ifdcis null, or if theGlobeorGLinstances indcare null.
-
popReferenceCenter
void popReferenceCenter(DrawContext dc)
Removes the model-view matrix on top of the matrix stack, and restores the original matrix.- Parameters:
dc- the current WorldWind drawing context on which the original matrix will be restored.- Throws:
java.lang.IllegalArgumentException- ifdcis null, or if theGlobeorGLinstances indcare null.
-
setReferenceCenter
Matrix setReferenceCenter(DrawContext dc, Vec4 referenceCenter)
Sets the reference center matrix without pushing the stack.- Parameters:
dc- the drawing context.referenceCenter- the new reference center- Returns:
- a new model-view matrix with origin is at
referenceCenter, or null if this method failed. - Throws:
java.lang.IllegalArgumentException- ifreferenceCenteris null, ifdcis null, or if theGlobeorGLinstances indcare null.- See Also:
pushReferenceCenter(gov.nasa.worldwind.render.DrawContext, gov.nasa.worldwind.geom.Vec4)
-
computeRayFromScreenPoint
Line computeRayFromScreenPoint(double x, double y)
Computes a line, in model coordinates, originating from the eye point, and passing through the point contained by (x, y) on theView'sprojection plane (or after projection into model space).- Parameters:
x- the horizontal coordinate originating from the left side ofView'sprojection plane.y- the vertical coordinate originating from the top ofView'sprojection plane.- Returns:
- a line beginning at the
View'seye point and passing through (x, y) transformed into model space.
-
computePositionFromScreenPoint
Position computePositionFromScreenPoint(double x, double y)
Computes the intersection of a line originating from the eye point and passing through (x, y) with theGlobe. Only the ellipsoid itself is considered; terrain elevations are not incorporated.- Parameters:
x- the horizontal coordinate originating from the left side ofView'sprojection plane.y- the vertical coordinate originating from the top ofView'sprojection plane.- Returns:
- the point on the surface in polar coordinates.
-
computePixelSizeAtDistance
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). 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.- 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.
- Throws:
java.lang.IllegalArgumentException- ifdistanceis negative.
-
getCenterPoint
Vec4 getCenterPoint()
Gets the center point of the view.- Returns:
- the center point of the view if that point is on the globe, otherwise, return null
-
getGlobe
Globe getGlobe()
Gets the globe associated with this view. The Globe is updated at the beginning of each frame, duringView.apply().View.getGlobe()returns null if called before the first invocation ofView.apply().- Returns:
- the globe being rendered by this view, or null before the first invocation of
View.apply().
-
getViewInputHandler
ViewInputHandler getViewInputHandler()
Gets theViewInputHandlerbeing used to map input events toViewcontrols.- Returns:
- the
ViewInputHandlerbeing used to map input events toViewcontrols.
-
stopAnimations
void stopAnimations()
Stops any animations that are active in thisView
-
goTo
void goTo(Position position, double elevation)
Animate to the specified position. The implementation is expected to animate theViewto look at the given position from the given elevation.- Parameters:
position- The position to animate to.elevation- The elevation to look at thepositionfrom.
-
isAnimating
boolean isAnimating()
Determine if there are any animations active in theView.- Returns:
- true if there are active animations, false otherwise.
-
getViewPropertyLimits
ViewPropertyLimits getViewPropertyLimits()
Get theViewPropertyLimitsfor this view.- Returns:
- the
ViewPropertyLimitsfor this view.
-
copyViewState
void copyViewState(View view)
Copy the state of the givenView.- Parameters:
view- TheViewwhose state is to be copied.
-
addAnimator
void addAnimator(Animator animator)
Add an animator to theView. This method does not start theAnimator. Starting theAnimatoris the responsibility of the application.- Parameters:
animator- theAnimatorto be added
-
getHorizonDistance
double getHorizonDistance()
Returns the horizon distance for this view's most recently used eye position. The eye position changes when this view changes, so the horizon distance also changes when this view changes. The value returned is the value used during the most recent model traversal.- Returns:
- the horizon position, in meters, or 0 if this view has not yet been applied.
-
-