Class Framework.LSystem

java.lang.Object
  extended by Framework.Plane2D
      extended by Framework.LSystem
All Implemented Interfaces:
Framework.Drawable
Enclosing class:
Framework

public class Framework.LSystem
extends Framework.Plane2D
implements Framework.Drawable

This class is a solution to the 2010-2011 Lindenmayer System assignment found here.

Author:
Chris D'Arcy

Field Summary
 java.lang.String axiom
          the initiator (axiom) of the fractal
 java.lang.String definition
          Holds the characters defining the fractals as a sequence of drawing commands for the Turtle
 double delta
          The angle the heading of the turtle is modified by at each turn
 double distance
          The distance or length of each line segment(decreases with each generation).
 int factor
          the factor used to decrease the distance with each generation
 double heading
          The initial angle of the Turtle in degrees
 java.lang.String keys
          holds the characters for which productions exist
 int n
          The number of generations to propagate.
 java.lang.String name
          The name of this instance of the LSystem object
 java.lang.String[] productions
          The array of productions (generators) that replace their respective key in each generation
 double xPos
          The initial x position of the turtle
 double yPos
          The initial y position of the turtle
 
Fields inherited from interface Framework.Drawable
palette, random
 
Constructor Summary
Framework.LSystem(java.awt.Dimension appDimen, java.lang.String name, java.lang.String axiom, java.lang.String keys, java.lang.String[] productions, double heading, double distance, double delta, int thickness, int factor, int numSides, int n, double xPos, double yPos)
          Constructor for LSystem curve: one key
 
Method Summary
 void draw(java.awt.image.BufferedImage drawTo)
          Draws itself to the parameterized BufferedImage.
 boolean finished()
          Sets the status of the rendering to completed.
 java.lang.String generate(int n)
          Recursive method used to propagate the definition of the PFC
 java.awt.Color getBackgroundColor()
          Merely returns the background color for this Drawable.
 java.lang.String getDefinition()
          Accessor method to return the String definition of the fractal.
 double getDelta()
          Accessor method to return the angle the Turtle is to change with each turn.
 double getDistance()
          Accessor method to return the length of the line segment to be drawn.
 java.lang.String getName()
          Accessor method return the name of the Koch object.
 java.lang.String replaceEmAll(java.lang.String str)
          Applies multiple productions in the development of the next generation
 void setCompleted()
          Sets the status of the rendering to completed.
 void setMouseEvent(java.awt.event.MouseEvent e)
          Allows all implementers to react to mouse events passed from the content class.
 
Methods inherited from class Framework.Plane2D
scrX, scrY
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

name

public java.lang.String name
The name of this instance of the LSystem object


axiom

public java.lang.String axiom
the initiator (axiom) of the fractal


keys

public java.lang.String keys
holds the characters for which productions exist


definition

public java.lang.String definition
Holds the characters defining the fractals as a sequence of drawing commands for the Turtle


productions

public java.lang.String[] productions
The array of productions (generators) that replace their respective key in each generation


heading

public double heading
The initial angle of the Turtle in degrees


xPos

public double xPos
The initial x position of the turtle


yPos

public double yPos
The initial y position of the turtle


distance

public double distance
The distance or length of each line segment(decreases with each generation).


delta

public double delta
The angle the heading of the turtle is modified by at each turn


factor

public int factor
the factor used to decrease the distance with each generation


n

public int n
The number of generations to propagate.

Constructor Detail

Framework.LSystem

public Framework.LSystem(java.awt.Dimension appDimen,
                         java.lang.String name,
                         java.lang.String axiom,
                         java.lang.String keys,
                         java.lang.String[] productions,
                         double heading,
                         double distance,
                         double delta,
                         int thickness,
                         int factor,
                         int numSides,
                         int n,
                         double xPos,
                         double yPos)
Constructor for LSystem curve: one key

Parameters:
appDimen - the Dimension object defining the size of the applet
name - the name of the Koch curve
axiom - the initial (generation 0) curve (the initiator in Koch parlance)
keys - the String containing the keys. Koch curve only has one key but other L-Systems have multiple keys
productions - the array of productions. Koch curve only has one production but keep as an array of String for future development
heading - the initial heading of the drawing pen (turtle) in degrees. 0 degrees is east. Positive is Counterclockwise.
distance - the length of the line to draw in pixels when moving the turtle forward (the F command)
delta - the change in the turtle's heading when executing + or - command. + is counterclockwise and - is clockwise
thickness - the thickness of the line drawn by the pen
factor - the reduction ratio applied to distance after each generation
numSides - the number of sides in the production. This aids in the rendering animation.
n - the number of generations to propagate the curve
xPos - the initial x position (column) of the turtle
yPos - the initial y position (row) of the turtle
Method Detail

generate

public java.lang.String generate(int n)
Recursive method used to propagate the definition of the PFC

Parameters:
n - the generation number
Returns:
the L-System representation of the n'th generation of the PFC

replaceEmAll

public java.lang.String replaceEmAll(java.lang.String str)
Applies multiple productions in the development of the next generation

Parameters:
str - the current definition
Returns:
the subsequent generation

getBackgroundColor

public java.awt.Color getBackgroundColor()
Description copied from interface: Framework.Drawable
Merely returns the background color for this Drawable.

Specified by:
getBackgroundColor in interface Framework.Drawable
Returns:
the Color of the background for this Drawable.

draw

public void draw(java.awt.image.BufferedImage drawTo)
Description copied from interface: Framework.Drawable
Draws itself to the parameterized BufferedImage.

Specified by:
draw in interface Framework.Drawable
Parameters:
drawTo - a BufferedImage to draw to.

getName

public java.lang.String getName()
Accessor method return the name of the Koch object.

Returns:
the name of the Koch object

getDefinition

public java.lang.String getDefinition()
Accessor method to return the String definition of the fractal.

Returns:
the current String definition

getDelta

public double getDelta()
Accessor method to return the angle the Turtle is to change with each turn.

Returns:
the angle the Turtle is to change with each turn

getDistance

public double getDistance()
Accessor method to return the length of the line segment to be drawn.

Returns:
the length of the line segment to be drawn

setMouseEvent

public void setMouseEvent(java.awt.event.MouseEvent e)
Description copied from interface: Framework.Drawable
Allows all implementers to react to mouse events passed from the content class.

Specified by:
setMouseEvent in interface Framework.Drawable
Parameters:
e - The MouseEvent that the object is to respond to.

finished

public boolean finished()
Description copied from interface: Framework.Drawable
Sets the status of the rendering to completed. Called by Content's stopThread method to interrupt and terminate the rendering thread.

Specified by:
finished in interface Framework.Drawable

setCompleted

public void setCompleted()
Description copied from interface: Framework.Drawable
Sets the status of the rendering to completed. Called by Content's stopThread method to interrupt and terminate the rendering thread.

Specified by:
setCompleted in interface Framework.Drawable