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

public class ASTLine extends SimpleNode {
  String name = "line";
  public ASTLine(int id) {
    super(id);
  }

  public ASTLine(drawphase3 p, int id) {
    super(p, id);
  }

  public String generate(String colour, int brushSize, int offsetX, int offsetY, int scaleH, int scaleV)
  {    
    //Generates a line if a normal line [X Y X Y] function is called.
    String temp;     
    temp = makeLine(((ASTInt) jjtGetChild(0)).val, ((ASTInt) jjtGetChild(1)).val, ((ASTInt) jjtGetChild(2)).val, ((ASTInt) jjtGetChild(3)).val, colour, brushSize, offsetX, offsetY, scaleH, scaleV);
    return temp;
  }
  
  public static String makeLine(int x1, int y1, int x2, int y2, String colour, int brushSize, int offsetX, int offsetY, int scaleH, int scaleV)
  {
  	//Generates a line from any set of coordinates. All polygons use this method to create their lines
  	//All scaling and offsetting of points is done in this method for each line individually.
  	String temp;
  	x1 = x1 * scaleH;
  	x2 = x2 * scaleH;
  	y1 = y1 * scaleV;
  	y2 = y2 * scaleV;
  	
  	x1 += offsetX;
  	x2 += offsetX;
  	y1 += offsetY;
  	y2 += offsetY;
  	
  	//Returns the necessary SVG code.
    temp = ("<line x1=\"" + x1 +
        "\" y1=\"" + y1 +
        "\" x2=\"" + x2 +
        "\" y2=\"" + y2 +
        "\" stroke=\"" + colour + "\" stroke-width=\"" + brushSize + "\"/>");
        
    System.out.println(temp);
    return temp;
  }
  
  public String getName()
  {
     return name;
  }

}
