/*
	Minimal application that reads data into variables and registers them with a 
	VariableOrganizer, then displays the content as a spreadsheet.
	lobsterman 01/04/24
*/

import JavaGrinders.*;

public class DataHandlingDemo2 {

	// first define variables and the VariableOrganizer used to coordinate them
	static integerVariable theInts;
	static numberVariable theDoubles;
	static VariableOrganizer myOrganizer;
	
	public static void main(String args[]) {
	try {
        // define and contruct a Parser for a DataFile with a given name.
        // Note, for this to work you need to place this file in the same
        // harddisk directory as your project. If no name is provided then
        // a standard filechooser dialog box will pop up allowing you to
        // select a file from your hard disk.
        DataFileParser myParser = new DataFileParser("../../DataFiles/Test.txt");
        // now construct a VariableOrganizer from the Parser. A variable
        // organizer allows you to coordinate a set of variables
        myOrganizer = new VariableOrganizer(myParser);
        // construct variables and register them with the VariableOrganizer 
        theInts = new integerVariable("xInteger",myOrganizer);
        theDoubles = new numberVariable("yDouble",myOrganizer);
        // now fill them with data from the internal array of the Parser 
        theInts.fillWithParser(myParser,0);
        theDoubles.fillWithParser(myParser,1);	
        // now create a spreadsheet table with the VariableOrganizer and display
        // everything the VariableOrganizer knows about - this is simply a display
        // of the data.
        myOrganizer.asTablePresenter();
	} catch (Throwable e) { System.err.println(e); }
	}
}
