Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added proximity sound to canvas

  • Loading branch information...
commit ad94a5e0d023d74538c87c5d12ca25a8b8e2eb3b 1 parent 3b1a494
@zk authored
View
4 .classpath
@@ -3,8 +3,8 @@
<classpathentry kind="src" output="target/classes" path="src/main/java"/>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>
<classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
- <classpathentry kind="src" path="src/main/groovy"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry excluding="napplelabs/dbssim/ui/BirdsEyeViewExample.java" kind="src" path="src/main/groovy"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
<classpathentry exported="true" kind="con" path="GROOVY_SUPPORT"/>
<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
View
2  .settings/org.eclipse.jdt.core.prefs
@@ -1,4 +1,4 @@
-#Tue Jan 20 22:09:41 MST 2009
+#Sun Feb 08 14:39:00 MST 2009
eclipse.preferences.version=1
org.eclipse.jdt.core.builder.resourceCopyExclusionFilter=*.launch,*.groovy
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
View
13 dbssim.iml
@@ -1,5 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<module relativePaths="true" MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
+ <component name="BuildJarSettings">
+ <containerInfo>
+ <containerElement type="module" name="dbssim">
+ <attribute name="method" value="1" />
+ <attribute name="URI" value="/" />
+ </containerElement>
+ </containerInfo>
+ <setting name="jarUrl" value="file://$MODULE_DIR$/dbssim.jar" />
+ <setting name="buildJar" value="true" />
+ <setting name="mainClass" value="" />
+ </component>
<component name="FacetManager">
<facet type="Groovy" name="Groovy">
<configuration />
@@ -16,6 +27,7 @@
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
+ <orderEntry type="library" name="groovy-1.6-beta-2" level="application" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" name="Maven: org.codehaus.groovy.maven.runtime:gmaven-runtime-default:1.0-rc-3" level="project" />
@@ -28,7 +40,6 @@
<orderEntry type="library" exported="" name="Maven: org.codehaus.groovy.maven:gmaven-common:1.0-rc-3" level="project" />
<orderEntry type="library" exported="" name="Maven: org.codehaus.plexus:plexus-utils:1.5.5" level="project" />
<orderEntry type="library" exported="" name="Maven: com.thoughtworks.qdox:qdox:1.6.3" level="project" />
- <orderEntry type="library" exported="" name="Maven: org.codehaus.groovy:groovy-all-minimal:1.5.6" level="project" />
<orderEntry type="library" exported="" name="Maven: org.apache.ant:ant:1.7.1" level="project" />
<orderEntry type="library" exported="" name="Maven: org.apache.ant:ant-launcher:1.7.1" level="project" />
<orderEntry type="library" exported="" name="Maven: jline:jline:0.9.94" level="project" />
View
2  dbssim.ipr
@@ -232,7 +232,7 @@
<module fileurl="file://$PROJECT_DIR$/dbssim.iml" filepath="$PROJECT_DIR$/dbssim.iml" />
</modules>
</component>
- <component name="ProjectRootManager" version="2" languageLevel="JDK_1_5" assert-keyword="true" jdk-15="true" project-jdk-name="1.6" project-jdk-type="JavaSDK">
+ <component name="ProjectRootManager" version="2" languageLevel="JDK_1_5" assert-keyword="true" jdk-15="true" project-jdk-name="1.5" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
<component name="ResourceManagerContainer">
View
352 dbssim.iws
@@ -15,7 +15,7 @@
<option name="historyRevisionsNumber" value="4" />
</component>
<component name="ChangeListManager">
- <list default="true" readonly="true" name="Default" comment="" />
+ <list default="true" name="Default" comment="" />
<ignored path="dbssim.iws" />
<ignored path=".idea/workspace.xml" />
</component>
@@ -73,46 +73,19 @@
</component>
<component name="FileEditorManager">
<leaf>
- <file leaf-file-name="SimUI.groovy" pinned="false" current="false" current-in-tab="false">
+ <file leaf-file-name="SimUI.groovy" pinned="false" current="true" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/src/main/groovy/napplelabs/dbssim/ui/SimUI.groovy">
<provider selected="true" editor-type-id="text-editor">
- <state line="99" column="0" selection-start="3675" selection-end="3675" vertical-scroll-proportion="0.0">
+ <state line="112" column="27" selection-start="4011" selection-end="4011" vertical-scroll-proportion="0.33628318">
<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">
+ <file leaf-file-name="NeuronPath.groovy" pinned="false" current="false" current-in-tab="false">
+ <entry file="file://$PROJECT_DIR$/src/main/groovy/napplelabs/dbssim/ui/NeuronPath.groovy">
<provider selected="true" editor-type-id="text-editor">
- <state line="61" column="21" selection-start="1826" selection-end="1826" vertical-scroll-proportion="0.94849783">
- <folding />
- </state>
- </provider>
- </entry>
- </file>
- <file leaf-file-name="BirdsEyeViewExample.java" pinned="false" current="false" current-in-tab="false">
- <entry file="file://$PROJECT_DIR$/src/main/groovy/napplelabs/dbssim/ui/BirdsEyeViewExample.java">
- <provider selected="true" editor-type-id="text-editor">
- <state line="324" column="40" selection-start="12135" selection-end="12135" vertical-scroll-proportion="0.0">
- <folding />
- </state>
- </provider>
- </entry>
- </file>
- <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="74" column="46" selection-start="2213" selection-end="2213" vertical-scroll-proportion="0.0">
- <folding />
- </state>
- </provider>
- </entry>
- </file>
- <file leaf-file-name="pom.xml" pinned="false" current="false" current-in-tab="false">
- <entry file="file://$PROJECT_DIR$/pom.xml">
- <provider selected="true" editor-type-id="text-editor">
- <state line="124" column="31" selection-start="2995" selection-end="2995" vertical-scroll-proportion="0.0">
+ <state line="14" column="6" selection-start="287" selection-end="287" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
@@ -125,6 +98,20 @@
<setting name="OPEN_NEW_TAB" value="false" />
</FindUsagesManager>
</component>
+ <component name="MavenEventsHandler">
+ <option name="beforeRun">
+ <map>
+ <entry key="Application#SimUI">
+ <value>
+ <MavenTask>
+ <option name="pomPath" value="$PROJECT_DIR$/pom.xml" />
+ <option name="goal" value="compile" />
+ </MavenTask>
+ </value>
+ </entry>
+ </map>
+ </option>
+ </component>
<component name="MavenImportPreferences">
<option name="generalSettings">
<MavenGeneralSettings>
@@ -247,8 +234,38 @@
<option name="myItemId" value="napplelabs" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
+ </PATH>
+ <PATH>
+ <PATH_ELEMENT>
+ <option name="myItemId" value="dbssim" />
+ <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
+ </PATH_ELEMENT>
+ <PATH_ELEMENT>
+ <option name="myItemId" value="dbssim" />
+ <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewModuleNode" />
+ </PATH_ELEMENT>
+ <PATH_ELEMENT>
+ <option name="myItemId" value="dbssim" />
+ <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
+ </PATH_ELEMENT>
+ <PATH_ELEMENT>
+ <option name="myItemId" value="src" />
+ <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
+ </PATH_ELEMENT>
+ <PATH_ELEMENT>
+ <option name="myItemId" value="main" />
+ <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
+ </PATH_ELEMENT>
+ <PATH_ELEMENT>
+ <option name="myItemId" value="groovy" />
+ <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
+ </PATH_ELEMENT>
+ <PATH_ELEMENT>
+ <option name="myItemId" value="napplelabs" />
+ <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
+ </PATH_ELEMENT>
<PATH_ELEMENT>
- <option name="myItemId" value="resources" />
+ <option name="myItemId" value="dbssim" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
</PATH>
@@ -285,6 +302,10 @@
<option name="myItemId" value="dbssim" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
+ <PATH_ELEMENT>
+ <option name="myItemId" value="ui" />
+ <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
+ </PATH_ELEMENT>
</PATH>
<PATH>
<PATH_ELEMENT>
@@ -320,7 +341,7 @@
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
- <option name="myItemId" value="ui" />
+ <option name="myItemId" value="example" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
</PATH>
@@ -344,24 +365,24 @@
</navigator>
</component>
<component name="PropertiesComponent">
- <property name="GoToFile.includeJavaFiles" value="false" />
- <property name="project.structure.last.edited" value="Modules" />
<property name="project.structure.proportion" value="0.0" />
+ <property name="project.structure.last.edited" value="Project" />
+ <property name="MemberChooser.copyJavadoc" value="false" />
<property name="options.splitter.main.proportions" value="0.3" />
- <property name="RunManagerConfig.showSettingsBeforeRunnig" value="true" />
<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.splitter.details.proportions" value="0.2" />
<property name="options.searchVisible" value="true" />
+ <property name="GoToFile.includeJavaFiles" value="false" />
+ <property name="options.splitter.details.proportions" value="0.2" />
+ <property name="GoToClass.includeLibraries" value="false" />
+ <property name="MemberChooser.showClasses" value="true" />
+ <property name="project.structure.side.proportion" value="0.2" />
+ <property name="options.lastSelected" value="com.intellij.compiler.options.CompilerConfigurable$3" />
+ <property name="GoToClass.toSaveIncludeLibraries" value="false" />
+ <property name="RunManagerConfig.showSettingsBeforeRunnig" value="true" />
</component>
- <component name="RunManager" selected="Application.BirdsEyeViewExample">
- <tempConfiguration default="false" name="BirdsEyeViewExample" type="Application" factoryName="Application" enabled="false" merge="false" sample_coverage="true" runner="emma">
- <option name="MAIN_CLASS_NAME" value="napplelabs.dbssim.ui.BirdsEyeViewExample" />
+ <component name="RunManager" selected="Application.SimUI">
+ <tempConfiguration default="false" name="SimUI" type="Application" factoryName="Application" enabled="false" merge="false" sample_coverage="true" runner="emma">
+ <option name="MAIN_CLASS_NAME" value="napplelabs.dbssim.ui.SimUI" />
<option name="VM_PARAMETERS" value="" />
<option name="PROGRAM_PARAMETERS" value="" />
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" />
@@ -375,50 +396,10 @@
<RunnerSettings RunnerId="Run" />
<ConfigurationWrapper RunnerId="Run" />
<method>
+ <option name="Run Maven goal" value="false" />
<option name="Make" value="true" />
</method>
</tempConfiguration>
- <configuration default="true" type="MavenRunConfiguration" factoryName="Maven">
- <MavenSettings>
- <option name="myCoreSettings">
- <MavenGeneralSettings>
- <option name="checksumPolicy" value="fail" />
- <option name="failureBehavior" value="fail-fast" />
- <option name="localRepository" value="" />
- <option name="mavenHome" value="" />
- <option name="mavenSettingsFile" value="" />
- <option name="nonRecursive" value="false" />
- <option name="pluginUpdatePolicy" value="false" />
- <option name="printErrorStackTraces" value="false" />
- <option name="usePluginRegistry" value="false" />
- <option name="workOffline" value="false" />
- </MavenGeneralSettings>
- </option>
- <option name="myRunnerSettings">
- <MavenRunnerSettings>
- <option name="jreName" value="1.6" />
- <option name="mavenProperties">
- <map />
- </option>
- <option name="runMavenInBackground" value="false" />
- <option name="skipTests" value="false" />
- <option name="vmOptions" value="" />
- </MavenRunnerSettings>
- </option>
- <option name="myRunnerParameters">
- <MavenRunnerParameters>
- <option name="goals">
- <list />
- </option>
- <option name="profiles">
- <set />
- </option>
- <option name="workingDirPath" value="" />
- </MavenRunnerParameters>
- </option>
- </MavenSettings>
- <method />
- </configuration>
<configuration default="true" type="Remote" factoryName="Remote">
<option name="USE_SOCKET_TRANSPORT" value="true" />
<option name="SERVER_MODE" value="false" />
@@ -426,7 +407,19 @@
<option name="HOST" value="localhost" />
<option name="PORT" value="5005" />
</configuration>
- <configuration default="true" type="TestNG" factoryName="TestNG" enabled="false" merge="false">
+ <configuration default="true" type="Applet" factoryName="Applet">
+ <module name="" />
+ <option name="MAIN_CLASS_NAME" />
+ <option name="HTML_FILE_NAME" />
+ <option name="HTML_USED" value="false" />
+ <option name="WIDTH" value="400" />
+ <option name="HEIGHT" value="300" />
+ <option name="POLICY_FILE" value="$APPLICATION_HOME_DIR$/bin/appletviewer.policy" />
+ <option name="VM_PARAMETERS" />
+ <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
+ <option name="ALTERNATIVE_JRE_PATH" />
+ </configuration>
+ <configuration default="true" type="TestNG" factoryName="TestNG" enabled="false" merge="false" runner="emma">
<module name="" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" />
@@ -452,31 +445,6 @@
<properties />
<listeners />
</configuration>
- <configuration default="true" type="Applet" factoryName="Applet">
- <module name="" />
- <option name="MAIN_CLASS_NAME" />
- <option name="HTML_FILE_NAME" />
- <option name="HTML_USED" value="false" />
- <option name="WIDTH" value="400" />
- <option name="HEIGHT" value="300" />
- <option name="POLICY_FILE" value="$APPLICATION_HOME_DIR$/bin/appletviewer.policy" />
- <option name="VM_PARAMETERS" />
- <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
- <option name="ALTERNATIVE_JRE_PATH" />
- </configuration>
- <configuration default="true" type="Application" factoryName="Application" enabled="false" merge="false" runner="emma">
- <option name="MAIN_CLASS_NAME" />
- <option name="VM_PARAMETERS" />
- <option name="PROGRAM_PARAMETERS" />
- <option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
- <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
- <option name="ALTERNATIVE_JRE_PATH" />
- <option name="ENABLE_SWING_INSPECTOR" value="false" />
- <option name="ENV_VARIABLES" />
- <option name="PASS_PARENT_ENVS" value="true" />
- <module name="" />
- <envs />
- </configuration>
<configuration default="true" type="JUnit" factoryName="JUnit" enabled="false" merge="false" runner="emma">
<module name="" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
@@ -496,13 +464,95 @@
</option>
<envs />
</configuration>
+ <configuration default="true" type="Application" factoryName="Application" enabled="false" merge="false" runner="emma">
+ <option name="MAIN_CLASS_NAME" />
+ <option name="VM_PARAMETERS" />
+ <option name="PROGRAM_PARAMETERS" />
+ <option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
+ <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
+ <option name="ALTERNATIVE_JRE_PATH" />
+ <option name="ENABLE_SWING_INSPECTOR" value="false" />
+ <option name="ENV_VARIABLES" />
+ <option name="PASS_PARENT_ENVS" value="true" />
+ <module name="" />
+ <envs />
+ </configuration>
+ <configuration default="true" type="MavenRunConfiguration" factoryName="Maven">
+ <MavenSettings>
+ <option name="myCoreSettings">
+ <MavenGeneralSettings>
+ <option name="checksumPolicy" value="fail" />
+ <option name="failureBehavior" value="fail-fast" />
+ <option name="localRepository" value="" />
+ <option name="mavenHome" value="" />
+ <option name="mavenSettingsFile" value="" />
+ <option name="nonRecursive" value="false" />
+ <option name="pluginUpdatePolicy" value="false" />
+ <option name="printErrorStackTraces" value="false" />
+ <option name="usePluginRegistry" value="false" />
+ <option name="workOffline" value="false" />
+ </MavenGeneralSettings>
+ </option>
+ <option name="myRunnerSettings">
+ <MavenRunnerSettings>
+ <option name="jreName" value="1.6" />
+ <option name="mavenProperties">
+ <map />
+ </option>
+ <option name="runMavenInBackground" value="false" />
+ <option name="skipTests" value="false" />
+ <option name="vmOptions" value="" />
+ </MavenRunnerSettings>
+ </option>
+ <option name="myRunnerParameters">
+ <MavenRunnerParameters>
+ <option name="goals">
+ <list />
+ </option>
+ <option name="profiles">
+ <set />
+ </option>
+ <option name="workingDirPath" value="" />
+ </MavenRunnerParameters>
+ </option>
+ </MavenSettings>
+ <method />
+ </configuration>
<list size="1">
- <item index="0" class="java.lang.String" itemvalue="Application.BirdsEyeViewExample" />
+ <item index="0" class="java.lang.String" itemvalue="Application.SimUI" />
</list>
<configuration name="&lt;template&gt;" type="WebApp" default="true" selected="false">
<Host>localhost</Host>
<Port>5050</Port>
</configuration>
+ <configuration name="&lt;template&gt;" type="WebApp" default="true" selected="false">
+ <Host>localhost</Host>
+ <Port>5050</Port>
+ </configuration>
+ <configuration name="&lt;template&gt;" type="WebApp" default="true" selected="false">
+ <Host>localhost</Host>
+ <Port>5050</Port>
+ </configuration>
+ <configuration name="&lt;template&gt;" type="WebApp" default="true" selected="false">
+ <Host>localhost</Host>
+ <Port>5050</Port>
+ </configuration>
+ <configuration name="&lt;template&gt;" type="WebApp" default="true" selected="false">
+ <Host>localhost</Host>
+ <Port>5050</Port>
+ </configuration>
+ <configuration name="&lt;template&gt;" type="WebApp" default="true" selected="false">
+ <Host>localhost</Host>
+ <Port>5050</Port>
+ </configuration>
+ <configuration name="&lt;template&gt;" type="WebApp" default="true" selected="false">
+ <Host>localhost</Host>
+ <Port>5050</Port>
+ </configuration>
+ <configuration name="&lt;template&gt;" type="WebApp" default="true" selected="false">
+ <Host>localhost</Host>
+ <Port>5050</Port>
+ </configuration>
</component>
<component name="ShelveChangesManager" show_recycled="false" />
<component name="StarteamConfiguration">
@@ -553,30 +603,31 @@
</todo-panel>
</component>
<component name="ToolWindowManager">
- <frame x="1" y="22" width="1280" height="774" extended-state="0" />
- <editor active="true" />
+ <frame x="0" y="22" width="1280" height="774" extended-state="6" />
+ <editor active="false" />
<layout>
- <window_info id="Changes" 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="Palette" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" />
- <window_info id="Database" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" />
- <window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="1" side_tool="false" />
- <window_info id="Find" 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="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.4" sideWeight="0.5" order="3" side_tool="false" />
- <window_info id="Dataflow to this" 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="IDEtalk Messages" 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="IDEtalk" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" />
- <window_info id="Version Control" 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="Messages" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.22580644" sideWeight="0.5" order="-1" side_tool="false" />
+ <window_info id="Web Preview" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" />
+ <window_info id="Dataflow to this" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" />
+ <window_info id="Maven Projects" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.25243506" sideWeight="0.76036865" order="3" side_tool="false" />
+ <window_info id="IDEtalk" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="3" side_tool="false" />
<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="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.27272728" sideWeight="0.76036865" order="0" side_tool="false" />
+ <window_info id="Find" 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="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="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" />
- <window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.1904762" sideWeight="0.5" order="2" side_tool="false" />
- <window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="4" side_tool="false" />
+ <window_info id="Messages" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.22427036" sideWeight="0.5" order="7" 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="7" side_tool="false" />
+ <window_info id="Palette" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="3" side_tool="false" />
+ <window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="1" side_tool="false" />
+ <window_info id="Database" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="3" side_tool="false" />
+ <window_info id="Changes" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" />
+ <window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.22887865" sideWeight="0.5" order="2" 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="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.4" sideWeight="0.5" order="3" side_tool="false" />
+ <window_info id="IDEtalk Messages" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" />
+ <window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" />
<window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="0" side_tool="false" />
+ <window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="4" side_tool="false" />
<window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="2" side_tool="false" />
</layout>
</component>
@@ -668,13 +719,6 @@
</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="74" column="46" selection-start="2213" selection-end="2213" 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">
@@ -696,44 +740,44 @@
</state>
</provider>
</entry>
- <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">
+ <entry file="file://$PROJECT_DIR$/src/main/groovy/napplelabs/dbssim/ui/NapPZoomEventHandler.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">
+ <state line="19" column="21" selection-start="907" selection-end="907" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
- <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">
+ <entry file="file://$PROJECT_DIR$/src/main/groovy/napplelabs/dbssim/ui/CanvasPanel.groovy">
<provider selected="true" editor-type-id="text-editor">
- <state line="2" column="7" selection-start="38" selection-end="38" vertical-scroll-proportion="0.0">
+ <state line="26" column="33" selection-start="768" selection-end="768" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
- <entry file="file://$PROJECT_DIR$/src/main/groovy/napplelabs/dbssim/ui/NapPZoomEventHandler.java">
+ <entry file="file://$PROJECT_DIR$/src/main/groovy/napplelabs/dbssim/ui/BirdsEyeViewExample.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">
+ <state line="324" column="40" selection-start="12135" selection-end="12135" 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$/src/main/groovy/napplelabs/dbssim/ui/TabManager.groovy">
<provider selected="true" editor-type-id="text-editor">
- <state line="99" column="0" selection-start="3675" selection-end="3675" vertical-scroll-proportion="0.0">
+ <state line="22" column="13" selection-start="619" selection-end="619" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
- <entry file="file://$PROJECT_DIR$/src/main/groovy/napplelabs/dbssim/ui/BirdsEyeViewExample.java">
+ <entry file="file://$PROJECT_DIR$/src/main/groovy/napplelabs/dbssim/ui/NeuronPath.groovy">
<provider selected="true" editor-type-id="text-editor">
- <state line="324" column="40" selection-start="12135" selection-end="12135" vertical-scroll-proportion="0.0">
+ <state line="14" column="6" selection-start="287" selection-end="287" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
- <entry file="file://$PROJECT_DIR$/src/main/groovy/napplelabs/dbssim/ui/CanvasPanel.groovy">
+ <entry file="file://$PROJECT_DIR$/src/main/groovy/napplelabs/dbssim/ui/SimUI.groovy">
<provider selected="true" editor-type-id="text-editor">
- <state line="61" column="21" selection-start="1826" selection-end="1826" vertical-scroll-proportion="0.94849783">
+ <state line="112" column="27" selection-start="4011" selection-end="4011" vertical-scroll-proportion="0.33628318">
<folding />
</state>
</provider>
View
101 neurons
@@ -0,0 +1,101 @@
+<object-stream>
+ <list>
+ <napplelabs.dbssim.neuron.NeuronPathRep>
+ <color>
+ <red>255</red>
+ <green>0</green>
+ <blue>0</blue>
+ <alpha>255</alpha>
+ </color>
+ <mediaFile>/Users/zkim/napplelabs/dbssim/src/main/resources/10-PD-STN.wav</mediaFile>
+ <location class="java.awt.geom.Point2D$Double">
+ <x>-40.381741228065515</x>
+ <y>69.91448588633693</y>
+ </location>
+ </napplelabs.dbssim.neuron.NeuronPathRep>
+ <napplelabs.dbssim.neuron.NeuronPathRep>
+ <color>
+ <red>0</red>
+ <green>255</green>
+ <blue>0</blue>
+ <alpha>255</alpha>
+ </color>
+ <mediaFile>/Users/zkim/napplelabs/dbssim/src/main/resources/15-PD-SNr.wav</mediaFile>
+ <location class="java.awt.geom.Point2D$Double">
+ <x>-87.55722748949846</x>
+ <y>240.17168246849485</y>
+ </location>
+ </napplelabs.dbssim.neuron.NeuronPathRep>
+ <napplelabs.dbssim.neuron.NeuronPathRep>
+ <color>
+ <red>0</red>
+ <green>0</green>
+ <blue>255</blue>
+ <alpha>255</alpha>
+ </color>
+ <mediaFile>/Users/zkim/napplelabs/dbssim/src/main/resources/Rage Against The Machine - rage against the machine - 06 - Know Your Enemy.mp3</mediaFile>
+ <location class="java.awt.geom.Point2D$Double">
+ <x>167.55631517543904</x>
+ <y>-599.3659360452199</y>
+ </location>
+ </napplelabs.dbssim.neuron.NeuronPathRep>
+ <napplelabs.dbssim.neuron.NeuronPathRep>
+ <color>
+ <red>255</red>
+ <green>0</green>
+ <blue>0</blue>
+ <alpha>255</alpha>
+ </color>
+ <mediaFile>/Users/zkim/napplelabs/dbssim/src/main/resources/10-PD-STN.wav</mediaFile>
+ <location class="java.awt.geom.Point2D$Double">
+ <x>-12.719061499187925</x>
+ <y>-6.410737685078022</y>
+ </location>
+ </napplelabs.dbssim.neuron.NeuronPathRep>
+ <napplelabs.dbssim.neuron.NeuronPathRep>
+ <color reference="../../napplelabs.dbssim.neuron.NeuronPathRep[4]/color"/>
+ <mediaFile>/Users/zkim/napplelabs/dbssim/src/main/resources/10-PD-STN.wav</mediaFile>
+ <location class="java.awt.geom.Point2D$Double">
+ <x>27.39323010435001</x>
+ <y>-75.56104274484736</y>
+ </location>
+ </napplelabs.dbssim.neuron.NeuronPathRep>
+ <napplelabs.dbssim.neuron.NeuronPathRep>
+ <color reference="../../napplelabs.dbssim.neuron.NeuronPathRep[4]/color"/>
+ <mediaFile>/Users/zkim/napplelabs/dbssim/src/main/resources/10-PD-STN.wav</mediaFile>
+ <location class="java.awt.geom.Point2D$Double">
+ <x>95.91906868857167</x>
+ <y>-282.4877549487037</y>
+ </location>
+ </napplelabs.dbssim.neuron.NeuronPathRep>
+ <napplelabs.dbssim.neuron.NeuronPathRep>
+ <color reference="../../napplelabs.dbssim.neuron.NeuronPathRep[4]/color"/>
+ <mediaFile>/Users/zkim/napplelabs/dbssim/src/main/resources/10-PD-STN.wav</mediaFile>
+ <location class="java.awt.geom.Point2D$Double">
+ <x>91.23789516925832</x>
+ <y>-360.2304966360077</y>
+ </location>
+ </napplelabs.dbssim.neuron.NeuronPathRep>
+ <napplelabs.dbssim.neuron.NeuronPathRep>
+ <color reference="../../napplelabs.dbssim.neuron.NeuronPathRep[4]/color"/>
+ <mediaFile>/Users/zkim/napplelabs/dbssim/src/main/resources/10-PD-STN.wav</mediaFile>
+ <location class="java.awt.geom.Point2D$Double">
+ <x>104.6663094542826</x>
+ <y>-446.57941097229025</y>
+ </location>
+ </napplelabs.dbssim.neuron.NeuronPathRep>
+ <napplelabs.dbssim.neuron.NeuronPathRep>
+ <color>
+ <red>0</red>
+ <green>255</green>
+ <blue>0</blue>
+ <alpha>255</alpha>
+ </color>
+ <mediaFile>/Users/zkim/napplelabs/dbssim/src/main/resources/15-PD-SNr.wav</mediaFile>
+ <location class="java.awt.geom.Point2D$Double">
+ <x>-59.57757863826585</x>
+ <y>309.33484390155263</y>
+ </location>
+ </napplelabs.dbssim.neuron.NeuronPathRep>
+ </list>
+</object-stream>
View
29 pom.xml
@@ -12,11 +12,11 @@
<artifactId>dbssim</artifactId>
<name>DBS Simulator</name>
<version>1.0-SNAPSHOT</version>
-
+
<repositories>
<repository>
- <id>napplelabs_public</id>
- <url>http://173.45.240.216:11081/nexus/content/groups/public/</url>
+ <id>napplelabs_public</id>
+ <url>http://173.45.240.216:11081/nexus/content/groups/public/</url>
</repository>
</repositories>
@@ -45,43 +45,43 @@
<artifactId>guice</artifactId>
<version>1.0</version>
</dependency>
-
+
<dependency>
<groupId>minim</groupId>
<artifactId>jl</artifactId>
<version>1.0</version>
</dependency>
-
+
<dependency>
<groupId>minim</groupId>
<artifactId>jsminim</artifactId>
<version>1.0</version>
</dependency>
-
+
<dependency>
<groupId>minim</groupId>
<artifactId>minim-spi</artifactId>
<version>1.0</version>
</dependency>
-
+
<dependency>
<groupId>minim</groupId>
<artifactId>minim</artifactId>
<version>1.0</version>
</dependency>
-
+
<dependency>
<groupId>minim</groupId>
<artifactId>mp3spi</artifactId>
<version>1.0</version>
</dependency>
-
+
<dependency>
<groupId>minim</groupId>
<artifactId>tritonus_aos</artifactId>
<version>1.0</version>
</dependency>
-
+
<dependency>
<groupId>minim</groupId>
<artifactId>tritonus_share</artifactId>
@@ -112,6 +112,11 @@
<artifactId>piccolox</artifactId>
<version>1.2.1</version>
</dependency>
+ <dependency>
+ <groupId>com.thoughtworks.xstream</groupId>
+ <artifactId>xstream</artifactId>
+ <version>1.3.1</version>
+ </dependency>
</dependencies>
<build>
@@ -121,8 +126,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
- <source>1.6</source>
- <target>1.6</target>
+ <source>1.5</source>
+ <target>1.5</target>
</configuration>
</plugin>
<plugin>
View
71 src/main/groovy/napplelabs/dbssim/neuron/NeuronPath.java
@@ -0,0 +1,71 @@
+package napplelabs.dbssim.neuron;
+
+import java.awt.Color;
+
+import ddf.minim.AudioPlayer;
+import ddf.minim.Minim;
+
+import edu.umd.cs.piccolo.PNode;
+import edu.umd.cs.piccolo.nodes.PPath;
+
+public class NeuronPath extends PNode {
+ Color color;
+ private String mediaFile;
+ private Minim minim;
+ private AudioPlayer player;
+ private PPath path;
+
+ public NeuronPath(Color color, String mediaFile, Minim minim) {
+ this.color = color;
+ this.mediaFile = mediaFile;
+ this.minim = minim;
+ init();
+ }
+
+ public void init() {
+ float d = 100f;
+ setPath(PPath.createEllipse(-d/2, -d/2, d, d));
+
+ Color c = new Color(color.getRed(), color.getGreen(), color.getBlue(), 190);
+ getPath().setPaint(c);
+
+ addChild(getPath());
+
+ player = minim.loadFile(mediaFile);
+ player.loop();
+ setLevel(0f);
+
+ //player.play();
+ }
+
+ public void setLevel(float level) {
+ float gain = (level * (80 + 14)) - 80;
+ player.setGain(gain);
+ }
+ public void setPlaying(boolean playing) {
+ if(playing)
+ player.play();
+ else
+ player.pause();
+ }
+ public boolean isPlaying() {
+ return player.isPlaying();
+ }
+
+ public void setPath(PPath path) {
+ this.path = path;
+ }
+
+ public PPath getPath() {
+ return path;
+ }
+
+ public Color getColor() {
+ return color;
+ }
+
+ public String getMediaFile() {
+ return mediaFile;
+ }
+}
+
View
10 src/main/groovy/napplelabs/dbssim/neuron/NeuronPathRep.java
@@ -0,0 +1,10 @@
+package napplelabs.dbssim.neuron;
+
+import java.awt.Color;
+import java.awt.geom.Point2D;
+
+public class NeuronPathRep {
+ public Color color = Color.black;
+ public String mediaFile = "";
+ public Point2D location = new Point2D.Double();
+}
View
195 src/main/groovy/napplelabs/dbssim/ui/BirdsEyeView.java
@@ -0,0 +1,195 @@
+package napplelabs.dbssim.ui;
+
+import java.awt.Color;
+import java.awt.geom.Rectangle2D;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
+import edu.umd.cs.piccolo.PCanvas;
+import edu.umd.cs.piccolo.PLayer;
+import edu.umd.cs.piccolo.PNode;
+import edu.umd.cs.piccolo.event.PDragSequenceEventHandler;
+import edu.umd.cs.piccolo.event.PInputEvent;
+import edu.umd.cs.piccolo.util.PDimension;
+import edu.umd.cs.piccolo.util.PPaintContext;
+import edu.umd.cs.piccolox.nodes.P3DRect;
+
+/**
+ * The Birds Eye View Class
+ */
+ public class BirdsEyeView extends PCanvas implements PropertyChangeListener {
+
+ /**
+ * This is the node that shows the viewed area.
+ */
+ PNode areaVisiblePNode;
+
+ /**
+ * This is the canvas that is being viewed
+ */
+ PCanvas viewedCanvas;
+
+ /**
+ * The change listener to know when to update the birds eye view.
+ */
+ PropertyChangeListener changeListener;
+
+ int layerCount;
+
+ /**
+ * Creates a new instance of a BirdsEyeView
+ */
+ public BirdsEyeView() {
+
+ // create the PropertyChangeListener for listening to the viewed
+ // canvas
+ changeListener = new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent evt) {
+ updateFromViewed();
+ }
+
+ };
+
+
+
+ setBounds(0, 0, 200, 200);
+
+ // create the coverage node
+ areaVisiblePNode = new P3DRect();
+ areaVisiblePNode.setPaint(new Color(128, 128, 255));
+ areaVisiblePNode.setTransparency(.8f);
+ areaVisiblePNode.setBounds(0, 0, 100, 100);
+ getCamera().addChild(areaVisiblePNode);
+
+ // add the drag event handler
+ getCamera().addInputEventListener(new PDragSequenceEventHandler() {
+ protected void startDrag(PInputEvent e) {
+ if (e.getPickedNode() == areaVisiblePNode)
+ super.startDrag(e);
+ }
+
+ protected void drag(PInputEvent e) {
+ PDimension dim = e.getDelta();
+ viewedCanvas.getCamera().translateView(0 - dim.getWidth(), 0 - dim.getHeight());
+ }
+
+ });
+
+ // remove Pan and Zoom
+ removeInputEventListener(getPanEventHandler());
+ removeInputEventListener(getZoomEventHandler());
+
+ //setDefaultRenderQuality(PPaintContext.LOW_QUALITY_RENDERING);
+
+ }
+
+ public void connect(PCanvas canvas, PLayer[] viewed_layers) {
+
+ this.viewedCanvas = canvas;
+ layerCount = 0;
+
+ viewedCanvas.getCamera().addPropertyChangeListener(changeListener);
+
+ for (layerCount = 0; layerCount < viewed_layers.length; ++layerCount) {
+ getCamera().addLayer(layerCount, viewed_layers[layerCount]);
+ }
+
+ }
+
+ /**
+ * Add a layer to list of viewed layers
+ */
+ public void addLayer(PLayer new_layer) {
+ getCamera().addLayer(new_layer);
+ layerCount++;
+ }
+
+ /**
+ * Remove the layer from the viewed layers
+ */
+ public void removeLayer(PLayer old_layer) {
+ getCamera().removeLayer(old_layer);
+ layerCount--;
+ }
+
+ /**
+ * Stop the birds eye view from receiving events from the viewed canvas
+ * and remove all layers
+ */
+ public void disconnect() {
+ viewedCanvas.getCamera().removePropertyChangeListener(changeListener);
+
+ for (int i = 0; i < getCamera().getLayerCount(); ++i) {
+ getCamera().removeLayer(i);
+ }
+
+ }
+
+ /**
+ * This method will get called when the viewed canvas changes
+ */
+ public void propertyChange(PropertyChangeEvent event) {
+ updateFromViewed();
+ }
+
+ /**
+ * This method gets the state of the viewed canvas and updates the
+ * BirdsEyeViewer This can be called from outside code
+ */
+ public void updateFromViewed() {
+
+ double viewedX;
+ double viewedY;
+ double viewedHeight;
+ double viewedWidth;
+
+ double ul_camera_x = viewedCanvas.getCamera().getViewBounds().getX();
+ double ul_camera_y = viewedCanvas.getCamera().getViewBounds().getY();
+ double lr_camera_x = ul_camera_x + viewedCanvas.getCamera().getViewBounds().getWidth();
+ double lr_camera_y = ul_camera_y + viewedCanvas.getCamera().getViewBounds().getHeight();
+
+ Rectangle2D drag_bounds = getCamera().getUnionOfLayerFullBounds();
+
+ double ul_layer_x = drag_bounds.getX();
+ double ul_layer_y = drag_bounds.getY();
+ double lr_layer_x = drag_bounds.getX() + drag_bounds.getWidth();
+ double lr_layer_y = drag_bounds.getY() + drag_bounds.getHeight();
+
+ // find the upper left corner
+
+ // set to the lesser value
+ if (ul_camera_x < ul_layer_x)
+ viewedX = ul_layer_x;
+ else
+ viewedX = ul_camera_x;
+
+ // same for y
+ if (ul_camera_y < ul_layer_y)
+ viewedY = ul_layer_y;
+ else
+ viewedY = ul_camera_y;
+
+ // find the lower right corner
+
+ // set to the greater value
+ if (lr_camera_x < lr_layer_x)
+ viewedWidth = lr_camera_x - viewedX;
+ else
+ viewedWidth = lr_layer_x - viewedX;
+
+ // same for height
+ if (lr_camera_y < lr_layer_y)
+ viewedHeight = lr_camera_y - viewedY;
+ else
+ viewedHeight = lr_layer_y - viewedY;
+
+ Rectangle2D bounds = new Rectangle2D.Double(viewedX, viewedY, viewedWidth, viewedHeight);
+ bounds = getCamera().viewToLocal(bounds);
+ areaVisiblePNode.setBounds(bounds);
+
+ // keep the birds eye view centered
+ getCamera().animateViewToCenterBounds(drag_bounds, true, 0);
+
+ }
+
+ } // class BirdsEyeView
View
451 src/main/groovy/napplelabs/dbssim/ui/BirdsEyeViewExample.java
@@ -1,451 +0,0 @@
-/*
- * 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.BasicStroke;
-import java.awt.Color;
-import java.awt.Graphics2D;
-import java.awt.geom.Ellipse2D;
-import java.awt.geom.Line2D;
-import java.awt.geom.Rectangle2D;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-
-import javax.swing.JDialog;
-
-import edu.umd.cs.piccolo.PCanvas;
-import edu.umd.cs.piccolo.PLayer;
-import edu.umd.cs.piccolo.PNode;
-import edu.umd.cs.piccolo.event.PBasicInputEventHandler;
-import edu.umd.cs.piccolo.event.PDragEventHandler;
-import edu.umd.cs.piccolo.event.PDragSequenceEventHandler;
-import edu.umd.cs.piccolo.event.PInputEvent;
-import edu.umd.cs.piccolo.nodes.PImage;
-import edu.umd.cs.piccolo.nodes.PPath;
-import edu.umd.cs.piccolo.nodes.PText;
-import edu.umd.cs.piccolo.util.PBounds;
-import edu.umd.cs.piccolo.util.PDimension;
-import edu.umd.cs.piccolo.util.PPaintContext;
-import edu.umd.cs.piccolox.PFrame;
-import edu.umd.cs.piccolox.nodes.P3DRect;
-
-/**
- * This example, contributed by Rowan Christmas, shows how to create a birds-eye
- * view window.
- */
-public class BirdsEyeViewExample extends PFrame {
-
- boolean fIsPressed = false;
-
- public BirdsEyeViewExample() {
- this(null);
- }
-
- public BirdsEyeViewExample(PCanvas aCanvas) {
- super("BirdsEyeViewExample", false, aCanvas);
- }
-
- public void initialize() {
-
- nodeDemo();
- createNodeUsingExistingClasses();
- subclassExistingClasses();
- composeOtherNodes();
- createCustomNode();
-
- // Last of all lets remove the default pan event handler, and add a
- // drag event handler instead. This way you will be able to drag the
- // nodes around with the mouse.
- getCanvas().removeInputEventListener(getCanvas().getPanEventHandler());
- getCanvas().addInputEventListener(new PDragEventHandler());
-
- // this will create the actual BirdsEyeView and put it in a JDialog
- BirdsEyeView bev = new BirdsEyeView();
- bev.connect(getCanvas(), new PLayer[] { getCanvas().getLayer() });
- JDialog bird = new JDialog();
- bird.getContentPane().add(bev);
- bird.pack();
- bird.setSize(150, 150);
- bird.setVisible(true);
-
- }
-
- // This method demonstrates the kinds of things that can be done with any
- // node.
- public void nodeDemo() {
- PLayer layer = getCanvas().getLayer();
- PNode aNode = PPath.createRectangle(0, 0, 100, 80);
-
- // A node needs to be a descendent of the root to be displayed on the
- // screen.
- layer.addChild(aNode);
-
- // The default color for a node is blue, but you can change that with
- // the setPaint method.
- aNode.setPaint(Color.red);
-
- // A node can have children nodes added to it.
- aNode.addChild(PPath.createRectangle(0, 0, 100, 80));
-
- // The base bounds of a node is easy to change. Note that changing the
- // base bounds of a node will not change it's children.
- aNode.setBounds(-10, -10, 200, 110);
-
- // Each node has a transform that can be used to transform the node, and
- // all its children on the screen.
- aNode.translate(100, 100);
- aNode.scale(1.5);
- aNode.rotate(45);
-
- // The transparency of any node can be set, this transparency will be
- // applied to any of the nodes children as well.
- aNode.setTransparency(0.75f);
-
- // Its easy to copy nodes.
- PNode aCopy = (PNode) aNode.clone();
-
- // Make is so that the copies children are not pickable. For this
- // example that means you will not be able to grab the child and remove
- // it from its parent.
- aNode.setChildrenPickable(false);
-
- // Change the look of the copy
- aNode.setPaint(Color.GREEN);
- aNode.setTransparency(1.0f);
-
- // Let's add the copy to the root, and translate it so that it does not
- // cover the original node.
- layer.addChild(aCopy);
- aCopy.setOffset(0, 0);
- aCopy.rotate(-45);
- }
-
- // So far we have just been using PNode, but of course PNode has many
- // subclasses that you can try out to.
- public void createNodeUsingExistingClasses() {
- PLayer layer = getCanvas().getLayer();
- layer.addChild(PPath.createEllipse(0, 0, 100, 100));
- layer.addChild(PPath.createRectangle(0, 100, 100, 100));
- layer.addChild(new PText("Hello World"));
-
- // Here we create an image node that displays a thumbnail
- // image of the root node. Note that you can easily get a thumbnail
- // of any node by using PNode.toImage().
- layer.addChild(new PImage(layer.toImage(300, 300, Color.YELLOW)));
- }
-
- // Another way to create nodes is to customize other nodes that already
- // exist. Here we create an ellipse, except when you press the mouse on
- // this ellipse it turns into a square, when you release the mouse it
- // goes back to being an ellipse.
- public void subclassExistingClasses() {
- final PNode n = new PPath(new Ellipse2D.Float(0, 0, 100, 80)) {
-
- public void paint(PPaintContext aPaintContext) {
- if (fIsPressed) {
- // if mouse is pressed draw self as a square.
- Graphics2D g2 = aPaintContext.getGraphics();
- g2.setPaint(getPaint());
- g2.fill(getBoundsReference());
- }
- else {
- // if mouse is not pressed draw self normally.
- super.paint(aPaintContext);
- }
- }
- };
-
- n.addInputEventListener(new PBasicInputEventHandler() {
- public void mousePressed(PInputEvent aEvent) {
- super.mousePressed(aEvent);
- fIsPressed = true;
- n.invalidatePaint(); // this tells the framework that the node
- // needs to be redisplayed.
- }
-
- public void mouseReleased(PInputEvent aEvent) {
- super.mousePressed(aEvent);
- fIsPressed = false;
- n.invalidatePaint(); // this tells the framework that the node
- // needs to be redisplayed.
- }
- });
-
- n.setPaint(Color.ORANGE);
- getCanvas().getLayer().addChild(n);
- }
-
- // Here a new "face" node is created. But instead of drawing the face
- // directly using Graphics2D we compose the face from other nodes.
- public void composeOtherNodes() {
- PNode myCompositeFace = PPath.createRectangle(0, 0, 100, 80);
-
- // create parts for the face.
- PNode eye1 = PPath.createEllipse(0, 0, 20, 20);
- eye1.setPaint(Color.YELLOW);
- PNode eye2 = (PNode) eye1.clone();
- PNode mouth = PPath.createRectangle(0, 0, 40, 20);
- mouth.setPaint(Color.BLACK);
-
- // add the face parts
- myCompositeFace.addChild(eye1);
- myCompositeFace.addChild(eye2);
- myCompositeFace.addChild(mouth);
-
- // don't want anyone grabbing out our eye's.
- myCompositeFace.setChildrenPickable(false);
-
- // position the face parts.
- eye2.translate(25, 0);
- mouth.translate(0, 30);
-
- // set the face bounds so that it neatly contains the face parts.
- PBounds b = myCompositeFace.getUnionOfChildrenBounds(null);
- myCompositeFace.setBounds(b.inset(-5, -5));
-
- // opps it to small, so scale it up.
- myCompositeFace.scale(1.5);
-
- getCanvas().getLayer().addChild(myCompositeFace);
- }
-
- // Here a completely new kind of node, a grid node" is created. We do
- // all the drawing ourselves here instead of passing the work off to
- // other parts of the framework.
- public void createCustomNode() {
- PNode n = new PNode() {
- public void paint(PPaintContext aPaintContext) {
- double bx = getX();
- double by = getY();
- double rightBorder = bx + getWidth();
- double bottomBorder = by + getHeight();
-
- Line2D line = new Line2D.Double();
- Graphics2D g2 = aPaintContext.getGraphics();
-
- g2.setStroke(new BasicStroke(0));
- g2.setPaint(getPaint());
-
- // draw vertical lines
- for (double x = bx; x < rightBorder; x += 5) {
- line.setLine(x, by, x, bottomBorder);
- g2.draw(line);
- }
-
- for (double y = by; y < bottomBorder; y += 5) {
- line.setLine(bx, y, rightBorder, y);
- g2.draw(line);
- }
- }
- };
- n.setBounds(0, 0, 100, 80);
- n.setPaint(Color.black);
- getCanvas().getLayer().addChild(n);
- }
-
- public static void main(String[] args) {
- new BirdsEyeViewExample();
- }
-
- /**
- * The Birds Eye View Class
- */
- public class BirdsEyeView extends PCanvas implements PropertyChangeListener {
-
- /**
- * This is the node that shows the viewed area.
- */
- PNode areaVisiblePNode;
-
- /**
- * This is the canvas that is being viewed
- */
- PCanvas viewedCanvas;
-
- /**
- * The change listener to know when to update the birds eye view.
- */
- PropertyChangeListener changeListener;
-
- int layerCount;
-
- /**
- * Creates a new instance of a BirdsEyeView
- */
- public BirdsEyeView() {
-
- // create the PropertyChangeListener for listening to the viewed
- // canvas
- changeListener = new PropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent evt) {
- updateFromViewed();
- }
- };
-
- // create the coverage node
- areaVisiblePNode = new P3DRect();
- areaVisiblePNode.setPaint(new Color(128, 128, 255));
- areaVisiblePNode.setTransparency(.8f);
- areaVisiblePNode.setBounds(0, 0, 100, 100);
- getCamera().addChild(areaVisiblePNode);
-
- // add the drag event handler
- getCamera().addInputEventListener(new PDragSequenceEventHandler() {
- protected void startDrag(PInputEvent e) {
- if (e.getPickedNode() == areaVisiblePNode)
- super.startDrag(e);
- }
-
- protected void drag(PInputEvent e) {
- PDimension dim = e.getDelta();
- viewedCanvas.getCamera().translateView(0 - dim.getWidth(), 0 - dim.getHeight());
- }
-
- });
-
- // remove Pan and Zoom
- removeInputEventListener(getPanEventHandler());
- removeInputEventListener(getZoomEventHandler());
-
- setDefaultRenderQuality(PPaintContext.LOW_QUALITY_RENDERING);
-
- }
-
- public void connect(PCanvas canvas, PLayer[] viewed_layers) {
-
- this.viewedCanvas = canvas;
- layerCount = 0;
-
- viewedCanvas.getCamera().addPropertyChangeListener(changeListener);
-
- for (layerCount = 0; layerCount < viewed_layers.length; ++layerCount) {
- getCamera().addLayer(layerCount, viewed_layers[layerCount]);
- }
-
- }
-
- /**
- * Add a layer to list of viewed layers
- */
- public void addLayer(PLayer new_layer) {
- getCamera().addLayer(new_layer);
- layerCount++;
- }
-
- /**
- * Remove the layer from the viewed layers
- */
- public void removeLayer(PLayer old_layer) {
- getCamera().removeLayer(old_layer);
- layerCount--;
- }
-
- /**
- * Stop the birds eye view from receiving events from the viewed canvas
- * and remove all layers
- */
- public void disconnect() {
- viewedCanvas.getCamera().removePropertyChangeListener(changeListener);
-
- for (int i = 0; i < getCamera().getLayerCount(); ++i) {
- getCamera().removeLayer(i);
- }
-
- }
-
- /**
- * This method will get called when the viewed canvas changes
- */
- public void propertyChange(PropertyChangeEvent event) {
- updateFromViewed();
- }
-
- /**
- * This method gets the state of the viewed canvas and updates the
- * BirdsEyeViewer This can be called from outside code
- */
- public void updateFromViewed() {
-
- double viewedX;
- double viewedY;
- double viewedHeight;
- double viewedWidth;
-
- double ul_camera_x = viewedCanvas.getCamera().getViewBounds().getX();
- double ul_camera_y = viewedCanvas.getCamera().getViewBounds().getY();
- double lr_camera_x = ul_camera_x + viewedCanvas.getCamera().getViewBounds().getWidth();
- double lr_camera_y = ul_camera_y + viewedCanvas.getCamera().getViewBounds().getHeight();
-
- Rectangle2D drag_bounds = getCamera().getUnionOfLayerFullBounds();
-
- double ul_layer_x = drag_bounds.getX();
- double ul_layer_y = drag_bounds.getY();
- double lr_layer_x = drag_bounds.getX() + drag_bounds.getWidth();
- double lr_layer_y = drag_bounds.getY() + drag_bounds.getHeight();
-
- // find the upper left corner
-
- // set to the lesser value
- if (ul_camera_x < ul_layer_x)
- viewedX = ul_layer_x;
- else
- viewedX = ul_camera_x;
-
- // same for y
- if (ul_camera_y < ul_layer_y)
- viewedY = ul_layer_y;
- else
- viewedY = ul_camera_y;
-
- // find the lower right corner
-
- // set to the greater value
- if (lr_camera_x < lr_layer_x)
- viewedWidth = lr_camera_x - viewedX;
- else
- viewedWidth = lr_layer_x - viewedX;
-
- // same for height
- if (lr_camera_y < lr_layer_y)
- viewedHeight = lr_camera_y - viewedY;
- else
- viewedHeight = lr_layer_y - viewedY;
-
- Rectangle2D bounds = new Rectangle2D.Double(viewedX, viewedY, viewedWidth, viewedHeight);
- bounds = getCamera().viewToLocal(bounds);
- areaVisiblePNode.setBounds(bounds);
-
- // keep the birds eye view centered
- getCamera().animateViewToCenterBounds(drag_bounds, true, 0);
-
- }
-
- } // class BirdsEyeView
-
-}
View
237 src/main/groovy/napplelabs/dbssim/ui/CanvasPanel.groovy
@@ -1,237 +0,0 @@
-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
-import edu.umd.cs.piccolo.PLayer
-import javax.swing.event.ChangeListener
-import java.awt.Canvas
-
-/**
- * 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()
-
- PLayer backgroundLayer = new PLayer();
- getCanvas().getCamera().addLayer(1, backgroundLayer);
-
- Probe probe = new Probe()
-
- panel.add(new FeaturePanel(canvas, canvas.layer), BorderLayout.CENTER)
- panel.add(new DepthPanel(canvas, probe), 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.rotate(Math.PI / 360 * 30)
- backgroundLayer.addChild(probe)
-
- canvas.layer.addInputEventListener(new NodeDragHandler())
-
- //Birds eye stuff
- }
-}
-
-class FeaturePanel extends JPanel {
-
- PCanvas canvas
- PLayer layer
-
- public FeaturePanel(PCanvas canvas, PLayer layer) {
- this.canvas = canvas
- this.layer = layer
- 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 {
- Probe probe
- PCanvas canvas
-
- public DepthPanel(PCanvas canvas, Probe probe) {
- this.probe = probe
- this.canvas = canvas
- init()
- }
-
- public void init() {
- JSlider slider = new JSlider(JSlider.VERTICAL)
- layout = new BorderLayout()
- add(slider, BorderLayout.CENTER)
- slider.maximum = 100
- slider.minimum = -200
- slider.value = 200
-
- slider.addChangeListener({
- probe.setDepth((double) slider.value / 10)
- canvas.repaint()
- } as ChangeListener)
- }
-}
-
-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 {
-
-
- public NodeDragHandler() {
-
- 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
-
- probe = PPath.createLine(0, 0, 0, -3000);
-
- probe.offset = new Point2D.Double(0, -2000)
- probe.stroke = new BasicStroke(5)
-
- addChild(path)
- addChild(probe)
-
- (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)
- }
-
- }
-
- PPath probe
-
- public void setDepth(double depth) {
- probe.offset = new Point2D.Double(0.0, -depth * 100.0 - 1000)
- }
-
- public double getDepth() {
- return probe.offset.y / 100
- }
-}
-
View
217 src/main/groovy/napplelabs/dbssim/ui/CanvasPanel.java
@@ -0,0 +1,217 @@
+package napplelabs.dbssim.ui;
+
+import java.awt.BorderLayout;
+import java.awt.Component;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.geom.Point2D;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.swing.JButton;
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+import javax.swing.JSlider;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
+
+import com.thoughtworks.xstream.XStream;
+
+import ddf.minim.Minim;
+
+import net.miginfocom.swing.MigLayout;
+
+import edu.umd.cs.piccolo.PCanvas;
+import edu.umd.cs.piccolo.PLayer;
+import edu.umd.cs.piccolo.util.PPaintContext;
+
+import napplelabs.dbssim.neuron.NeuronPath;
+import napplelabs.dbssim.neuron.NeuronPathRep;
+
+public class CanvasPanel extends JPanel {
+
+ PCanvas canvas = new PCanvas();
+
+ List<NeuronPath> neurons = new ArrayList<NeuronPath>();
+
+ private Probe probe;
+
+ private Minim minim;
+
+ public CanvasPanel(Minim minim) {
+ this.minim = minim;
+ setLayout(new BorderLayout());
+ add(canvas, BorderLayout.CENTER);
+ JPanel panel = new JPanel();
+ add(panel, BorderLayout.EAST);
+ panel.setLayout(new BorderLayout());
+
+ PLayer backgroundLayer = new PLayer();
+ canvas.getCamera().addLayer(1, backgroundLayer);
+
+ probe = new Probe();
+
+ panel.add(createFeaturePanel(), BorderLayout.CENTER);
+ panel.add(createDepthPanel(), BorderLayout.WEST);
+
+ canvas.setZoomEventHandler(new NapPZoomEventHandler());
+ canvas.setAnimatingRenderQuality(PPaintContext.HIGH_QUALITY_RENDERING);
+ canvas.setInteractingRenderQuality(PPaintContext.HIGH_QUALITY_RENDERING);
+ canvas.getCamera().setViewOffset(1000 / 2, 700 / 2);
+
+
+ probe.rotate(Math.PI / 360 * 30);
+ backgroundLayer.addChild(probe);
+
+ canvas.getLayer().addInputEventListener(new NodeDragHandler(this));
+
+
+ load();
+ //Birds eye stuff
+
+ BirdsEyeView view = new BirdsEyeView();
+ view.connect(canvas, new PLayer[] { canvas.getLayer(), backgroundLayer} );
+
+
+ //view.viewedCanvas = canvas;
+ //view.addLayer(canvas.getLayer());
+ //view.addLayer(backgroundLayer);
+
+ canvas.getCamera().addChild(view.getCamera());
+
+
+ }
+
+ private Component createFeaturePanel() {
+
+ JPanel panel = new JPanel();
+ panel.setLayout(new MigLayout("wrap 1"));
+ JButton thal = new JButton("Thalamus");
+ thal.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ addNeuron(new ThalamusPath(minim));
+ }
+ });
+ panel.add(thal);
+
+ JButton stn = new JButton("STN");
+ stn.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ addNeuron(new StnPath(minim));
+ }
+ });
+ panel.add(stn);
+
+ JButton snr = new JButton("SNr");
+ snr.addActionListener(new ActionListener() {
+
+ public void actionPerformed(ActionEvent e) {
+ addNeuron(new SnrPath(minim));
+ }
+ });
+ panel.add(snr);
+
+ return panel;
+
+ }
+
+ public void addNeuron(NeuronPath path) {
+ path.translate (canvas.getCamera().getViewBounds().getCenterX(), canvas.getCamera().getViewBounds().getCenterY());
+ canvas.getLayer().addChild(path);
+ neurons.add(path);
+
+ persist();
+ }
+
+ private Component createDepthPanel() {
+ JPanel panel = new JPanel();
+ final JSlider slider = new JSlider(JSlider.VERTICAL);
+ panel.setLayout(new BorderLayout());
+ panel.add(slider, BorderLayout.CENTER);
+ slider.setMaximum(2000);
+ slider.setMinimum(-1000);
+ slider.setValue(2000);
+ slider.addChangeListener(new ChangeListener() {
+ public void stateChanged(ChangeEvent e) {
+ probe.setDepth((double) slider.getValue() / 1000);
+ canvas.repaint();
+ recalcDistances();
+ }
+ });
+
+ return panel;
+
+ }
+
+ public void recalcDistances() {
+ Point2D p = probe.getProbe().getGlobalTranslation();
+ for(NeuronPath np: neurons) {
+ float diff = (float) p.distance(np.getPath().getGlobalTranslation());
+ if(diff < 100) {
+ np.setLevel((100f - diff)/100f);
+ } else {
+ np.setLevel(0f);
+ }
+ }
+ }
+
+ public void persist() {
+ XStream xs = new XStream();
+
+ //Write to a file in the file system
+ try {
+
+ List<NeuronPathRep> reps = new ArrayList<NeuronPathRep>();
+ for(NeuronPath p: neurons) {
+ NeuronPathRep r = new NeuronPathRep();
+ r.color = p.getColor();
+ r.mediaFile = p.getMediaFile();
+ r.location = p.getGlobalTranslation();
+ reps.add(r);
+ }
+
+ ObjectOutputStream os = xs.createObjectOutputStream(new FileWriter(new File("./neurons")));
+
+
+ os.writeObject(reps);
+ os.close();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ public void load() {
+ XStream xs = new XStream();
+
+ //Write to a file in the file system
+ try {
+ ObjectInputStream is = xs.createObjectInputStream(new FileReader(new File("./neurons")));
+ List<NeuronPathRep> paths = (List<NeuronPathRep>) is.readObject();
+
+ for(NeuronPathRep r: paths) {
+ NeuronPath np = new NeuronPath(r.color, r.mediaFile, minim);
+ np.setOffset(r.location);
+ addNeuron(np);
+ }
+
+ is.close();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (ClassNotFoundException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+
+ }
+}
View
64 src/main/groovy/napplelabs/dbssim/ui/NeuronPath.groovy
@@ -0,0 +1,64 @@
+package napplelabs.dbssim.ui
+
+import edu.umd.cs.piccolo.PNode
+import java.awt.Color
+import edu.umd.cs.piccolo.nodes.PPath
+import napplelabs.dbssim.neuron.NeuronPath
+import ddf.minim.Minim
+import java.awt.BasicStroke
+import java.awt.geom.Point2D
+import edu.umd.cs.piccolo.nodes.PText
+import java.awt.Font
+class ThalamusPath extends NeuronPath {
+ public ThalamusPath(Minim minim) {
+ super(Color.blue, "/Users/zkim/napplelabs/dbssim/src/main/resources/Rage Against The Machine - rage against the machine - 06 - Know Your Enemy.mp3", minim)
+ }
+}
+
+class StnPath extends NeuronPath {
+ public StnPath(Minim minim) {
+ super(Color.red, "/Users/zkim/napplelabs/dbssim/src/main/resources/10-PD-STN.wav", minim)
+ }
+}
+
+class SnrPath extends NeuronPath {
+ public SnrPath(Minim minim) {
+ super(Color.green, "/Users/zkim/napplelabs/dbssim/src/main/resources/15-PD-SNr.wav", minim)
+ }
+}
+
+class Probe extends PNode {
+ public Probe() {
+ init()
+ }
+
+ public void init() {
+ PPath path = PPath.createLine(0, -1000, 0, 2000);
+ //path.rotate(Math.PI)
+ path.stroke = new BasicStroke(3)
+ path.paint = Color.lightGray
+ path.strokePaint = Color.lightGray
+
+ probe = PPath.createLine(0, 0, 0, -3000);
+
+ probe.offset = new Point2D.Double(0, -2000)
+ probe.stroke = new BasicStroke(5)
+
+ addChild(path)
+ addChild(probe)
+
+ (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)
+ }
+
+ }
+
+ PPath probe
+
+ public void setDepth(double depth) {
+ probe.offset = new Point2D.Double(0.0, -depth * 1000.0)
+ }
View
45 src/main/groovy/napplelabs/dbssim/ui/NodeDragHandler.java
@@ -0,0 +1,45 @@
+package napplelabs.dbssim.ui;
+
+import napplelabs.dbssim.neuron.NeuronPath;
+import edu.umd.cs.piccolo.PNode;
+import edu.umd.cs.piccolo.event.PDragSequenceEventHandler;
+import edu.umd.cs.piccolo.event.PInputEvent;
+
+class NodeDragHandler extends PDragSequenceEventHandler {
+
+ private CanvasPanel cp;
+
+ public NodeDragHandler(CanvasPanel cp) {
+ this.cp = cp;
+ 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();
+ PNode n = node;
+ while(true) {
+ n = n.getParent();
+ if(n instanceof NeuronPath) break;
+ if(n == null) break;
+ }
+
+ if(n == null) return;
+ //if (probe.children.contains(node)) return
+ n.translate(e.getDelta().width, e.getDelta().height);
+
+ cp.recalcDistances();
+ cp.persist();
+ }
+}
View
2  src/main/groovy/napplelabs/dbssim/ui/SimUI.groovy
@@ -97,7 +97,7 @@ class SimUI {
tracePanel = new TracePApplet(container)
tracePanel.init()
- def canvasPanel = new CanvasPanel()
+ def canvasPanel = new CanvasPanel(minim)
TabManager tabManager = new TabManager(mf.content)
tabManager.add("Canvas", canvasPanel)
View
BIN  src/main/resources/Rage Against The Machine - rage against the machine - 06 - Know Your Enemy.mp3
Binary file not shown
Please sign in to comment.
Something went wrong with that request. Please try again.