vmm.fractals
Class RepeatedSegmentFractal

java.lang.Object
  extended by vmm.core.Exhibit
      extended by vmm.fractals.RepeatedSegmentFractal
All Implemented Interfaces:
java.util.EventListener, javax.swing.event.ChangeListener, Decorateable, Parameterizable
Direct Known Subclasses:
Dragon, Hilbert, Koch, KochEscher, Sierpinski

public abstract class RepeatedSegmentFractal
extends Exhibit

A fractal curve in which a level (N+1) approximation of the fractal is computed from a level N approximation by replacing each line segement with a scaled and transformed copy of the entire curve. Examples include Koch and Hilbert.


Nested Class Summary
 class RepeatedSegmentFractal.RSFView
          Defines the default View of an exhibit of type RepeatedSegmentFractal.
 
Field Summary
protected  int colorRepeatFactor
          Used in coloring the curve.
protected  int fastDrawRecursionLevel
          Used during "fast drawing", such as when the curve is being dragged.
protected  RealParamAnimateable fractality
          This parameter determines the fractal dimension of the curve.
protected  IntegerParam recursionLevel
          Determines the number of "levels" that are computed.
 
Fields inherited from class vmm.core.Exhibit
decorations, exhibitNeedsRedraw, isMorphing, morphingView, parameters, previousTransform
 
Constructor Summary
RepeatedSegmentFractal()
          Constructor sets a default color of BLACK and a default window of (-1,1,-1,1).
 
Method Summary
protected  void computeDrawData(View view, boolean exhibitNeedsRedraw, Transform previousTransform, Transform newTransform)
          Computes the data for the curve.
protected abstract  Complex[] computeNextLevel(Complex[] curvePoints, int computedLevel)
          This abstract method computes one approximation level from the previous one, which has already been computed.
protected  void doDraw(java.awt.Graphics2D g, View view, Transform transform)
          Draws the curve in continuous rainbow colors.
 Animation getCreateAnimation(View view)
          Returns a create animation that shows the curve at each approximation level from 1 up to the currently selected level of recursion.
 View getDefaultView()
          Returns a default view of type RSFView, where RSFView is a nested class inside this class.
 
Methods inherited from class vmm.core.Exhibit
addChangeListener, addDecoration, addExtraXML, addParameter, addView, clearDecorations, computeDrawDataHook, doDrawHook, fireExhibitChangeEvent, forceRedraw, getActionsForView, getAdditionalAnimationsForView, getAlternativeViews, getBuildAnimation, getDecorations, getDefaultBackground, getDefaultForeground, getDefaultTransform, 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

colorRepeatFactor

protected int colorRepeatFactor
Used in coloring the curve. The color spectrum is repeated this many times from one end of the curve to the next. Subclasses should set the value in their constructors. The default value, as set in this class, is 3.


fastDrawRecursionLevel

protected int fastDrawRecursionLevel
Used during "fast drawing", such as when the curve is being dragged. This is the maximum level of recursion that is used during fast drawing. Subclasses should set the value in their constructors. The default value, as set in this class, is 5.


fractality

protected RealParamAnimateable fractality
This parameter determines the fractal dimension of the curve. The default value is 1/3. The default limits for animation are 0.25 to 0.5. These are also set as the minimum and maximum allowed values for user input. (These values are suitable for the Koch curve; other subclasses should change them if necessary.)


recursionLevel

protected IntegerParam recursionLevel
Determines the number of "levels" that are computed. The process of replacing segments of the curve with copies of the curve is repeated this many times to produce an approximation of the true fractal curve. The default value is 6. The minimum and maximum allowed values for input are 1 and 10. These values should be changed by subclasses, if necessary.

Constructor Detail

RepeatedSegmentFractal

public RepeatedSegmentFractal()
Constructor sets a default color of BLACK and a default window of (-1,1,-1,1). It also adds "fractility" and "recursionLevel" parameters to the exhibit.

Method Detail

computeNextLevel

protected abstract Complex[] computeNextLevel(Complex[] curvePoints,
                                              int computedLevel)
This abstract method computes one approximation level from the previous one, which has already been computed. This abstract method must be defined in any concrete subclass.

Parameters:
curvePoints - This array stores the points that have been computed for the current approximation level. This array can be null, if the computedLevel is zero.
computedLevel - This is the approximation level that has been comptuted to get the points in curvePoints. A zero value for this paramter means that the first, or base level, approximation should be computed.
Returns:
An array containing the points in the next level approximation of the curve.

computeDrawData

protected void computeDrawData(View view,
                               boolean exhibitNeedsRedraw,
                               Transform previousTransform,
                               Transform newTransform)
Computes the data for the curve.

Overrides:
computeDrawData in class Exhibit
Parameters:
view - The View that is drawing the Exhibit.
exhibitNeedsRedraw - This parameter is set to "true" if the Exhibit's forceRedraw() method has been called since the last redraw. If it is true, then presumably the appearance of the Exhibit has changed, so any cached data should be recomputed.
previousTransform - 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.
newTransform - 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 in case any cached data depends on the xy-window or on the pixel coordinates. Note that the Transform might have changed even if exhibitNeedsRedraw is false.
See Also:
Exhibit.render(Graphics2D, View, Transform, ArrayList), Exhibit.forceRedraw(), Exhibit.doDraw(Graphics2D, View, Transform)

doDraw

protected void doDraw(java.awt.Graphics2D g,
                      View view,
                      Transform transform)
Draws the curve in continuous rainbow colors.

Overrides:
doDraw in class Exhibit
Parameters:
g - The graphics context where the Exhibit is being drawn. It has already been cleared to the background color (assuming that drawing is being done in the usual way, as defined in the top-level View class).
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.
transform - 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), Exhibit.computeDrawData(View, boolean, Transform, Transform)

getCreateAnimation

public Animation getCreateAnimation(View view)
Returns a create animation that shows the curve at each approximation level from 1 up to the currently selected level of recursion.

Overrides:
getCreateAnimation in class Exhibit
Parameters:
view - A View that is displaying this Exhibit. The animation, if any, that is returned by this method will be installed in the View's display. If the view is null, than a creation animation that can run independently of a view could be returned.
Returns:
A creation animation for the given View of this Exhibit. The return value can be null to indicate that no creation animation is to be run.

getDefaultView

public View getDefaultView()
Returns a default view of type RSFView, where RSFView is a nested class inside this class.

Overrides:
getDefaultView in class Exhibit