|
NetLogo API version 3.1.5 |
|||||||||
| 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
public class 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/interfaces 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, worldLoader |
| 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 | |
|---|---|
int |
calculateHeight(int worldHeight,
double patchSize)
|
int |
calculateWidth(int worldWidth,
double patchSize)
|
void |
changeTopology(boolean wrapX,
boolean wrapY)
|
void |
clearDrawing()
|
void |
clearOutput()
Internal use only. |
void |
command(String source)
Runs NetLogo commands and waits for them to complete. |
double |
computePatchSize(int width,
int numPatches)
|
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 |
fontSize(int fontSize)
|
void |
generateModelTest(String model)
|
static void |
generateModelTests()
Internal use only. |
BufferedImage |
getAndCreateDrawing()
|
org.nlogo.agent.Shape |
getDefaultLinkDirectionShape()
|
org.nlogo.agent.Shape |
getDefaultLinkShape()
|
org.nlogo.agent.Shape |
getDefaultShape()
|
BufferedImage |
getGraphics()
Get a snapshot of the 2D view. |
void |
getGraphics(BufferedImage image)
Get a snapshot of the 2D view, using an existing BufferedImage object. |
int |
getMinimumWidth()
|
void |
halt()
Halts all running NetLogo code in this workspace. |
void |
hexDraw(boolean hexDraw)
|
void |
importDrawing(org.nlogo.util.File file)
|
void |
initForTesting(int minPxcor,
int maxPxcor,
int minPycor,
int maxPycor)
|
void |
initForTesting(int minPxcor,
int maxPxcor,
int minPycor,
int maxPycor,
String source)
Internal use only. |
void |
initForTesting(org.nlogo.agent.WorldDimensions d)
|
void |
initForTesting(org.nlogo.agent.WorldDimensions d,
String source)
|
void |
initModel()
|
int |
insetWidth()
|
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 |
makePreviews(boolean allModels,
boolean overwrite)
|
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. |
void |
paint(Graphics2D g)
Internal use only. |
double |
patchSize()
|
void |
patchSize(double patchSize)
|
void |
periodicUpdate()
Internal use only. |
org.nlogo.lab.Protocol |
protocolFromModel(String name)
|
void |
refreshShaped(boolean shapesOn)
|
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 |
setDimensions(org.nlogo.agent.WorldDimensions d)
Kills all turtles, clears all patch variables, and makes a new patch grid. |
void |
setDimensions(org.nlogo.agent.WorldDimensions d,
double patchSize)
|
void |
setImporterErrorHandler(org.nlogo.agent.Importer.ErrorHandler importErrorHandler)
Internal use only. |
void |
setSize(int x,
int y)
|
boolean |
shapesOn()
|
void |
shapesOn(boolean shapesOn)
|
void |
stamp(org.nlogo.agent.Turtle turtle,
boolean erase)
|
boolean |
stripPlottingCommands()
Internal use only. |
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, clearAll, 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()
isHeadless in class org.nlogo.workspace.AbstractWorkspacepublic void ensureRenderer()
public void setCompilerTestingMode(boolean testing)
public boolean isCompilerTestingMode()
isCompilerTestingMode in class org.nlogo.workspace.AbstractWorkspace
public void waitFor(org.nlogo.nvm.CommandRunnable runnable)
throws LogoException
waitFor in interface org.nlogo.nvm.WorkspaceLogoException
public Object waitForResult(org.nlogo.nvm.ReporterRunnable runnable)
throws LogoException
waitForResult in interface org.nlogo.nvm.WorkspaceLogoExceptionpublic void waitForQueuedEvents()
waitForQueuedEvents in interface org.nlogo.nvm.Workspace
public void initForTesting(int minPxcor,
int maxPxcor,
int minPycor,
int maxPycor,
String source)
throws CompilerException
CompilerException
public void initForTesting(org.nlogo.agent.WorldDimensions d,
String source)
throws CompilerException
CompilerException
public void initForTesting(int minPxcor,
int maxPxcor,
int minPycor,
int maxPycor)
public void initForTesting(org.nlogo.agent.WorldDimensions d)
initForTesting in class org.nlogo.workspace.AbstractWorkspacepublic void setDimensions(org.nlogo.agent.WorldDimensions d)
setDimensions in interface org.nlogo.agent.WorldResizer
public void setDimensions(org.nlogo.agent.WorldDimensions d,
double patchSize)
setDimensions in interface org.nlogo.workspace.WorldLoaderInterfacepublic int getMinimumWidth()
getMinimumWidth in interface org.nlogo.workspace.WorldLoaderInterfacepublic int insetWidth()
insetWidth in interface org.nlogo.workspace.WorldLoaderInterface
public double computePatchSize(int width,
int numPatches)
computePatchSize in interface org.nlogo.workspace.WorldLoaderInterface
public int calculateHeight(int worldHeight,
double patchSize)
calculateHeight in interface org.nlogo.workspace.WorldLoaderInterface
public int calculateWidth(int worldWidth,
double patchSize)
calculateWidth in interface org.nlogo.workspace.WorldLoaderInterfacepublic void resizeWorld()
resizeWorld in interface org.nlogo.agent.WorldResizerpublic void patchSize(double patchSize)
patchSize in interface org.nlogo.agent.WorldResizerpatchSize in interface org.nlogo.workspace.WorldLoaderInterfacepublic double patchSize()
patchSize in interface org.nlogo.nvm.Workspace
public void changeTopology(boolean wrapX,
boolean wrapY)
changeTopology in interface org.nlogo.nvm.WorkspacechangeTopology in interface org.nlogo.workspace.WorldLoaderInterfacepublic void refreshShaped(boolean shapesOn)
refreshShaped in interface org.nlogo.workspace.WorldLoaderInterfacepublic void fontSize(int fontSize)
fontSize in interface org.nlogo.workspace.WorldLoaderInterfacepublic void hexDraw(boolean hexDraw)
hexDraw in interface org.nlogo.workspace.WorldLoaderInterface
public void setSize(int x,
int y)
setSize in interface org.nlogo.workspace.WorldLoaderInterfacepublic void createPatchesNotify()
public void inspectAgent(Class agentClass,
org.nlogo.agent.Agent agent)
inspectAgent in interface org.nlogo.nvm.Workspace
public void stamp(org.nlogo.agent.Turtle turtle,
boolean erase)
stamp in interface org.nlogo.nvm.Workspacepublic BufferedImage getAndCreateDrawing()
getAndCreateDrawing in interface org.nlogo.nvm.Workspace
public void importDrawing(org.nlogo.util.File file)
throws IOException
importDrawing in class org.nlogo.workspace.AbstractWorkspaceIOExceptionpublic void clearDrawing()
clearDrawing in interface org.nlogo.nvm.WorkspaceclearDrawing in class org.nlogo.workspace.AbstractWorkspace
public void exportDrawing(String filename,
String format)
throws IOException
exportDrawing in interface org.nlogo.nvm.WorkspaceIOExceptionpublic void exportDrawingToCSV(PrintWriter writer)
exportDrawingToCSV in class org.nlogo.workspace.AbstractWorkspacepublic void exportOutput(String filename)
exportOutput in interface org.nlogo.nvm.Workspacepublic void exportOutputAreaToCSV(PrintWriter writer)
exportOutputAreaToCSV in class org.nlogo.workspace.AbstractWorkspacepublic void clearOutput()
clearOutput in interface org.nlogo.nvm.Workspacepublic void setImporterErrorHandler(org.nlogo.agent.Importer.ErrorHandler importErrorHandler)
public BufferedImage getGraphics()
public void getGraphics(BufferedImage image)
public void paint(Graphics2D g)
public void exportGraphics(String filename,
String format)
throws IOException
exportGraphics in interface org.nlogo.nvm.WorkspaceIOExceptionpublic void exportInterface(String filename)
exportInterface in interface org.nlogo.nvm.Workspacepublic void writeGraphicsData(PrintWriter writer)
writeGraphicsData in class org.nlogo.workspace.AbstractWorkspacepublic void ownerFinished(org.nlogo.nvm.JobOwner owner)
ownerFinished in interface org.nlogo.nvm.JobManagerOwnerpublic void updateDisplay(boolean force)
updateDisplay in interface org.nlogo.nvm.JobManagerOwnerpublic void periodicUpdate()
periodicUpdate in interface org.nlogo.nvm.JobManagerOwnerpublic void magicOpen(String name)
magicOpen in interface org.nlogo.nvm.WorkspacemagicOpen in class org.nlogo.workspace.AbstractWorkspace
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
open in interface org.nlogo.workspace.Controllableopen in class org.nlogo.workspace.AbstractWorkspacepath - 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.Controllablesource - The command or commands to run
CompilerException - if the code fails to compile
LogoException - if the code fails to run
public Object report(String source)
throws CompilerException,
LogoException
report in interface org.nlogo.workspace.Controllablesource - 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()
halt in class org.nlogo.workspace.AbstractWorkspacepublic boolean stripPlottingCommands()
stripPlottingCommands in class org.nlogo.workspace.AbstractWorkspace
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
InterruptedExceptionpublic void shapesOn(boolean shapesOn)
shapesOn in class org.nlogo.workspace.AbstractWorkspacepublic boolean shapesOn()
shapesOn in class org.nlogo.workspace.AbstractWorkspace
public void generateModelTest(String model)
throws IOException,
CompilerException,
LogoException
IOException
CompilerException
LogoException
public void initModel()
throws LogoException,
CompilerException
initModel in interface org.nlogo.nvm.WorkspaceLogoException
CompilerException
public static void generateModelTests()
throws IOException
IOException
public void makePreviews(boolean allModels,
boolean overwrite)
makePreviews in interface org.nlogo.nvm.Workspacepublic org.nlogo.agent.Shape getDefaultShape()
getDefaultShape in class org.nlogo.workspace.AbstractWorkspacepublic org.nlogo.agent.Shape getDefaultLinkShape()
getDefaultLinkShape in class org.nlogo.workspace.AbstractWorkspacepublic org.nlogo.agent.Shape getDefaultLinkDirectionShape()
getDefaultLinkDirectionShape in class org.nlogo.workspace.AbstractWorkspace
|
NetLogo API version 3.1.5 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||