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

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

  	public ASTPolygon(drawphase2 p, int id) 
  	{
    	super(p, id);
  	}
  	
  	/*************************************************
	
	Generates a string containing the SVG code for a
	polygon.
		
	*************************************************/  	
    
  	public String generateSVG()
  	{
  		String temp = "";
  		int childSize = sizeOfChild(), brushSize = 1, offsetX = 0, offsetY = 0;
  		
  		String colour="black";
  		
  		/*************************************************
	
		Checks to see whether the parent 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 whether the parent of the parent 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 whether the parent of the parent of the
				parent 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();
  					}
  				}
  			}
  		}
  		
  		/*************************************************
		
		Method to loop around the number of co-ordinates of
		the polygon and create the indiviual lines. The line
		outside the loop is the final line that links the final
		co-ordinate with the first to complete the polygon
	
		*************************************************/
  		
   		for(int i = 0; i < sizeOfChild()-2; i++)
   		{
   			temp = temp + ("<line");
   			temp = temp + (" x1=\"" + (((ASTInt) jjtGetChild(i)).val + offsetX) + "\"");
    		temp = temp + (" y1=\"" + (((ASTInt) jjtGetChild(i+1)).val + offsetY) + "\"");
   			temp = temp + (" x2=\"" + (((ASTInt) jjtGetChild(i+2)).val + offsetX) + "\"");
   			temp = temp + (" y2=\"" + (((ASTInt) jjtGetChild(i+3)).val + offsetY) + "\"");
   			temp = temp + (" stroke=\"" + colour + "\" stroke-width=\""+brushSize+"\"/>\n");
   			i = i+1;
   		}

    	
    	temp = temp + ("<line");
    	temp = temp + (" x1=\"" + (((ASTInt) jjtGetChild(childSize-2)).val + offsetX) + "\"");
    	temp = temp + (" y1=\"" + (((ASTInt) jjtGetChild(childSize-1)).val + offsetY) + "\"");
    	temp = temp + (" x2=\"" + (((ASTInt) jjtGetChild(0)).val + offsetX) + "\"");
    	temp = temp + (" y2=\"" + (((ASTInt) jjtGetChild(1)).val + offsetY) + "\"");
    	temp = temp + (" stroke=\"" + colour + "\" stroke-width=\""+brushSize+"\"/>");
    	
    	return temp;
    	
  	}
  	
  	/*************************************************
	
	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;
  	}

}
