public abstract class View
extends java.lang.Object
A view draws its world on one or more view canvases. The simplest and typical scenario is that a view draws on only one canvas.
A view manages a world-to-view transform, which is that part of the OpenGL modelview transform that depends on the view. A view also manages the view-to-cube and cube-to-pixel transforms of each of its view canvases, as necessary.
All three transforms - world-to-view, view-to-cube, and cube-to-pixel - are view-dependent. Because the latter two transforms may vary among the multiple view canvases on which a view draws, those transforms are stored with each view canvas. Nevertheless, the view updates the view-to-cube and cube-to-pixel transforms for each view canvas on which it draws.
Some aspects of the world-to-view transform are common to all classes of views. These include an initial translation, scaling, and rotation of the world coordinate system. Typically, these initial transforms are followed by other view-specific transforms, but all classes of views provide at least these aspects.
Classes that extend this abstract base class must implement two methods:
updateTransforms(ViewCanvas)
and draw(ViewCanvas)
. The
method updateTransforms(ViewCanvas)
is called to update the
three view-dependent transforms for a specified view canvas. The method
draw(ViewCanvas)
is called to draw the view on a specified view
canvas.
Constructor and Description |
---|
View()
Constructs a view of no world.
|
View(World world)
Constructs a view of the specified world.
|
Modifier and Type | Method and Description |
---|---|
int |
countCanvases()
Returns the number of canvases on which this view draws.
|
protected abstract void |
draw(ViewCanvas canvas)
Draws this view on the specified canvas.
|
AxesOrientation |
getAxesOrientation() |
Tuple3 |
getAxesScale() |
java.util.Iterator<ViewCanvas> |
getCanvases()
Gets an iterator for the canvases on which this view draws.
|
World |
getWorld()
Gets the world drawn by in this view.
|
Matrix44 |
getWorldToView()
Gets the world-to-view transform managed by this view.
|
void |
repaint()
Repaints all canvases on which this view draws.
|
void |
setAxesOrientation(AxesOrientation axesOrientation) |
void |
setAxesScale(double sx,
double sy,
double sz) |
void |
setAxesScale(Tuple3 s) |
void |
setWorld(World world)
Sets the world drawn by this view.
|
void |
setWorldToView(Matrix44 worldToView)
Sets the world-to-view transform managed by this view.
|
void |
updateTransforms()
Updates transforms for this view and all canvases on which it draws.
|
protected abstract void |
updateTransforms(ViewCanvas canvas)
Updates the transforms for a canvas on which this view draws.
|
public View()
public View(World world)
world
- the world.public AxesOrientation getAxesOrientation()
public void setAxesOrientation(AxesOrientation axesOrientation)
public Tuple3 getAxesScale()
public void setAxesScale(Tuple3 s)
public void setAxesScale(double sx, double sy, double sz)
public void setWorld(World world)
world
- the world.public World getWorld()
public void setWorldToView(Matrix44 worldToView)
worldToView
- the world-to-view transform; copied, not referenced.public Matrix44 getWorldToView()
public int countCanvases()
public java.util.Iterator<ViewCanvas> getCanvases()
public void updateTransforms()
public void repaint()
protected abstract void updateTransforms(ViewCanvas canvas)
canvas
- the view canvas.protected abstract void draw(ViewCanvas canvas)
canvas
- the view canvas.