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

public class ASTEllipse extends SimpleNode {
  public ASTEllipse(int id) {
    super(id);
  }

  public ASTEllipse(drawphase1 p, int id) {
    super(p, id);
  }
  
  public String generate()
  {
  	String temp;
  	int centerX, centerY, rX, rY;
  	//Calculates the center point and the radii for Ellipses.
  	if (jjtGetNumChildren() == 4)
  	{
  		centerX = (((ASTInt) jjtGetChild(0)).val + ((ASTInt) jjtGetChild(2)).val)/2;
  		centerY = (((ASTInt) jjtGetChild(1)).val + ((ASTInt) jjtGetChild(3)).val)/2;
  		if(((ASTInt) jjtGetChild(2)).val > ((ASTInt) jjtGetChild(0)).val)
  		{
  			rX = (((ASTInt) jjtGetChild(2)).val - ((ASTInt) jjtGetChild(0)).val)/2;
  		}
  		else
  		{
  			rX = (((ASTInt) jjtGetChild(0)).val - ((ASTInt) jjtGetChild(2)).val)/2;
  		}
  		
  		if(((ASTInt) jjtGetChild(1)).val > ((ASTInt) jjtGetChild(3)).val)
  		{  		
  			rY = (((ASTInt) jjtGetChild(1)).val - ((ASTInt) jjtGetChild(3)).val)/2;
  		}
  		else
  		{
  			rY = (((ASTInt) jjtGetChild(3)).val - ((ASTInt) jjtGetChild(1)).val)/2;
  		}
    }
    //Calculates the center point and the radii for Circles.
    else
    {
    	centerX = (((ASTInt) jjtGetChild(0)).val + ((ASTInt) jjtGetChild(2)).val)/2;
    	centerY = ((ASTInt) jjtGetChild(1)).val + ((((ASTInt) jjtGetChild(2)).val - ((ASTInt) jjtGetChild(0)).val)/2);
    	if(((ASTInt) jjtGetChild(2)).val > ((ASTInt) jjtGetChild(0)).val)
  		{
  			rX = (((ASTInt) jjtGetChild(2)).val - ((ASTInt) jjtGetChild(0)).val)/2;
  		}
  		else
  		{
  			rX = (((ASTInt) jjtGetChild(0)).val - ((ASTInt) jjtGetChild(2)).val)/2;
  		}
    	rY = rX;
    }
       	    
        
    //Prints out and returns the necessary line of SVG code.
    temp = ("<ellipse transform=\"translate(" + centerX + " " + centerY + ")\" rx=\"" + rX + "\" ry=\"" + rY + "\" fill=\"none\" stroke = \"black\" stroke-width=\"1\"  />");
	System.out.println(temp);
	return temp;
    
  }
}
