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

public class ASTOffset extends SimpleNode 
{
	String Offset;
	
	/*************************************************
	
					Constructors
		
	*************************************************/
	
	public ASTOffset(int id) 
	{
    	super(id);
  	}

  	public ASTOffset(drawphase2 p, int id) 
  	{
    	super(p, id);
  	}
  	
  	/*************************************************
	
	Generates all the children of the offset parent and
	prints them to the console. if the first child is 
	seen to be a offset element, the loop begins with the 
	second child, if not it begins with	the first
		
	*************************************************/
  	
  	public void generate()
  	{
  		int offsetX = ((ASTInt) jjtGetChild(0)).val;
  		int offsetY = ((ASTInt) jjtGetChild(1)).val;
  		int combineOffset = offsetX + offsetY;
  		
  		//Checks if first element is and offset node
  		
  		if(combineOffset==0)
  		{
  			for(int i = 0; i < jjtGetNumChildren(); i++)
  			{
  				System.out.println(jjtGetChild(i).generateSVG());
  			}
  		}
  		
  		else
  		{
  			
  			for(int i = 2; i < jjtGetNumChildren(); i++)
  			{
  				
  				System.out.println(jjtGetChild(i).generateSVG());
  			}
  		}
  	}
  	
  	/*************************************************
	
	Generates all the children of the colour parent and
	prints them to the console. if the first child is 
	seen to be a colour element, the loop begins with the 
	second child, if not it begins with	the first
		
	*************************************************/
  	
  	public String generateSVG()
  	{
  		String temp = "";
  		
  		int offsetX = ((ASTInt) jjtGetChild(0)).val;
  		int offsetY = ((ASTInt) jjtGetChild(1)).val;
  		int combineOffset = offsetX + offsetY;
  		
  		if(combineOffset==0)
  		{
  			for(int i = 1; i < jjtGetNumChildren(); i++)
  			{
  				temp = temp + jjtGetChild(i).generateSVG();
  			}
  		}
  		
  		else
  		{
  			for(int i = 2; i < jjtGetNumChildren(); i++)
  			{
  				temp = temp + jjtGetChild(i).generateSVG();
  			}
  		}
  		
  		return temp;
  	}
  	
  	/*************************************************
	
	Methods required by Node interface
		
	*************************************************/
  	
  	/*************************************************
	
	Returns "offset" as the parent type so it can be
	destingushed from colour and brush
		
	*************************************************/
  	
  	public String getColour()
  	{
  		return null;
  	}
  	
  	public int getBrush()
  	{
  		return 0;
  	}
  	
  	public String getParentType()
  	{
  		String type = "offset";
  		
  		return type;
  	}
  	
  	/*************************************************
	
	getOffsetX() and getOffsetY() return the relivant
	value of each for use within the shape objects
		
	*************************************************/
  	
  	public int getOffsetX()
  	{
  		int offsetX = ((ASTInt) jjtGetChild(0)).val;
  		
  		return offsetX;
  	}
  	
  	public int getOffsetY()
  	{
  		int offsetY = ((ASTInt) jjtGetChild(1)).val;
  		
  		return offsetY;
  	}

}
