Search in sources :

Example 1 with SceneManager

use of org.concord.energy3d.scene.SceneManager in project energy3d by concord-consortium.

the class MainApplication method main.

public static void main(final String[] args) {
    // testRegex();
    System.out.println("Initiating...");
    final long t = System.nanoTime();
    // checkSingleInstance(MainApplication.class, args);
    // startDeadlockDetectionThread();
    agents = new ArrayList<Agent>();
    // TODO: temporary test code below
    // agents.add(new ConformanceChecker("Conformance Checker"));
    // agents.add(new EventMinerSheet2("Event Miner Sheet 2"));
    // agents.add(new EventMinerSheet3("Event Miner Sheet 3"));
    final File testFile = new File(System.getProperty("user.dir"), "test.txt");
    // can't use File.canWrite() to check if we can write a file to this folder. So we have to walk extra miles as follows.
    try {
        testFile.createNewFile();
        testFile.delete();
    } catch (final Throwable e) {
        appDirectoryWritable = false;
    }
    System.setProperty("jogl.gljpanel.noglsl", "true");
    if (System.getProperty("os.name").startsWith("Mac")) {
        System.setProperty("apple.laf.useScreenMenuBar", "true");
        System.setProperty("com.apple.mrj.application.apple.menu.about.name", "Energy3D");
    }
    Config.setWebStart(System.getProperty("javawebstart.version", null) != null);
    if (!Config.isWebStart()) {
        System.setProperty("jogamp.gluegen.UseTempJarCache", "false");
    }
    final boolean isJarOrEclipse = !Config.isWebStart() && !System.getProperty("java.library.path").contains("jogl");
    if (isJarOrEclipse) {
        setupLibraryPath();
    }
    try {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (final Exception e) {
        e.printStackTrace();
    }
    initializing = true;
    EventQueue.invokeLater(new Runnable() {

        @Override
        public void run() {
            // this calls Swing GUI
            final SceneManager sceneManager = SceneManager.getInstance();
            // this calls Swing GUI
            Scene.getInstance();
            sceneManagerThread = new Thread(sceneManager, "Energy3D Main Application");
            sceneManagerThread.start();
            final MainFrame mainFrame = MainFrame.getInstance();
            mainFrame.updateTitleBar();
            mainFrame.setVisible(true);
            new Thread("Energy3D Open File") {

                @Override
                public void run() {
                    try {
                        if (Config.isMac()) {
                            Thread.sleep(200);
                        }
                        if (isMacOpeningFile) {
                            return;
                        }
                        // somehow newFile() must be called to set up the scene before we can correctly load the content when an NG3 file is double-clicked without an open instance
                        if (Scene.getURL() == null) {
                            Scene.newFile();
                        }
                        if (Config.isWebStart()) {
                            if (args.length > 1 && !args[args.length - 1].startsWith("-")) {
                                mainFrame.open(args[args.length - 1]);
                            }
                        } else {
                            if (args.length > 0) {
                                mainFrame.open(args[0]);
                            }
                        }
                    } catch (final Exception e) {
                        e.printStackTrace();
                    } finally {
                        initializing = false;
                    }
                }
            }.start();
            Updater.download();
        }
    });
    /* initialize data logging */
    addShutdownHook(new Runnable() {

        @Override
        public void run() {
            TimeSeriesLogger.getInstance().close();
        }
    });
    TimeSeriesLogger.getInstance().start();
    SnapshotLogger.getInstance().start(20);
    System.out.println("Initiatialization phase 2 done.");
    System.out.println("Time = " + (System.nanoTime() - t) / 1000000000.0);
}
Also used : Agent(org.concord.energy3d.agents.Agent) SceneManager(org.concord.energy3d.scene.SceneManager) File(java.io.File) MainFrame(org.concord.energy3d.gui.MainFrame)

Aggregations

File (java.io.File)1 Agent (org.concord.energy3d.agents.Agent)1 MainFrame (org.concord.energy3d.gui.MainFrame)1 SceneManager (org.concord.energy3d.scene.SceneManager)1