Fractal
Class LSystem2Renderer

java.lang.Object
  extended by Fractal.LSystem2Renderer
Direct Known Subclasses:
LSystem2FDBoxCounting, PSLSystem2

public abstract class LSystem2Renderer
extends java.lang.Object

Base class for rendering an LSystem. Extend and override drawLine to render to a particular context, calling setDimension and render beforehand

Author:
eliott bartley

Constructor Summary
LSystem2Renderer(java.lang.String axiom, java.lang.String grammar, int depth, float angle)
          Create a new renderable LSystem
 
Method Summary
protected abstract  void drawLine(java.lang.Object user, int x, int y, int u, int v)
           
 java.lang.String getDerivedGrammar()
          Get the grammar expanded to the specified depth
 void render(java.lang.Object user)
          Render the LSystem, calls on drawLine to do actual drawing
 void setDimension(float width, float height)
          Set the width and hight to scale the render to.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LSystem2Renderer

public LSystem2Renderer(java.lang.String axiom,
                        java.lang.String grammar,
                        int depth,
                        float angle)
Create a new renderable LSystem

Parameters:
grammar - The grammar of the LSystem
depth - The recursive depth of the grammar
angle - The angle distance each turn should make, in degrees
Method Detail

setDimension

public void setDimension(float width,
                         float height)
Set the width and hight to scale the render to. All calls to drawLine will have (x u) and (y v) inside the range [0..width) and [0..height)

Parameters:
width -
height -

render

public void render(java.lang.Object user)
Render the LSystem, calls on drawLine to do actual drawing

Parameters:
user - User object that is passed to drawLine

drawLine

protected abstract void drawLine(java.lang.Object user,
                                 int x,
                                 int y,
                                 int u,
                                 int v)

getDerivedGrammar

public java.lang.String getDerivedGrammar()
Get the grammar expanded to the specified depth

Returns:
the grammar expanded to the specified depth