NASA World Wind

gov.nasa.worldwind
Class AbstractView

java.lang.Object
  extended by gov.nasa.worldwind.AVListImpl
      extended by gov.nasa.worldwind.WWObjectImpl
          extended by gov.nasa.worldwind.AbstractView
All Implemented Interfaces:
AVList, View, WWObject, PropertyChangeListener, EventListener
Direct Known Subclasses:
BasicOrbitView

public abstract class AbstractView
extends WWObjectImpl
implements View


Field Summary
 
Fields inherited from class gov.nasa.worldwind.AVListImpl
changeSupport
 
Constructor Summary
AbstractView()
           
 
Method Summary
 void apply(DrawContext dc)
          Calculates and applies View's internal state to the graphics context in DrawContext.
protected  void applyMatrixState(DrawContext dc, Matrix4 modelView, Matrix4 projection)
           
 double computeHorizonDistance()
          Returns the distance from the View's eye point to the horizon point on the last rendered Globe.
protected  double computeHorizonDistance(Globe globe, double verticalExaggeration, Point eyePoint)
           
 double computePixelSizeAtDistance(double distance)
          Computes the screen-aligned dimension (in meters) that a screen pixel would cover at a given distance (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).
protected abstract  void doApply(DrawContext dc)
           
 Point getEyePoint()
          Returns the eye position in model coordinates.
 Angle getFieldOfView()
          Returns the horizontal field-of-view angle (the angle of visibility) associated with this View, or null if the View implementation does not support a field-of-view.
 Point getForwardVector()
          Returns the View z-axis orientation in model coordinates.
 Frustum getFrustumInModelCoordinates()
          Returns the viewing Frustum transformed to model coordinates.
 Matrix4 getModelViewMatrix()
          Returns the 'model-view' matrix computed in apply(), which transforms model coordinates to eye coordinates (where the eye is located at the origin, facing down the negative-z axis).
 Matrix4 getProjectionMatrix()
          Returns the 'projection' matrix computed in apply(), which transforms eye coordinates to homogeneous clip coordinates (a box of dimension (2, 2, 2) centered at the origin).
 Point getUpVector()
          Returns the View y-axis orientation in model coordinates.
 Rectangle getViewport()
          Returns a Rectangle representing the window bounds (x, y, width, height) of the viewport, computed in apply().
 void popReferenceCenter(DrawContext dc)
          Removes the model-view matrix on top of the matrix stack, and restores the matrix now on top.
 Point project(Point modelPoint)
          Maps a Point in model (cartesian) coordinates to a Point in screen coordinates.
 void pushReferenceCenter(DrawContext dc, Point referenceCenter)
          Generates a new coordinate system in which the View does not move, and model coordinates are reverse transformed into eye coordinates.
 void setFieldOfView(Angle newFov)
          Sets the horiziontal field-of-view angle (the angle of visibillity) associated with this View.
 Point unProject(Point windowPoint)
          Maps a Point in screen coordinates to a Point in model coordinates.
protected  void validateDrawContext(DrawContext dc)
           
 
Methods inherited from class gov.nasa.worldwind.AVListImpl
addPropertyChangeListener, addPropertyChangeListener, copy, firePropertyChange, firePropertyChange, getStringValue, getValue, hasKey, propertyChange, removeKey, removePropertyChangeListener, removePropertyChangeListener, setValue
 
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
getAltitude, getFrustum, getHeading, getPitch, getPitchConstraints, getPosition, getRoll, getZoom, getZoomConstraints, goToAltitude, goToCoordinate, goToLatLon, isEnablePitchConstraints, isEnableZoomConstraints, setEnablePitchConstraints, setEnableZoomConstraints, setHeading, setPitch, setPitchConstraints, setRoll, setZoom, setZoomConstraints
 
Methods inherited from interface gov.nasa.worldwind.AVList
addPropertyChangeListener, addPropertyChangeListener, copy, firePropertyChange, firePropertyChange, getStringValue, getValue, hasKey, removeKey, removePropertyChangeListener, removePropertyChangeListener, setValue
 
Methods inherited from interface java.beans.PropertyChangeListener
propertyChange
 

Constructor Detail

AbstractView

public AbstractView()
Method Detail

apply

public void apply(DrawContext dc)
Description copied from interface: View
Calculates and applies View's internal state to the graphics context in DrawContext. 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 model-view matrix and Frustum.

Specified by:
apply in interface View
Parameters:
dc - the current World Wind drawing context on which View's state will apply.

applyMatrixState

protected void applyMatrixState(DrawContext dc,
                                Matrix4 modelView,
                                Matrix4 projection)

computeHorizonDistance

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

Specified by:
computeHorizonDistance in interface View
Returns:
the distance from the eye point to the horizon (in meters).

computeHorizonDistance

protected double computeHorizonDistance(Globe globe,
                                        double verticalExaggeration,
                                        Point eyePoint)

computePixelSizeAtDistance

public double computePixelSizeAtDistance(double distance)
Description copied from interface: View
Computes the screen-aligned dimension (in meters) that a screen pixel would cover at a given distance (also in meters). This computation assumes that pixels dimensions are square, and therefore returns a single dimension.

Specified by:
computePixelSizeAtDistance in interface View
Parameters:
distance - the distance from the eye point, in eye coordinates, along the z-axis. 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
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
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.

doApply

protected abstract void doApply(DrawContext dc)

getEyePoint

public Point getEyePoint()
Description copied from interface: View
Returns the eye position in model coordinates.

Specified by:
getEyePoint in interface View
Returns:
the eye position in model coordinates.

getFieldOfView

public Angle getFieldOfView()
Description copied from interface: View
Returns the horizontal field-of-view angle (the angle of visibility) associated with this View, or null if the View implementation does not support a field-of-view.

Specified by:
getFieldOfView in interface View
Returns:
horizontal field-of-view angle, or null if none exists.

getForwardVector

public Point getForwardVector()
Description copied from interface: View
Returns the View z-axis orientation in model coordinates.

Specified by:
getForwardVector in interface View
Returns:
the z-axis vector in model coordinates.

getFrustumInModelCoordinates

public Frustum getFrustumInModelCoordinates()
Description copied from interface: View
Returns the viewing Frustum transformed to model coordinates. Model coordinate frustums are useful for performing multiple intersection tests in model coordinates.

Specified by:
getFrustumInModelCoordinates in interface View
Returns:
the current viewing frustum in model coordinates.

getModelViewMatrix

public Matrix4 getModelViewMatrix()
Description copied from interface: View
Returns the 'model-view' matrix computed in apply(), which transforms model coordinates to eye coordinates (where the eye is located at the origin, facing down the negative-z axis). This matrix is constructed using the model space translation and orientation specific to each implementation of View.

Specified by:
getModelViewMatrix in interface View
Returns:
the current model-view matrix.

getProjectionMatrix

public Matrix4 getProjectionMatrix()
Description copied from interface: View
Returns the 'projection' matrix computed in apply(), which transforms eye coordinates to homogeneous clip coordinates (a box of dimension (2, 2, 2) centered at the origin). This matrix is constructed using the projection parameters specific to each implementation of View (e.g. field-of-view, clipping plane distances). The View.getFrustum() method returns the planes corresponding to this matrix.

Specified by:
getProjectionMatrix in interface View
Returns:
the current projection matrix.

getUpVector

public Point getUpVector()
Description copied from interface: View
Returns the View y-axis orientation in model coordinates.

Specified by:
getUpVector in interface View
Returns:
the y-axis vector in model coordinates.

getViewport

public Rectangle getViewport()
Description copied from interface: View
Returns a Rectangle representing the window bounds (x, y, width, height) of the viewport, computed in apply(). Implementations of View will configure themselves to render in this viewport.

Specified by:
getViewport in interface View
Returns:
the current window bounds of the viewport, or null if none exists.

popReferenceCenter

public void popReferenceCenter(DrawContext dc)
Description copied from interface: View
Removes the model-view matrix on top of the matrix stack, and restores the matrix now on top. This has the effect of immediately replacing the current OpenGL model-view matrix with the matrix below the top. When the stack size is one, therefore containing the original model-view matrix computed by apply(), this method will throw an exception.

Specified by:
popReferenceCenter in interface View
Parameters:
dc - the current World Wind drawing context on which View's state will apply.

project

public Point project(Point 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
Parameters:
modelPoint - the model coordinate Point to project.
Returns:
the mapped screen coordinate Point.

pushReferenceCenter

public void pushReferenceCenter(DrawContext dc,
                                Point referenceCenter)
Description copied from interface: View
Generates a new coordinate system in which the View does not move, and model coordinates are reverse transformed into eye coordinates. The origin for these coordinates will be referenceCenter, therefore all objects drawn after a call to pushReferenceCenter should be with respect to this Point, rather than the customary origin (0, 0, 0). This creates a new model-view matrix, which is placed on the top of a matrix stack, and immediately applied to the current OpenGL context. In order to return to the original coordinate space, callers should invoke View.popReferenceCenter(gov.nasa.worldwind.DrawContext) after rendering is complete. Note that calls to View.getModelViewMatrix() will not return reference-center model-view matrix, but the original matrix.

Specified by:
pushReferenceCenter in interface View
Parameters:
dc - the current World Wind drawing context on which View's state will apply.
referenceCenter - the Point to become the new model space origin.

setFieldOfView

public void setFieldOfView(Angle newFov)
Description copied from interface: View
Sets the horiziontal field-of-view angle (the angle of visibillity) associated with this View. This call may be ignored by implementations that do not support a field-of-view.

Specified by:
setFieldOfView in interface View
Parameters:
newFov - the new horizontal field-of-view angle.

unProject

public Point unProject(Point 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
Parameters:
windowPoint - the window coordinate Point to project.
Returns:
the mapped screen coordinate Point.

validateDrawContext

protected void validateDrawContext(DrawContext dc)

NASA World Wind