package unileipzig.isys.neuronviz.app;

import java.io.FileNotFoundException;

import unileipzig.isys.neuronviz.kernel.StreamParser;
import unileipzig.isys.neuronviz.streamer.FileInputStreamer;
import unileipzig.isys.neuronviz.streamer.StandardInputStreamer;
import unileipzig.isys.neuronviz.viz.NetVisualizer;

/**
 * Class NeuronViz
 */
public class NeuronViz
{
	public NeuronViz()
	{
		// create a new visualizer
		NetVisualizer netVisualizer = new NetVisualizer();
		
		// a parser object to parse received Data
		StreamParser parser = new StreamParser();
		
		// streamer object to get data into the programm
/*		FileInputStreamer streamer = null;
		try
		{
			streamer = new FileInputStreamer("testdescription2.txt");
		} catch (FileNotFoundException e)
		{
			System.out.println("The specified file was not found. Programm will terminate.");
			e.printStackTrace();
			System.exit(0);
		}
*/
		StandardInputStreamer streamer = new StandardInputStreamer();
		
		// streamer should inform the parser about new data received
		streamer.addDataListener(parser);
		
		// parser informs visualizer about new parsed data
		parser.addParseListener(netVisualizer);
		
		// the visualizer should control the data streamer
		netVisualizer.setDataStreamer(streamer);
		
		// create main frame and add visualizer panel
		NeuronVizFrame mainFrame = new NeuronVizFrame();
		mainFrame.getContentPane().add(netVisualizer);
		
		// show window
		mainFrame.setVisible(true);

		// start receiving data from the stream
		streamer.startStreaming();
	}
	
	public static void main(String[] args)
	{
		new NeuronViz();
	}
}
