private void compileSource( org.nlogo.api.JobOwner owner, List<org.nlogo.window.Events.CompiledEvent> errorEvents) { try { CompilerResults results = workspace .compiler() .compileMoreCode( owner.source(), scala.Some.apply(owner.classDisplayName() + " '" + owner.displayName() + "'"), workspace.world.program(), workspace.getProcedures(), workspace.getExtensionManager()); if (!results.procedures().isEmpty()) { results.head().init(workspace); results.head().setOwner(owner); new org.nlogo.window.Events.CompiledEvent( owner, workspace.world.program(), results.head(), null) .raise(this); } } catch (CompilerException error) { errorEvents.add( new org.nlogo.window.Events.CompiledEvent(owner, workspace.world.program(), null, error)); } }
public void handle(org.nlogo.window.Events.CompileMoreSourceEvent e) { JobOwner owner = e.owner; if (isLoading) { widgets.add(owner); return; } if (owner.isCommandCenter()) { try { CompilerResults results = workspace .compiler() .compileMoreCode( owner.source(), scala.Some.apply(owner.classDisplayName()), workspace.world.program(), workspace.getProcedures(), workspace.getExtensionManager()); results.head().init(workspace); results.head().setOwner(owner); new org.nlogo.window.Events.CompiledEvent( owner, workspace.world.program(), results.head(), null) .raise(this); } catch (CompilerException error) { new org.nlogo.window.Events.CompiledEvent(owner, workspace.world.program(), null, error) .raise(this); } } else { compileWidgets(); } }
public Object load(scala.collection.Seq<String> strings, String version) { workspace.loadWorld(strings, version, this); // we can't clearAll here because the globals may not // be allocated yet ev 7/12/06 // note that we clear turtles inside the load method so // it can happen before we set the topology ev 7/19/06 workspace.world().tickCounter.clear(); workspace.world().clearPatches(); workspace.world().displayOn(true); return this; }
public void setDimensions(int minPxcor, int maxPxcor, int minPycor, int maxPycor) { newMinX = minPxcor; newMaxX = maxPxcor; newMinY = minPycor; newMaxY = maxPycor; if (minPxcor != workspace.world().minPxcor() || maxPxcor != workspace.world().maxPxcor() || minPycor != workspace.world().minPycor() || maxPycor != workspace.world().maxPycor()) { prepareForWorldResize(); workspace.world().createPatches(minPxcor, maxPxcor, minPycor, maxPycor); finishWorldResize(); } }
public boolean wrappingY() { if (!wrappingChanged) { newWrapY = workspace.world().wrappingAllowedInY(); } return newWrapY; }
public boolean wrappingX() { if (!wrappingChanged) { newWrapX = workspace.world().wrappingAllowedInX(); } return newWrapX; }
public SpeedSliderPanel(GUIWorkspace workspace, boolean labelsBelow) { this.workspace = workspace; this.labelsBelow = labelsBelow; speedSlider = new SpeedSlider((int) workspace.speedSliderPosition()); speedSlider.setFocusable(false); speedSlider.addChangeListener(this); speedSlider.addMouseListener(this); speedSlider.setOpaque(false); org.nlogo.awt.Fonts.adjustDefaultFont(normal); setOpaque(false); if (labelsBelow) { GridBagLayout gridbag = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); setLayout(gridbag); c.gridwidth = GridBagConstraints.REMAINDER; add(speedSlider, c); c.gridwidth = 1; c.anchor = GridBagConstraints.CENTER; add(normal, c); } else { java.awt.BorderLayout layout = new java.awt.BorderLayout(); layout.setVgap(0); setLayout(layout); add(speedSlider, java.awt.BorderLayout.CENTER); add(normal, java.awt.BorderLayout.EAST); } enableLabels(0); }
public void stateChanged(javax.swing.event.ChangeEvent e) { int value = speedSlider.getValue(); // adjust the speed reported to the workspace // so there isn't a big gap between the snap area // and outside the snap area. ev 2/22/07 if (value < -10) { value += 10; } else if (value > 10) { value -= 10; } else { value = 0; } workspace.speedSliderPosition(value / 2); if (org.nlogo.api.Version.isLoggingEnabled()) { org.nlogo.log.Logger.logSpeedSlider(value); } enableLabels(value); workspace.updateManager().nudgeSleeper(); }
private boolean compileProcedures() { workspace.world.program(workspace.world.newProgram()); try { CompilerResults results = workspace .compiler() .compileProgram( proceduresInterface.innerSource(), workspace.world.newProgram(getGlobalVariableNames()), workspace.getExtensionManager()); workspace.setProcedures(results.proceduresMap()); for (Procedure procedure : workspace.getProcedures().values()) { if (procedure.fileName.equals("")) { procedure.setOwner(proceduresInterface); } else if (procedure.fileName.equals("aggregate")) { procedure.setOwner(workspace.aggregateManager()); } else { procedure.setOwner(new ExternalFileInterface(procedure.fileName)); } } workspace.init(); workspace.world.program(results.program()); new org.nlogo.window.Events.CompiledEvent(proceduresInterface, results.program(), null, null) .raise(this); return true; } catch (CompilerException error) { if (AbstractWorkspace.isApplet()) { System.err.println("CompilerException: " + error); error.printStackTrace(); new org.nlogo.window.Events.CompiledEvent(proceduresInterface, null, null, error) .raise(this); } if (error.fileName().equals("")) { new org.nlogo.window.Events.CompiledEvent(proceduresInterface, null, null, error) .raise(this); } else if (error.fileName().equals("aggregate")) { new org.nlogo.window.Events.CompiledEvent(workspace.aggregateManager(), null, null, error) .raise(this); } else { new org.nlogo.window.Events.CompiledEvent( new ExternalFileInterface(error.fileName()), null, null, error) .raise(this); } return false; } }
void reset() { enableSizeControls( (workspace.world().maxPxcor() == -workspace.world().minPxcor() || workspace.world().minPxcor() == 0 || workspace.world().maxPxcor() == 0), (workspace.world().maxPycor() == -workspace.world().minPycor() || workspace.world().minPycor() == 0 || workspace.world().maxPycor() == 0)); // this next line shouldn't be necessary, but in Java 1.4.2U1DP3 // on OS X it became necessary in the applet, which is // probably a VM bug, but it's OK, I think it's harmless // - ST 7/13/04 doLayout(); }
public void frameRate(double frameRate) { workspace.frameRate(frameRate); }
public void setValue(int speed) { if (speedSlider.getValue() != speed) { speedSlider.setValue(speed); } enableLabels((int) workspace.speedSliderPosition()); }
private boolean newSizeOK(int sizeX, int sizeY) { return sizeX >= 1 && sizeY >= 1 && workspace.world().patchSize() * sizeX >= getMinimumSize().width; }
void prepareForWorldResize() { workspace.jobManager.haltNonObserverJobs(); workspace.world().clearTurtles(); workspace.world().clearLinks(); }
void finishWorldResize() { workspace.patchesCreatedNotify(); gWidget.resetSize(); workspace.clearDrawing(); }
public void setDimensions(org.nlogo.api.WorldDimensions d, double patchSize) { workspace.world().patchSize(patchSize); setDimensions(d); patchSize(patchSize); gWidget.resetSize(); }
public double patchSize() { return workspace.world().patchSize(); }
public void dualView(boolean on) { workspace.dualView(on); }
public void maxPycor(int maxPycor) { if (maxPycor >= 0) { newMaxY = maxPycor; edgesChanged = edgesChanged || (newMaxY != workspace.world().maxPycor()); } }
public UpdateMode updateMode() { return workspace.updateMode(); }
public double frameRate() { return workspace.frameRate(); }
public void wrappingY(boolean value) { newWrapY = value; wrappingChanged = wrappingChanged || (newWrapY != workspace.world().wrappingAllowedInY()); }
public void updateMode(UpdateMode updateMode) { workspace.updateMode(updateMode); }
public void wrappingX(boolean value) { newWrapX = value; wrappingChanged = wrappingChanged || (newWrapX != workspace.world().wrappingAllowedInX()); }
public boolean dualView() { return workspace.dualView(); }
public void clearTurtles() { workspace.world().clearTurtles(); }
public void changeTopology(boolean wrapX, boolean wrapY) { workspace.changeTopology(wrapX, wrapY); }
public void minPycor(int minPycor) { if (minPycor <= 0) { newMinY = minPycor; edgesChanged = edgesChanged || (newMinY != workspace.world().minPycor()); } }