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

import java.io.*;

public class ASTProgram extends SimpleNode 
{
	/*************************************************
	
					Constructors
		
	*************************************************/
	
	public ASTProgram(int id) 
	{
    	super(id);
  	}

  	public ASTProgram(drawphase2 p, int id) 
  	{
    	super(p, id);
  	}
  	
  	/*************************************************
	
	generate() method to loop through all the child nodes
	of program and print them to the console when called.
	
	*************************************************/

  	public void generate()
  	{
    	int test = sizeOfChild();
		String picture;
    	String[] temp = new String[test];

		picture = jjtGetChild(0).generateSVG();
		
	   	System.out.println(picture);
	   	
		for(int i = 1; i < sizeOfChild(); i++)
    	{
        	System.out.println(jjtGetChild(i).generateSVG());
    	}
   		System.out.println("</svg>");
    
   	}
   	
   	/*************************************************
	
	Method to produce the SVG file using a file writer
	and a loop round all the children of program
	
	*************************************************/
   	
   	public void generateFile()
   	{
   	   	String file = "test.svg";
    	
    	try
    	{
    		FileWriter fw = new FileWriter (file);
		    BufferedWriter bw = new BufferedWriter (fw);
		    PrintWriter outFile = new PrintWriter (bw);
		    
		    outFile.println(jjtGetChild(0).generateSVG());
		    
		    for(int i = 1; i < sizeOfChild(); ++i)
    		{
        		outFile.println(jjtGetChild(i).generateSVG());
    		}
    		
   			outFile.println("</svg>");
   			outFile.println("");
   			
   			outFile.close();
    
    		System.out.println("Output to file " + file);
  		}
  
  		catch(IOException exception)
  		{ 
    		System.out.print("Error: " + exception); 
			System.exit(1); 
  		}
   	}
   	
   	/*************************************************
	
	Method to loop around the number of co-ordinates of
	the polygon and create the indiviual lines. The line
	outside the loop is the final line that links the final
	co-ordinate with the first to complete the polygon
	
	*************************************************/
   	
   	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;
  	}
}
