java.lang.Objectorg.nlogo.app.App
public final class App
The main class for the complete NetLogo application.
All methods in this class, including the constructor, must be called from the AWT event queue thread, unless otherwise specified.
See the "Controlling" section of the NetLogo User Manual for example code.
Nested Class Summary | |
---|---|
static class |
App.AppFrame
|
Field Summary | |
---|---|
static App |
app
Once main() has been called, holds the singleton
instance of this class. |
App.AppFrame |
frame
|
org.nlogo.window.GUIWorkspace |
workspace
|
Constructor Summary | |
---|---|
App()
|
Method Summary | |
---|---|
void |
command(String source)
Runs NetLogo commands and waits for them to complete. |
void |
commandLater(String source)
Runs NetLogo commands in the background. |
void |
compile()
Recompiles the model. |
App.AppFrame |
getLinkParent()
|
String |
getProcedures()
Returns the contents of the Procedures tab. |
String |
getSource(String filename)
Internal use only. |
void |
handle(org.nlogo.window.Events.AboutToQuitEvent e)
Internal use only. |
void |
handle(org.nlogo.window.Events.AppEvent e)
Internal use only. |
void |
handle(org.nlogo.window.Events.BeforeLoadEvent e)
Internal use only. |
void |
handle(org.nlogo.window.Events.LoadBeginEvent e)
Internal use only. |
void |
handle(org.nlogo.window.Events.LoadEndEvent e)
Internal use only. |
void |
handle(org.nlogo.window.Events.LoadSectionEvent e)
Internal use only. |
void |
handle(org.nlogo.window.Events.ModelSavedEvent e)
Internal use only. |
void |
handle(org.nlogo.app.Events.SwitchedTabsEvent e)
Internal use only. |
void |
handle(Throwable throwable)
Internal use only. |
org.nlogo.shape.ShapesManagerInterface |
linkShapesManager()
|
static void |
main(String[] args)
Should be called once at startup to create the application and start it running. |
void |
makeWidget(String text)
Adds new widget to Interface tab given its specification, in the same (undocumented) format found in a saved model. |
void |
open(String path)
Opens a model stored in a file. |
void |
openFromSource(String name,
String source)
Opens a model stored in a string. |
void |
pressButton(String name)
Not currently supported. |
void |
quit()
Quits NetLogo by exiting the JVM. |
Object |
report(String source)
Runs a NetLogo reporter. |
void |
selectTab(int number)
Switches tabs. |
void |
setProcedures(String source)
Replaces the contents of the Procedures tab. |
org.nlogo.shape.ShapesManagerInterface |
turtleShapesManager()
|
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public App.AppFrame frame
public final org.nlogo.window.GUIWorkspace workspace
public static App app
main()
has been called, holds the singleton
instance of this class.
Constructor Detail |
---|
public App()
Method Detail |
---|
public static void main(String[] args)
app
.
This method must not be called from the AWT event queue thread.
args
- Should be empty. (Passing non-empty arguments
is not currently documented.)public void quit() throws org.nlogo.awt.UserCancelException
org.nlogo.awt.UserCancelException
public void handle(org.nlogo.window.Events.AppEvent e)
handle
in interface org.nlogo.window.Events.AppEvent.Handler
public void handle(org.nlogo.app.Events.SwitchedTabsEvent e)
public void handle(org.nlogo.window.Events.ModelSavedEvent e)
handle
in interface org.nlogo.window.Events.ModelSavedEvent.Handler
public void handle(org.nlogo.window.Events.LoadBeginEvent e)
handle
in interface org.nlogo.window.Events.LoadBeginEvent.Handler
public void handle(org.nlogo.window.Events.BeforeLoadEvent e)
handle
in interface org.nlogo.window.Events.BeforeLoadEvent.Handler
public org.nlogo.shape.ShapesManagerInterface turtleShapesManager()
public org.nlogo.shape.ShapesManagerInterface linkShapesManager()
public void handle(org.nlogo.window.Events.LoadEndEvent e)
handle
in interface org.nlogo.window.Events.LoadEndEvent.Handler
public void handle(org.nlogo.window.Events.AboutToQuitEvent e)
handle
in interface org.nlogo.window.Events.AboutToQuitEvent.Handler
public void handle(Throwable throwable)
handle
in interface org.nlogo.util.Exceptions.Handler
public void open(String path) throws IOException
open
in interface Controllable
path
- the path (absolute or relative) of the NetLogo model to open.
IOException
public void openFromSource(String name, String source)
name
- Model name (will appear in the main window's title bar)source
- The complete model, including widgets and so forth,
in the same format as it would be stored in a file.public void command(String source) throws CompilerException
This method must not be called from the AWT event queue thread or while that thread is blocked. It is an error to do so.
command
in interface Controllable
source
- The command or commands to run
CompilerException
- if the code fails to compile
IllegalStateException
- if called from the AWT event queue threadcommandLater(java.lang.String)
public void commandLater(String source) throws CompilerException
This method may be called from any thread.
source
- The command or commands to run
CompilerException
- if the code fails to compilecommand(java.lang.String)
public Object report(String source) throws CompilerException
This method must not be called from the AWT event queue thread or while that thread is blocked. It is an error to do so.
report
in interface Controllable
source
- The reporter to run
LogoList
,
Agent
, AgentSet, or Nobody
CompilerException
- if the code fails to compile
IllegalStateException
- if called from the AWT event queue threadpublic String getProcedures()
public void setProcedures(String source)
source
- new contentscompile()
public void compile()
setProcedures()
.
setProcedures(java.lang.String)
public void selectTab(int number)
number
- which tab to switch to. 0 is the Interface tab,
1 the Information tab, 2 the Procedures tab, 3 the
Errors tab.public void pressButton(String name)
command
or commandLater()
instead.
name
- the button to presscommand(java.lang.String)
,
commandLater(java.lang.String)
public void makeWidget(String text)
text
- the widget specificationpublic void handle(org.nlogo.window.Events.LoadSectionEvent e)
handle
in interface org.nlogo.window.Events.LoadSectionEvent.Handler
public String getSource(String filename)
getSource
in interface org.nlogo.window.ExternalFileManager
public App.AppFrame getLinkParent()
getLinkParent
in interface org.nlogo.window.Event.LinkChild