/* 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(drawphase3 p, int id) 
  	{
    	super(p, id);
  	}
  	
  	/*************************************************

	Loops through all of the children of the offset node
	and prints them to the console
						
	*************************************************/
  	
  	public void generate()
  	{
  		int offsetX = ((ASTInt) jjtGetChild(0)).val;
  		int offsetY = ((ASTInt) jjtGetChild(1)).val;
  		int combineOffset = offsetX + offsetY;
  		
  		/*************************************************

		If the first child is not of type offset, the the loop
		begins with the first child
						
		*************************************************/
  		
  		if(combineOffset==0)
  		{
  			for(int i = 0; i < jjtGetNumChildren(); i++)
  			{
  				System.out.println(jjtGetChild(i).generateSVG());
  			}
  		}
  		
  		/*************************************************

		If the first child IS of type offset, the the loop
		begins with the second child
						
		*************************************************/
  		
  		else
  		{
  			
  			for(int i = 2; i < jjtGetNumChildren(); i++)
  			{
  				
  				System.out.println(jjtGetChild(i).generateSVG());
  			}
  		}
  	}
  	
  	/*************************************************
	
	Similar to above but instead of printing to console,
	the SVG code is returned in a string
						
	*************************************************/
  	
  	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 needed by Node interface
	
	*************************************************/
	
	/*************************************************

	Returns the node type for distinction between offset,
	colour, brush, scale and repeat
						
	*************************************************/
  	
  	public String getParentType()
  	{
  		String type = "offset";
  		
  		return type;
  	}
  	
  	/*************************************************

	Returns the value of the X offset value
	
	*************************************************/
  	
  	public int getOffsetX()
  	{
  		int offsetX = ((ASTInt) jjtGetChild(0)).val;
  		
  		return offsetX;
  	}
  	
  	/*************************************************

	Returns the value of the Y offset value
	
	*************************************************/
  	
  	public int getOffsetY()
  	{
  		int offsetY = ((ASTInt) jjtGetChild(1)).val;
  		
  		return offsetY;
  	}
  	
  	public int getScaleX()
  	{
  		return 0;
  	}
  
  	public int getScaleY()
  	{
  		return 0;
  	}
  	
  	public int getRepeatX()
  	{
  		return 0;
  	}
  	
  	public int getRepeatY()
  	{
  		return 0;
  	}
  	
  	public int getNoRepeat()
  	{
  		return 0;
  	}

}
