/* Generated By:JavaCC: Do not edit this line. SymbolShapeParser.java */
package org.jplot2d.javacc;
import java.awt.Shape;
import java.awt.geom.Arc2D;
import java.awt.geom.Ellipse2D;
import java.awt.geom.GeneralPath;
import java.awt.geom.Line2D;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import java.io.StringReader;
import java.util.ArrayList;
public class SymbolShapeParser implements SymbolShapeParserConstants {
private ArrayList _drawShapeList = new ArrayList();
private ArrayList _fillShapeList = new ArrayList();
public ArrayList getDrawShapeList() {
return _drawShapeList;
}
public ArrayList getFillShapeList() {
return _fillShapeList;
}
final public void parse(String s) throws ParseException {
ReInit(new StringReader(s));
_drawShapeList.clear();
_fillShapeList.clear();
jj_consume_token(6);
label_1:
while (true) {
shape();
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 8:
case 9:
case 10:
case 11:
case 12:
case 13:
case 14:
;
break;
default:
jj_la1[0] = jj_gen;
break label_1;
}
}
jj_consume_token(7);
jj_consume_token(0);
}
final private void shape() throws ParseException {
Shape shape;
boolean fill;
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 8:
jj_consume_token(8);
shape = shapeol();
fill=true;
break;
case 9:
case 10:
case 11:
case 12:
case 13:
case 14:
shape = shapeol();
fill=false;
break;
default:
jj_la1[1] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
if (fill) {
_fillShapeList.add(shape);
} else {
_drawShapeList.add(shape);
}
}
final private Shape shapeol() throws ParseException {
Shape shape;
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 9:
jj_consume_token(9);
shape = arc();
break;
case 10:
jj_consume_token(10);
shape = circle();
break;
case 11:
jj_consume_token(11);
shape = ellipse();
break;
case 12:
jj_consume_token(12);
shape = line();
break;
case 13:
jj_consume_token(13);
shape = rectangle();
break;
case 14:
jj_consume_token(14);
shape = polygon();
break;
default:
jj_la1[2] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
{if (true) return shape;}
throw new Error("Missing return statement in function");
}
final private Line2D line() throws ParseException {
Point2D a, b;
a = point();
b = point();
{if (true) return new Line2D.Double(a, b);}
throw new Error("Missing return statement in function");
}
final private Arc2D arc() throws ParseException {
int type = 0;
Rectangle2D.Double r;
double as, ae;
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 10:
case 14:
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 10:
jj_consume_token(10);
type = 1;
break;
case 14:
jj_consume_token(14);
type = 2;
break;
default:
jj_la1[3] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
break;
default:
jj_la1[4] = jj_gen;
;
}
r = rectangle();
jj_consume_token(15);
as = num();
jj_consume_token(16);
ae = num();
jj_consume_token(17);
// -as -ae because angle wise is not affect by AffineTransform
{if (true) return new Arc2D.Double(r, -as, -ae, type);}
throw new Error("Missing return statement in function");
}
final private Ellipse2D circle() throws ParseException {
double x, y, r;
jj_consume_token(15);
x = num();
jj_consume_token(16);
y = num();
jj_consume_token(16);
r = num();
jj_consume_token(17);
{if (true) return new Ellipse2D.Double(x-r, y-r, r*2, r*2);}
throw new Error("Missing return statement in function");
}
final private Ellipse2D ellipse() throws ParseException {
Rectangle2D.Double r;
r = rectangle();
{if (true) return new Ellipse2D.Double(r.x, r.y, r.width, r.height);}
throw new Error("Missing return statement in function");
}
final private Rectangle2D.Double rectangle() throws ParseException {
double ax, ay, bx, by;
double x, y, w, h;
jj_consume_token(15);
ax = num();
jj_consume_token(16);
ay = num();
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 17:
jj_consume_token(17);
jj_consume_token(15);
bx = num();
jj_consume_token(16);
by = num();
jj_consume_token(17);
if (ax < bx) { x = ax; w = bx - ax; }
else { x = bx; w = ax - bx; }
if (ay < by) { y = ay; h = by - ay; }
else { y = by; h = ay - by; }
break;
case 16:
jj_consume_token(16);
w = num();
jj_consume_token(16);
h = num();
jj_consume_token(17);
x = ax; y = ay;
break;
default:
jj_la1[5] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
{if (true) return new Rectangle2D.Double(x,y,w,h);}
throw new Error("Missing return statement in function");
}
final private GeneralPath polygon() throws ParseException {
Point2D p,ps;
ArrayList pl = new ArrayList();
ps = point();
p = point();
pl.add(p);
label_2:
while (true) {
p = point();
pl.add(p);
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 15:
;
break;
default:
jj_la1[6] = jj_gen;
break label_2;
}
}
GeneralPath gp = new GeneralPath();
gp.moveTo((float)ps.getX(), (float)ps.getY());
for (int i=0; i jj_expentries = new java.util.ArrayList();
private int[] jj_expentry;
private int jj_kind = -1;
/** Generate ParseException. */
public ParseException generateParseException() {
jj_expentries.clear();
boolean[] la1tokens = new boolean[18];
if (jj_kind >= 0) {
la1tokens[jj_kind] = true;
jj_kind = -1;
}
for (int i = 0; i < 7; i++) {
if (jj_la1[i] == jj_gen) {
for (int j = 0; j < 32; j++) {
if ((jj_la1_0[i] & (1<
Ads help maintain this website.