package vgp.tutor.lsystem;
/**
* Generate a tree with a context-free L-system.
*
* @author Konrad Polthier
* @version 04.11.01, 2.50 revised (kp) Current state m_tree converted into char[] from string.
* 30.10.01, 2.00 revised (kp) Converted into a project.
* 16.02.00, 1.00 created (kp)
*/
public class LSystem {
/** Default set of available characters. */
protected char [] m_defAlphabet = {'F', '+', '-', '[', ']'};
/** Set of available characters. */
protected char [] m_alphabet;
/** Default initial configuration. */
protected String m_defAxiom = "F";
/** Initial configuration of L-system. */
protected String m_axiom;
/** Default production rule. */
protected String [] m_defRule = {"F[+F]F[-F]F", "+", "-", "[", "]"};
/**
* Production rule of each character of the alphabet. There
* must exist one rule per character.
*/
protected String [] m_rule;
/** Container to hold the current state of the L-system. */
protected String m_tree;
/** Constructor. */
public LSystem() {
if (getClass() == LSystem.class)
init();
}
public void init() {
m_alphabet = m_defAlphabet;
m_axiom = m_defAxiom;
int numLetters = m_defRule.length;
m_rule = new String[numLetters];
for (int i=0; i