Skip to content
Browse files

Middle of adding canvas stuff

  • Loading branch information...
1 parent 7371ac7 commit 8fd15b7c1b275f10c7dea6602219d55cddc55697 @zk committed
View
134 dbssim.iws
@@ -73,10 +73,55 @@
</component>
<component name="FileEditorManager">
<leaf>
- <file leaf-file-name="SimUI.groovy" pinned="false" current="true" current-in-tab="true">
+ <file leaf-file-name="SimUI.groovy" pinned="false" current="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/main/groovy/napplelabs/dbssim/ui/SimUI.groovy">
<provider selected="true" editor-type-id="text-editor">
- <state line="27" column="33" selection-start="869" selection-end="869" vertical-scroll-proportion="-1.7510917">
+ <state line="104" column="33" selection-start="3863" selection-end="3863" vertical-scroll-proportion="0.0">
+ <folding />
+ </state>
+ </provider>
+ </entry>
+ </file>
+ <file leaf-file-name="CanvasPanel.groovy" pinned="false" current="true" current-in-tab="true">
+ <entry file="file://$PROJECT_DIR$/src/main/groovy/napplelabs/dbssim/ui/CanvasPanel.groovy">
+ <provider selected="true" editor-type-id="text-editor">
+ <state line="50" column="6" selection-start="1517" selection-end="1517" vertical-scroll-proportion="-2.5475688">
+ <folding />
+ </state>
+ </provider>
+ </entry>
+ </file>
+ <file leaf-file-name="NapPZoomEventHandler.java" pinned="false" current="false" current-in-tab="false">
+ <entry file="file://$PROJECT_DIR$/src/main/groovy/napplelabs/dbssim/ui/NapPZoomEventHandler.java">
+ <provider selected="true" editor-type-id="text-editor">
+ <state line="19" column="21" selection-start="907" selection-end="907" vertical-scroll-proportion="0.0">
+ <folding />
+ </state>
+ </provider>
+ </entry>
+ </file>
+ <file leaf-file-name="SnrPath.java" pinned="false" current="false" current-in-tab="false">
+ <entry file="file://$PROJECT_DIR$/../../Library/Caches/IntelliJIDEA80/compiler/dbssim.dbssim4c3d0c13/.generated/Groovy_to_java_source_code_generator/dbssim.4c3d0bb0/production/napplelabs/dbssim/ui/SnrPath.java">
+ <provider selected="true" editor-type-id="text-editor">
+ <state line="2" column="7" selection-start="38" selection-end="38" vertical-scroll-proportion="0.0">
+ <folding />
+ </state>
+ </provider>
+ </entry>
+ </file>
+ <file leaf-file-name="StnPath.java" pinned="false" current="false" current-in-tab="false">
+ <entry file="file://$PROJECT_DIR$/../../Library/Caches/IntelliJIDEA80/compiler/dbssim.dbssim4c3d0c13/.generated/Groovy_to_java_source_code_generator/dbssim.4c3d0bb0/production/napplelabs/dbssim/ui/StnPath.java">
+ <provider selected="true" editor-type-id="text-editor">
+ <state line="2" column="7" selection-start="38" selection-end="38" vertical-scroll-proportion="0.0">
+ <folding />
+ </state>
+ </provider>
+ </entry>
+ </file>
+ <file leaf-file-name="PPath.class" pinned="false" current="false" current-in-tab="false">
+ <entry file="jar://$MAVEN_REPOSITORY$/piccolo/piccolo/1.2.1/piccolo-1.2.1.jar!/edu/umd/cs/piccolo/nodes/PPath.class">
+ <provider selected="true" editor-type-id="text-editor">
+ <state line="5" column="13" selection-start="162" selection-end="162" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
@@ -94,7 +139,7 @@
<file leaf-file-name="TabManager.groovy" pinned="false" current="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/main/groovy/napplelabs/dbssim/ui/TabManager.groovy">
<provider selected="true" editor-type-id="text-editor">
- <state line="66" column="69" selection-start="2038" selection-end="2038" vertical-scroll-proportion="0.0">
+ <state line="74" column="46" selection-start="2213" selection-end="2213" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
@@ -150,6 +195,10 @@
<option name="myItemId" value="dbssim" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewModuleNode" />
</PATH_ELEMENT>
+ <PATH_ELEMENT>
+ <option name="myItemId" value="Libraries" />
+ <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.LibraryGroupNode" />
+ </PATH_ELEMENT>
</PATH>
<PATH>
<PATH_ELEMENT>
@@ -332,16 +381,19 @@
</component>
<component name="PropertiesComponent">
<property name="GoToFile.includeJavaFiles" value="false" />
- <property name="GoToClass.toSaveIncludeLibraries" value="false" />
+ <property name="project.structure.last.edited" value="Modules" />
+ <property name="project.structure.proportion" value="0.0" />
<property name="options.splitter.main.proportions" value="0.3" />
<property name="RunManagerConfig.showSettingsBeforeRunnig" value="true" />
- <property name="options.lastSelected" value="MavenSettings" />
<property name="MemberChooser.sorted" value="false" />
+ <property name="options.lastSelected" value="project.propGUI" />
+ <property name="project.structure.side.proportion" value="0.0" />
+ <property name="MemberChooser.copyJavadoc" value="false" />
+ <property name="GoToClass.toSaveIncludeLibraries" value="false" />
<property name="MemberChooser.showClasses" value="true" />
<property name="GoToClass.includeLibraries" value="false" />
- <property name="options.searchVisible" value="true" />
<property name="options.splitter.details.proportions" value="0.2" />
- <property name="MemberChooser.copyJavadoc" value="false" />
+ <property name="options.searchVisible" value="true" />
</component>
<component name="RunManager" selected="Application.SimUI">
<tempConfiguration default="false" name="SimUI" type="Application" factoryName="Application" enabled="false" merge="false" sample_coverage="true" runner="emma">
@@ -554,7 +606,7 @@
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="6" side_tool="false" />
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="1" side_tool="false" />
<window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.4" sideWeight="0.5" order="0" side_tool="false" />
- <window_info id="Maven Projects" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.32954547" sideWeight="0.79877114" order="-1" side_tool="false" />
+ <window_info id="Maven Projects" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.24837662" sideWeight="0.79877114" order="-1" side_tool="false" />
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.25" sideWeight="0.79877114" order="0" side_tool="false" />
<window_info id="Dependency Viewer" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" />
<window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.4" sideWeight="0.5" order="5" side_tool="false" />
@@ -638,23 +690,79 @@
</state>
</provider>
</entry>
+ <entry file="file://$PROJECT_DIR$/src/main/groovy/napplelabs/dbssim/ui/TracePApplet.java">
+ <provider selected="true" editor-type-id="text-editor">
+ <state line="1" column="16" selection-start="30" selection-end="30" vertical-scroll-proportion="0.0">
+ <folding />
+ </state>
+ </provider>
+ </entry>
+ <entry file="file://$PROJECT_DIR$/src/main/groovy/napplelabs/dbssim/ui/SimUI.groovy">
+ <provider selected="true" editor-type-id="text-editor">
+ <state line="104" column="33" selection-start="3863" selection-end="3863" vertical-scroll-proportion="0.0">
+ <folding />
+ </state>
+ </provider>
+ </entry>
+ <entry file="jar:///System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home/../Classes/classes.jar!/javax/swing/JSlider.class">
+ <provider selected="true" editor-type-id="text-editor">
+ <state line="0" column="0" selection-start="0" selection-end="0" vertical-scroll-proportion="0.0">
+ <folding />
+ </state>
+ </provider>
+ </entry>
+ <entry file="jar://$MAVEN_REPOSITORY$/piccolo/piccolo/1.2.1/piccolo-1.2.1.jar!/edu/umd/cs/piccolo/nodes/PPath.class">
+ <provider selected="true" editor-type-id="text-editor">
+ <state line="5" column="13" selection-start="162" selection-end="162" vertical-scroll-proportion="0.0">
+ <folding />
+ </state>
+ </provider>
+ </entry>
+ <entry file="jar://$MAVEN_REPOSITORY$/piccolo/piccolo/1.2.1/piccolo-1.2.1.jar!/edu/umd/cs/piccolo/PCanvas.class">
+ <provider selected="true" editor-type-id="text-editor">
+ <state line="5" column="13" selection-start="156" selection-end="156" vertical-scroll-proportion="-0.07860262">
+ <folding />
+ </state>
+ </provider>
+ </entry>
<entry file="file://$PROJECT_DIR$/src/main/groovy/napplelabs/dbssim/ui/TabManager.groovy">
<provider selected="true" editor-type-id="text-editor">
- <state line="66" column="69" selection-start="2038" selection-end="2038" vertical-scroll-proportion="0.0">
+ <state line="74" column="46" selection-start="2213" selection-end="2213" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
- <entry file="file://$PROJECT_DIR$/src/main/groovy/napplelabs/dbssim/ui/TracePApplet.java">
+ <entry file="file://$PROJECT_DIR$/../../Library/Caches/IntelliJIDEA80/compiler/dbssim.dbssim4c3d0c13/.generated/Groovy_to_java_source_code_generator/dbssim.4c3d0bb0/production/napplelabs/dbssim/ui/SnrPath.java">
<provider selected="true" editor-type-id="text-editor">
- <state line="1" column="16" selection-start="30" selection-end="30" vertical-scroll-proportion="0.0">
+ <state line="2" column="7" selection-start="38" selection-end="38" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
- <entry file="file://$PROJECT_DIR$/src/main/groovy/napplelabs/dbssim/ui/SimUI.groovy">
+ <entry file="file://$PROJECT_DIR$/../../Library/Caches/IntelliJIDEA80/compiler/dbssim.dbssim4c3d0c13/.generated/Groovy_to_java_source_code_generator/dbssim.4c3d0bb0/production/napplelabs/dbssim/ui/StnPath.java">
+ <provider selected="true" editor-type-id="text-editor">
+ <state line="2" column="7" selection-start="38" selection-end="38" vertical-scroll-proportion="0.0">
+ <folding />
+ </state>
+ </provider>
+ </entry>
+ <entry file="file://$PROJECT_DIR$/src/main/groovy/napplelabs/dbssim/ui/NapPZoomEventHandler.java">
+ <provider selected="true" editor-type-id="text-editor">
+ <state line="19" column="21" selection-start="907" selection-end="907" vertical-scroll-proportion="0.0">
+ <folding />
+ </state>
+ </provider>
+ </entry>
+ <entry file="jar://$MAVEN_REPOSITORY$/piccolo/piccolo/1.2.1/piccolo-1.2.1.jar!/edu/umd/cs/piccolo/nodes/PText.class">
+ <provider selected="true" editor-type-id="text-editor">
+ <state line="0" column="0" selection-start="0" selection-end="0" vertical-scroll-proportion="0.0">
+ <folding />
+ </state>
+ </provider>
+ </entry>
+ <entry file="file://$PROJECT_DIR$/src/main/groovy/napplelabs/dbssim/ui/CanvasPanel.groovy">
<provider selected="true" editor-type-id="text-editor">
- <state line="27" column="33" selection-start="869" selection-end="869" vertical-scroll-proportion="-1.7510917">
+ <state line="50" column="6" selection-start="1517" selection-end="1517" vertical-scroll-proportion="-2.5475688">
<folding />
</state>
</provider>
View
215 src/main/groovy/napplelabs/dbssim/ui/CanvasPanel.groovy
@@ -0,0 +1,215 @@
+package napplelabs.dbssim.ui
+
+import edu.umd.cs.piccolo.PCanvas
+import java.awt.BorderLayout
+import javax.swing.JPanel
+import net.miginfocom.swing.MigLayout
+import javax.swing.JButton
+import java.awt.event.ActionListener
+import javax.swing.JSlider
+import edu.umd.cs.piccolo.nodes.PPath
+import java.awt.Color
+import edu.umd.cs.piccolo.PNode
+import edu.umd.cs.piccolo.util.PPaintContext
+import edu.umd.cs.piccolo.event.PDragSequenceEventHandler
+import edu.umd.cs.piccolo.event.PInputEvent
+import java.awt.BasicStroke
+import edu.umd.cs.piccolo.nodes.PText
+import java.awt.geom.Point2D
+import java.awt.Font
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: zkim
+ * Date: Jan 31, 2009
+ * Time: 7:37:16 PM
+ * To change this template use File | Settings | File Templates.
+ */
+
+public class CanvasPanel extends JPanel {
+
+ PCanvas canvas = new PCanvas();
+
+ public CanvasPanel() {
+ layout = new BorderLayout()
+ add(canvas, BorderLayout.CENTER)
+ JPanel panel = new JPanel()
+ add(panel, BorderLayout.EAST)
+ panel.layout = new BorderLayout()
+ panel.add(new FeaturePanel(canvas), BorderLayout.CENTER)
+ panel.add(new DepthPanel(), BorderLayout.WEST)
+
+ canvas.zoomEventHandler = new NapPZoomEventHandler()
+ canvas.animatingRenderQuality = PPaintContext.HIGH_QUALITY_RENDERING
+ canvas.interactingRenderQuality = PPaintContext.HIGH_QUALITY_RENDERING
+ canvas.camera.setViewOffset(1000 / 2, 700 / 2);
+
+ Probe probe = new Probe()
+ probe.rotate(Math.PI / 360 * 30)
+ canvas.layer.addChild(probe)
+
+ //canvas.layer.
+
+ canvas.layer.addInputEventListener(new NodeDragHandler(probe))
+
+
+ }
+}
+
+class FeaturePanel extends JPanel {
+
+ PCanvas canvas
+
+ public FeaturePanel(PCanvas canvas) {
+ this.canvas = canvas
+ init()
+ }
+
+ public void init() {
+ layout = new MigLayout("wrap 1")
+ JButton thal = new JButton("Thalamus")
+ thal.addActionListener({
+ NeuronPath path = new ThalamusPath()
+ path.translate (canvas.camera.viewBounds.centerX, canvas.camera.viewBounds.centerY)
+
+ canvas.layer.addChild(path)
+ } as ActionListener)
+ add(thal)
+
+ JButton stn = new JButton("STN")
+ stn.addActionListener({
+ NeuronPath path = new StnPath()
+ path.translate (canvas.camera.viewBounds.centerX, canvas.camera.viewBounds.centerY)
+
+ canvas.layer.addChild(path)
+ } as ActionListener)
+ add(stn)
+
+ JButton snr = new JButton("SNr")
+ snr.addActionListener({
+ NeuronPath path = new SnrPath()
+ path.translate (canvas.camera.viewBounds.centerX, canvas.camera.viewBounds.centerY)
+
+ canvas.layer.addChild(path)
+ } as ActionListener)
+ add(snr)
+
+ }
+
+}
+
+class DepthPanel extends JPanel {
+ public DepthPanel() {
+ init()
+ }
+
+ public void init() {
+ JSlider slider = new JSlider(JSlider.VERTICAL)
+ layout = new BorderLayout()
+ add(slider, BorderLayout.CENTER)
+ slider.maximum = 200
+ slider.minimum = -100
+ slider.value = 200
+ }
+}
+
+class NeuronPath extends PNode {
+ Color color
+
+ public NeuronPath(Color color) {
+ this.color = color
+ init()
+ }
+
+ public void init() {
+ PPath path = PPath.createEllipse(0, 0, 20, 20)
+ path.paint = color
+
+ addChild(path)
+ }
+}
+
+class ThalamusPath extends NeuronPath {
+ public ThalamusPath() {
+ super(Color.blue)
+ }
+}
+
+class StnPath extends NeuronPath {
+ public StnPath() {
+ super(Color.red)
+ }
+}
+
+class SnrPath extends NeuronPath {
+ public SnrPath() {
+ super(Color.green)
+ }
+}
+
+class NodeDragHandler extends PDragSequenceEventHandler {
+ Probe probe
+
+ public NodeDragHandler(Probe probe) {
+ this.probe = probe
+ getEventFilter().setMarksAcceptedEventsAsHandled(true);
+ }
+
+ public void mouseEntered(PInputEvent e) {
+ if (e.getButton() == 0) {
+ //e.getPickedNode().setPaint(Color.red);
+ }
+ }
+
+ public void mouseExited(PInputEvent e) {
+ if (e.getButton() == 0) {
+ //e.getPickedNode().setPaint(Color.white);
+ }
+ }
+
+ public void drag(PInputEvent e) {
+ PNode node = e.getPickedNode();
+ //if (probe.children.contains(node)) return
+ node.translate(e.getDelta().width, e.getDelta().height);
+
+ }
+}
+
+class Probe extends PNode {
+ public Probe() {
+ init()
+ }
+
+ public void init() {
+ PPath path = PPath.createLine(0, 2000, 0, -1000);
+ path.rotate(Math.PI)
+ path.stroke = new BasicStroke(3)
+ path.paint = Color.lightGray
+ path.strokePaint = Color.lightGray
+
+ //PPath probe = PPath.createLine(0, 1000)
+
+ addChild(path)
+
+ (10..-20).each {int i->
+ PText t = new PText(-i+"mm")
+ t.font = new Font("Arial", Font.PLAIN, 16)
+ t.offset = new Point2D.Double(30, i*100)
+ t.textPaint = Color.lightGray
+ addChild(t)
+ }
+
+
+
+
+ }
+
+ public void setDepth(float depth) {
+
+ }
+
+ public float getDepth() {
+
+ }
+}
+
View
160 src/main/groovy/napplelabs/dbssim/ui/NapPZoomEventHandler.java
@@ -0,0 +1,160 @@
+/*
+ * Copyright (c) 2008, Piccolo2D project, http://piccolo2d.org
+ * Copyright (c) 1998-2008, University of Maryland
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are permitted provided
+ * that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this list of conditions
+ * and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice, this list of conditions
+ * and the following disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * None of the name of the University of Maryland, the name of the Piccolo2D project, or the names of its
+ * contributors may be used to endorse or promote products derived from this software without specific
+ * prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package napplelabs.dbssim.ui;
+
+import java.awt.event.InputEvent;
+import java.awt.geom.Point2D;
+
+import edu.umd.cs.piccolo.PCamera;
+import edu.umd.cs.piccolo.event.PDragSequenceEventHandler;
+import edu.umd.cs.piccolo.event.PInputEvent;
+import edu.umd.cs.piccolo.event.PInputEventFilter;
+import edu.umd.cs.piccolo.event.PZoomEventHandler;
+
+/**
+ * <b>ZoomEventhandler</b> provides event handlers for basic zooming of the
+ * canvas view with the right (third) button. The interaction is that the
+ * initial mouse press defines the zoom anchor point, and then moving the mouse
+ * to the right zooms with a speed proportional to the amount the mouse is moved
+ * to the right of the anchor point. Similarly, if the mouse is moved to the
+ * left, the the view is zoomed out.
+ * <P>
+ * On a Mac with its single mouse button one may wish to change the standard
+ * right mouse button zooming behavior. This can be easily done with the
+ * PInputEventFilter. For example to zoom with button one and shift you would do
+ * this:
+ * <P>
+ * <code>
+ * <pre>
+ * zoomEventHandler.getEventFilter().setAndMask(InputEvent.BUTTON1_MASK |
+ * InputEvent.SHIFT_MASK);
+ * </pre>
+ * </code>
+ * <P>
+ *
+ * @version 1.0
+ * @author Jesse Grosjean
+ */
+public class NapPZoomEventHandler extends PZoomEventHandler {
+
+ private double minScale = 0;
+ private double maxScale = Double.MAX_VALUE;
+
+ /**
+ * Creates a new zoom handler.
+ */
+ public NapPZoomEventHandler() {
+ super();
+ //setEventFilter(new PInputEventFilter(InputEvent.));
+ }
+
+ // ****************************************************************
+ // Zooming
+ // ****************************************************************
+
+ /**
+ * Returns the minimum view magnification factor that this event handler is
+ * bound by. The default is 0.
+ *
+ * @return the minimum camera view scale
+ */
+ public double getMinScale() {
+ return minScale;
+ }
+
+ /**
+ * Sets the minimum view magnification factor that this event handler is
+ * bound by. The camera is left at its current scale even if
+ * <code>minScale</code> is larger than the current scale.
+ *
+ * @param minScale the minimum scale, must not be negative.
+ */
+ public void setMinScale(double minScale) {
+ this.minScale = minScale;
+ }
+
+ /**
+ * Returns the maximum view magnification factor that this event handler is
+ * bound by. The default is Double.MAX_VALUE.
+ *
+ * @return the maximum camera view scale
+ */
+ public double getMaxScale() {
+ return maxScale;
+ }
+
+ /**
+ * Sets the maximum view magnification factor that this event handler is
+ * bound by. The camera is left at its current scale even if
+ * <code>maxScale</code> is smaller than the current scale. Use
+ * Double.MAX_VALUE to specify the largest possible scale.
+ *
+ * @param maxScale the maximum scale, must not be negative.
+ */
+ public void setMaxScale(double maxScale) {
+ this.maxScale = maxScale;
+ }
+
+ protected void dragActivityFirstStep(PInputEvent aEvent) {
+
+ }
+
+ protected void dragActivityStep(PInputEvent aEvent) {
+
+ }
+
+ public void processEvent(final PInputEvent evt, final int i) {
+ if (evt.isMouseWheelEvent()) {
+
+ Point2D viewZoomPoint = evt.getPosition();
+
+ PCamera camera = evt.getCamera();
+ double dx = - evt.getWheelRotation();
+
+ double scaleDelta = (1.0 + (0.05 * dx));
+
+ double currentScale = camera.getViewScale();
+ double newScale = currentScale * scaleDelta;
+
+ if (newScale < minScale) {
+ scaleDelta = minScale / currentScale;
+ }
+ if ((maxScale > 0) && (newScale > maxScale)) {
+ scaleDelta = maxScale / currentScale;
+ }
+
+ camera.scaleViewAboutPoint(scaleDelta, viewZoomPoint.getX(), viewZoomPoint.getY());
+ }
+ }
+
+ // ****************************************************************
+ // Debugging - methods for debugging
+ // ****************************************************************
+
+}
View
14 src/main/groovy/napplelabs/dbssim/ui/SimUI.groovy
@@ -75,7 +75,9 @@ class SimUI {
//panel.start()
//mf.content.add(panel, BorderLayout.CENTER)
-
+
+
+ //Set up control button
AbstractButton playButton =
MacButtonFactory.makeUnifiedToolBarButton(
new JButton("Control", new ImageIcon(SimUI.class.getResource(
@@ -89,24 +91,26 @@ class SimUI {
mf.addToolbarComponentRight(playButton)
- final JPanel canvasPanel = new JPanel()
+
+ //Set up tabs
tracePanel = new TracePApplet(container)
tracePanel.init()
+ def canvasPanel = new CanvasPanel()
+
TabManager tabManager = new TabManager(mf.content)
tabManager.add("Canvas", canvasPanel)
tabManager.add("Trace", tracePanel)
- tabManager.load("Canvas");
-
-
mf.addToolbarComponentCenter(tabManager.build().component)
mf.frame.visible = true
container.play()
+
+ tabManager.currentComponent = canvasPanel
controlHud = new ControlHud(container)
//controlHud.visible = true
View
16 src/main/groovy/napplelabs/dbssim/ui/TabManager.groovy
@@ -58,7 +58,7 @@ public class TabManager {
currentComponent = tabComponents[name]
SwingUtilities.invokeLater({
parent.repaint()
- //parent.revalidate()
+ parent.revalidate()
} as Runnable)
} as ActionListener);
@@ -68,15 +68,25 @@ public class TabManager {
- LabeledComponentGroup viewButtons = new LabeledComponentGroup(null, controls);
+ LabeledComponentGroup viewButtons = new LabeledComponentGroup("Views", controls);
}
public void load(String name) {
- def component = tabComponents[name]
+ def component = tabComponents.get(name)
if(!component) return
+
+ currentComponent = component
+ }
+
+ public void setCurrentComponent(Component component) {
+
parent.remove(currentComponent)
currentComponent = component
parent.add currentComponent, BorderLayout.CENTER
}
+
+ public Component getCurrentComponent() {
+ return currentComponent
+ }
}
View
125 target/generated-sources/groovy-stubs/main/napplelabs/dbssim/SignalContainer.java
@@ -1,125 +0,0 @@
-//
-// Generated stub from file:/Users/zkim/napplelabs/dbssim/src/main/groovy/napplelabs/dbssim/SignalContainer.groovy
-//
-
-package napplelabs.dbssim;
-
-import java.lang.*;
-import java.io.*;
-import java.net.*;
-import java.util.*;
-import groovy.lang.*;
-import groovy.util.*;
-import java.util.List;
-import ddf.minim.AudioPlayer;
-import ddf.minim.AudioSignal;
-import ddf.minim.signals.PinkNoise;
-import ddf.minim.Minim;
-import processing.core.PApplet;
-import ddf.minim.AudioOutput;
-import java.io.File;
-
-public class SignalContainer
- extends java.lang.Object
-{
- private List recordedSignals = null;
-
- private PinkNoise pink = null;
- public PinkNoise getPink() {
- throw new InternalError("Stubbed method");
- }
- public void setPink(PinkNoise value) {
- throw new InternalError("Stubbed method");
- }
-
- private AudioOutput out = null;
- public AudioOutput getOut() {
- throw new InternalError("Stubbed method");
- }
- public void setOut(AudioOutput value) {
- throw new InternalError("Stubbed method");
- }
-
- private Minim minim = null;
- public Minim getMinim() {
- throw new InternalError("Stubbed method");
- }
- public void setMinim(Minim value) {
- throw new InternalError("Stubbed method");
- }
-
- private float lastAmp = 0.0f;
-
- private SignalContainer(java.lang.Void void1, java.lang.Void void2, java.lang.Void void3) {
- throw new InternalError("Stubbed method");
- }
-
- public SignalContainer() {
- this((java.lang.Void)null, (java.lang.Void)null, (java.lang.Void)null);
- throw new InternalError("Stubbed method");
- }
-
- public void addSignal(java.lang.String signal) {
- throw new InternalError("Stubbed method");
- }
-
- public void play() {
- throw new InternalError("Stubbed method");
- }
-
- public void pause() {
- throw new InternalError("Stubbed method");
- }
-
- public float getGain() {
- throw new InternalError("Stubbed method");
- }
-
- public void setGain(float gain) {
- throw new InternalError("Stubbed method");
- }
-
- public void close() {
- throw new InternalError("Stubbed method");
- }
-
- public void setMute(boolean b) {
- throw new InternalError("Stubbed method");
- }
-
- public void add(RecordedSignal sig) {
- throw new InternalError("Stubbed method");
- }
-
- public void remove(AudioPlayer player) {
- throw new InternalError("Stubbed method");
- }
-
- public float[] getSamples() {
- throw new InternalError("Stubbed method");
- }
-
- public static void main(java.lang.String[] args) {
- throw new InternalError("Stubbed method");
- }
-
- public groovy.lang.MetaClass getMetaClass() {
- throw new InternalError("Stubbed method");
- }
-
- public void setMetaClass(groovy.lang.MetaClass metaClass) {
- throw new InternalError("Stubbed method");
- }
-
- public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) {
- throw new InternalError("Stubbed method");
- }
-
- public java.lang.Object getProperty(java.lang.String name) {
- throw new InternalError("Stubbed method");
- }
-
- public void setProperty(java.lang.String name, java.lang.Object value) {
- throw new InternalError("Stubbed method");
- }
-}
View
153 target/generated-sources/groovy-stubs/main/napplelabs/dbssim/ui/ControlHud.java
@@ -1,153 +0,0 @@
-//
-// Generated stub from file:/Users/zkim/napplelabs/dbssim/src/main/groovy/napplelabs/dbssim/ui/ControlHud.groovy
-//
-
-package napplelabs.dbssim.ui;
-
-import java.lang.*;
-import java.io.*;
-import java.net.*;
-import java.util.*;
-import groovy.lang.*;
-import groovy.util.*;
-import com.explodingpixels.macwidgets.HudWindow;
-import java.awt.Dimension;
-import javax.swing.JPanel;
-import net.miginfocom.swing.MigLayout;
-import javax.swing.JCheckBox;
-import java.awt.BorderLayout;
-import com.explodingpixels.macwidgets.plaf.HudCheckBoxUI;
-import javax.swing.JDialog;
-import javax.swing.JDialog;
-import javax.swing.JFrame;
-import java.awt.Color;
-import ddf.minim.signals.PinkNoise;
-import java.awt.event.ActionListener;
-import javax.swing.JSlider;
-import javax.swing.event.ChangeListener;
-import napplelabs.dbssim.NeuronSignal;
-import com.google.inject.Injector;
-import com.google.inject.Guice;
-import com.google.inject.Binder;
-import com.google.inject.Module;
-import com.google.inject.Inject;
-import com.explodingpixels.macwidgets.plaf.HudButtonUI;
-import ddf.minim.AudioOutput;
-import napplelabs.dbssim.SignalContainer;
-
-public class ControlHud
- extends java.lang.Object
-{
- private JSlider pinkSlider = null;
- public JSlider getPinkSlider() {
- throw new InternalError("Stubbed method");
- }
- public void setPinkSlider(JSlider value) {
- throw new InternalError("Stubbed method");
- }
-
- private float lastAmp = 0.0f;
- public float getLastAmp() {
- throw new InternalError("Stubbed method");
- }
- public void setLastAmp(float value) {
- throw new InternalError("Stubbed method");
- }
-
- private JPanel panel = null;
- public JPanel getPanel() {
- throw new InternalError("Stubbed method");
- }
- public void setPanel(JPanel value) {
- throw new InternalError("Stubbed method");
- }
-
- private JDialog dialog = null;
- public JDialog getDialog() {
- throw new InternalError("Stubbed method");
- }
- public void setDialog(JDialog value) {
- throw new InternalError("Stubbed method");
- }
-
- private JSlider minSlider = null;
- public JSlider getMinSlider() {
- throw new InternalError("Stubbed method");
- }
- public void setMinSlider(JSlider value) {
- throw new InternalError("Stubbed method");
- }
-
- private JSlider maxSlider = null;
- public JSlider getMaxSlider() {
- throw new InternalError("Stubbed method");
- }
- public void setMaxSlider(JSlider value) {
- throw new InternalError("Stubbed method");
- }
-
- private AudioOutput out = null;
- public AudioOutput getOut() {
- throw new InternalError("Stubbed method");
- }
- public void setOut(AudioOutput value) {
- throw new InternalError("Stubbed method");
- }
-
- private SignalContainer container = null;
- public SignalContainer getContainer() {
- throw new InternalError("Stubbed method");
- }
- public void setContainer(SignalContainer value) {
- throw new InternalError("Stubbed method");
- }
-
- private ControlHud(java.lang.Void void1, java.lang.Void void2, java.lang.Void void3) {
- throw new InternalError("Stubbed method");
- }
-
- public ControlHud(SignalContainer container) {
- this((java.lang.Void)null, (java.lang.Void)null, (java.lang.Void)null);
- throw new InternalError("Stubbed method");
- }
-
- public java.lang.Object setVisible(boolean vis) {
- throw new InternalError("Stubbed method");
- }
-
- public java.lang.Object createMasterControls() {
- throw new InternalError("Stubbed method");
- }
-
- public java.lang.Object createNeuronControls() {
- throw new InternalError("Stubbed method");
- }
-
- public java.lang.Object createPinkNoiseControls() {
- throw new InternalError("Stubbed method");
- }
-
- public static void main(java.lang.String[] args) {
- throw new InternalError("Stubbed method");
- }
-
- public groovy.lang.MetaClass getMetaClass() {
- throw new InternalError("Stubbed method");
- }
-
- public void setMetaClass(groovy.lang.MetaClass metaClass) {
- throw new InternalError("Stubbed method");
- }
-
- public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) {
- throw new InternalError("Stubbed method");
- }
-
- public java.lang.Object getProperty(java.lang.String name) {
- throw new InternalError("Stubbed method");
- }
-
- public void setProperty(java.lang.String name, java.lang.Object value) {
- throw new InternalError("Stubbed method");
- }
-}
View
145 target/generated-sources/groovy-stubs/main/napplelabs/dbssim/ui/MacFrame.java
@@ -1,145 +0,0 @@
-//
-// Generated stub from file:/Users/zkim/napplelabs/dbssim/src/main/groovy/napplelabs/dbssim/ui/MacFrame.groovy
-//
-
-package napplelabs.dbssim.ui;
-
-import java.lang.*;
-import java.io.*;
-import java.net.*;
-import java.util.*;
-import groovy.lang.*;
-import groovy.util.*;
-import javax.swing.JFrame;
-import java.awt.Dimension;
-import javax.swing.SwingUtilities;
-import java.lang.Runnable;
-import com.explodingpixels.macwidgets.MacWidgetFactory;
-import com.explodingpixels.macwidgets.TriAreaComponent;
-import java.awt.BorderLayout;
-import com.explodingpixels.macwidgets.BottomBarSize;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-import javax.swing.JButton;
-import ddf.minim.Minim;
-import napplelabs.dbssim.NeuronSignal;
-import ddf.minim.signals.PinkNoise;
-import napplelabs.dbssim.TracePanel;
-import ddf.minim.AudioOutput;
-import javax.swing.AbstractButton;
-import javax.swing.JComponent;
-import java.util.List;
-import javax.swing.ButtonGroup;
-import com.explodingpixels.macwidgets.LabeledComponentGroup;
-
-/**
- * @author zkim
- */
-public class MacFrame
- extends java.lang.Object
-{
- private JFrame frame = null;
- public JFrame getFrame() {
- throw new InternalError("Stubbed method");
- }
- public void setFrame(JFrame value) {
- throw new InternalError("Stubbed method");
- }
-
- private TriAreaComponent toolbar = null;
- public TriAreaComponent getToolbar() {
- throw new InternalError("Stubbed method");
- }
- public void setToolbar(TriAreaComponent value) {
- throw new InternalError("Stubbed method");
- }
-
- private TriAreaComponent bottombar = null;
- public TriAreaComponent getBottombar() {
- throw new InternalError("Stubbed method");
- }
- public void setBottombar(TriAreaComponent value) {
- throw new InternalError("Stubbed method");
- }
-
- private JPanel content = null;
- public JPanel getContent() {
- throw new InternalError("Stubbed method");
- }
- public void setContent(JPanel value) {
- throw new InternalError("Stubbed method");
- }
-
- private List toolbarButtons = null;
- public List getToolbarButtons() {
- throw new InternalError("Stubbed method");
- }
- public void setToolbarButtons(List value) {
- throw new InternalError("Stubbed method");
- }
-
- private boolean visible = false;
- public boolean isVisible() {
- throw new InternalError("Stubbed method");
- }
- public void setVisible(boolean value) {
- throw new InternalError("Stubbed method");
- }
-
- private MacFrame(java.lang.Void void1, java.lang.Void void2, java.lang.Void void3) {
- throw new InternalError("Stubbed method");
- }
-
- public MacFrame(int width, int height) {
- this((java.lang.Void)null, (java.lang.Void)null, (java.lang.Void)null);
- throw new InternalError("Stubbed method");
- }
-
- public void setVisisble(boolean vis) {
- throw new InternalError("Stubbed method");
- }
-
- public boolean getVisible() {
- throw new InternalError("Stubbed method");
- }
-
- public java.lang.Object revalidate() {
- throw new InternalError("Stubbed method");
- }
-
- public java.lang.Object addToolbarComponentRight(JComponent comp) {
- throw new InternalError("Stubbed method");
- }
-
- public java.lang.Object addToolbarComponentCenter(JComponent comp) {
- throw new InternalError("Stubbed method");
- }
-
- public java.lang.Object addToolbarButton(List buttons) {
- throw new InternalError("Stubbed method");
- }
-
- public static void main(java.lang.String[] args) {
- throw new InternalError("Stubbed method");
- }
-
- public groovy.lang.MetaClass getMetaClass() {
- throw new InternalError("Stubbed method");
- }
-
- public void setMetaClass(groovy.lang.MetaClass metaClass) {
- throw new InternalError("Stubbed method");
- }
-
- public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) {
- throw new InternalError("Stubbed method");
- }
-
- public java.lang.Object getProperty(java.lang.String name) {
- throw new InternalError("Stubbed method");
- }
-
- public void setProperty(java.lang.String name, java.lang.Object value) {
- throw new InternalError("Stubbed method");
- }
-}
View
107 target/generated-sources/groovy-stubs/main/napplelabs/dbssim/ui/SimUI.java
@@ -1,107 +0,0 @@
-//
-// Generated stub from file:/Users/zkim/napplelabs/dbssim/src/main/groovy/napplelabs/dbssim/ui/SimUI.groovy
-//
-
-package napplelabs.dbssim.ui;
-
-import java.lang.*;
-import java.io.*;
-import java.net.*;
-import java.util.*;
-import groovy.lang.*;
-import groovy.util.*;
-import ddf.minim.Minim;
-import ddf.minim.AudioOutput;
-import napplelabs.dbssim.NeuronSignal;
-import napplelabs.dbssim.TracePanel;
-import ddf.minim.signals.PinkNoise;
-import java.awt.BorderLayout;
-import com.explodingpixels.macwidgets.MacButtonFactory;
-import javax.swing.AbstractButton;
-import javax.swing.JButton;
-import javax.swing.ImageIcon;
-import javax.swing.JToggleButton;
-import javax.swing.ButtonGroup;
-import com.explodingpixels.macwidgets.LabeledComponentGroup;
-import java.awt.event.ActionListener;
-import javax.swing.SwingUtilities;
-import java.lang.Runnable;
-import javax.swing.JComponent;
-import javax.swing.JPanel;
-import javax.swing.JLabel;
-import com.explodingpixels.macwidgets.HudWindow;
-import java.awt.Dimension;
-import ddf.minim.AudioPlayer;
-import processing.core.PApplet;
-import napplelabs.dbssim.SignalContainer;
-import java.awt.Component;
-
-public class SimUI
- extends java.lang.Object
-{
- private MacFrame mf = null;
- public MacFrame getMf() {
- throw new InternalError("Stubbed method");
- }
- public void setMf(MacFrame value) {
- throw new InternalError("Stubbed method");
- }
-
- private Component currentComponent = null;
- public void setCurrentComponent(Component value) {
- throw new InternalError("Stubbed method");
- }
-
- private Component tracePanel = null;
- public Component getTracePanel() {
- throw new InternalError("Stubbed method");
- }
- public void setTracePanel(Component value) {
- throw new InternalError("Stubbed method");
- }
-
- private ControlHud controlHud = null;
- public ControlHud getControlHud() {
- throw new InternalError("Stubbed method");
- }
- public void setControlHud(ControlHud value) {
- throw new InternalError("Stubbed method");
- }
-
- private SimUI(java.lang.Void void1, java.lang.Void void2, java.lang.Void void3) {
- throw new InternalError("Stubbed method");
- }
-
- public SimUI() {
- this((java.lang.Void)null, (java.lang.Void)null, (java.lang.Void)null);
- throw new InternalError("Stubbed method");
- }
-
- public JComponent getCurrentComponent() {
- throw new InternalError("Stubbed method");
- }
-
- public static void main(java.lang.String[] args) {
- throw new InternalError("Stubbed method");
- }
-
- public groovy.lang.MetaClass getMetaClass() {
- throw new InternalError("Stubbed method");
- }
-
- public void setMetaClass(groovy.lang.MetaClass metaClass) {
- throw new InternalError("Stubbed method");
- }
-
- public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) {
- throw new InternalError("Stubbed method");
- }
-
- public java.lang.Object getProperty(java.lang.String name) {
- throw new InternalError("Stubbed method");
- }
-
- public void setProperty(java.lang.String name, java.lang.Object value) {
- throw new InternalError("Stubbed method");
- }
-}

0 comments on commit 8fd15b7

Please sign in to comment.
Something went wrong with that request. Please try again.