vmm.planecurve.parametric
Class NormalBundleDecoration

java.lang.Object
  extended by vmm.core.Decoration
      extended by vmm.planecurve.parametric.NormalBundleDecoration

public class NormalBundleDecoration
extends Decoration

A decoration that computes normal lines to points on a ParametricPlaneCurve and that can also show osculating circles, the evolute of the curve, and one or two parallel curves. (The points are those that are in the point array that defines the curve.) Either unit normals or normals whose length is given by the radius of curvature can be shown, and they can be shown at any number of points, including zero; this allows a partial normal bundle to be shown, so that the bundle can be built up gradually on the screen by adding one vector at a time. The decoration can also show several features that are computed based on the normal bundle: the evolute of the curve, an osculating circle at one point, and parallel curves.


Field Summary
 
Fields inherited from class vmm.core.Decoration
decorationNeedsRedraw
 
Constructor Summary
NormalBundleDecoration()
          Creates a normal bundle with no associated curve.
NormalBundleDecoration(PlaneCurveParametric curve)
          Create a decoration that can be used on a specified curve.
 
Method Summary
 void computeDrawData(View view, boolean exhibitNeedsRedraw, Transform previousLimits, Transform newLimits)
          Computes the normal vectors that are needed for drawing the array.
 void doDraw(java.awt.Graphics2D g, View view, Transform limits)
          This method is called by the render method of the Exhbit class to draw the Decoration.
 PlaneCurveParametric getCurve()
          Returns the curve pn which the decoration is shown.
 java.awt.Color getEvoluteColor()
          Returns the color used for drawing the evolute.
 java.awt.Color getNormalsColor()
          Retruns the color used for drawing normal vectors.
 java.awt.Color getOsculatingCircleColor()
          Retruns the color used for drawing the osculating circle.
 int getOsculatingCircleIndex()
          Tells the index of the point where an osculatting circle is drawn.
 java.awt.Color getParallelCurveColor()
          Returns the color used for drawing the (first) parallel curve.
 java.awt.Color getParallelCurveColor2()
          Returns the color used for drawing the second parallel curve.
 double getParallelCurveOffset()
          Tells the distance between the curve and any parallel curves that are drawn.
 int getPointCount()
          Gets the number of points on which normals appear.
 boolean getShowEvolute()
          Tells whether the evolute is curve is drawn.
 boolean getShowTwoParallelCurves()
          Tells whether two parallel curves are drawn, or just one.
 java.awt.geom.Line2D[] getUnitNormals()
          Gets an array containing unit normals for all points on the curve.
 boolean getUseUnitNormals()
          Tells whether unit normals are drawn, or normals of length equal to the radius of the osculatting circle.
 void setCurve(PlaneCurveParametric c)
          Set the curve on which this decoration is shown.
 void setEvoluteColor(java.awt.Color color)
          Set the color used for the evolute; the default is a medium dark green.
 void setNormalsColor(java.awt.Color color)
          Set the color used for the normal lines; the default is red.
 void setOsculatingCircleColor(java.awt.Color color)
          Set the color used for the osculating circle; the default is blue.
 void setOsculatingCircleIndex(int i)
          Set the index of the point on the curve where an osculating circle is to be shown.
 void setOsculatingCircleIndex(int i, boolean showEvoluteSoFar)
          Set the index of the point on the curve where an osculating circle is to be shown.
 void setParallelCurveColor(java.awt.Color color)
          Set the color used for the parallel curve; the default is a dark-ish cyan.
 void setParallelCurveColor2(java.awt.Color color)
          Set the color used for the second parallel curve, if there is one; the default is a light red.
 void setParallelCurveOffset(double offset)
          If the parallelCurveOffset is set to Double.NaN, then no parallel curve is drawn; this is the default.
 void setPointCount(int pointCt)
          Sets the number of points on the curve at which normals appear.
 void setShowEvolute(boolean show)
          If set to true, then the evolute curve will be drawn.
 void setShowTwoParallelCurves(boolean show)
          If set to true, two parallel curves are drawn whenever the parallelCurveOffset property is set to a real number.
 void setUseUnitNormals(boolean useUnitNormals)
          Set whether unit normals are drawn.
 
Methods inherited from class vmm.core.Decoration
addChangeListener, addExtraXML, fireDecorationChangeEvent, forceRedraw, getLayer, readExtraXML, removeChangeListener, setLayer
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NormalBundleDecoration

public NormalBundleDecoration()
Creates a normal bundle with no associated curve. The curve can be set later with setCurve(PlaneCurveParametric). This constructor exists mostly because it is required when the decoration is saved to an XML file.


NormalBundleDecoration

public NormalBundleDecoration(PlaneCurveParametric curve)
Create a decoration that can be used on a specified curve. By default, nothing is actually visible. Use the methods setShowEvolute(), setPointCount(), and setOsculatingCircleIndex() to make various things visible.

Parameters:
curve - The curve object to which the decoration applies. (A null value is OK but is unusual.)
Method Detail

getCurve

public PlaneCurveParametric getCurve()
Returns the curve pn which the decoration is shown.


setCurve

public void setCurve(PlaneCurveParametric c)
Set the curve on which this decoration is shown. (Usually, the curve is set in the constructor, and if it is not, it will be set implicitely when computeDrawData is called.)


setPointCount

public void setPointCount(int pointCt)
Sets the number of points on the curve at which normals appear. If the specified number of points is less than zero, it is treated as zero. In the specified number is greater than the number of points on the curve (that is, greater than 1+curve.getTResolution()), it is not considered an error, and all normals are drawn. Thus, setting the number of points to a very large value will ensure that all normals are drawn.


getPointCount

public int getPointCount()
Gets the number of points on which normals appear.

See Also:
setPointCount(int)

getShowEvolute

public boolean getShowEvolute()
Tells whether the evolute is curve is drawn.

See Also:
setShowEvolute(boolean)

setShowEvolute

public void setShowEvolute(boolean show)
If set to true, then the evolute curve will be drawn. This is the curve through the centers of the osculating circles. By default, it is not shown.


getParallelCurveOffset

public double getParallelCurveOffset()
Tells the distance between the curve and any parallel curves that are drawn. The default value, Double.NaN, indicates that the parallel curves are not drawn.

See Also:
setParallelCurveOffset(double)

setParallelCurveOffset

public void setParallelCurveOffset(double offset)
If the parallelCurveOffset is set to Double.NaN, then no parallel curve is drawn; this is the default. Otherwise, a parallel curve is drawn that connects the endpoints of normal lines of length given by the offsets. If in addition the value of showTwoParallelCurves is true, then a second parallel curve is drawn with the negative of the specified offset.

See Also:
setShowTwoParallelCurves(boolean)

getNormalsColor

public java.awt.Color getNormalsColor()
Retruns the color used for drawing normal vectors.

See Also:
setNormalsColor(Color)

setNormalsColor

public void setNormalsColor(java.awt.Color color)
Set the color used for the normal lines; the default is red.

Parameters:
color - The color to be used. If this is null, the default (red) is used.

getEvoluteColor

public java.awt.Color getEvoluteColor()
Returns the color used for drawing the evolute.

See Also:
setEvoluteColor(Color)

setEvoluteColor

public void setEvoluteColor(java.awt.Color color)
Set the color used for the evolute; the default is a medium dark green.

Parameters:
color - The color to be used. If this is null, the default is used.

getOsculatingCircleColor

public java.awt.Color getOsculatingCircleColor()
Retruns the color used for drawing the osculating circle.

See Also:
setOsculatingCircleColor(Color)

setOsculatingCircleColor

public void setOsculatingCircleColor(java.awt.Color color)
Set the color used for the osculating circle; the default is blue.

Parameters:
color - The color to be used. If this is null, the default (blue) is used.

getParallelCurveColor

public java.awt.Color getParallelCurveColor()
Returns the color used for drawing the (first) parallel curve.

See Also:
setParallelCurveColor(Color)

setParallelCurveColor

public void setParallelCurveColor(java.awt.Color color)
Set the color used for the parallel curve; the default is a dark-ish cyan.

Parameters:
color - The color to be used. If this is null, the default is used.

getParallelCurveColor2

public java.awt.Color getParallelCurveColor2()
Returns the color used for drawing the second parallel curve.

See Also:
setParallelCurveColor2(Color)

setParallelCurveColor2

public void setParallelCurveColor2(java.awt.Color color)
Set the color used for the second parallel curve, if there is one; the default is a light red.

Parameters:
color - The color to be used. If this is null, the default is used.
See Also:
setShowTwoParallelCurves(boolean)

getShowTwoParallelCurves

public boolean getShowTwoParallelCurves()
Tells whether two parallel curves are drawn, or just one.

See Also:
setShowTwoParallelCurves(boolean)

setShowTwoParallelCurves

public void setShowTwoParallelCurves(boolean show)
If set to true, two parallel curves are drawn whenever the parallelCurveOffset property is set to a real number. The offset for the second curve is the negative of the value of parallelCurveOffset. The default value is true.

See Also:
setParallelCurveOffset(double)

getUseUnitNormals

public boolean getUseUnitNormals()
Tells whether unit normals are drawn, or normals of length equal to the radius of the osculatting circle.

See Also:
setUseUnitNormals(boolean)

getOsculatingCircleIndex

public int getOsculatingCircleIndex()
Tells the index of the point where an osculatting circle is drawn.

See Also:
setOsculatingCircleIndex(int)

setOsculatingCircleIndex

public void setOsculatingCircleIndex(int i)
Set the index of the point on the curve where an osculating circle is to be shown. If the index is less than zero, no circle is shown; this is the default. Otherwise, the value is clamped to the range 0 to curve.getTResolution(), inclusive, and an osculating circle appears at the specified point on the curve. When an osculating circle is drawn, its radius is also drawn, and the evolute curve is also drawn.


setOsculatingCircleIndex

public void setOsculatingCircleIndex(int i,
                                     boolean showEvoluteSoFar)
Set the index of the point on the curve where an osculating circle is to be shown. If the index is less than zero, no circle is shown; this is the default. Otherwise, the value is clamped to the range 0 to curve.getTResolution(), inclusive, and an osculating circle appears at the specified point on the curve. When an osculating circle is drawn, its radius is also drawn. If showEvoluteSoFar is true, then the evolute curve is shown from the first point on the curve to the point specified for the osculating circle.


setUseUnitNormals

public void setUseUnitNormals(boolean useUnitNormals)
Set whether unit normals are drawn. The default is false, meaning that the length of a normal will be the radius of the osculating circle (except that it will be limited to a large maximum length).


getUnitNormals

public java.awt.geom.Line2D[] getUnitNormals()
Gets an array containing unit normals for all points on the curve. If this method is called before the decoration has been drawn, the return value will be null. An elemeent of the array can be null, if the curve or its derivative is undefined as the point.


computeDrawData

public void computeDrawData(View view,
                            boolean exhibitNeedsRedraw,
                            Transform previousLimits,
                            Transform newLimits)
Computes the normal vectors that are needed for drawing the array.

Overrides:
computeDrawData in class Decoration
Parameters:
view - The View that is drawing the Exhibit; this object contains other information that might be of use, such as the Display where the Exhibit is drawn and the the Exhibit that is being drawn.
exhibitNeedsRedraw - This parameter is set to "true" when the Exhibit changes. If it is true, then presumably the appearance of the Exhibit has changed, so any cached data for this decoration should probably be recomputed.
previousLimits - The Transform object that was used the last time the Exhibit was drawn. This can be null if the Exhibit is being drawn for the first time.
newLimits - The Transform object that is being used for this drawing of the Exhibit. Transform objects contain data about the window in the xy-plane where the Exhibit is being drawn and about the pixel coordinates on the drawing area. The two Transform objects are provided just in case any cached data depends on the xy-window or on the pixel coordinates.
See Also:
Exhibit.render(Graphics2D, View, Transform, ArrayList), Decoration.doDraw(Graphics2D, View, Transform)

doDraw

public void doDraw(java.awt.Graphics2D g,
                   View view,
                   Transform limits)
Description copied from class: Decoration
This method is called by the render method of the Exhbit class to draw the Decoration. The computeDrawData method is called by render before it calls this method, so any cached data should be valid by the time this method is called. (Note that subclasses of View and Exhibit are not necessarily required to follow this pattern.) The method in this class does nothing. Subclasses will ordinarily override this method to draw the Decoration.

Overrides:
doDraw in class Decoration
Parameters:
g - The graphics context where the Exhibit and its decorations are being drawn.
view - The View that is drawing the Exhibit; this object contains other information that might be of use, such as the Display, if any, associated with the View, and the the actual Exhibit that is being drawn.
limits - Contains information about the rectangular area in the xy-plane that is being drawn and about the rectangle of pixels in the graphics context where it is drawn. Note that at least for the top-level View class, transform.getX() and transform.getY() can be assumed to be zero.
See Also:
Exhibit.render(Graphics2D, View, Transform, ArrayList), Decoration.computeDrawData(View, boolean, Transform, Transform)