Permalink
Browse files

Merge remote-tracking branch 'origin/5.0.x'

Conflicts:
	headless/src/main/org/nlogo/hubnet/server/HubNetUtils.scala
	project/autogen/events.txt
	src/main/org/nlogo/app/App.scala
	src/main/org/nlogo/app/CodeTab.scala
	src/main/org/nlogo/app/InfoTab.scala
	src/main/org/nlogo/app/WidgetPanel.java
	test/benchdumps/Fire.txt
	test/benchdumps/FireBig.txt
	test/benchdumps/Life.txt
  • Loading branch information...
SethTisue committed Apr 3, 2013
2 parents e23a218 + 18bf5ae commit 5faea6318b692795fd11a254d882b9630a370864
View
@@ -7092,14 +7092,14 @@ <h4>
self
<br>
<img alt="Turtle Command" src="images/turtle.gif"> <img alt=
- "Patch Command" src="images/patch.gif">
+ "Patch Command" src="images/patch.gif"> <img alt="Link Command" src="images/link.gif">
</h4>
<p>
- Reports this turtle or patch.
+ Reports this turtle, patch, or link.
<p>
&quot;self&quot; and &quot;myself&quot; are very different.
&quot;self&quot; is simple; it means &quot;me&quot;.
- &quot;myself&quot; means &quot;the turtle or patch who asked me to
+ &quot;myself&quot; means &quot;the agent who asked me to
do what I'm doing right now.&quot;
<p>
See also <a href="#myself">myself</a>.
@@ -80,6 +80,8 @@ object ChecksumsAndPreviews {
def okPath(path: String) = (for {
(message, slices) <- Seq(
None -> List("HUBNET", "/CURRICULAR MODELS/"),
+ Some("it renders slightly differently on Mac vs. Linux") -> List(
+ "/CODE EXAMPLES/LINK BREEDS EXAMPLE.NLOGO"), // see 407ddcdd49f88395915b1a87c663b13000758d35 in `models` repo
Some("it uses the sound extension") -> List(
"/GAMES/FROGGER.NLOGO",
"/ART/SOUND MACHINES.NLOGO",
@@ -17,7 +17,7 @@ object HubNetUtils {
val SERVER_DISCOVERY_ANNOUNCE_INTERVAL = 1000
// these are terrible - JC 8/21/10
- var viewMirroring = false
+ var viewMirroring = true
// this doesnt appear to be used - JC 8/21/10
def checkPacketSize(obj: Object, message: String) {
View
@@ -52,4 +52,4 @@ window.WidgetAdded - widget: Widget
window.WidgetEdited - widget: Widget
window.WidgetForegrounded - widget: Widget
window.WidgetRemoved - widget: Widget
-window.Zoomed - zoomFactor: Double
+window.Zoomed - action: Int
@@ -276,6 +276,7 @@ class App extends
Events.MagicOpenEventHandler with
Events.ReloadEventHandler with
Events.SwitchedTabsEventHandler with
+ ZoomedEventHandler with
Controllable {
import App.{pico, logger, commandLineMagic, commandLineModel, commandLineURL, commandLineModelIsLaunch, loggingName}
@@ -435,7 +436,7 @@ class App extends
add(fileMenu)
add(new EditMenu(App.this))
add(pico.getComponent(classOf[ToolsMenu]))
- add(new ZoomMenu(App.this))
+ add(new ZoomMenu)
add(tabs.tabsMenu)
}
// a little ugly we have to typecast here, but oh well - ST 10/11/05
@@ -492,7 +493,7 @@ class App extends
def createFileMenu: JMenu = pico.getComponent(classOf[FileMenu])
def createEditMenu: JMenu = new EditMenu(App.this)
def createToolsMenu: JMenu = new ToolsMenu(App.this)
- def createZoomMenu: JMenu = new ZoomMenu(App.this)
+ def createZoomMenu: JMenu = new ZoomMenu
override def addHelpMenu(menuBar:JMenuBar) = {
val newMenu = new HelpMenu (App.this, new EditorColorizer(workspace))
menuBar.add(newMenu)
@@ -577,21 +578,15 @@ class App extends
else fileMenu.newModel()
}
- /// zooming stuff
- private var zoomSteps = 0
- def zoomLarger(){ zoomSteps+=1; finishZoom() }
- def resetZoom() { zoomSteps=0; finishZoom() }
- def zoomSmaller() {
- zoomSteps-=1
- zoomSteps = StrictMath.max(-5, zoomSteps)
- finishZoom()
- }
- private def finishZoom() {
- new ZoomedEvent(1.0 + zoomSteps * 0.1).raise(this)
+ /// zooming
+
+ def handle(e: ZoomedEvent) {
smartPack(frame.getPreferredSize)
}
- /// more event handlers
+ def resetZoom() {
+ new ZoomedEvent(0).raise(this)
+ }
def handle(e: Events.ReloadEvent) {
val modelType = workspace.getModelType
@@ -984,21 +979,25 @@ class App extends
tabs.interfaceTab.adjustTargetSize(targetSize)
- // reduce our size ambitions if necessary
- var newWidth = StrictMath.min(targetSize.width, maxWidth )
- var newHeight = StrictMath.min(targetSize.height, maxHeight)
+ import StrictMath.{ max, min }
+
+ val (currentWidth, currentHeight) = (frame.getWidth, frame.getHeight)
+
+ // Maybe grow the window, but never shrink it
+ var newWidth = max(min(targetSize.width, maxWidth), currentWidth)
+ var newHeight = max(min(targetSize.height, maxHeight), currentHeight)
// move up/left to get more room if possible and necessary
- val moveLeft = StrictMath.max(0, frame.getLocation().x + newWidth - maxX)
- val moveUp = StrictMath.max(0, frame.getLocation().y + newHeight - maxY)
+ val moveLeft = max(0, frame.getLocation().x + newWidth - maxX)
+ val moveUp = max(0, frame.getLocation().y + newHeight - maxY)
// now we can compute our new position
- val newX = StrictMath.max(maxBoundsX, frame.getLocation().x - moveLeft)
- val newY = StrictMath.max(maxBoundsY, frame.getLocation().y - moveUp )
+ val newX = max(maxBoundsX, frame.getLocation().x - moveLeft)
+ val newY = max(maxBoundsY, frame.getLocation().y - moveUp)
// and now that we know our position, we can compute our new size
- newWidth = StrictMath.min(newWidth, maxX - newX)
- newHeight = StrictMath.min(newHeight, maxY - newY)
+ newWidth = min(newWidth, maxX - newX)
+ newHeight = min(newHeight, maxY - newY)
// now do it!
frame.setBounds(newX, newY, newWidth, newHeight)
@@ -17,7 +17,7 @@ class CodeTab(val workspace: AbstractWorkspace) extends JPanel
with ProceduresMenuTarget
with Events.SwitchedTabsEventHandler
with org.nlogo.window.Events.CompiledEventHandler
- with org.nlogo.window.Events.ZoomedEventHandler
+ with org.nlogo.window.Zoomable
with org.nlogo.swing.Printable {
private val listener = new TextListener() {
@@ -28,6 +28,7 @@ class CodeTab(val workspace: AbstractWorkspace) extends JPanel
}
val text = new EditorFactory(workspace).newEditor(100, 100, true, listener, true)
text.setBorder(BorderFactory.createEmptyBorder(4, 7, 4, 7))
+ override def zoomTarget = text
val errorLabel = new EditorAreaErrorLabel(text)
val toolBar = getToolBar
@@ -104,14 +105,12 @@ class CodeTab(val workspace: AbstractWorkspace) extends JPanel
}
private var originalFontSize = -1
- private var zoomFactor = 1.0
- def handle(e: org.nlogo.window.Events.ZoomedEvent) {
- if(zoomFactor != e.zoomFactor) {
- zoomFactor = e.zoomFactor
- if(originalFontSize == -1) originalFontSize = text.getFont.getSize
- text.setFont(text.getFont.deriveFont(StrictMath.ceil(originalFontSize * zoomFactor).toFloat))
- errorLabel.zoom(zoomFactor)
- }
+ override def handle(e: org.nlogo.window.Events.ZoomedEvent) {
+ super.handle(e)
+ if(originalFontSize == -1)
+ originalFontSize = text.getFont.getSize
+ text.setFont(text.getFont.deriveFont(StrictMath.ceil(originalFontSize * zoomFactor).toFloat))
+ errorLabel.zoom(zoomFactor)
}
// Error code
@@ -11,6 +11,7 @@ import org.nlogo.api.{ AgentKind, I18N }
class CommandCenter(workspace: org.nlogo.workspace.AbstractWorkspaceScala,
locationToggleAction: Action) extends JPanel
+ with org.nlogo.window.Zoomable
with org.nlogo.window.CommandCenterInterface
with org.nlogo.window.Events.LoadBeginEventHandler
with org.nlogo.window.Events.ZoomedEventHandler {
@@ -143,13 +144,4 @@ class CommandCenter(workspace: org.nlogo.workspace.AbstractWorkspaceScala,
repaintPrompt()
commandLine.requestFocus()
}
- /// zooming
- private lazy val zoomer: Zoomer = new Zoomer(this)
- private var zoomFactor = 1.0
- def zoomSubcomponents = true
- def handle(e: org.nlogo.window.Events.ZoomedEvent) {
- zoomer.scaleComponentFont(this, e.zoomFactor, zoomFactor, true)
- zoomFactor = e.zoomFactor
- revalidate()
- }
}
@@ -21,7 +21,8 @@ import java.io.File
class InfoTab(attachModelDir: String => String) extends JPanel with
DocumentListener with Printable with HyperlinkListener with
org.nlogo.window.Events.LoadSectionEventHandler with
- org.nlogo.window.Events.ZoomedEventHandler {
+ org.nlogo.window.Events.ZoomedEventHandler with
+ org.nlogo.window.Zoomable {
val baseDocUrl = "docs/infotab.html"
@@ -73,6 +74,8 @@ class InfoTab(attachModelDir: String => String) extends JPanel with
ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED)
+ override def zoomTarget = scrollPane
+
locally {
resetBorders()
setLayout(new BorderLayout())
@@ -145,15 +148,13 @@ class InfoTab(attachModelDir: String => String) extends JPanel with
private var editorPaneFontSize = InfoFormatter.defaultFontSize
private var originalFontSize = -1
- private var zoomFactor = 1.0
- def handle(e: org.nlogo.window.Events.ZoomedEvent) {
- if(zoomFactor != e.zoomFactor) {
- zoomFactor = e.zoomFactor
- if(originalFontSize == -1) { originalFontSize = textArea.getFont.getSize }
- textArea.setFont(textArea.getFont.deriveFont(StrictMath.ceil(originalFontSize * zoomFactor).toFloat))
- editorPaneFontSize = StrictMath.ceil(InfoFormatter.defaultFontSize * zoomFactor).toInt
- updateEditorPane()
- }
+ override def handle(e: org.nlogo.window.Events.ZoomedEvent) {
+ super.handle(e)
+ if(originalFontSize == -1)
+ originalFontSize = textArea.getFont.getSize
+ textArea.setFont(textArea.getFont.deriveFont(StrictMath.ceil(originalFontSize * zoomFactor).toFloat))
+ editorPaneFontSize = StrictMath.ceil(InfoFormatter.defaultFontSize * zoomFactor).toInt
+ updateEditorPane()
}
// the textArea will give us an outlandlishly large preferred size unless we restrain it
@@ -273,16 +273,16 @@ public String convert(String source, boolean reporter) {
parent.setSize(viewWidget.asWidget().getSize());
enforceMinimumAndMaximumWidgetSizes(viewWidget.asWidget());
parent.setLocation(x, y);
- zoomer.zoomWidgetLocation
+ zoomer().zoomWidgetLocation
(getWrapper(viewWidget.asWidget()),
- true, true, 1.0, zoomer.zoomFactor());
- zoomer.zoomWidgetSize
+ true, true, 1.0, zoomer().zoomFactor());
+ zoomer().zoomWidgetSize
(getWrapper(viewWidget.asWidget()),
- true, true, 1.0, zoomer.zoomFactor());
- zoomer.scaleComponentFont
+ true, true, 1.0, zoomer().zoomFactor());
+ zoomer().scaleComponentFont
(((org.nlogo.window.ViewWidget) viewWidget)
.view,
- zoomer.zoomFactor(), 1.0, false);
+ zoomFactor(), 1.0, false);
}
return viewWidget.asWidget();
} else {
@@ -26,16 +26,14 @@
java.awt.event.FocusListener,
org.nlogo.window.Events.WidgetEditedEventHandler,
org.nlogo.window.Events.WidgetRemovedEventHandler,
- org.nlogo.window.Events.LoadBeginEventHandler,
- org.nlogo.window.Events.ZoomedEventHandler {
+ org.nlogo.window.Events.LoadBeginEventHandler {
static final int GRID_SNAP = 5; // set the size of the grid, in pixels
protected java.awt.Rectangle selectionRect;
protected java.awt.Point startDragPoint;
protected WidgetWrapper newWidget;
protected List<WidgetWrapper> widgetsBeingDragged;
protected final GUIWorkspace workspace;
- final Zoomer zoomer = new Zoomer(this);
protected final javax.swing.JComponent glassPane =
new javax.swing.JComponent() {
@Override
@@ -540,7 +538,7 @@ protected WidgetWrapper addWidget(Widget widget, int x, int y,
wrapper.validate();
wrapper.setVisible(true);
- zoomer.zoomWidget(wrapper, true, loadingWidget, 1.0, zoomer.zoomFactor());
+ zoomer().zoomWidget(wrapper, true, loadingWidget, 1.0, zoomFactor());
if (select) {
newWidget = wrapper;
@@ -623,8 +621,9 @@ public void sliderEventOnReleaseOnly(boolean sliderEventOnReleaseOnly) {
}
public void handle(org.nlogo.window.Events.ZoomedEvent e) {
+ super.handle(e);
unselectWidgets();
- zoomer.zoomWidgets(e.zoomFactor());
+ zoomer().zoomWidgets(zoomFactor());
revalidate();
}
@@ -655,7 +654,7 @@ public String convert(String source, boolean reporter) {
public void handle(org.nlogo.window.Events.WidgetEditedEvent e) {
new org.nlogo.window.Events.DirtyEvent().raise(this);
- zoomer.updateZoomInfo(e.widget());
+ zoomer().updateZoomInfo(e.widget());
}
public void handle(org.nlogo.window.Events.WidgetRemovedEvent e) {
@@ -678,7 +677,7 @@ public void handle(org.nlogo.window.Events.WidgetRemovedEvent e) {
public void handle(org.nlogo.window.Events.LoadBeginEvent e) {
unselectWidgets();
removeAllWidgets();
- zoomer.forgetAllZoomInfo();
+ zoomer().forgetAllZoomInfo();
}
@Override
@@ -822,19 +821,19 @@ public String getBoundsString(Widget widget) {
}
public java.awt.Rectangle getUnzoomedBounds(java.awt.Component component) {
- return zoomer.getUnzoomedBounds(component);
+ return zoomer().getUnzoomedBounds(component);
}
public void resetZoomInfo(Widget widget) {
- zoomer.updateZoomInfo(widget);
+ zoomer().updateZoomInfo(widget);
}
public void resetSizeInfo(Widget widget) {
getWrapper(widget).widgetResized();
}
public boolean isZoomed() {
- return zoomer.zoomFactor() != 1.0;
+ return zoomer().zoomFactor() != 1.0;
}
public boolean canAddWidget(String widget) {
@@ -262,7 +262,7 @@ void foreground() {
if (getParent() instanceof WidgetPanel && !widget.isNote()) {
WidgetPanel iP = (WidgetPanel) getParent();
- dim = iP.zoomer.zoomSize(dim);
+ dim = iP.zoomer().zoomSize(dim);
}
if (selected()) {
dim.width += BORDER_E + BORDER_W;
@@ -596,15 +596,15 @@ public void mouseReleased(java.awt.event.MouseEvent e) {
void doDrop() {
selected(true, true); // 2nd true = change was temporary
new org.nlogo.window.Events.DirtyEvent().raise(this);
- ((WidgetPanel) getParent()).zoomer.updateZoomInfo(widget);
+ ((WidgetPanel) getParent()).zoomer().updateZoomInfo(widget);
}
private void enforceMinimumSize(java.awt.Rectangle r) {
if (widget() != null) {
java.awt.Dimension minWidgetSize = widget().getMinimumSize();
if (getParent() instanceof WidgetPanel) {
WidgetPanel iP = (WidgetPanel) getParent();
- minWidgetSize = iP.zoomer.zoomSize(minWidgetSize);
+ minWidgetSize = iP.zoomer().zoomSize(minWidgetSize);
}
if (minWidgetSize == null) {
minWidgetSize = new java.awt.Dimension(MIN_WIDGET_WIDTH, MIN_WIDGET_HEIGHT);
@@ -695,7 +695,7 @@ private void enforceMaximumSize(java.awt.Rectangle r) {
}
if (getParent() instanceof WidgetPanel) {
WidgetPanel iP = (WidgetPanel) getParent();
- maxWidgetSize = iP.zoomer.zoomSize(maxWidgetSize);
+ maxWidgetSize = iP.zoomer().zoomSize(maxWidgetSize);
}
switch (mouseMode()) {
@@ -833,7 +833,7 @@ public void handle(org.nlogo.window.Events.WidgetForegroundedEvent e) {
// return what our location would be if we *weren't* selected... this
// is needed for the zooming code in InterfacePanel
- java.awt.Point getUnselectedLocation() {
+ public java.awt.Point getUnselectedLocation() {
java.awt.Point result = getLocation();
if (selected()) {
result.x += BORDER_E;
Oops, something went wrong.

0 comments on commit 5faea63

Please sign in to comment.