import java.applet.Applet;
import java.io.*;
import java.util.*;
import java.lang.*;

public class RobboExplorative extends Applet
{
    String PATH;
    static RobboFrame RF;

    public void ProcessConfig (String STRING)
    {
	StringTokenizer ST = new StringTokenizer (STRING);
	if (!ST.hasMoreTokens ()) // HACK
	    return;
	String S = ST.nextToken ();
	if (S.equals ("TotalDirectory"))
	    {
		RF.SetupTotalDirectory (new File (ST.nextToken ()));
		return;
	    }
	if (S.equals ("TripleDirectory"))
	    {
		RF.SetupTripleDirectory (new File (ST.nextToken ()));
		return;
	    }
	if (S.equals ("RobboExplorer"))
	    {
		RF.SetupRobboExplorer (new File (ST.nextToken ()));
		return;
	    }
    }

    public void ReadConfigFile (File file)
    {
	BufferedReader BR;
	try
	    {
		FileReader FR = new FileReader (file);
		BR = new BufferedReader (FR);
		RF.TellInfo ("Reading RE.config file");
		while (BR.ready ())
		    {
			ProcessConfig (BR.readLine ());
		    }
		    BR.close ();
	    }
	catch (IOException io_e)
	    {

	    }
    }

    public void LoadStartup ()
    {
	PATH = getClass ().getProtectionDomain ().getCodeSource ().
	    getLocation ().toString ();
	File file = new File ("RE.config");
	if (!file.exists ())
	    RF.TellInfo ("No RE.config file noticed");
	else
	    ReadConfigFile (file);
    }

    public void RunLoop ()
    {
	int count = 0;
	while (true)
	    {
		count = count + 1;
		try
		    {
			Thread.sleep (10);
		    }
		catch (InterruptedException int_e)
		    {
		    }
		if (count == 100 && false)
		    {
			count = 0;
			RF.redraw ();
		    }
	    }
    }

    public void MakeRobboFrame ()
    {
	RF = new RobboFrame ();
    }

    /* Copyright (c) Roberto Pescatore plus Decembrists (all), PUBLICDOMAIN (workers) */

    public static void main (String[] Arguments)
    {
	RobboExplorative RE = new RobboExplorative ();
	RE.MakeRobboFrame ();
	RE.LoadStartup ();
	RE.RunLoop ();
    }

}
