|
NetLogo API version 3.0.2 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.nlogo.workspace.AbstractWorkspace
org.nlogo.headless.HeadlessWorkspace
The main class for headless (no GUI) operation of NetLogo.
You may create more than one HeadlessWorkspace object. Multiple instances can operate separately and independently. (Behind the scenes, this is supported by creating a separate thread for each instance.)
When you are done using a HeadlessWorkspace, you should call its dispose() method. This will shut down the thread associated with the workspace and allow resources to be freed.
See the "Controlling" section of the NetLogo User Manual for example code.
Nested Class Summary |
Nested classes inherited from class org.nlogo.workspace.AbstractWorkspace |
org.nlogo.workspace.AbstractWorkspace.HubNetManagerFactory |
Field Summary | |
LogoException |
lastLogoException
Internal use only. |
StringBuffer |
outputAreaBuffer
|
String[] |
protocolLines
|
org.nlogo.render.Renderer |
renderer
|
static int |
SPREADSHEET
constant for specifying format of BehaviorSpace output |
static int |
TABLE
constant for specifying format of BehaviorSpace output |
static String |
TEST_DECLARATIONS
Internal use only. |
Fields inherited from class org.nlogo.workspace.AbstractWorkspace |
aggregateManager, DEFAULT_PREVIEW_COMMANDS, jobManager, previewCommands, TYPE_CONVERTED, TYPE_LIBRARY, TYPE_NEW, TYPE_NORMAL, world |
Fields inherited from interface org.nlogo.nvm.Workspace |
OUTPUT_NORMAL, OUTPUT_TO_FILE, OUTPUT_TO_OUTPUT_AREA |
Constructor Summary | |
HeadlessWorkspace()
Makes a new instance of NetLogo capable of running a model "headless", with no GUI. |
Method Summary | |
void |
clearAll()
|
void |
clearDrawing()
|
void |
clearOutput()
Internal use only. |
void |
command(String source)
Runs NetLogo commands and waits for them to complete. |
void |
createPatchesNotify()
Internal use only. |
void |
ensureRenderer()
Internal use only. |
void |
exportDrawing(String filename,
String format)
|
void |
exportDrawingToCSV(PrintWriter writer)
|
void |
exportGraphics(String filename,
String format)
|
void |
exportInterface(String filename)
Not implemented. |
void |
exportOutput(String filename)
|
void |
exportOutputAreaToCSV(PrintWriter writer)
|
void |
generateModelTest(String model)
|
static void |
generateModelTests()
Internal use only. |
BufferedImage |
getAndCreateDrawing()
|
double |
getColorUnder(double xcor,
double ycor)
|
org.nlogo.agent.Shape |
getDefaultShape()
|
BufferedImage |
getGraphics()
Get a snapshot of the 2D view. |
int |
getRGBUnder(double xcor,
double ycor)
|
void |
halt()
Halts all running NetLogo code in this workspace. |
void |
importDrawing(org.nlogo.util.File file)
|
void |
initForTesting(int sex,
int sey)
|
void |
initForTesting(int sex,
int sey,
String source)
Internal use only. |
void |
initModel()
|
void |
inspectAgent(Class agentClass,
org.nlogo.agent.Agent agent)
Internal use only. |
boolean |
isCompilerTestingMode()
Internal use only. |
boolean |
isHeadless()
Internal use only. |
void |
magicOpen(String name)
Internal use only. |
static void |
main(String[] args)
|
void |
open(String path)
Opens a model stored in a file. |
void |
openFromSource(String source)
Opens a model stored in a string. |
void |
ownerFinished(org.nlogo.nvm.JobOwner owner)
Internal use only. |
double |
patchSize()
|
void |
patchSize(double patchSize)
|
void |
periodicUpdate()
Internal use only. |
org.nlogo.lab.Protocol |
protocolFromModel(String name)
|
Object |
report(String source)
Runs a NetLogo reporter. |
void |
resizeWorld()
|
void |
runExperiment(File file,
int format,
PrintWriter writer)
Runs a BehaviorSpace experiment. |
void |
runExperiment(File file,
String name,
int format,
PrintWriter writer)
Runs a BehaviorSpace experiment. |
void |
runExperiment(String xml,
int format,
PrintWriter writer)
Runs a BehaviorSpace experiment. |
org.nlogo.lab.Experiment |
runExperimentFromModel(String name)
|
void |
runExperimentFromModel(String name,
int format,
PrintWriter writer)
Runs a BehaviorSpace experiment. |
void |
runtimeError(org.nlogo.nvm.JobOwner owner,
org.nlogo.nvm.Context context,
org.nlogo.command.Instruction instruction,
Exception ex)
Internal use only. |
void |
setCompilerTestingMode(boolean testing)
Internal use only. |
void |
setImporterErrorHandler(org.nlogo.agent.Importer.ErrorHandler importErrorHandler)
Internal use only. |
void |
setModelPath(String path)
Internal use only. |
void |
setModelType(int modelType)
Internal use only. |
void |
setScreenEdges(int screenEdgeX,
int screenEdgeY)
Kills all turtles, clears all patch variables, and makes a new patch grid. |
void |
setSpotlightSize(double size)
|
boolean |
shapesOn()
|
void |
shapesOn(boolean shapesOn)
|
void |
stamp(org.nlogo.agent.Turtle turtle)
|
void |
updateDisplay(boolean force)
Internal use only. |
void |
waitFor(org.nlogo.nvm.CommandRunnable runnable)
Internal use only. |
void |
waitForQueuedEvents()
Internal use only. |
Object |
waitForResult(org.nlogo.nvm.ReporterRunnable runnable)
Internal use only. |
void |
writeGraphicsData(PrintWriter writer)
|
Methods inherited from class org.nlogo.workspace.AbstractWorkspace |
addJobFromJobThread, attachModelDir, compileCommands, compileForRun, compileReporter, computerHubNetRunning, computerHubNetRunning, convertToNormal, dispose, evaluateCommands, evaluateCommands, evaluateCommands, evaluateReporter, evaluateReporter, exportBehaviors, exportWorld, fileManager, forceSaveAs, getExtensionManager, getHubNetManager, getModelDir, getModelFileName, getModelPath, getModelType, guessExportName, hubnetManager, importDrawing, importWorld, init, isApp, isApp, isApplet, isApplet, joinForeverButtons, modelNameForDisplay, outputObject, resetTimer, runCompiledCommands, runCompiledReporter, setOutputAreaContents, updateChecksum, warningMessage, world |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public String[] protocolLines
public static final int TABLE
public static final int SPREADSHEET
public org.nlogo.render.Renderer renderer
public final StringBuffer outputAreaBuffer
public static final String TEST_DECLARATIONS
public LogoException lastLogoException
Constructor Detail |
public HeadlessWorkspace()
Method Detail |
public boolean isHeadless()
public void ensureRenderer()
public void setCompilerTestingMode(boolean testing)
public boolean isCompilerTestingMode()
public void waitFor(org.nlogo.nvm.CommandRunnable runnable) throws LogoException
waitFor
in interface org.nlogo.nvm.Workspace
LogoException
public Object waitForResult(org.nlogo.nvm.ReporterRunnable runnable) throws LogoException
waitForResult
in interface org.nlogo.nvm.Workspace
LogoException
public void waitForQueuedEvents()
waitForQueuedEvents
in interface org.nlogo.nvm.Workspace
public void initForTesting(int sex, int sey, String source) throws CompilerException
CompilerException
public void initForTesting(int sex, int sey)
public void setScreenEdges(int screenEdgeX, int screenEdgeY)
setScreenEdges
in interface org.nlogo.agent.WorldResizer
screenEdgeX
- new value for screen-edge-xscreenEdgeY
- new value for screen-edge-ypublic void resizeWorld()
resizeWorld
in interface org.nlogo.agent.WorldResizer
public void patchSize(double patchSize)
patchSize
in interface org.nlogo.agent.WorldResizer
public double patchSize()
patchSize
in interface org.nlogo.nvm.Workspace
public void setModelPath(String path)
public void setModelType(int modelType)
public void clearAll() throws LogoException
clearAll
in interface org.nlogo.nvm.Workspace
LogoException
public void createPatchesNotify()
public void inspectAgent(Class agentClass, org.nlogo.agent.Agent agent)
inspectAgent
in interface org.nlogo.nvm.Workspace
public double getColorUnder(double xcor, double ycor)
getColorUnder
in interface org.nlogo.nvm.Workspace
public int getRGBUnder(double xcor, double ycor)
getRGBUnder
in interface org.nlogo.nvm.Workspace
public void stamp(org.nlogo.agent.Turtle turtle)
stamp
in interface org.nlogo.nvm.Workspace
public BufferedImage getAndCreateDrawing()
getAndCreateDrawing
in interface org.nlogo.nvm.Workspace
public void importDrawing(org.nlogo.util.File file) throws IOException
IOException
public void clearDrawing()
clearDrawing
in interface org.nlogo.nvm.Workspace
public void exportDrawing(String filename, String format) throws IOException
exportDrawing
in interface org.nlogo.nvm.Workspace
IOException
public void exportDrawingToCSV(PrintWriter writer)
public void exportOutput(String filename)
exportOutput
in interface org.nlogo.nvm.Workspace
public void exportOutputAreaToCSV(PrintWriter writer)
public void clearOutput()
clearOutput
in interface org.nlogo.nvm.Workspace
public void setImporterErrorHandler(org.nlogo.agent.Importer.ErrorHandler importErrorHandler)
public BufferedImage getGraphics()
public void exportGraphics(String filename, String format) throws IOException
exportGraphics
in interface org.nlogo.nvm.Workspace
IOException
public void exportInterface(String filename)
exportInterface
in interface org.nlogo.nvm.Workspace
public void writeGraphicsData(PrintWriter writer)
public void ownerFinished(org.nlogo.nvm.JobOwner owner)
ownerFinished
in interface org.nlogo.nvm.JobManagerOwner
public void updateDisplay(boolean force)
updateDisplay
in interface org.nlogo.nvm.JobManagerOwner
public void periodicUpdate()
periodicUpdate
in interface org.nlogo.nvm.JobManagerOwner
public void magicOpen(String name)
magicOpen
in interface org.nlogo.nvm.Workspace
public void setSpotlightSize(double size)
setSpotlightSize
in interface org.nlogo.nvm.Workspace
public void runtimeError(org.nlogo.nvm.JobOwner owner, org.nlogo.nvm.Context context, org.nlogo.command.Instruction instruction, Exception ex)
runtimeError
in interface org.nlogo.nvm.JobManagerOwner
public void open(String path) throws IOException, CompilerException, LogoException
path
- the path (absolute or relative) of the NetLogo model to open.
IOException
CompilerException
LogoException
public void openFromSource(String source) throws CompilerException, LogoException
source
- The complete model, including widgets and so forth,
in the same format as it would be stored in a file.
CompilerException
LogoException
public void command(String source) throws CompilerException, LogoException
command
in interface org.nlogo.workspace.Controllable
source
- The command or commands to run
CompilerException
- if the code fails to compile
LogoException
- if the code fails to runpublic Object report(String source) throws CompilerException, LogoException
report
in interface org.nlogo.workspace.Controllable
source
- The reporter to run
LogoList
,
Agent
, AgentSet, or Nobody
CompilerException
- if the code fails to compile
LogoException
- if the code fails to runpublic void halt()
public void runExperiment(String xml, int format, PrintWriter writer) throws CompilerException, SAXException
xml
- a single experiment setup represented in XMLformat
- TABLE or SPREADSHEETwriter
- where to send the results
Writes the results of the experiment to the given writer in
CSV (comma separated values) format.
CompilerException
SAXException
public void runExperiment(File file, int format, PrintWriter writer) throws IOException, CompilerException, SAXException
file
- file containing a single experiment setup
represented in XMLformat
- TABLE or SPREADSHEETwriter
- where to send the results
Writes the results of the experiment to the given writer in
CSV (comma separated values) format.
IOException
CompilerException
SAXException
public void runExperiment(File file, String name, int format, PrintWriter writer) throws IOException, CompilerException, SAXException
file
- file containing one or more experiment setups
represented in XMLname
- name of the experiment setup to run; must match
the name of one of the setups in the XML fileformat
- TABLE or SPREADSHEETwriter
- where to send the results
Writes the results of the experiment to the given writer in
CSV (comma separated values) format.
IOException
CompilerException
SAXException
public org.nlogo.lab.Protocol protocolFromModel(String name) throws SAXException
SAXException
public org.nlogo.lab.Experiment runExperimentFromModel(String name) throws CompilerException, SAXException
CompilerException
SAXException
public void runExperimentFromModel(String name, int format, PrintWriter writer) throws CompilerException, SAXException
name
- the name of an experiment setup which is stored
in the currently loaded model fileformat
- TABLE or SPREADSHEETwriter
- where to send the results
Writes the results of the experiment to the given writer in
CSV (comma separated values) format.
CompilerException
SAXException
public static void main(String[] args) throws InterruptedException
InterruptedException
public void shapesOn(boolean shapesOn)
public boolean shapesOn()
public void generateModelTest(String model) throws IOException, CompilerException, LogoException
IOException
CompilerException
LogoException
public void initModel() throws LogoException, CompilerException
initModel
in interface org.nlogo.nvm.Workspace
LogoException
CompilerException
public static void generateModelTests() throws IOException
IOException
public org.nlogo.agent.Shape getDefaultShape()
|
NetLogo API version 3.0.2 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |