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

public class ASTCircle extends SimpleNode 
{
  	/*************************************************

					Constructors

	*************************************************/
  	
  	public ASTCircle(int id) 
  	{
    	super(id);
  	}

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

	Returns a string containing the SVG code for the file
	writer to use in ASTProgram

	*************************************************/  	
  
  	public String generateSVG()
  	{
  		String colour="black", temp ="";
  		int brushSize = 1, offsetX = 0, offsetY = 0, scaleX = 1, scaleY = 1, 
  			repeatX = 0, repeatY = 0, noRepeat = 1;
  		
  		//Sets up the variables and the value of the children
  		
  		int cx = ((ASTInt) jjtGetChild(0)).val;
  		int cy = ((ASTInt) jjtGetChild(1)).val;
  		int rx = ((ASTInt) jjtGetChild(2)).val;
  		int ry = ((ASTInt) jjtGetChild(2)).val;
  	
  		int width = (rx - cx);
  		int height = (ry - cy); 
  		
  		int cx1 = cx + (width/2);
  		int cy1 = cy + (height/2);
  		int rx1;
  		int ry1;
  		
  		/*************************************************

		Checks if parent 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();
  				
  				width = (rx + offsetX) - (cx + offsetX);
  				height = (ry + offsetX) - (cy + offsetY); 
  				
  				cx1 = (cx + offsetX) + (width/2);
  				cy1 = (cy + offsetY) + (height/2);
  			}
  			
  			if(jjtGetParent().getParentType().equals("scale"))
  			{
  				scaleX = jjtGetParent().getScaleX();
  				scaleY = jjtGetParent().getScaleY();
  				
  				width = ((rx * scaleX) - (cx * scaleX));
  				height = ((ry * scaleY) - (cy * scaleY));
  				cx1 = (width/2) * scaleX;
  				cy1 = (height/2) * scaleY;		
  			}
  			
  			if(jjtGetParent().getParentType().equals("repeat"))
  			{
  				repeatX = jjtGetParent().getRepeatX();
  				repeatY = jjtGetParent().getRepeatY();
  				noRepeat = jjtGetParent().getNoRepeat();
  				System.out.println(noRepeat);
  			}
  			
  			/*************************************************

			Checks if parent of parent 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();
  				
  					width = (rx + offsetX) - (cx + offsetX);
  					height = (ry + offsetX) - (cy + offsetY); 
  				
  					cx1 = (cx + offsetX) + (width/2);
  					cy1 = (cy + offsetY) + (height/2);
  				}
  				
  				if(jjtGetParent().jjtGetParent().getParentType().equals("scale"))
				{
					scaleX = jjtGetParent().jjtGetParent().getScaleX();
  					scaleY = jjtGetParent().jjtGetParent().getScaleY(); 
  				  				
  					width = ((rx * scaleX) - (cx * scaleX));
  					height = ((ry * scaleY) - (cy * scaleY));
  					cx1 = (width/2) * scaleX;
  					cy1 = (height/2) * scaleY;
				}
				
				if(jjtGetParent().jjtGetParent().getParentType().equals("repeat"))
  				{
  					repeatX = jjtGetParent().jjtGetParent().getRepeatX();
  					repeatY = jjtGetParent().jjtGetParent().getRepeatY();
  					noRepeat = jjtGetParent().jjtGetParent().getNoRepeat();
  					System.out.println(noRepeat);
  				}
  				
  				/*************************************************

				Checks if parent of parent of parent 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();
  						
  						width = (rx + offsetX) - (cx + offsetX);
  						height = (ry + offsetX) - (cy + offsetY); 
  				
  						cx1 = (cx + offsetX) + (width/2);
  						cy1 = (cy + offsetY) + (height/2);
  					}
  					
  					if(jjtGetParent().jjtGetParent().jjtGetParent().getParentType().equals("scale"))
  					{
  						scaleX = jjtGetParent().jjtGetParent().jjtGetParent().getScaleX();
  						scaleY = jjtGetParent().jjtGetParent().jjtGetParent().getScaleY(); 
  				  				
  						width = ((rx * scaleX) - (cx * scaleX));
  						height = ((ry * scaleY) - (cy * scaleY));
  						cx1 = (width/2) * scaleX;
  						cy1 = (height/2) * scaleY;
  					}
  					
  					if(jjtGetParent().jjtGetParent().jjtGetParent().getParentType().equals("repeat"))
  					{
  						repeatX = jjtGetParent().jjtGetParent().jjtGetParent().getRepeatX();
  						repeatY = jjtGetParent().jjtGetParent().jjtGetParent().getRepeatY();
  						noRepeat = jjtGetParent().jjtGetParent().jjtGetParent().getNoRepeat();
  						System.out.println(noRepeat);
  					}
  					
  					/*************************************************

					Checks if parent of parent of parent of parent 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();
  							
  							width = ((rx * scaleX) - (cx * scaleX));
  							height = ((ry * scaleY) - (cy * scaleY));
  							cx1 = (width/2) * scaleX;
  							cy1 = (height/2) * scaleY;
  						}
  					
  						if(jjtGetParent().jjtGetParent().jjtGetParent().jjtGetParent().getParentType().equals("scale"))
  						{
  							scaleX = jjtGetParent().jjtGetParent().jjtGetParent().jjtGetParent().getScaleX();
  							scaleY = jjtGetParent().jjtGetParent().jjtGetParent().jjtGetParent().getScaleY(); 
  				  				
  							width = ((rx * scaleX) - (cx * scaleX));
  							height = ((ry * scaleY) - (cy * scaleY));
  							cx1 = (width/2) * scaleX;
  							cy1 = (height/2) * 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();
  							System.out.println(noRepeat);
  						}
  						
  						/*************************************************

						Checks if the parent of parent of parent of parent of 
						parent is null

						*************************************************/
  						
  						if(!(jjtGetParent().jjtGetParent().jjtGetParent().jjtGetParent().jjtGetParent().getParentType() == null))
  						{
  							if(jjtGetParent().jjtGetParent().jjtGetParent().jjtGetParent().jjtGetParent().getParentType().equals("brush"))
  							{
  								brushSize = jjtGetParent().jjtGetParent().jjtGetParent().jjtGetParent().jjtGetParent().getBrush();
  							}
  		
  							if(jjtGetParent().jjtGetParent().jjtGetParent().jjtGetParent().jjtGetParent().getParentType().equals("colour"))
  							{
  								colour = jjtGetParent().jjtGetParent().jjtGetParent().jjtGetParent().jjtGetParent().getColour();
  							}
  		
  							if(jjtGetParent().jjtGetParent().jjtGetParent().jjtGetParent().jjtGetParent().getParentType().equals("offset"))
  							{	
  								offsetX = jjtGetParent().jjtGetParent().jjtGetParent().jjtGetParent().jjtGetParent().getOffsetX();
  								offsetY = jjtGetParent().jjtGetParent().jjtGetParent().jjtGetParent().jjtGetParent().getOffsetY();
  							
  								width = ((rx * scaleX) - (cx * scaleX));
  								height = ((ry * scaleY) - (cy * scaleY));
  								cx1 = (width/2) * scaleX;
  								cy1 = (height/2) * scaleY;
  							}
  					
	  						if(jjtGetParent().jjtGetParent().jjtGetParent().jjtGetParent().jjtGetParent().getParentType().equals("scale"))
	  						{
	  							scaleX = jjtGetParent().jjtGetParent().jjtGetParent().jjtGetParent().jjtGetParent().getScaleX();
	  							scaleY = jjtGetParent().jjtGetParent().jjtGetParent().jjtGetParent().jjtGetParent().getScaleY(); 
	  				  				
	  							width = ((rx * scaleX) - (cx * scaleX));
	  							height = ((ry * scaleY) - (cy * scaleY));
	  							cx1 = (width/2) * scaleX;
	  							cy1 = (height/2) * 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();
	  							System.out.println(noRepeat);
	  						}
  						}
  					}
  				}
  			}
  		}
  		
  		//sets the radius values of the circle
  		
  		rx1 = (width/2);
  		ry1 = (height/2);
  		
  		/*************************************************

		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++)
  		{
			temp = temp + ("<ellipse cx=\"" + (cx1 + (inc*repeatX)) + "\" cy=\""
				+ (cy1 + (inc*repeatY)) + "\" rx=\"" + rx1  
				+ "\" ry=\"" + ry1 + "\" fill=\"none\" stroke=\""
				+ colour +"\" stroke-width=\""+brushSize+"\"/>\n");
    	        
    	    inc++;
        }

  		return temp;
  	}
  	
  	/*************************************************

	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;
  	}

}

