/* Generated By:JJTree: Do not edit this line. SimpleNode.java */

public class SimpleNode implements Node {
  protected Node parent;
  protected Node[] children;
  protected int id;
  protected drawphase2 parser;

  public SimpleNode(int i) {
    id = i;
  }

  public SimpleNode(drawphase2 p, int i) {
    this(i);
    parser = p;
  }

  public void jjtOpen() {
  }

  public void jjtClose() {
  }
  
  public void jjtSetParent(Node n) { parent = n; }
  public Node jjtGetParent() { return parent; }

  public void jjtAddChild(Node n, int i) {
    if (children == null) {
      children = new Node[i + 1];
    } else if (i >= children.length) {
      Node c[] = new Node[i + 1];
      System.arraycopy(children, 0, c, 0, children.length);
      children = c;
    }
    children[i] = n;
  }

  public Node jjtGetChild(int i) {
    return children[i];
  }

  public int jjtGetNumChildren() {
    return (children == null) ? 0 : children.length;
  }

  /* You can override these two methods in subclasses of SimpleNode to
     customize the way the node appears when the tree is dumped.  If
     your output uses more than one line you should override
     toString(String), otherwise overriding toString() is probably all
     you need to do. */

  public String toString() { return drawphase2TreeConstants.jjtNodeName[id]; }
  public String toString(String prefix) { return prefix + toString(); }

  /* Override this method if you want to customize how the node dumps
     out its children. */

  public void dump(String prefix) {
    System.out.println(toString(prefix));
    if (children != null) {
      for (int i = 0; i < children.length; ++i) {
	SimpleNode n = (SimpleNode)children[i];
	if (n != null) {
	  n.dump(prefix + " ");
	}
      }
    }
  }
  
  /* Added methods */

  /*-----------------------------------------------*/
  /* Formats a line based on arguments provided    */
  /*-----------------------------------------------*/
  public String formatLine(int x1, int y1, int x2, int y2, String color, int brush, int offsetX, int offsetY)
  {
    if (color.equals("UNDEFINED") == true) { color = "black"; }

      return "  <line x1=\"" + (x1+offsetX) + "\" y1=\"" + (y1+offsetY) + 
                  "\" x2=\"" + (x2+offsetX) + "\" y2=\"" + (y2+offsetY) + 
                  "\" stroke=\"" + color + "\" stroke-width=\"" + brush + "\"/>";
  }

  /*-----------------------------------------------*/
  /* Finds and Returns Specified Colour            */
  /*-----------------------------------------------*/
  public String getColour()
  {
      String colour;

      if (jjtGetParent().getType().equals("Colour") == true )
      {
        colour = jjtGetParent().getColour(); 
      }
      else if (jjtGetParent().getType().equals("Block") == true )
      {
        colour = jjtGetParent().getColour(); 
      }
      else if (jjtGetParent().getType().equals("Brush") == true )
      {
        colour = jjtGetParent().getColour(); 
      }
      else if (jjtGetParent().getType().equals("Offset") == true )
      {
        colour = jjtGetParent().getColour(); 
      }
      else 
      {
        colour = "black"; 
      }
      return colour;
  }

  /*-----------------------------------------------*/
  /* Finds and Returns Specified Brush Size        */
  /*-----------------------------------------------*/
  public int getBrush()
  {
      int brush;

      if (jjtGetParent().getType().equals("Brush") == true )
      {
        brush = jjtGetParent().getBrush(); 
      }
      else if (jjtGetParent().getType().equals("Block") == true )
      {
        brush = jjtGetParent().getBrush(); 
      }
      else if (jjtGetParent().getType().equals("Offset") == true )
      {
        brush = jjtGetParent().getBrush(); 
      }      
      else if (jjtGetParent().getType().equals("Colour") == true )
      {
        brush = jjtGetParent().getBrush(); 
      }
      else 
      {
        brush = 1; 
      }
      return brush;
  }

  /*-----------------------------------------------*/
  /* Finds and Returns Specified X Offset          */
  /*-----------------------------------------------*/
  public int getOffsetX()
  {
      int offsetX;

      if (jjtGetParent().getType().equals("Brush") == true )
      {
        offsetX = jjtGetParent().getOffsetX(); 
      }
      else if (jjtGetParent().getType().equals("Block") == true )
      {
        offsetX = jjtGetParent().getOffsetX(); 
      }
      else if (jjtGetParent().getType().equals("Offset") == true )
      {
        offsetX = jjtGetParent().getOffsetValueX(); 
      }      
      else if (jjtGetParent().getType().equals("Colour") == true )
      {
        offsetX = jjtGetParent().getOffsetX(); 
      }
      else 
      {
        offsetX = 0; 
      }
      return offsetX;
  }

  /*-----------------------------------------------*/
  /* Finds and Returns Specified Y Offset          */
  /*-----------------------------------------------*/
  public int getOffsetY()
  {
      int offsetY;

      if (jjtGetParent().getType().equals("Brush") == true )
      {
        offsetY = jjtGetParent().getOffsetY(); 
      }
      else if (jjtGetParent().getType().equals("Block") == true )
      {
        offsetY = jjtGetParent().getOffsetY(); 
      }
      else if (jjtGetParent().getType().equals("Offset") == true )
      {
        offsetY = jjtGetParent().getOffsetValueY(); 
      }      
      else if (jjtGetParent().getType().equals("Colour") == true )
      {
        offsetY = jjtGetParent().getOffsetY(); 
      }
      else 
      {
        offsetY = 0; 
      }
      return offsetY;
  }

  public String getString() { return null; }
  public String getType() { return "undefined"; }
  public int getOffsetValueX() { return 0; }
  public int getOffsetValueY() { return 0; }
}
