vmm.spacecurve
Class SpaceCurve

java.lang.Object
  extended by vmm.core.Exhibit
      extended by vmm.core3D.Exhibit3D
          extended by vmm.spacecurve.SpaceCurve
All Implemented Interfaces:
java.util.EventListener, javax.swing.event.ChangeListener, Decorateable, Parameterizable
Direct Known Subclasses:
SpaceCurveParametric

public abstract class SpaceCurve
extends Exhibit3D

Represents a curve, or set of curve segments, in three-space. The curve is defined by an array of 3D points.


Field Summary
protected  Vector3D[] points
          The array of 3D points that define the curve.
 
Fields inherited from class vmm.core3D.Exhibit3D
defaultViewpoint, defaultViewUp, previousTransform3D
 
Fields inherited from class vmm.core.Exhibit
decorations, exhibitNeedsRedraw, isMorphing, morphingView, parameters, previousTransform
 
Constructor Summary
SpaceCurve()
           
 
Method Summary
protected  void computeDrawData3D(View3D view, boolean exhibitNeedsRedraw, Transform3D previousTransform, Transform3D newTransform)
          Computes the array of points.
protected  void doDraw3D(java.awt.Graphics2D g, View3D view, Transform3D transform)
          Draws the curve.
 View getDefaultView()
          Returns a SpaceCurveView with antialiasing turned on.
 Vector3D getPoint(int i)
          Get one of the points from the array that defines the curve.
 int getPointCount()
          Get the size of the array of points that define this curve.
protected abstract  void makePoints()
          Subclasses must override this method to compute the array of points that define the curve.
 
Methods inherited from class vmm.core3D.Exhibit3D
computeDrawDataHook, doDrawHook, getDefaultTransform, getDefaultViewpoint, getDefaultViewUp, setDefaultViewpoint, setDefaultViewUp
 
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

points

protected Vector3D[] points
The array of 3D points that define the curve. This array must be computed in the makePoints(). method. The curve is formed by connecting the points in the array with line segments. Null values are allowed in the array. A null value effectively breaks the curve into two segments.

Constructor Detail

SpaceCurve

public SpaceCurve()
Method Detail

makePoints

protected abstract void makePoints()
Subclasses must override this method to compute the array of points that define the curve. The array must be assigned to the protected variable points.


getDefaultView

public View getDefaultView()
Returns a SpaceCurveView with antialiasing turned on.

Overrides:
getDefaultView in class Exhibit3D

getPointCount

public int getPointCount()
Get the size of the array of points that define this curve. If the array has not yet been computed, because the curve has not yet been drawn, then the return value will be 0.


getPoint

public Vector3D getPoint(int i)
Get one of the points from the array that defines the curve.

Parameters:
i - The index of the point in the array. This must be in the range 0 to getPointCount()-1, or an error will occur.
Returns:
The i-th point from the array. This can be null, indicating a break in the curve.

computeDrawData3D

protected void computeDrawData3D(View3D view,
                                 boolean exhibitNeedsRedraw,
                                 Transform3D previousTransform,
                                 Transform3D newTransform)
Computes the array of points. This is not meant to be called directlly.

Overrides:
computeDrawData3D in class Exhibit3D
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.
previousTransform - 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).
newTransform - 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 the curve. This is not meant to be called directly.

Overrides:
doDraw3D in class Exhibit3D
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.