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

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

  	public ASTColour(drawphase2 p, int id) 
  	{
    	super(p, id);
  	} 
  	
  	/*************************************************
	
	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 void generate()
  	{
  		int i, k = jjtGetNumChildren();
  		
  		colour = ((ASTLiteral) jjtGetChild(0)).name;
  		
  		//If first child IS NOT a colour element
  		
  		if(colour.equals("null"))
  		{
  		   	for (i = 0; i < k; i++)
  		   	{
        		System.out.println(jjtGetChild(i).generateSVG());
        	
        	}
        }
        
        //If first child IS a colour element
        
        else
        {
        	for (i = 1; i < k; i++)
        	{
        		System.out.println(jjtGetChild(i).generateSVG());
        	}
        }
  		  		 		
  	}
  	
  	/*************************************************
	
	generateSVG() creates a string holding all the children 
	of the colour parent and returns them. 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()
  	{
  		int i, k = jjtGetNumChildren();
  		String temp ="";
  		
  		colour = ((ASTLiteral) jjtGetChild(0)).name;
  		
  		//If first child IS NOT a colour element
  		
  		if(colour.equals("null"))
  		{
  			for (i = 0; i < k; i++)
     		{
        		temp = temp + jjtGetChild(i).generateSVG();
        	}
        }
        
        //If first child IS a colour element
        
        else
        {
        	for (i = 1; i < k; i++)
     		{
        		temp = temp + jjtGetChild(i).generateSVG();
        	}
        }
  		
  		return temp;
  	}
  	
  	/*************************************************
	
	Methods required by Node interface
		
	*************************************************/	
  	
   	public int getBrush()
  	{
  		return 0;
  	}
  	
  	/*************************************************
	
	Obtains the colour given and returns it for use in
	the shapes
		
	*************************************************/	
  	
  	public String getColour()
  	{
    	colour = ((ASTLiteral) jjtGetChild(0)).name;
    	
    	return colour;
  	}
  	
  	/*************************************************
	
	Returns the parent type for distinction between colour,
	brush and offset
		
	*************************************************/	
  	
  	public String getParentType()
  	{
  		String type = "colour";
  		
  		return type;
  	}
  	
  	public int getOffsetX()
  	{
  		return 0;
  	}
  
  	public int getOffsetY()
	{
  		return 0;
  	}
}
