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

public class ASTRectangle extends SimpleNode 
{
	/*************************************************
	
					Constructors
	
	*************************************************/
	
	public ASTRectangle(int id) 
	{
    	super(id);
  	}

  	public ASTRectangle(drawphase2 p, int id) 
  	{
    	super(p, id);
  	}

  	/*************************************************
	
	Method to return a string containing the SVG code for
	a rectangle
	
	*************************************************/
  
  	public String generateSVG()
  	{
  		String rectangle, right, left, top, bottom, colour = "black";
  		int brushSize = 1, offsetX = 0, offsetY = 0;
  		
  		/*************************************************
	
		Checks to see if the parent type is null
	
		*************************************************/
  		
  		if(!(jjtGetParent().getParentType() == null))
        {
        
  			if(jjtGetParent().getParentType().equals("brush"))
  			{
  				brushSize = jjtGetParent().getBrush();
  			}
  		
  			if(jjtGetParent().getParentType().equals("colour"))
  			{
  				colour = jjtGetParent().getColour();
  			}
  		
  			if(jjtGetParent().getParentType().equals("offset"))
  			{
  				System.out.println("inside offset");
  				offsetX = jjtGetParent().getOffsetX();
  				offsetY = jjtGetParent().getOffsetY();
  			}
  			
  			/*************************************************
	
			Checks to see if the parent of the parent's type is null
	
			*************************************************/
  			
  			if(!(jjtGetParent().jjtGetParent().getParentType() == null))
        	{
  		
  				if(jjtGetParent().jjtGetParent().getParentType().equals("brush"))
  				{
  					brushSize = jjtGetParent().jjtGetParent().getBrush();
  				}
  		
  				if(jjtGetParent().jjtGetParent().getParentType().equals("colour"))
  				{
  					colour = jjtGetParent().jjtGetParent().getColour();
  				}
  		
  				if(jjtGetParent().jjtGetParent().getParentType().equals("offset"))
  				{
  					System.out.println("inside parent offset");
  					offsetX = jjtGetParent().jjtGetParent().getOffsetX();
  					offsetY = jjtGetParent().jjtGetParent().getOffsetY();
  				}
  				
  				/*************************************************
	
				Checks to see if the parent of the parent of the 
				parent's type is null
		
				*************************************************/
  				
  				if(!(jjtGetParent().jjtGetParent().jjtGetParent().getParentType() == null))
  				{
  					if(jjtGetParent().jjtGetParent().jjtGetParent().getParentType().equals("brush"))
  					{
  						brushSize = jjtGetParent().jjtGetParent().jjtGetParent().getBrush();
  					}
  		
  					if(jjtGetParent().jjtGetParent().jjtGetParent().getParentType().equals("colour"))
  					{
  						colour = jjtGetParent().jjtGetParent().jjtGetParent().getColour();
  					}
  		
  					if(jjtGetParent().jjtGetParent().jjtGetParent().getParentType().equals("offset"))
  					{	
  						offsetX = jjtGetParent().jjtGetParent().jjtGetParent().getOffsetX();
  						offsetY = jjtGetParent().jjtGetParent().jjtGetParent().getOffsetY();
  					}
  				}
  			}
  		}
  		
  		/*************************************************
	
		Adds the SVG line code to a string to create the whole
		rectangle object
	
		*************************************************/
  		
  		right = ("<line x1=\"" + (((ASTInt) jjtGetChild(0)).val + offsetX) +
        	"\" y1=\"" + (((ASTInt) jjtGetChild(1)).val + offsetY) +
        	"\" x2=\"" + (((ASTInt) jjtGetChild(0)).val + offsetX) +
        	"\" y2=\"" + (((ASTInt) jjtGetChild(3)).val + offsetY) +
        	"\" stroke=\"" + colour + "\" stroke-width=\""+brushSize+"\"/>");
        	
        left = ("<line x1=\"" + (((ASTInt) jjtGetChild(2)).val + offsetX) +
        	"\" y1=\"" + (((ASTInt) jjtGetChild(1)).val + offsetY) +
        	"\" x2=\"" + (((ASTInt) jjtGetChild(2)).val + offsetX) +
        	"\" y2=\"" + (((ASTInt) jjtGetChild(3)).val + offsetY) +
        	"\" stroke=\"" + colour + "\" stroke-width=\""+brushSize+"\"/>");
        
        top = ("<line x1=\"" + (((ASTInt) jjtGetChild(0)).val + offsetX) +
        	"\" y1=\"" + (((ASTInt) jjtGetChild(1)).val + offsetY) +
        	"\" x2=\"" + (((ASTInt) jjtGetChild(2)).val + offsetX) +
        	"\" y2=\"" + (((ASTInt) jjtGetChild(1)).val + offsetY) +
        	"\" stroke=\"" + colour + "\" stroke-width=\""+brushSize+"\"/>");
        
        bottom = ("<line x1=\"" + (((ASTInt) jjtGetChild(0)).val + offsetX) +
        	"\" y1=\"" + (((ASTInt) jjtGetChild(3)).val + offsetX) +
        	"\" x2=\"" + (((ASTInt) jjtGetChild(2)).val + offsetX) +
        	"\" y2=\"" + (((ASTInt) jjtGetChild(3)).val + offsetX) +
        	"\" stroke=\"" + colour + "\" stroke-width=\""+brushSize+"\"/>");
        	
        rectangle = right + left + top + bottom;
        
        return rectangle;
  	}
  	
  	/*************************************************
	
	Methods required by Node interface
	
	*************************************************/
  	
  	public void generate()
  	{
  	}
  	
  	public int getBrush()
  	{
  		return 0;
  	}
  	 
  	 public String getColour()
  	{
  		return null;
  	}
  	
  	public String getParentType()
  	{
  		return null;
  	}
  	
  	public int getOffsetX()
  	{
  		return 0;
  	}
  
  	public int getOffsetY()
	{
  		return 0;
  	}

}
