/* 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(drawphase1 p, int id) 
  	{
    	super(p, id);
  	}
  	
  	/*************************************************
	
	Loops through all the children of the program printing
	them out to the console, via the returned string from
	the generateSVG() method
	
	*************************************************/

  	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>");
    
   	}
   	
   	/*************************************************
	
	generateFile() method is where the SVG file is created
	using a print writer and a loop round all the child
	node in a similar way to the generate() method above
	
	*************************************************/
   	
   	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); 
  		}
   	}
}
