Permalink
Browse files

Merge remote-tracking branch 'origin/master' into core

Conflicts:
	bin/issues.scala
	bin/release.sh
	devel/depend.graffle
	dist/modelwords.txt
	docs/dictionary.html
	src/main/org/nlogo/app/App.scala
	src/main/org/nlogo/headless/HeadlessWorkspace.scala
	src/main/org/nlogo/headless/Main.scala
	src/main/org/nlogo/lab/gui/Supervisor.scala
	src/main/org/nlogo/nvm/Workspace.java
	src/main/org/nlogo/window/AppEventType.java
	src/test/org/nlogo/nvm/DummyWorkspace.scala
  • Loading branch information...
2 parents e6cfa20 + 06614b9 commit e8518e2d9edef85708355999effce8f89ae09b81 @SethTisue SethTisue committed Jun 5, 2012
2 models
Submodule models updated from 596d12 to dc8db9
@@ -30,7 +30,7 @@ trait Libraries extends DefaultProject {
val jmock = "org.jmock" % "jmock" % "2.5.1" % "test"
val jmockLegacy = "org.jmock" % "jmock-legacy" % "2.5.1" % "test"
val jmockJUnit = "org.jmock" % "jmock-junit4" % "2.5.1" % "test"
- val scalacheck = "org.scalacheck" % "scalacheck_2.9.1" % "1.9" % "test"
- val scalatest = "org.scalatest" %% "scalatest" % "1.8.RC1" % "test"
+ val scalacheck = "org.scalacheck" %% "scalacheck" % "1.9" % "test"
+ val scalatest = "org.scalatest" %% "scalatest" % "1.8" % "test"
}
@@ -394,9 +394,6 @@ class App extends
e.`type` match {
case RELOAD => reload()
case MAGIC_OPEN => magicOpen(e.args(0).toString)
- case OPEN_INDEX => openIndex
- case OPEN_NEXT => openNext(1)
- case OPEN_PREVIOUS => openNext(-1)
case CHANGE_LANGUAGE => changeLanguage()
case _ =>
}
@@ -443,18 +440,6 @@ class App extends
org.nlogo.swing.OptionDialog.show(frame, "Change Language", restart, Array(I18N.gui.get("common.buttons.ok")))
}
- private def openIndex() {
- fileMenu.openFromPath(workspace.getModelPath.replaceFirst(" \\S+.nlogo$", " Index.nlogo"), workspace.getModelType)
- }
-
- private def openNext(increment: Int) {
- val path = workspace.getModelPath.replaceFirst(".nlogo$", "")
- val split = path.split(" ")
- val modelNumber = increment + split(split.length - 1).toInt
- fileMenu.openFromPath(
- workspace.getModelPath.replaceFirst(" \\d+.nlogo$", " " + modelNumber + ".nlogo"), workspace.getModelType)
- }
-
///
/**
@@ -433,24 +433,8 @@ with org.nlogo.api.ViewSettings {
/**
* Internal use only.
*/
- def openIndex() = unsupported
-
- /**
- * Internal use only.
- */
- def openNext() = unsupported
-
- /**
- * Internal use only.
- */
- def openPrevious() = unsupported
-
// This lastLogoException stuff is gross. We should write methods that are declared to throw
// LogoException, rather than requiring that this variable be checked. - ST 2/28/05
-
- /**
- * Internal use only.
- */
override var lastLogoException: LogoException = null
// this is a blatant hack that makes it possible to test the new stack trace stuff.
@@ -1,16 +1,18 @@
// (C) Uri Wilensky. https://github.com/NetLogo/NetLogo
package org.nlogo.headless
+
import org.nlogo.api.WorldDimensions
-import org.nlogo.api.{APIVersion,Version}
+import org.nlogo.api.{ APIVersion, Version }
import org.nlogo.workspace.AbstractWorkspace
import org.nlogo.nvm.LabInterface.Settings
+
object Main {
- def main(args:Array[String]) {
+ def main(args: Array[String]) {
setHeadlessProperty()
parseArgs(args).foreach(runExperiment)
}
- def runExperiment(settings:Settings) {
+ def runExperiment(settings: Settings) {
def newWorkspace = {
val w = HeadlessWorkspace.newInstance
w.open(settings.model)
@@ -29,21 +31,21 @@ object Main {
if(System.getProperty(p) == null)
System.setProperty(p, "true")
}
- private def parseArgs(args:Array[String]):Option[Settings] = {
- var model:Option[String] = None
- var minPxcor:Option[String] = None
- var maxPxcor:Option[String] = None
- var minPycor:Option[String] = None
- var maxPycor:Option[String] = None
- var setupFile:Option[java.io.File] = None
- var experiment:Option[String] = None
- var tableWriter:Option[java.io.PrintWriter] = None
- var spreadsheetWriter:Option[java.io.PrintWriter] = None
+ private def parseArgs(args: Array[String]): Option[Settings] = {
+ var model: Option[String] = None
+ var minPxcor: Option[String] = None
+ var maxPxcor: Option[String] = None
+ var minPycor: Option[String] = None
+ var maxPycor: Option[String] = None
+ var setupFile: Option[java.io.File] = None
+ var experiment: Option[String] = None
+ var tableWriter: Option[java.io.PrintWriter] = None
+ var spreadsheetWriter: Option[java.io.PrintWriter] = None
var threads = Runtime.getRuntime.availableProcessors
var suppressErrors = false
val it = args.iterator
- def die(msg:String) { System.err.println(msg); System.exit(1) }
- def path2writer(path:String) =
+ def die(msg: String) { System.err.println(msg); System.exit(1) }
+ def path2writer(path: String) =
if(path == "-")
new java.io.PrintWriter(System.out) {
// don't close System.out - ST 6/9/09
@@ -154,38 +154,47 @@ class Worker(val protocol: Protocol)
throw new FailedException(
"Reporter for measuring runs failed to report a result:\n" + result)
result }
+ def checkForRuntimeError() {
+ if(ws.lastLogoException != null) {
+ val ex = ws.lastLogoException
+ ws.clearLastLogoException()
+ if(!aborted)
+ eachListener(_.runtimeError(ws, runNumber, ex))
+ }
+ }
ws.behaviorSpaceRunNumber(runNumber)
setVariables(settings)
eachListener(_.runStarted(ws, runNumber, settings))
ws.runCompiledCommands(owner(ws.world.mainRNG), setupProcedure)
+ checkForRuntimeError()
if(protocol.runMetricsEveryStep && listeners.nonEmpty) {
val m = takeMeasurements()
eachListener(_.measurementsTaken(ws, runNumber, 0, m))
+ checkForRuntimeError()
}
var steps = 0
while((protocol.timeLimit == 0 || steps < protocol.timeLimit) &&
!exitConditionTrue && !ws.runCompiledCommands(owner(ws.world.mainRNG), goProcedure))
{
+ checkForRuntimeError()
steps += 1
eachListener(_.stepCompleted(ws, steps))
if(protocol.runMetricsEveryStep && listeners.nonEmpty) {
val m = takeMeasurements()
eachListener(_.measurementsTaken(ws, runNumber, steps, m))
+ checkForRuntimeError()
}
ws.updateDisplay(false)
if(aborted) return
}
if(!protocol.runMetricsEveryStep && listeners.nonEmpty) {
val m = takeMeasurements()
eachListener(_.measurementsTaken(ws, runNumber, steps, m))
+ checkForRuntimeError()
}
ws.runCompiledCommands(owner(ws.world.mainRNG), finalProcedure)
+ checkForRuntimeError()
eachListener(_.runCompleted(ws, runNumber, steps))
- if(ws.lastLogoException != null) {
- val ex = ws.lastLogoException
- ws.clearLastLogoException()
- throw ex
- }
}
}
}
@@ -1,40 +1,42 @@
// (C) Uri Wilensky. https://github.com/NetLogo/NetLogo
package org.nlogo.nvm
+
import org.nlogo.api.WorldDimensions
+
object LabInterface {
trait Worker {
- def addListener(l:ProgressListener)
- def addTableWriter(modelFileName:String,initialDims:WorldDimensions,w:java.io.PrintWriter)
- def addSpreadsheetWriter(modelFileName:String,initialDims:WorldDimensions,w:java.io.PrintWriter)
- def run(testWorkspace:Workspace,fn:()=>Workspace,threads:Int)
- def compile(w:Workspace) // only for testing purposes
+ def addListener(l: ProgressListener)
+ def addTableWriter(modelFileName: String, initialDims: WorldDimensions, w: java.io.PrintWriter)
+ def addSpreadsheetWriter(modelFileName: String, initialDims: WorldDimensions, w: java.io.PrintWriter)
+ def run(testWorkspace: Workspace, fn: ()=>Workspace, threads: Int)
+ def compile(w: Workspace) // only for testing purposes
}
trait ProgressListener {
def experimentStarted() { }
def experimentAborted() { }
def experimentCompleted() { }
- def runStarted(w:Workspace,runNumber:Int,settings:List[Pair[String,Any]]) { }
- def measurementsTaken(w:Workspace,runNumber:Int,step:Int,values:List[AnyRef]) { }
- def stepCompleted(w:Workspace,step:Int) { }
- def runCompleted(w:Workspace,runNumber:Int,steps:Int) { }
- def runtimeError(w:Workspace,runNumber:Int,t:Throwable) { }
+ def runStarted(w: Workspace, runNumber: Int, settings: List[Pair[String, Any]]) { }
+ def measurementsTaken(w: Workspace, runNumber: Int, step: Int, values: List[AnyRef]) { }
+ def stepCompleted(w: Workspace, step: Int) { }
+ def runCompleted(w: Workspace, runNumber: Int, steps: Int) { }
+ def runtimeError(w: Workspace, runNumber: Int, t: Throwable) { }
}
- case class Settings(model:String,
- setupFile:Option[java.io.File],
- experiment:Option[String],
- tableWriter:Option[java.io.PrintWriter],
- spreadsheetWriter:Option[java.io.PrintWriter],
- dims:Option[WorldDimensions],
- threads:Int,
- suppressErrors:Boolean)
+ case class Settings(model: String,
+ setupFile: Option[java.io.File],
+ experiment: Option[String],
+ tableWriter: Option[java.io.PrintWriter],
+ spreadsheetWriter: Option[java.io.PrintWriter],
+ dims: Option[WorldDimensions],
+ threads: Int,
+ suppressErrors: Boolean)
}
trait LabInterface {
import LabInterface._
- def load(protocols:String)
- def names:List[String]
- def newWorker(protocolName:String):Worker
- def newWorker(setupFile:java.io.File):Worker
- def newWorker(protocolName:String,setupFile:java.io.File):Worker
- def run(settings:Settings,fn:()=>Workspace)
+ def load(protocols: String)
+ def names: List[String]
+ def newWorker(protocolName: String): Worker
+ def newWorker(setupFile: java.io.File): Worker
+ def newWorker(protocolName: String, setupFile: java.io.File): Worker
+ def run(settings: Settings, fn: ()=>Workspace)
}
@@ -211,12 +211,6 @@ void openString(String modelContents)
void changeLanguage();
- void openIndex();
-
- void openNext();
-
- void openPrevious();
-
CompilerInterface compiler();
boolean isHeadless();
@@ -25,7 +25,7 @@ class PlotExporter(private val plot: Plot, private val csv: CSV) {
double2Double(plot.yMin),
double2Double(plot.yMax),
boolean2Boolean(plot.autoPlotOn),
- plot.currentPen.get.name,
+ plot.currentPen.map(_.name).getOrElse(""),
boolean2Boolean(plot.legendIsOpen),
int2Integer(plot.pens.size))))
writer.println()
@@ -4,7 +4,6 @@
public enum AppEventType {
RELOAD, MAGIC_OPEN,
- OPEN_INDEX, OPEN_NEXT, OPEN_PREVIOUS,
CHANGE_LANGUAGE
}
@@ -361,28 +361,6 @@ public void openString(String modelContents) {
}
// called from the job thread
- public void openIndex() {
- new org.nlogo.window.Events.AppEvent
- (AppEventType.OPEN_INDEX, new Object[]{})
- .raiseLater(this);
- }
-
- // called from the job thread
- public void openNext() {
- new org.nlogo.window.Events.AppEvent
- (AppEventType.OPEN_NEXT,
- new Object[]{})
- .raiseLater(this);
- }
-
- // called from the job thread
- public void openPrevious() {
- new org.nlogo.window.Events.AppEvent
- (AppEventType.OPEN_PREVIOUS, new Object[]{})
- .raiseLater(this);
- }
-
- // called from the job thread
public void reload() {
new org.nlogo.window.Events.AppEvent
(AppEventType.RELOAD, new Object[]{})
@@ -64,9 +64,6 @@ class DummyWorkspace extends DummyCompilerServices with Workspace {
override def changeTopology(wrapX: Boolean, wrapY: Boolean) = unsupported
override def magicOpen(name: String) = unsupported
override def changeLanguage() = unsupported
- override def openIndex() = unsupported
- override def openNext() = unsupported
- override def openPrevious() = unsupported
override def lastRunTimes() = unsupported
override def completedActivations() = unsupported
override def compiler() = unsupported
@@ -27,9 +27,6 @@ extends AbstractWorkspaceScala(new World)
override def openString(modelContents: String) = unsupported
override def magicOpen(name: String) = unsupported
override def changeLanguage() = unsupported
- override def openIndex(): Unit = unsupported
- override def openNext(): Unit = unsupported
- override def openPrevious(): Unit = unsupported
override def clearOutput(): Unit = unsupported
override def sendOutput(oo: org.nlogo.agent.OutputObject, toOutputArea: Boolean): Unit = unsupported
override def importerErrorHandler: org.nlogo.agent.Importer.ErrorHandler = unsupported

0 comments on commit e8518e2

Please sign in to comment.