Back to Tutorials Index... ## Using the VisualSceneMaker in a Java application. Basically there are 2 ways how to employ the VisualSceneMaker in an existing Java application. <h3>VisualSceneMaker Editor mode</h3> The following code snipped can be used in Java applications to create the graphical user interface of the VisualSceneMaker. The needed parameter <code>file</code> should point to a VisualSceneMaker project directory. <code> // Get the singelton editor instance<br> final EditorInstance sEditor = EditorInstance.getInstance();<br> // Get an editor project from file<br> sEditor.openProject(file);<br> // Show the singelton editor instance<br> sEditor.setVisible(true);<br> </code> <h3>VisualSceneMaker Runtime mode</h3> This code snippet can be used in order to execute an existing Sceneflow+Scene model (a project) without the graphical user interface. The needed parameter <code>file</code> should point to a VisualSceneMaker project directory. <code> // Get an editor project from file<br> final RunTimeProject data = new RunTimeProject(file);<br> // Get the singelton runtime instance<br> final RunTimeInstance sRunTime = RunTimeInstance.getInstance();<br> // Launch the runtime with the project<br> if (sRunTime.launch(data)) {<br> &nbsp;&nbsp;// Start the runtime with the project<br> &nbsp;&nbsp;if (sRunTime.start(data)) {<br> &nbsp;&nbsp;&nbsp;&nbsp;// Wait until user aborts execution<br> &nbsp;&nbsp;&nbsp;&nbsp;System.err.println("Press Key To Abort ...");<br> &nbsp;&nbsp;&nbsp;&nbsp;// TODO: Stop waiting if execution<br> &nbsp;&nbsp;&nbsp;&nbsp;// has been aborted in another way<br> &nbsp;&nbsp;&nbsp;&nbsp;try {<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;final int in = System.in.read();<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (in != -1) {<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// Aborting the execution now<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br> &nbsp;&nbsp;&nbsp;&nbsp;} catch (final IOException exc) {<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// Do nothing<br> &nbsp;&nbsp;&nbsp;&nbsp;} finally {<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// Abort the runtime with the project<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sRunTime.abort(data);<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// Unload the project from the runtime<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sRunTime.unload(data);<br> &nbsp;&nbsp;&nbsp;&nbsp;}<br> &nbsp;&nbsp;}<br> }<br> </code> Compared to the editor mode, the project is registered by <code>sRunTime.launch(data)</code> in the VisualSceneMaker runtime for execution. The (obvious) next step is to execute the project by <code>sRunTime.start(data)</code>. The projects ends if it gets aborted <code>sRunTime.abort(data)</code>. There are methods to <code>stop</code>, <code>pause</code> and <code>resume</code> (see API). In order to cleanup the project is unregistered <code>sRunTime.unload(data)</code>.
Back to Tutorials Index...