NetLogo API
version 2.1.0

org.nlogo.workspace
Class HeadlessWorkspace

java.lang.Object
  extended byorg.nlogo.workspace.Workspace
      extended byorg.nlogo.workspace.HeadlessWorkspace
All Implemented Interfaces:
org.nlogo.nvm.JobManagerOwner, org.nlogo.agent.WorldResizer

public class HeadlessWorkspace
extends org.nlogo.workspace.Workspace

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.Workspace
org.nlogo.workspace.Workspace.HubNetManagerFactory
 
Field Summary
 LogoException lastLogoException
          Internal use only.
static String TEST_DECLARATIONS
          Internal use only.
 
Fields inherited from class org.nlogo.workspace.Workspace
evaluator, fileManager, jobManager, OUTPUT_NORMAL, OUTPUT_TO_FILE, OUTPUT_TO_OUTPUT_AREA, profilingTracer, TYPE_CONVERTED, TYPE_LIBRARY, TYPE_NEW, TYPE_NORMAL, world
 
Constructor Summary
HeadlessWorkspace()
          Makes a new instance of NetLogo capable of running a model "headless", with no GUI.
 
Method Summary
 void clearOutput()
          Internal use only.
 void command(String source)
          Runs NetLogo commands and waits for them to complete.
 void createPatchesNotify()
          Internal use only.
 void dispose()
          Shuts down the background thread associated with this workspace, allowing resources to be freed.
 void exportGraphics(String filename, String format)
          Not implemented.
 void exportInterface(String filename)
          Not implemented.
 boolean headless()
          Internal use only.
 void initForTesting(int sex, int sey)
          Internal use only.
 void initForTesting(int sex, int sey, String source)
          Internal use only.
 void inspectAgent(Class agentClass, org.nlogo.agent.Agent agent)
          Internal use only.
 void magicOpen(String name)
          Internal use only.
 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 periodicUpdate()
          Internal use only.
 Object report(String source)
          Runs a NetLogo reporter.
 void resizeWorld(int screenEdgeX, int screenEdgeY)
          Not implemented.
 void runtimeError(org.nlogo.nvm.JobOwner owner, org.nlogo.nvm.Context context, org.nlogo.command.Instruction instruction, Exception ex)
          Internal use only.
 void setModelPath(String path)
          Internal use only.
 void setModelType(int modelType)
          Internal use only.
 void updateDisplay(boolean force)
          Internal use only.
 
Methods inherited from class org.nlogo.workspace.Workspace
attachModelDir, clearAll, computerHubNetRunning, computerHubNetRunning, convertToNormal, exportBehaviors, exportWorld, forceSaveAs, getDefaultShape, getExtensionManager, getHubNetManager, getModelDir, getModelFileName, getModelPath, getModelType, importWorld, init, isApp, isApp, isApplet, isApplet, modelNameForDisplay, outputObject, resetTimer, warningMessage
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TEST_DECLARATIONS

public static final String TEST_DECLARATIONS
Internal use only.

See Also:
Constant Field Values

lastLogoException

public LogoException lastLogoException
Internal use only.

Constructor Detail

HeadlessWorkspace

public HeadlessWorkspace()
Makes a new instance of NetLogo capable of running a model "headless", with no GUI.

Method Detail

dispose

public void dispose()
             throws InterruptedException
Shuts down the background thread associated with this workspace, allowing resources to be freed.

Throws:
InterruptedException

headless

public boolean headless()
Internal use only.


initForTesting

public void initForTesting(int sex,
                           int sey)
Internal use only.


initForTesting

public void initForTesting(int sex,
                           int sey,
                           String source)
                    throws CompilerException
Internal use only.

Throws:
CompilerException

resizeWorld

public void resizeWorld(int screenEdgeX,
                        int screenEdgeY)
Not implemented.


setModelPath

public void setModelPath(String path)
Internal use only.


setModelType

public void setModelType(int modelType)
Internal use only.


createPatchesNotify

public void createPatchesNotify()
Internal use only.


inspectAgent

public void inspectAgent(Class agentClass,
                         org.nlogo.agent.Agent agent)
Internal use only.


clearOutput

public void clearOutput()
Internal use only.


exportGraphics

public void exportGraphics(String filename,
                           String format)
Not implemented.


exportInterface

public void exportInterface(String filename)
Not implemented.


ownerFinished

public void ownerFinished(org.nlogo.nvm.JobOwner owner)
Internal use only.


updateDisplay

public void updateDisplay(boolean force)
Internal use only.


periodicUpdate

public void periodicUpdate()
Internal use only.


magicOpen

public void magicOpen(String name)
Internal use only.


runtimeError

public void runtimeError(org.nlogo.nvm.JobOwner owner,
                         org.nlogo.nvm.Context context,
                         org.nlogo.command.Instruction instruction,
                         Exception ex)
Internal use only.


open

public void open(String path)
          throws IOException,
                 CompilerException,
                 LogoException
Opens a model stored in a file.

Parameters:
path - the path (absolute or relative) of the NetLogo model to open.
Throws:
IOException
CompilerException
LogoException

openFromSource

public void openFromSource(String source)
                    throws CompilerException,
                           LogoException
Opens a model stored in a string.

Parameters:
source - The complete model, including widgets and so forth, in the same format as it would be stored in a file.
Throws:
CompilerException
LogoException

command

public void command(String source)
             throws CompilerException,
                    LogoException
Runs NetLogo commands and waits for them to complete.

Parameters:
source - The command or commands to run
Throws:
CompilerException - if the code fails to compile
LogoException - if the code fails to run

report

public Object report(String source)
              throws CompilerException,
                     LogoException
Runs a NetLogo reporter.

Parameters:
source - The reporter to run
Returns:
the result reported; may be of type java.lang.Integer, java.lang.Double, java.lang.Boolean, java.lang.String, LogoList, Agent, AgentSet, or Nobody
Throws:
CompilerException - if the code fails to compile
LogoException - if the code fails to run

NetLogo API
version 2.1.0