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

public class ASTTriangle extends SimpleNode 
{
  	/*************************************************

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

  	public ASTTriangle(drawphase3 p, int id) 
  	{
    	super(p, id);
  	}
  	
	/*************************************************

	Returns a string with the SVG code for the three lines
	that make up the triangle object.
	
	*************************************************/
  
  	public String generateSVG()
  	{
  		String triangle, sideA="", sideB="", sideC="", colour="black";
  		int brushSize = 1, offsetX = 0, offsetY = 0, scaleX = 1, scaleY = 1, 
  			repeatX = 0, repeatY = 0, noRepeat = 1;
  			
  		//Sets up each co-ordinate of the triangle from the child values
  		
  		int x1 = ((ASTInt) jjtGetChild(0)).val;
    	int y1 = ((ASTInt) jjtGetChild(1)).val;
    	int	x2 = ((ASTInt) jjtGetChild(2)).val;
    	int	y2 = ((ASTInt) jjtGetChild(3)).val;
    	int	x3 = ((ASTInt) jjtGetChild(4)).val;
    	int	y3 = ((ASTInt) jjtGetChild(5)).val;
    	
    	/*************************************************

		Checks if parent type is null
		
		*************************************************/
  		
  		if(!(jjtGetParent().getParentType() == null))
        {
        
  			if(jjtGetParent().getParentType().equals("brush"))
  			{
  				brushSize = jjtGetParent().getBrush();
  			}
  		
  			if(jjtGetParent().getParentType().equals("colour"))
  			{
  				colour = jjtGetParent().getColour();
  			}
  		
  			if(jjtGetParent().getParentType().equals("offset"))
  			{
  				offsetX = jjtGetParent().getOffsetX();
  				offsetY = jjtGetParent().getOffsetY();
  				
  				x1 = x1 + offsetX; 
  				y1 = y1 + offsetY;
				x2 = x2 + offsetX; 
				y2 = y2 + offsetY;
				x3 = x3 + offsetX;
				y3 = y3 + offsetY;
  			}
  			
  			if(jjtGetParent().getParentType().equals("scale"))
  			{
  				scaleX = jjtGetParent().getScaleX();
  				scaleY = jjtGetParent().getScaleY();
  				
  				x1 = x1 * scaleX; 
  				y1 = y1 * scaleY;
  				x2 = x2 * scaleX; 
  				y2 = y2 * scaleY;
  				x3 = x3 * scaleX;
  				y3 = y3 * scaleY;
  			}
  			
  			if(jjtGetParent().getParentType().equals("repeat"))
  			{
  				repeatX = jjtGetParent().getRepeatX();
  				repeatY = jjtGetParent().getRepeatY();
  				noRepeat = jjtGetParent().getNoRepeat();
  			}
  			
  			/*************************************************

			Checks if parent of parent's type is null
		
			*************************************************/
  			
  			if(!(jjtGetParent().jjtGetParent().getParentType() == null))
        	{
  		
  				if(jjtGetParent().jjtGetParent().getParentType().equals("brush"))
  				{
  					brushSize = jjtGetParent().jjtGetParent().getBrush();
  				}
  		
  				if(jjtGetParent().jjtGetParent().getParentType().equals("colour"))
  				{
  					colour = jjtGetParent().jjtGetParent().getColour();
  				}
  		
  				if(jjtGetParent().jjtGetParent().getParentType().equals("offset"))
  				{
  					offsetX = jjtGetParent().jjtGetParent().getOffsetX();
  					offsetY = jjtGetParent().jjtGetParent().getOffsetY();
  					
  					x1 = x1 + offsetX; 
  					y1 = y1 + offsetY;
					x2 = x2 + offsetX; 
					y2 = y2 + offsetY;
					x3 = x3 + offsetX;
					y3 = y3 + offsetY;
  				}
  				
  				if(jjtGetParent().jjtGetParent().getParentType().equals("scale"))
  				{
  					scaleX = jjtGetParent().jjtGetParent().getScaleX();
  					scaleY = jjtGetParent().jjtGetParent().getScaleY();
  					
  					x1 = x1 * scaleX; 
  					y1 = y1 * scaleY;
  					x2 = x2 * scaleX; 
  					y2 = y2 * scaleY;
  					x3 = x3 * scaleX;
  					y3 = y3 * scaleY;
  				}
  				
  				if(jjtGetParent().jjtGetParent().getParentType().equals("scale"))
  				{
  					scaleX = jjtGetParent().jjtGetParent().getScaleX();
  					scaleY = jjtGetParent().jjtGetParent().getScaleY();
  					
  					x1 = x1 * scaleX;
  					y1 = y1 * scaleY;
  					x2 = x2 * scaleX;
  					y2 = y2 * scaleY;
  				}
  				
  				if(jjtGetParent().jjtGetParent().getParentType().equals("repeat"))
  				{
  					repeatX = jjtGetParent().jjtGetParent().getRepeatX();
  					repeatY = jjtGetParent().jjtGetParent().getRepeatY();
  					noRepeat = jjtGetParent().jjtGetParent().getNoRepeat();
  				}
  				
  				/*************************************************

				Checks if parent of parent of parent's type is null
		
				*************************************************/
  				
  				if(!(jjtGetParent().jjtGetParent().jjtGetParent().getParentType() == null))
  				{
  					if(jjtGetParent().jjtGetParent().jjtGetParent().getParentType().equals("brush"))
  					{
  						brushSize = jjtGetParent().jjtGetParent().jjtGetParent().getBrush();
  					}
  		
  					if(jjtGetParent().jjtGetParent().jjtGetParent().getParentType().equals("colour"))
  					{
  						colour = jjtGetParent().jjtGetParent().jjtGetParent().getColour();
  					}
  		
  					if(jjtGetParent().jjtGetParent().jjtGetParent().getParentType().equals("offset"))
  					{	
  						offsetX = jjtGetParent().jjtGetParent().jjtGetParent().getOffsetX();
  						offsetY = jjtGetParent().jjtGetParent().jjtGetParent().getOffsetY();
  						
  						x1 = x1 + offsetX; 
  						y1 = y1 + offsetY;
						x2 = x2 + offsetX; 
						y2 = y2 + offsetY;
						x3 = x3 + offsetX;
						y3 = y3 + offsetY;
  					}
  					
  					if(jjtGetParent().jjtGetParent().jjtGetParent().getParentType().equals("scale"))
  					{
  						scaleX = jjtGetParent().jjtGetParent().jjtGetParent().getScaleX();
  						scaleY = jjtGetParent().jjtGetParent().jjtGetParent().getScaleY();
  						
  						x1 = x1 * scaleX; 
  						y1 = y1 * scaleY;
  						x2 = x2 * scaleX; 
  						y2 = y2 * scaleY;
  						x3 = x3 * scaleX;
  						y3 = y3 * scaleY;
  					}
  					
  					if(jjtGetParent().jjtGetParent().jjtGetParent().getParentType().equals("repeat"))
  					{
  						repeatX = jjtGetParent().jjtGetParent().jjtGetParent().getRepeatX();
  						repeatY = jjtGetParent().jjtGetParent().jjtGetParent().getRepeatY();
  						noRepeat = jjtGetParent().jjtGetParent().jjtGetParent().getNoRepeat();
  					}
  					
  					/*************************************************

					Checks if parent of parent of parent of parent's 
					type is null
		
					*************************************************/
  					
  					if(!(jjtGetParent().jjtGetParent().jjtGetParent().jjtGetParent().getParentType() == null))
  					{
  						if(jjtGetParent().jjtGetParent().jjtGetParent().jjtGetParent().getParentType().equals("brush"))
  						{
  							brushSize = jjtGetParent().jjtGetParent().jjtGetParent().jjtGetParent().getBrush();
  						}
  		
  						if(jjtGetParent().jjtGetParent().jjtGetParent().jjtGetParent().getParentType().equals("colour"))
  						{
  							colour = jjtGetParent().jjtGetParent().jjtGetParent().jjtGetParent().getColour();
  						}
  		
  						if(jjtGetParent().jjtGetParent().jjtGetParent().jjtGetParent().getParentType().equals("offset"))
  						{	
  							offsetX = jjtGetParent().jjtGetParent().jjtGetParent().jjtGetParent().getOffsetX();
  							offsetY = jjtGetParent().jjtGetParent().jjtGetParent().jjtGetParent().getOffsetY();
  							
  							x1 = x1 + offsetX; 
  							y1 = y1 + offsetY;
							x2 = x2 + offsetX; 
							y2 = y2 + offsetY;
							x3 = x3 + offsetX;
							y3 = y3 + offsetY;
  						}
  					
  						if(jjtGetParent().jjtGetParent().jjtGetParent().jjtGetParent().getParentType().equals("scale"))
  						{
  							scaleX = jjtGetParent().jjtGetParent().jjtGetParent().jjtGetParent().getScaleX();
  							scaleY = jjtGetParent().jjtGetParent().jjtGetParent().jjtGetParent().getScaleY();
  							
  							x1 = x1 * scaleX; 
  							y1 = y1 * scaleY;
  							x2 = x2 * scaleX; 
			  				y2 = y2 * scaleY;
  							x3 = x3 * scaleX;
			  				y3 = y3 * scaleY;
  						}
  						
  						if(jjtGetParent().jjtGetParent().jjtGetParent().jjtGetParent().getParentType().equals("repeat"))
  						{
  							repeatX = jjtGetParent().jjtGetParent().jjtGetParent().jjtGetParent().getRepeatX();
  							repeatY = jjtGetParent().jjtGetParent().jjtGetParent().jjtGetParent().getRepeatY();
  							noRepeat = jjtGetParent().jjtGetParent().jjtGetParent().jjtGetParent().getNoRepeat();
  						}
  						
  						/*************************************************

						Checks if parent of parent of parent of parent of 
						parent's type is null
		
						*************************************************/
  						
  						if(!(jjtGetParent().jjtGetParent().jjtGetParent().jjtGetParent().jjtGetParent().getParentType() == null))
  						{
  							if(jjtGetParent().jjtGetParent().jjtGetParent().jjtGetParent().getParentType().equals("brush"))
  							{
  								brushSize = jjtGetParent().jjtGetParent().jjtGetParent().jjtGetParent().getBrush();
  							}
  		
	  						if(jjtGetParent().jjtGetParent().jjtGetParent().jjtGetParent().getParentType().equals("colour"))
  							{
  								colour = jjtGetParent().jjtGetParent().jjtGetParent().jjtGetParent().getColour();
  							}
  		
  							if(jjtGetParent().jjtGetParent().jjtGetParent().jjtGetParent().getParentType().equals("offset"))
  							{	
  								offsetX = jjtGetParent().jjtGetParent().jjtGetParent().jjtGetParent().getOffsetX();
  								offsetY = jjtGetParent().jjtGetParent().jjtGetParent().jjtGetParent().getOffsetY();
  							
	  							x1 = x1 + offsetX; 
	  							y1 = y1 + offsetY;
		 	 					x2 = x2 + offsetX; 
		 	 					y2 = y2 + offsetY;
		 	 					x3 = x3 + offsetX;
		 	 					y3 = y3 + offsetY;
  							}
  						
  							if(jjtGetParent().jjtGetParent().jjtGetParent().jjtGetParent().getParentType().equals("scale"))
  							{
  								scaleX = jjtGetParent().jjtGetParent().jjtGetParent().jjtGetParent().jjtGetParent().getScaleX();
  								scaleY = jjtGetParent().jjtGetParent().jjtGetParent().jjtGetParent().jjtGetParent().getScaleY();
  							
  								x1 = x1 * scaleX; 
  								y1 = y1 * scaleY;
  								x2 = x2 * scaleX;
  								y2 = y2 * scaleY;
  								x3 = x3 * scaleX;
  								y3 = y3 * scaleY;
  							}
  						
  							if(jjtGetParent().jjtGetParent().jjtGetParent().jjtGetParent().jjtGetParent().getParentType().equals("repeat"))
  							{
  								repeatX = jjtGetParent().jjtGetParent().jjtGetParent().jjtGetParent().jjtGetParent().getRepeatX();
  								repeatY = jjtGetParent().jjtGetParent().jjtGetParent().jjtGetParent().jjtGetParent().getRepeatY();
  								noRepeat = jjtGetParent().jjtGetParent().jjtGetParent().jjtGetParent().jjtGetParent().getNoRepeat();
  							}
  						}
  					}
  				}
  			}
  		}
  		
  		/*************************************************

		Loop to initiate repeat command if required. Loops
		through for the number of repeats required and 
		increments each individual variable of the circle
		for each loop

		*************************************************/
  		
  		int inc = 1;
  		
  		for(int i = 0; i < noRepeat; i++)
  		{
  		
	  		sideA = sideA + ("<line x1=\"" + (x1 + (inc*repeatX)) +
	        	"\" y1=\"" + (y1 + (inc*repeatY)) +
	        	"\" x2=\"" + (x2 + (inc*repeatX)) +
	        	"\" y2=\"" + (y2 + (inc*repeatY)) +
	        	"\" stroke=\""+colour+"\" stroke-width=\""+brushSize+"\"/>\n");
	        	
	        sideB = sideB + ("<line x1=\"" + (x3 + (inc*repeatX)) +
	        	"\" y1=\"" + (y3 + (inc*repeatY)) + 
	        	"\" x2=\"" + (x2 + (inc*repeatX)) +
	        	"\" y2=\"" + (y2 + (inc*repeatY)) +
	        	"\" stroke=\""+colour+"\" stroke-width=\""+brushSize+"\"/>\n");
	        
	        sideC = sideC + ("<line x1=\"" + (x1 + (inc*repeatX)) +
	        	"\" y1=\"" + (y1 + (inc*repeatY)) +
	        	"\" x2=\"" + (x3 + (inc*repeatX)) +
	        	"\" y2=\"" + (y3 + (inc*repeatY)) +
	        	"\" stroke=\""+colour+"\" stroke-width=\""+brushSize+"\"/>\n");
	        	
	        inc++;
        }
        
        triangle = sideA + sideB + sideC;
        
        return triangle;
  	}
  	
  	/*************************************************

	Methods required by Node interface
	
	*************************************************/
  	
  	public void generate()
  	{
    }
  	
  	public int getBrush()
  	{
  		return 0;
  	}
  	 
  	 public String getColour()
  	{
  		return null;
  	}
  	
  	public String getParentType()
  	{
  		return null;
  	}
  	
  	public int getOffsetX()
  	{
  		return 0;
  	}
  
  	public int getOffsetY()
	{
  		return 0;
  	}
  	
  	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;
  	}

}
