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

public class ASTRepeat extends SimpleNode 
{
	String repeat;
	
	/*************************************************

						Constructors
						
	*************************************************/
	
	public ASTRepeat(int id) 
	{
    	super(id);
  	}

  	public ASTRepeat(drawphase3 p, int id) 
  	{
    	super(p, id);
  	}
  	
  	/*************************************************
	
	Loops through all the children of the repeat node
	and prints them to the console

	*************************************************/
  	
  	public void generate()
  	{
  		 int i, k = jjtGetNumChildren();
  		 String isRepeat = getParentType();
  		 
  		 /*************************************************
	
		Checks if the first child is of type repeat. If it is
		NOT a repeat node, then the loop begins at 0

		*************************************************/
  		 
  		 if(isRepeat==null)
  		 {  		 
  		 	for(i = 0; i < k; i++)
  		 	{
  		 		System.out.println(jjtGetChild(i).generateSVG());
  		 	}
  		 }
  		 
  		 /*************************************************
	
		If the first child is a repeat node then the loop begins
		from the second child

		*************************************************/
		
  		 else
  		 {
  		 	for(i = 1; i < k; i++)
  		 	{
  		 		System.out.println(jjtGetChild(i).generateSVG());
  		 	}
  		 }
  	}
  	
  	/*************************************************
	
	Method as above but returns a string instead of
	printing to the console

	*************************************************/
  	
  	public String generateSVG()
  	{
  		int i, k = jjtGetNumChildren();
  		String isRepeat = getParentType(), temp = "";
  		
  		if(isRepeat==null)
  		{  		 
  			for(i = 0; i < k; i++)
  		 	{
  		 		temp = jjtGetChild(i).generateSVG();
  		 	}
  		}
  		else
  		{
  		 	for(i = 1; i < k; i++)
  		 	{
  		 		temp = jjtGetChild(i).generateSVG();
  		 	}
  		}
  		
  		return temp;
  	}
  	
  	/*************************************************
	
	Methods required by Node interface

	*************************************************/
  	
   	public int getBrush()
  	{
  		return 0;
  	}
  	
  	public String getColour()
  	{
    	return null;
  	}
  	
  	/*************************************************
		
	Returns the type of node	

	*************************************************/
  	
  	public String getParentType()
  	{
  		String type = "repeat";
  		
  		return type;
  	}
  	
  	public int getOffsetX()
  	{
  		return 0;
  	}
  
  	public int getOffsetY()
	{
  		return 0;
  	}
  	
  	public int getScaleX()
  	{
  		return 0;
  	}
  
  	public int getScaleY()
  	{
  		return 0;
  	} 
  	
  	/*************************************************
	
	Returns the increment in the X axis of each repeated
	shape

	*************************************************/	
  	
  	public int getRepeatX()
  	{
  		int repeatX = ((ASTInt) jjtGetChild(0)).val;
  		
  		return repeatX;
  	}
  	
  	/*************************************************
	
	Returns the increment in the Y axis of each repeated
	shape

	*************************************************/	
  	
  	public int getRepeatY()
  	{
  		int repeatY = ((ASTInt) jjtGetChild(1)).val;
  		
  		return repeatY;
  	}
  	
  	/*************************************************
	
	Returns the number of repreated shapes required

	*************************************************/	
  	
  	public int getNoRepeat()
  	{
  		int getNoRepeat = ((ASTInt) jjtGetChild(2)).val;

   		return getNoRepeat;
  	}

}
