/*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
*
* - Neither the name of Oracle nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
* This source code is provided to illustrate the usage of a given feature
* or technique and has been deliberately simplified. Additional steps
* required for a production-quality application, such as security checks,
* input validation and proper error handling, might not be present in
* this sample code.
*/
/**
* A (not-yet) Context sensitive L-System Fractal applet class.
*
* The rules for the Context L-system are read from the java.applet.Applet's
* attributes and then the system is iteratively applied for the
* given number of levels, possibly drawing each generation as it
* is generated. Note that the ContextLSystem class does not yet
* handle the lContext and rContext attributes, although this
* class is already designed to parse the '[' and ']' characters
* typically used in Context sensitive L-Systems.
*
* @author Jim Graham
*/
@SuppressWarnings("serial")
public class CLSFractal
implements Runnable, MouseListener {
boolean incrementalUpdates;
float Xmin;
float Xmax;
float Ymin;
float Ymax;
int border;
boolean normalizescaling;
public void init() {
String s;
cls = new ContextLSystem(this);
s = getParameter("level");
if (s != null) {
}
s = getParameter("incremental");
if (s != null) {
}
s = getParameter("delay");
if (s != null) {
}
s = getParameter("startAngle");
if (s != null) {
}
s = getParameter("rotAngle");
if (s != null) {
}
s = getParameter("border");
if (s != null) {
}
s = getParameter("normalizescale");
if (s != null) {
}
addMouseListener(this);
}
public void destroy() {
removeMouseListener(this);
}
public void run() {
boolean needsRepaint = false;
repaint();
try {
} catch (InterruptedException ignored) {
}
} else {
needsRepaint = true;
}
}
if (needsRepaint) {
repaint();
}
}
}
public void start() {
}
public void stop() {
}
/*1.1 event handling */
}
}
cls = new ContextLSystem(this);
start();
e.consume();
}
}
}
if (fractalPath == null) {
super.paint(g);
return;
}
}
for (int i = 0; i < border; i++) {
false);
}
render(g, fractalPath);
}
if (g == null) {
Xmin = 1E20f;
Ymin = 1E20f;
Xmax = -1E20f;
Ymax = -1E20f;
} else {
if (frwidth == 0) {
frwidth = 1;
}
if (frheight == 0) {
frheight = 1;
}
if (normalizescaling) {
}
}
}
case '+':
break;
case '-':
break;
case '[':
break;
case ']':
break;
case 'f':
break;
case 'F':
if (g == null) {
} else {
}
break;
default:
break;
}
}
}
void includePt(float x, float y) {
if (x < Xmin) {
Xmin = x;
}
if (x > Xmax) {
Xmax = x;
}
if (y < Ymin) {
Ymin = y;
}
if (y > Ymax) {
Ymax = y;
}
}
return "Title: CLSFractal 1.1f, 27 Mar 1995 \nAuthor: Jim Graham \nA "
+ "(not yet) Context Sensitive L-System production rule. \n"
+ "This class encapsulates a production rule for a Context "
+ "Sensitive\n L-System \n(pred, succ, lContext, rContext)."
+ " The matches() method, however, does not \n(yet) verify "
+ "the lContext and rContext parts of the rule.";
}
{ "level", "int", "Maximum number of recursions. Default is 1." },
{ "incremental", "boolean", "Whether or not to repaint between "
+ "recursions. Default is true." },
{ "delay", "integer", "Sets delay between repaints. Default is 50." },
{ "startAngle", "float", "Sets the starting angle. Default is 0." },
{ "rotAngle", "float", "Sets the rotation angle. Default is 45." },
{ "border", "integer", "Width of border. Default is 2." },
{ "normalizeScale", "boolean", "Whether or not to normalize "
+ "the scaling. Default is true." },
{ "pred", "String",
"Initializes the rules for Context Sensitive L-Systems." },
{ "succ", "String",
"Initializes the rules for Context Sensitive L-Systems." },
{ "lContext", "String",
"Initializes the rules for Context Sensitive L-Systems." },
{ "rContext", "String",
"Initializes the rules for Context Sensitive L-Systems." }
};
return info;
}
}
/**
* A Logo turtle class designed to support Context sensitive L-Systems.
*
* This turtle performs a few basic maneuvers needed to support the
* set of characters used in Context sensitive L-Systems "+-fF[]".
*
* @author Jim Graham
*/
class CLSTurtle {
float angle;
float X;
float Y;
float scaleX;
float scaleY;
int xoff;
int yoff;
X = x * sx;
Y = y * sy;
}
X = turtle.X;
Y = turtle.Y;
}
}
public void jump() {
}
X = x;
Y = y;
}
}
/**
* A (non-)Context sensitive L-System class.
*
* This class initializes the rules for Context sensitive L-Systems
* (pred, succ, lContext, rContext) from the given java.applet.Applet's attributes.
* The generate() method, however, does not (yet) apply the lContext
* and rContext parts of the rules.
*
* @author Jim Graham
*/
class ContextLSystem {
int level;
int num = 1;
while (true) {
break;
}
num++;
}
level = 0;
}
public int getLevel() {
return level;
}
}
currentPath = path;
level++;
}
public void generate() {
int pos = 0;
pos++;
} else {
}
}
}
return rule;
}
}
return null;
}
}
/**
* A Context sensitive L-System production rule.
*
* This class encapsulates a production rule for a Context sensitive
* L-System (pred, succ, lContext, rContext).
* The matches() method, however, does not (yet) verify the lContext
* and rContext parts of the rule.
*
* @author Jim Graham
*/
class CLSRule {
pred = p;
succ = d;
lContext = l;
rContext = r;
}
return false;
}
}
}