vmm.core3D
Class Exhibit3D

java.lang.Object
  extended by vmm.core.Exhibit
      extended by vmm.core3D.Exhibit3D
All Implemented Interfaces:
java.util.EventListener, javax.swing.event.ChangeListener, Decorateable, Parameterizable
Direct Known Subclasses:
ConformalMap, IFS, LatticeModel, ODE_3D, SpaceCurve, Surface, SurfaceImplicit

public abstract class Exhibit3D
extends Exhibit

An exhibit that can be rendered in 3D can be defined as a subclass of this class. It is not an absolute requirement that a 3D exhibit be a subclass of this class, since an Exhibit is always in charge of rendering itself. However, this class does provide some convenient default behavior for 3D exhibits. Remember that it is possible for a single exhibit to have both 2D and 3D views.


Field Summary
protected  Vector3D defaultViewpoint
          The value of this variable is returned by the getDefaultViewpoint() method.
protected  Vector3D defaultViewUp
          The value of this variable is returned by the getDefaultViewUp() method.
protected  Transform3D previousTransform3D
          When the computeDrawDataHook(View, Transform) method is called with a 3D View and Transform, the Transform3D that is being used is recorded here so that it can be compared with the Transform3D that is used the next time the method is called.
 
Fields inherited from class vmm.core.Exhibit
decorations, exhibitNeedsRedraw, isMorphing, morphingView, parameters, previousTransform
 
Constructor Summary
Exhibit3D()
           
 
Method Summary
protected  void computeDrawData3D(View3D view, boolean exhibitNeedsRedraw, Transform3D previousTransform3D, Transform3D newTransform3D)
          Recopmputes cached data, if necessary, for a 3D rendering of this exhibit.
protected  void computeDrawDataHook(View view, Transform transform)
          Called by Exhibit.render(Graphics2D, View, Transform, ArrayList) to give the exhibit a chance to compute its cached data, if necessary.
protected  void doDraw3D(java.awt.Graphics2D g, View3D view, Transform3D transform)
          Draws this Exhibit in a 3D view.
protected  void doDrawHook(java.awt.Graphics2D g, View view, Transform transform)
          Called by Exhibit.doDraw(Graphics2D, View, Transform) when the exhibit needs to redraw itself.
 Transform getDefaultTransform(View view)
          Returns the default transform for use in the specified View.
 View getDefaultView()
          Returns the default View of this Exhibit.
 Vector3D getDefaultViewpoint()
          Returns the default viewpoint for viewing this Exhibit in 3D.
 Vector3D getDefaultViewUp()
          Returns the default view up for viewing this Exhibit in 3D.
 void setDefaultViewpoint(Vector3D defaultViewpoint)
          Set the default viewpoint for viewing this exhibit in 3D.
 void setDefaultViewUp(Vector3D defaultViewUp)
          Set the default view up vector for viewing this exhibit in 3D.
 
Methods inherited from class vmm.core.Exhibit
addChangeListener, addDecoration, addExtraXML, addParameter, addView, clearDecorations, computeDrawData, doDraw, fireExhibitChangeEvent, forceRedraw, getActionsForView, getAdditionalAnimationsForView, getAlternativeViews, getBuildAnimation, getCreateAnimation, getDecorations, getDefaultBackground, getDefaultForeground, getDefaultWindow, getFramesForMorphing, getMorphingAnimation, getName, getParameterByName, getParameters, getSettingsCommandsForView, getTitle, getUseFilmstripForMorphing, getViews, parameterChanged, readExtraXML, removeChangeListener, removeDecoration, removeParameter, removeView, render, setDefaultBackground, setDefaultForeground, setDefaultWindow, setDefaultWindow, setFramesForMorphing, setName, setUseFilmstripForMorphing, stateChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

previousTransform3D

protected Transform3D previousTransform3D
When the computeDrawDataHook(View, Transform) method is called with a 3D View and Transform, the Transform3D that is being used is recorded here so that it can be compared with the Transform3D that is used the next time the method is called. This is only for use in rare circumstances when am Exhibit has cached data that depends on the transform.


defaultViewpoint

protected Vector3D defaultViewpoint
The value of this variable is returned by the getDefaultViewpoint() method. When the Exhibit is installed in a View3D, this vector is used as the initial viewpoint for viewing the exhibit.


defaultViewUp

protected Vector3D defaultViewUp
The value of this variable is returned by the getDefaultViewUp() method. When the Exhibit is installed in a View3D, this vector is used as the initial view up vector. A null value indicates that the default should be used.

Constructor Detail

Exhibit3D

public Exhibit3D()
Method Detail

getDefaultTransform

public Transform getDefaultTransform(View view)
Returns the default transform for use in the specified View. If the View is an instance of the View3D class, then a Transform3D object is returned; this object is constructed from the exhibit's default viewpoint and default window. If the view is not a View3D, then a 2D Transform is returned that is constructed using the exhibit's default window only.

Overrides:
getDefaultTransform in class Exhibit
Parameters:
view - The View is provided as a parameter since there might be several types of View appropriate for a given exhibit, and they might require different Transforms. In particular, for example, a 3D View will require a 3D Transform.
Returns:
In this top-level Exhibit class, the Transform that is returned is a 2D Transform created by calling "new Transform(xmin,xmax,ymin,ymax)" where the values of xmin, xmax, ymin, and ymax are taken from the array returned by getDefaultWindow.
See Also:
setDefaultViewpoint(Vector3D), Exhibit.setDefaultWindow(double, double, double, double)

getDefaultView

public View getDefaultView()
Returns the default View of this Exhibit. In the Exhibit3D class, the return value is a basic View3D.

Overrides:
getDefaultView in class Exhibit

getDefaultViewpoint

public Vector3D getDefaultViewpoint()
Returns the default viewpoint for viewing this Exhibit in 3D.

See Also:
setDefaultViewpoint(Vector3D)

setDefaultViewpoint

public void setDefaultViewpoint(Vector3D defaultViewpoint)
Set the default viewpoint for viewing this exhibit in 3D. The default viewpoint is used to construct the default 3D view of this Exhibit in getDefaultTransform(View). Subclasses of Exhibit3D can call this method -- probably in a construtor -- to set a resonable viewpoint for the particular exhibit. If the default viewpoint is set to null, then the default of the Transform3D class is used; this default is the point (20,0,0).

Parameters:
defaultViewpoint - the default viewpoint for this Exhibit3D, or null to indicate that the default viewpoint in Transform3D is to be used.

getDefaultViewUp

public Vector3D getDefaultViewUp()
Returns the default view up for viewing this Exhibit in 3D.

See Also:
setDefaultViewUp(Vector3D)

setDefaultViewUp

public void setDefaultViewUp(Vector3D defaultViewUp)
Set the default view up vector for viewing this exhibit in 3D. The value of this vector is used to set the view up vector when the exhibit is installed. The initial value is null, which indicates that the default view up should be accepeted.

Parameters:
defaultViewUp - the default view up vector for this Exhibit3D, or null to indicate that the default view up should be accepted.

computeDrawDataHook

protected void computeDrawDataHook(View view,
                                   Transform transform)
Called by Exhibit.render(Graphics2D, View, Transform, ArrayList) to give the exhibit a chance to compute its cached data, if necessary. This method is not meant to be called directly. It exists only to make it possible to write a unified render method that will work for both the basic Exhibit class and for its subclasses. The method in this Exhibit3D class simply calls either Exhibit.computeDrawData(View, boolean, Transform, Transform) or computeDrawData3D(View3D, boolean, Transform3D, Transform3D), depending on whether the View is a 2D or 3D View.

Subclasses should almost always override computeDrawData and/or computeDrawData3D instead of overriding this method.

Overrides:
computeDrawDataHook in class Exhibit

doDrawHook

protected void doDrawHook(java.awt.Graphics2D g,
                          View view,
                          Transform transform)
Called by Exhibit.doDraw(Graphics2D, View, Transform) when the exhibit needs to redraw itself. This method is not meant to be called directly. It exists only to make it possible to write a unified doDraw method that will work for both the basic Exhibit class and for its subclasses. The method in this Exhibit3D class simply calls either Exhibit.doDraw(Graphics2D, View, Transform) or doDraw3D(Graphics2D, View3D, Transform3D), depending on whether the View is a 2D or 3D View.

Subclasses should almost always override doDraw and/or doDraw3D instead of overriding this method.

Overrides:
doDrawHook in class Exhibit

computeDrawData3D

protected void computeDrawData3D(View3D view,
                                 boolean exhibitNeedsRedraw,
                                 Transform3D previousTransform3D,
                                 Transform3D newTransform3D)
Recopmputes cached data, if necessary, for a 3D rendering of this exhibit. The method in the Exhibit3D class does nothing. Subclasses should override this method as appropriate. Note that this method is called only if the Exhibit is being rendered in a View3D. Exhibits that have both two and three dimensional renderings can also override Exhibit.computeDrawData(View, boolean, Transform, Transform) to say what should be drawn in a 2D view.

Parameters:
view - the 3D View where the Exhibit is about to be drawn.
exhibitNeedsRedraw - if true, then something about the Exhibit has changed that probably requires recomputation of cached data. For example, this is set to true when one of the Parameters of the Exhibit has changed since the previous redraw.
previousTransform3D - the Transform3D that was used the last time this exhibit was drawn. This can be null, if this is the first time that the Exhibit is being drawn (in 3D).
newTransform3D - the transform that will be used to draw the Exhibit during the current drawing operation. This parameter and the previousTransform3D parameter are provided so that the Exhbit can detect those rare cases where cached data exists that depends on the transform. Most Exhibits will just ignore the transform parameters.

doDraw3D

protected void doDraw3D(java.awt.Graphics2D g,
                        View3D view,
                        Transform3D transform)
Draws this Exhibit in a 3D view. The method in the Exhibit3D class does nothing. Subclasses should override this method to do the actual drawing. When this method is called, computeDrawData3D(View3D, boolean, Transform3D, Transform3D) has already been called, so that any cached data should be correct. Note that this method is called only if the Exhibit is being drawn in a View3D. Exhibits that have both two and three dimensional renderings should also override Exhibit.doDraw(Graphics2D, View, Transform).

When drawing a 3D exhibit, you are strongly advised to use the drawing routines supplied by the View3D and View3DLit classes. These routines will automatically produce the correct results in stereo views -- the same is not true about direct drawing to the graphics context.

Parameters:
g - the graphics context where the exhibit is being drawn.
view - The View3D in which the exhibit is being drawn. In general, it is advisable to use the view for all drawing operations.
transform - The transform that is being used to draw the exhibit.