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

public class ASTBlock extends SimpleNode {
  String name = "block";
  
  public ASTBlock(int id) {
    super(id);
  }

  public ASTBlock(drawphase2 p, int id) {
    super(p, id);
  }
  
  public String generate(String colour, int brushSize, int offsetX, int offsetY)
  {
  	String temp = "";
  	//generates each child in the block.
  	for(int i = 0; i < jjtGetNumChildren(); i++)
    {    		
    	String childName = jjtGetChild(i).getName();
    	
    		//This block works out the type of each child before generation.    		
    		if (childName.equals("colour") == true)
    		{
    			colour = jjtGetChild(i).generate(colour, brushSize, offsetX, offsetY);
    		}
    		else if (childName.equals("brush") == true)
    		{
    			brushSize = Integer.parseInt(jjtGetChild(i).generate(colour, brushSize, offsetX, offsetY));
    		}
    		else if (childName.equals("offset") == true)
    		{
    			offsetX += jjtGetChild(i).generateX();
    			offsetY += jjtGetChild(i).generateY();
    		}
    		else
    		{
    			temp += (jjtGetChild(i).generate(colour, brushSize, offsetX, offsetY)); 
    			  
    			//resets all the variables if returning from a block.
    			if(childName.equals("block") == true)
    			{
    				colour = "black";
    				brushSize = 1;
    				offsetX = 0;
    				offsetY = 0;
    			}  			    			
    		}    
    				
    }
    return temp;
  }
  
  public String getName()
  {
  	return name;
  }

}
