/* Generated By:JJTree&JavaCC: Do not edit this line. drawphase2.java */
import java.io.*;
import java.util.ArrayList;
public class drawphase2/*@bgen(jjtree)*/implements drawphase2TreeConstants, drawphase2Constants {/*@bgen(jjtree)*/
  protected static JJTdrawphase2State jjtree = new JJTdrawphase2State();
        static FileWriter fw;
        static BufferedWriter bw;
        static PrintWriter pw;
        static int offsetX = 0, offsetY = 0;

        static String colour = "black";
        static int brush = 1;
        static boolean brushAlter = false, colourAlter = false,
                        offsetAlter = false;

        {try{
                fw = new FileWriter("drawphase2.SVG");
                bw = new BufferedWriter(fw);
                pw = new PrintWriter(bw);
                }
                catch (IOException IOX)
      {
         System.out.println("IOEXception!");
      }}

public static void main(String args[]) throws ParseException{
drawphase2 parser = new drawphase2(System.in);
parser.Input();
        }

  static final public void Input() throws ParseException {
 /*@bgen(jjtree) Input */
  SimpleNode jjtn000 = new SimpleNode(JJTINPUT);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);
    try {
      Statement();
    } catch (Throwable jjte000) {
          if (jjtc000) {
            jjtree.clearNodeScope(jjtn000);
            jjtc000 = false;
          } else {
            jjtree.popNode();
          }
          if (jjte000 instanceof RuntimeException) {
            {if (true) throw (RuntimeException)jjte000;}
          }
          if (jjte000 instanceof ParseException) {
            {if (true) throw (ParseException)jjte000;}
          }
          {if (true) throw (Error)jjte000;}
    } finally {
          if (jjtc000) {
            jjtree.closeNodeScope(jjtn000, true);
          }
    }
  }

  static final public void Statement() throws ParseException {
 /*@bgen(jjtree) Statement */
  SimpleNode jjtn000 = new SimpleNode(JJTSTATEMENT);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);
    try {
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case LINE:
        lineStatement();
        break;
      case PICTURE:
        pictureStatement();
        break;
      case RECTANGLE:
        rectangleStatement();
        break;
      case SQUARE:
        squareStatement();
        break;
      case ELLIPSE:
        ellipseStatement();
        break;
      case CIRCLE:
        circleStatement();
        break;
      case TRIANGLE:
        triangleStatement();
        break;
      case POLYGON:
        polygonStatement();
        break;
      case TEXT:
        textStatement();
        break;
      case STARTBLOCK:
        Block();
        break;
      case COLOUR:
      case BRUSH:
      case OFFSET:
        alterStatement();
        break;
      default:
        jj_la1[0] = jj_gen;
        jj_consume_token(-1);
        throw new ParseException();
      }
    } catch (Throwable jjte000) {
          if (jjtc000) {
            jjtree.clearNodeScope(jjtn000);
            jjtc000 = false;
          } else {
            jjtree.popNode();
          }
          if (jjte000 instanceof RuntimeException) {
            {if (true) throw (RuntimeException)jjte000;}
          }
          if (jjte000 instanceof ParseException) {
            {if (true) throw (ParseException)jjte000;}
          }
          {if (true) throw (Error)jjte000;}
    } finally {
          if (jjtc000) {
            jjtree.closeNodeScope(jjtn000, true);
          }
    }
  }

  static final public void alterStatement() throws ParseException {
 /*@bgen(jjtree) alterStatement */
  SimpleNode jjtn000 = new SimpleNode(JJTALTERSTATEMENT);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);
    try {
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case BRUSH:
        brushStatement();
        break;
      case COLOUR:
        colourStatement();
        break;
      case OFFSET:
        offsetStatement();
        break;
      default:
        jj_la1[1] = jj_gen;
        jj_consume_token(-1);
        throw new ParseException();
      }
    } catch (Throwable jjte000) {
          if (jjtc000) {
            jjtree.clearNodeScope(jjtn000);
            jjtc000 = false;
          } else {
            jjtree.popNode();
          }
          if (jjte000 instanceof RuntimeException) {
            {if (true) throw (RuntimeException)jjte000;}
          }
          if (jjte000 instanceof ParseException) {
            {if (true) throw (ParseException)jjte000;}
          }
          {if (true) throw (Error)jjte000;}
    } finally {
          if (jjtc000) {
            jjtree.closeNodeScope(jjtn000, true);
          }
    }
  }

  static final public void pictureStatement() throws ParseException {
 /*@bgen(jjtree) pictureStatement */
 SimpleNode jjtn000 = new SimpleNode(JJTPICTURESTATEMENT);
 boolean jjtc000 = true;
 jjtree.openNodeScope(jjtn000);Token widthTok, heightTok; int width, height;
    try {
      jj_consume_token(PICTURE);
      jj_consume_token(START);
      widthTok = jj_consume_token(INTEGER);
      heightTok = jj_consume_token(INTEGER);
      jj_consume_token(END);
      drawPicture(widthTok, heightTok);
      label_1:
      while (true) {
        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
        case LINE:
        case RECTANGLE:
        case SQUARE:
        case ELLIPSE:
        case CIRCLE:
        case TRIANGLE:
        case POLYGON:
        case PICTURE:
        case COLOUR:
        case BRUSH:
        case TEXT:
        case OFFSET:
        case STARTBLOCK:
          ;
          break;
        default:
          jj_la1[2] = jj_gen;
          break label_1;
        }
        Statement();
      }
      picEnd();
    } catch (Throwable jjte000) {
          if (jjtc000) {
            jjtree.clearNodeScope(jjtn000);
            jjtc000 = false;
          } else {
            jjtree.popNode();
          }
          if (jjte000 instanceof RuntimeException) {
            {if (true) throw (RuntimeException)jjte000;}
          }
          if (jjte000 instanceof ParseException) {
            {if (true) throw (ParseException)jjte000;}
          }
          {if (true) throw (Error)jjte000;}
    } finally {
          if (jjtc000) {
            jjtree.closeNodeScope(jjtn000, true);
          }
    }
  }

  static final public void lineStatement() throws ParseException {
 /*@bgen(jjtree) lineStatement */
 SimpleNode jjtn000 = new SimpleNode(JJTLINESTATEMENT);
 boolean jjtc000 = true;
 jjtree.openNodeScope(jjtn000);Token x1tok, y1tok, x2tok, y2tok; int x1, x2, y1, y2;
    try {
      jj_consume_token(LINE);
      jj_consume_token(START);
      x1tok = jj_consume_token(INTEGER);
      y1tok = jj_consume_token(INTEGER);
      x2tok = jj_consume_token(INTEGER);
      y2tok = jj_consume_token(INTEGER);
      jj_consume_token(END);
         x1 = Integer.parseInt(x1tok.image); y1 = Integer.parseInt(y1tok.image);
        x2 = Integer.parseInt(x2tok.image);     y2 = Integer.parseInt(y2tok.image);
      drawLine(x1, y1, x2, y2);
    } catch (Throwable jjte000) {
          if (jjtc000) {
            jjtree.clearNodeScope(jjtn000);
            jjtc000 = false;
          } else {
            jjtree.popNode();
          }
          if (jjte000 instanceof RuntimeException) {
            {if (true) throw (RuntimeException)jjte000;}
          }
          if (jjte000 instanceof ParseException) {
            {if (true) throw (ParseException)jjte000;}
          }
          {if (true) throw (Error)jjte000;}
    } finally {
          if (jjtc000) {
            jjtree.closeNodeScope(jjtn000, true);
          }
    }
  }

  static final public void rectangleStatement() throws ParseException {
 /*@bgen(jjtree) rectangleStatement */
 SimpleNode jjtn000 = new SimpleNode(JJTRECTANGLESTATEMENT);
 boolean jjtc000 = true;
 jjtree.openNodeScope(jjtn000);Token x1tok, y1tok, x2tok, y2tok; int x1, x2, y1, y2;
    try {
      jj_consume_token(RECTANGLE);
      jj_consume_token(START);
      x1tok = jj_consume_token(INTEGER);
      y1tok = jj_consume_token(INTEGER);
      x2tok = jj_consume_token(INTEGER);
      y2tok = jj_consume_token(INTEGER);
      jj_consume_token(END);
         x1 = Integer.parseInt(x1tok.image); y1 = Integer.parseInt(y1tok.image);
        x2 = Integer.parseInt(x2tok.image);     y2 = Integer.parseInt(y2tok.image);
      drawLine(x1, y1, x2, y1);
      drawLine(x1, y1, x1, y2);
      drawLine(x1, y2, x2, y2);
      drawLine(x2, y1, x2, y2);
    } catch (Throwable jjte000) {
          if (jjtc000) {
            jjtree.clearNodeScope(jjtn000);
            jjtc000 = false;
          } else {
            jjtree.popNode();
          }
          if (jjte000 instanceof RuntimeException) {
            {if (true) throw (RuntimeException)jjte000;}
          }
          if (jjte000 instanceof ParseException) {
            {if (true) throw (ParseException)jjte000;}
          }
          {if (true) throw (Error)jjte000;}
    } finally {
          if (jjtc000) {
            jjtree.closeNodeScope(jjtn000, true);
          }
    }
  }

  static final public void squareStatement() throws ParseException {
 /*@bgen(jjtree) squareStatement */
 SimpleNode jjtn000 = new SimpleNode(JJTSQUARESTATEMENT);
 boolean jjtc000 = true;
 jjtree.openNodeScope(jjtn000);Token x1tok, y1tok, x2tok; int x1, x2, y1, y2;
    try {
      jj_consume_token(SQUARE);
      jj_consume_token(START);
      x1tok = jj_consume_token(INTEGER);
      y1tok = jj_consume_token(INTEGER);
      x2tok = jj_consume_token(INTEGER);
      jj_consume_token(END);
         x1 = Integer.parseInt(x1tok.image); y1 = Integer.parseInt(y1tok.image);
        x2 = Integer.parseInt(x2tok.image); y2 = Math.abs(y1 +(x2 - x1));
      drawLine(x1, y1, x2, y1);
      drawLine(x1, y1, x1, y2);
      drawLine(x1, y2, x2, y2);
      drawLine(x2, y1, x2, y2);
    } catch (Throwable jjte000) {
          if (jjtc000) {
            jjtree.clearNodeScope(jjtn000);
            jjtc000 = false;
          } else {
            jjtree.popNode();
          }
          if (jjte000 instanceof RuntimeException) {
            {if (true) throw (RuntimeException)jjte000;}
          }
          if (jjte000 instanceof ParseException) {
            {if (true) throw (ParseException)jjte000;}
          }
          {if (true) throw (Error)jjte000;}
    } finally {
          if (jjtc000) {
            jjtree.closeNodeScope(jjtn000, true);
          }
    }
  }

  static final public void ellipseStatement() throws ParseException {
 /*@bgen(jjtree) ellipseStatement */
 SimpleNode jjtn000 = new SimpleNode(JJTELLIPSESTATEMENT);
 boolean jjtc000 = true;
 jjtree.openNodeScope(jjtn000);Token x1tok, y1tok, x2tok, y2tok; int x1, x2, y1, y2, cx, cy, rx, ry;
    try {
      jj_consume_token(ELLIPSE);
      jj_consume_token(START);
      x1tok = jj_consume_token(INTEGER);
      y1tok = jj_consume_token(INTEGER);
      x2tok = jj_consume_token(INTEGER);
      y2tok = jj_consume_token(INTEGER);
      jj_consume_token(END);
         x1 = Integer.parseInt(x1tok.image); y1 = Integer.parseInt(y1tok.image);
        x2 = Integer.parseInt(x2tok.image);     y2 = Integer.parseInt(y2tok.image);
        rx = ((x2 - x1)/2); ry = ((y2 - y1)/2); cx = x1+rx; cy = y1+ry;
      drawEllipse(cx, cy, rx, ry);
    } catch (Throwable jjte000) {
          if (jjtc000) {
            jjtree.clearNodeScope(jjtn000);
            jjtc000 = false;
          } else {
            jjtree.popNode();
          }
          if (jjte000 instanceof RuntimeException) {
            {if (true) throw (RuntimeException)jjte000;}
          }
          if (jjte000 instanceof ParseException) {
            {if (true) throw (ParseException)jjte000;}
          }
          {if (true) throw (Error)jjte000;}
    } finally {
          if (jjtc000) {
            jjtree.closeNodeScope(jjtn000, true);
          }
    }
  }

  static final public void circleStatement() throws ParseException {
 /*@bgen(jjtree) circleStatement */
 SimpleNode jjtn000 = new SimpleNode(JJTCIRCLESTATEMENT);
 boolean jjtc000 = true;
 jjtree.openNodeScope(jjtn000);Token x1tok, y1tok, x2tok; int x1, x2, y1, y2, cx, cy, rx, ry;
    try {
      jj_consume_token(CIRCLE);
      jj_consume_token(START);
      x1tok = jj_consume_token(INTEGER);
      y1tok = jj_consume_token(INTEGER);
      x2tok = jj_consume_token(INTEGER);
      jj_consume_token(END);
         x1 = Integer.parseInt(x1tok.image); y1 = Integer.parseInt(y1tok.image);
        x2 = Integer.parseInt(x2tok.image); y2 = Math.abs(y1 + (x2 - x1));
        rx = ((x2 - x1)/2); ry = ((y2 - y1)/2); cx = x1+rx; cy = y1+ry;
      drawEllipse(cx, cy, rx, ry);
    } catch (Throwable jjte000) {
          if (jjtc000) {
            jjtree.clearNodeScope(jjtn000);
            jjtc000 = false;
          } else {
            jjtree.popNode();
          }
          if (jjte000 instanceof RuntimeException) {
            {if (true) throw (RuntimeException)jjte000;}
          }
          if (jjte000 instanceof ParseException) {
            {if (true) throw (ParseException)jjte000;}
          }
          {if (true) throw (Error)jjte000;}
    } finally {
          if (jjtc000) {
            jjtree.closeNodeScope(jjtn000, true);
          }
    }
  }

  static final public void triangleStatement() throws ParseException {
 /*@bgen(jjtree) triangleStatement */
 SimpleNode jjtn000 = new SimpleNode(JJTTRIANGLESTATEMENT);
 boolean jjtc000 = true;
 jjtree.openNodeScope(jjtn000);Token x1tok, y1tok, x2tok, y2tok, x3tok, y3tok; int x1, y1, x2, y2, x3, y3;
    try {
      jj_consume_token(TRIANGLE);
      jj_consume_token(START);
      x1tok = jj_consume_token(INTEGER);
      y1tok = jj_consume_token(INTEGER);
      x2tok = jj_consume_token(INTEGER);
      y2tok = jj_consume_token(INTEGER);
      x3tok = jj_consume_token(INTEGER);
      y3tok = jj_consume_token(INTEGER);
      jj_consume_token(END);
         x1 = Integer.parseInt(x1tok.image); y1 = Integer.parseInt(y1tok.image);
        x2 = Integer.parseInt(x2tok.image); y2 = Integer.parseInt(y2tok.image);
        x3 = Integer.parseInt(x3tok.image); y3 = Integer.parseInt(y3tok.image);
      drawLine(x1, y1, x2, y2);
      drawLine(x2, y2, x3, y3);
      drawLine(x3, y3, x1, y1);
    } catch (Throwable jjte000) {
          if (jjtc000) {
            jjtree.clearNodeScope(jjtn000);
            jjtc000 = false;
          } else {
            jjtree.popNode();
          }
          if (jjte000 instanceof RuntimeException) {
            {if (true) throw (RuntimeException)jjte000;}
          }
          if (jjte000 instanceof ParseException) {
            {if (true) throw (ParseException)jjte000;}
          }
          {if (true) throw (Error)jjte000;}
    } finally {
          if (jjtc000) {
            jjtree.closeNodeScope(jjtn000, true);
          }
    }
  }

  static final public void polygonStatement() throws ParseException {
 /*@bgen(jjtree) polygonStatement */
 SimpleNode jjtn000 = new SimpleNode(JJTPOLYGONSTATEMENT);
 boolean jjtc000 = true;
 jjtree.openNodeScope(jjtn000);Token[] tok = new Token[100]; int i = 0, j = 0;
    try {
      jj_consume_token(POLYGON);
      jj_consume_token(START);
      label_2:
      while (true) {
        tok[i++] = jj_consume_token(INTEGER);
        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
        case INTEGER:
          ;
          break;
        default:
          jj_la1[3] = jj_gen;
          break label_2;
        }
      }
      jj_consume_token(END);
          jjtree.closeNodeScope(jjtn000, true);
          jjtc000 = false;
         while(j < (i-1)){
                if (j == (i-2)){
                drawLine(Integer.parseInt(tok[j++].image), Integer.parseInt(tok[j].image),
                                        Integer.parseInt(tok[0].image), Integer.parseInt(tok[1].image));
                j+=30;
                }
                else{
                drawLine(Integer.parseInt(tok[j++].image), Integer.parseInt(tok[j++].image),
                                        Integer.parseInt(tok[j++].image), Integer.parseInt(tok[j].image));
                j--;}
        }
    } finally {
          if (jjtc000) {
            jjtree.closeNodeScope(jjtn000, true);
          }
    }
  }

  static final public void textStatement() throws ParseException {
 /*@bgen(jjtree) textStatement */
 SimpleNode jjtn000 = new SimpleNode(JJTTEXTSTATEMENT);
 boolean jjtc000 = true;
 jjtree.openNodeScope(jjtn000);Token xtok, ytok, sizeTok, wordTok[] = new Token[12]; int x, y, j = 0,
                                         size; String textToWrite;
    try {
      jj_consume_token(TEXT);
      jj_consume_token(START);
      xtok = jj_consume_token(INTEGER);
      ytok = jj_consume_token(INTEGER);
      sizeTok = jj_consume_token(INTEGER);
      jj_consume_token(TEXTBOUNDER);
      label_3:
      while (true) {
        wordTok[j++] = jj_consume_token(WORD);
        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
        case WORD:
          ;
          break;
        default:
          jj_la1[4] = jj_gen;
          break label_3;
        }
      }
      jj_consume_token(TEXTBOUNDER);
      jj_consume_token(END);
         x = Integer.parseInt(xtok.image); y = Integer.parseInt(ytok.image);
        size = Integer.parseInt(sizeTok.image);
        textToWrite = wordTok[0].image;
         for (int i = 1; i < j; i++){
                        textToWrite = textToWrite.concat(" ");
                        textToWrite = textToWrite.concat(wordTok[i].image);
         };
      drawText(x, y, size, textToWrite);
    } catch (Throwable jjte000) {
          if (jjtc000) {
            jjtree.clearNodeScope(jjtn000);
            jjtc000 = false;
          } else {
            jjtree.popNode();
          }
          if (jjte000 instanceof RuntimeException) {
            {if (true) throw (RuntimeException)jjte000;}
          }
          if (jjte000 instanceof ParseException) {
            {if (true) throw (ParseException)jjte000;}
          }
          {if (true) throw (Error)jjte000;}
    } finally {
          if (jjtc000) {
            jjtree.closeNodeScope(jjtn000, true);
          }
    }
  }

  static final public void colourStatement() throws ParseException {
 /*@bgen(jjtree) colourStatement */
 SimpleNode jjtn000 = new SimpleNode(JJTCOLOURSTATEMENT);
 boolean jjtc000 = true;
 jjtree.openNodeScope(jjtn000);Token col;
    try {
      jj_consume_token(COLOUR);
      jj_consume_token(START);
      col = jj_consume_token(WORD);
      jj_consume_token(END);
                                                    colour = col.image;
      colourAlter();
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case BRUSH:
        brushStatement();
        break;
      default:
        jj_la1[5] = jj_gen;
        ;
      }
      Statement();
      colourAlter();
    } catch (Throwable jjte000) {
          if (jjtc000) {
            jjtree.clearNodeScope(jjtn000);
            jjtc000 = false;
          } else {
            jjtree.popNode();
          }
          if (jjte000 instanceof RuntimeException) {
            {if (true) throw (RuntimeException)jjte000;}
          }
          if (jjte000 instanceof ParseException) {
            {if (true) throw (ParseException)jjte000;}
          }
          {if (true) throw (Error)jjte000;}
    } finally {
          if (jjtc000) {
            jjtree.closeNodeScope(jjtn000, true);
          }
    }
  }

  static final public void offsetStatement() throws ParseException {
 /*@bgen(jjtree) offsetStatement */
 SimpleNode jjtn000 = new SimpleNode(JJTOFFSETSTATEMENT);
 boolean jjtc000 = true;
 jjtree.openNodeScope(jjtn000);Token x, y;
    try {
      jj_consume_token(OFFSET);
      jj_consume_token(START);
      x = jj_consume_token(INTEGER);
      y = jj_consume_token(INTEGER);
         offsetX = Integer.parseInt(x.image); offsetY = Integer.parseInt(x.image);
      jj_consume_token(END);
      offsetAlter();
      Statement();
      offsetAlter();
    } catch (Throwable jjte000) {
          if (jjtc000) {
            jjtree.clearNodeScope(jjtn000);
            jjtc000 = false;
          } else {
            jjtree.popNode();
          }
          if (jjte000 instanceof RuntimeException) {
            {if (true) throw (RuntimeException)jjte000;}
          }
          if (jjte000 instanceof ParseException) {
            {if (true) throw (ParseException)jjte000;}
          }
          {if (true) throw (Error)jjte000;}
    } finally {
          if (jjtc000) {
            jjtree.closeNodeScope(jjtn000, true);
          }
    }
  }

  static final public void brushStatement() throws ParseException {
 /*@bgen(jjtree) brushStatement */
 SimpleNode jjtn000 = new SimpleNode(JJTBRUSHSTATEMENT);
 boolean jjtc000 = true;
 jjtree.openNodeScope(jjtn000);Token b;
    try {
      jj_consume_token(BRUSH);
      jj_consume_token(START);
      b = jj_consume_token(INTEGER);
                                       brush = Integer.parseInt(b.image);
      jj_consume_token(END);
      brushAlter();
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case COLOUR:
        colourStatement();
        break;
      default:
        jj_la1[6] = jj_gen;
        ;
      }
      Statement();
      brushAlter();
    } catch (Throwable jjte000) {
          if (jjtc000) {
            jjtree.clearNodeScope(jjtn000);
            jjtc000 = false;
          } else {
            jjtree.popNode();
          }
          if (jjte000 instanceof RuntimeException) {
            {if (true) throw (RuntimeException)jjte000;}
          }
          if (jjte000 instanceof ParseException) {
            {if (true) throw (ParseException)jjte000;}
          }
          {if (true) throw (Error)jjte000;}
    } finally {
          if (jjtc000) {
            jjtree.closeNodeScope(jjtn000, true);
          }
    }
  }

  static final public void Block() throws ParseException {
 /*@bgen(jjtree) Block */
  SimpleNode jjtn000 = new SimpleNode(JJTBLOCK);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);
    try {
      jj_consume_token(STARTBLOCK);
      label_4:
      while (true) {
        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
        case LINE:
        case RECTANGLE:
        case SQUARE:
        case ELLIPSE:
        case CIRCLE:
        case TRIANGLE:
        case POLYGON:
        case PICTURE:
        case COLOUR:
        case BRUSH:
        case TEXT:
        case OFFSET:
        case STARTBLOCK:
          ;
          break;
        default:
          jj_la1[7] = jj_gen;
          break label_4;
        }
        Statement();
      }
      jj_consume_token(ENDBLOCK);
    } catch (Throwable jjte000) {
    if (jjtc000) {
      jjtree.clearNodeScope(jjtn000);
      jjtc000 = false;
    } else {
      jjtree.popNode();
    }
    if (jjte000 instanceof RuntimeException) {
      {if (true) throw (RuntimeException)jjte000;}
    }
    if (jjte000 instanceof ParseException) {
      {if (true) throw (ParseException)jjte000;}
    }
    {if (true) throw (Error)jjte000;}
    } finally {
    if (jjtc000) {
      jjtree.closeNodeScope(jjtn000, true);
    }
    }
  }

  static final public void brushAlter() throws ParseException {
 /*@bgen(jjtree) brushAlter */
  SimpleNode jjtn000 = new SimpleNode(JJTBRUSHALTER);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);
    try {
          jjtree.closeNodeScope(jjtn000, true);
          jjtc000 = false;
         if (brushAlter){
                brushAlter = false;
                brush = 1;
        }
        else
                brushAlter = true;
    } finally {
          if (jjtc000) {
            jjtree.closeNodeScope(jjtn000, true);
          }
    }
  }

  static final public void colourAlter() throws ParseException {
 /*@bgen(jjtree) colourAlter */
  SimpleNode jjtn000 = new SimpleNode(JJTCOLOURALTER);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);
    try {
          jjtree.closeNodeScope(jjtn000, true);
          jjtc000 = false;
         if (colourAlter){
                colourAlter = false;
                colour = "black";
        }
        else
                colourAlter = true;
    } finally {
          if (jjtc000) {
            jjtree.closeNodeScope(jjtn000, true);
          }
    }
  }

  static final public void offsetAlter() throws ParseException {
 /*@bgen(jjtree) offsetAlter */
  SimpleNode jjtn000 = new SimpleNode(JJTOFFSETALTER);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);
    try {
          jjtree.closeNodeScope(jjtn000, true);
          jjtc000 = false;
         if (offsetAlter){
                offsetAlter = false;
                offsetX = 0; offsetY = 0;
        }
        else
                offsetAlter = true;
    } finally {
          if (jjtc000) {
            jjtree.closeNodeScope(jjtn000, true);
          }
    }
  }

  static final public void drawLine(int x1, int y1, int x2, int y2) throws ParseException {
 /*@bgen(jjtree) drawLine */
  SimpleNode jjtn000 = new SimpleNode(JJTDRAWLINE);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);
    try {
          jjtree.closeNodeScope(jjtn000, true);
          jjtc000 = false;
         if(offsetAlter)
                x1 += offsetX; x2 += offsetX; y1 += offsetY; y2 += offsetY;

        pw.print("<line x1=\""+x1+"\" y1=\""+y1+"\" x2=\""+x2+"\" y2=\""+y2+"\""+
        " stroke =\"" +colour+ "\" stroke-width=\"" +brush+ "\"/>");
    } finally {
          if (jjtc000) {
            jjtree.closeNodeScope(jjtn000, true);
          }
    }
  }

  static final public void drawEllipse(int cx, int cy, int rx, int ry) throws ParseException {
 /*@bgen(jjtree) drawEllipse */
  SimpleNode jjtn000 = new SimpleNode(JJTDRAWELLIPSE);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);
    try {
          jjtree.closeNodeScope(jjtn000, true);
          jjtc000 = false;
         pw.print("<ellipse cx=\""+cx+"\" cy=\""+cy+"\" rx=\""+rx+"\" ry=\""+ry+
   "\" fill = \"none\" stroke =\"" +colour+ "\" stroke-width=\"" +brush+ "\"/>");
    } finally {
          if (jjtc000) {
            jjtree.closeNodeScope(jjtn000, true);
          }
    }
  }

  static final public void drawText(int x, int y, int size, String textToWrite) throws ParseException {
 /*@bgen(jjtree) drawText */
  SimpleNode jjtn000 = new SimpleNode(JJTDRAWTEXT);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);
    try {
                  jjtree.closeNodeScope(jjtn000, true);
                  jjtc000 = false;
                 pw.print("<text x=\""+x+"\" y=\""+y+"\" font-size=\""+size+"\""+
      " stroke =\"" +colour+ "\" stroke-width=\"" +brush+ "\">"+
      textToWrite+"</text>");
    } finally {
                  if (jjtc000) {
                    jjtree.closeNodeScope(jjtn000, true);
                  }
    }
  }

  static final public void drawPicture(Token w, Token h) throws ParseException {
 /*@bgen(jjtree) drawPicture */
  SimpleNode jjtn000 = new SimpleNode(JJTDRAWPICTURE);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);
    try {
          jjtree.closeNodeScope(jjtn000, true);
          jjtc000 = false;
         pw.println("<svg  width = \""+ w +"\" height = \""+h+"\">");
    } finally {
          if (jjtc000) {
            jjtree.closeNodeScope(jjtn000, true);
          }
    }
  }

  static final public void picEnd() throws ParseException {
 /*@bgen(jjtree) picEnd */
  SimpleNode jjtn000 = new SimpleNode(JJTPICEND);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);
    try {
          jjtree.closeNodeScope(jjtn000, true);
          jjtc000 = false;
         pw.println("</svg>");pw.close();
    } finally {
          if (jjtc000) {
            jjtree.closeNodeScope(jjtn000, true);
          }
    }
  }

  static private boolean jj_initialized_once = false;
  static public drawphase2TokenManager token_source;
  static SimpleCharStream jj_input_stream;
  static public Token token, jj_nt;
  static private int jj_ntk;
  static private int jj_gen;
  static final private int[] jj_la1 = new int[8];
  static private int[] jj_la1_0;
  static {
      jj_la1_0();
   }
   private static void jj_la1_0() {
      jj_la1_0 = new int[] {0x4fff0,0xb000,0x4fff0,0x200000,0x400000,0x2000,0x1000,0x4fff0,};
   }

  public drawphase2(java.io.InputStream stream) {
    if (jj_initialized_once) {
      System.out.println("ERROR: Second call to constructor of static parser.  You must");
      System.out.println("       either use ReInit() or set the JavaCC option STATIC to false");
      System.out.println("       during parser generation.");
      throw new Error();
    }
    jj_initialized_once = true;
    jj_input_stream = new SimpleCharStream(stream, 1, 1);
    token_source = new drawphase2TokenManager(jj_input_stream);
    token = new Token();
    jj_ntk = -1;
    jj_gen = 0;
    for (int i = 0; i < 8; i++) jj_la1[i] = -1;
  }

  static public void ReInit(java.io.InputStream stream) {
    jj_input_stream.ReInit(stream, 1, 1);
    token_source.ReInit(jj_input_stream);
    token = new Token();
    jj_ntk = -1;
    jjtree.reset();
    jj_gen = 0;
    for (int i = 0; i < 8; i++) jj_la1[i] = -1;
  }

  public drawphase2(java.io.Reader stream) {
    if (jj_initialized_once) {
      System.out.println("ERROR: Second call to constructor of static parser.  You must");
      System.out.println("       either use ReInit() or set the JavaCC option STATIC to false");
      System.out.println("       during parser generation.");
      throw new Error();
    }
    jj_initialized_once = true;
    jj_input_stream = new SimpleCharStream(stream, 1, 1);
    token_source = new drawphase2TokenManager(jj_input_stream);
    token = new Token();
    jj_ntk = -1;
    jj_gen = 0;
    for (int i = 0; i < 8; i++) jj_la1[i] = -1;
  }

  static public void ReInit(java.io.Reader stream) {
    jj_input_stream.ReInit(stream, 1, 1);
    token_source.ReInit(jj_input_stream);
    token = new Token();
    jj_ntk = -1;
    jjtree.reset();
    jj_gen = 0;
    for (int i = 0; i < 8; i++) jj_la1[i] = -1;
  }

  public drawphase2(drawphase2TokenManager tm) {
    if (jj_initialized_once) {
      System.out.println("ERROR: Second call to constructor of static parser.  You must");
      System.out.println("       either use ReInit() or set the JavaCC option STATIC to false");
      System.out.println("       during parser generation.");
      throw new Error();
    }
    jj_initialized_once = true;
    token_source = tm;
    token = new Token();
    jj_ntk = -1;
    jj_gen = 0;
    for (int i = 0; i < 8; i++) jj_la1[i] = -1;
  }

  public void ReInit(drawphase2TokenManager tm) {
    token_source = tm;
    token = new Token();
    jj_ntk = -1;
    jjtree.reset();
    jj_gen = 0;
    for (int i = 0; i < 8; i++) jj_la1[i] = -1;
  }

  static final private Token jj_consume_token(int kind) throws ParseException {
    Token oldToken;
    if ((oldToken = token).next != null) token = token.next;
    else token = token.next = token_source.getNextToken();
    jj_ntk = -1;
    if (token.kind == kind) {
      jj_gen++;
      return token;
    }
    token = oldToken;
    jj_kind = kind;
    throw generateParseException();
  }

  static final public Token getNextToken() {
    if (token.next != null) token = token.next;
    else token = token.next = token_source.getNextToken();
    jj_ntk = -1;
    jj_gen++;
    return token;
  }

  static final public Token getToken(int index) {
    Token t = token;
    for (int i = 0; i < index; i++) {
      if (t.next != null) t = t.next;
      else t = t.next = token_source.getNextToken();
    }
    return t;
  }

  static final private int jj_ntk() {
    if ((jj_nt=token.next) == null)
      return (jj_ntk = (token.next=token_source.getNextToken()).kind);
    else
      return (jj_ntk = jj_nt.kind);
  }

  static private java.util.Vector jj_expentries = new java.util.Vector();
  static private int[] jj_expentry;
  static private int jj_kind = -1;

  static public ParseException generateParseException() {
    jj_expentries.removeAllElements();
    boolean[] la1tokens = new boolean[23];
    for (int i = 0; i < 23; i++) {
      la1tokens[i] = false;
    }
    if (jj_kind >= 0) {
      la1tokens[jj_kind] = true;
      jj_kind = -1;
    }
    for (int i = 0; i < 8; i++) {
      if (jj_la1[i] == jj_gen) {
        for (int j = 0; j < 32; j++) {
          if ((jj_la1_0[i] & (1<<j)) != 0) {
            la1tokens[j] = true;
          }
        }
      }
    }
    for (int i = 0; i < 23; i++) {
      if (la1tokens[i]) {
        jj_expentry = new int[1];
        jj_expentry[0] = i;
        jj_expentries.addElement(jj_expentry);
      }
    }
    int[][] exptokseq = new int[jj_expentries.size()][];
    for (int i = 0; i < jj_expentries.size(); i++) {
      exptokseq[i] = (int[])jj_expentries.elementAt(i);
    }
    return new ParseException(token, exptokseq, tokenImage);
  }

  static final public void enable_tracing() {
  }

  static final public void disable_tracing() {
  }

}
