Permalink
Browse files

Started the UI portion, added basic mac views (no sourcelist yet).

  • Loading branch information...
1 parent a4746b4 commit 742cf50c3464e76ec4f5d22135354c5df5f0e2a4 @zk committed Jan 15, 2009
View
@@ -10,5 +10,8 @@
<classpathentry kind="lib" path="lib/jsminim.jar"/>
<classpathentry kind="lib" path="lib/tritonus_aos.jar"/>
<classpathentry kind="lib" path="lib/tritonus_share.jar"/>
+ <classpathentry kind="lib" path="lib/mac_widgets.jar"/>
+ <classpathentry kind="lib" path="lib/forms-1.2.1.jar"/>
+ <classpathentry exported="true" kind="con" path="GROOVY_SUPPORT"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
View
@@ -6,12 +6,18 @@
</projects>
<buildSpec>
<buildCommand>
+ <name>org.codehaus.groovy.eclipse.groovyBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.codehaus.groovy.eclipse.groovyNature</nature>
</natures>
</projectDescription>
@@ -0,0 +1,3 @@
+#Wed Jan 14 20:14:49 MST 2009
+eclipse.preferences.version=1
+groovy.compiler.output.path=bin-groovy
@@ -1,5 +1,6 @@
-#Wed Jan 14 13:54:56 MST 2009
+#Wed Jan 14 20:14:49 MST 2009
eclipse.preferences.version=1
+org.eclipse.jdt.core.builder.resourceCopyExclusionFilter=*.launch,*.groovy
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
Binary file not shown.
Binary file not shown.
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
@@ -33,9 +33,16 @@
private float[] spike;
private int counter = 0;
+ private int space_len = 44100;
+ //private int spike_cnt = 0;
+ private int space_cnt = 0;
+ private float minRate = 1;
+ private float maxRate = 10;
- public NeuronSignal(float[] spike) {
+ public NeuronSignal(float[] spike, float minRate, float maxRate) {
this.spike = spike;
+ this.minRate = minRate;
+ this.maxRate = maxRate;
}
public void generate(float[] signal) {
@@ -45,9 +52,26 @@ public void generate(float[] signal) {
}
public float getNextValue() {
- float next = spike[counter];
+ float next = 0;
+
+ //If counter is within spike range, output next spike value
+ if(counter < spike.length) {
+ next = spike[counter];
+ }
+
+ //else it's in the space range, output 0
+
counter++;
- if(counter >= spike.length) counter = 0;
+
+ if(counter >= spike.length + space_len) {
+ counter = 0;
+ float diff = maxRate - minRate;
+ //System.out.println(diff);
+ float rnd = (float) (Math.random() * diff + minRate);
+ space_len = (int) (44100 / rnd);
+ //System.out.println(space_len);
+ //System.out.println();
+ }
return next;
}
@@ -33,7 +33,7 @@ public void paint(Graphics _g) {
double one = (double) getWidth() / (double) leftSize;
double diff = i * one;
- g.drawLine((int) diff, (int) (getHeight()/2 + signal.left.get(i)*getHeight()/2), (int) (diff + one), (int) (getHeight()/2 + signal.left.get(i+1)*getHeight()/2));
+ g.drawLine((int) diff, (int) (getHeight()/2 + -signal.left.get(i)*getHeight()/2), (int) (diff + one), (int) (getHeight()/2 + -signal.left.get(i+1)*getHeight()/2));
}
}
@@ -22,15 +22,16 @@ public static void main(String[] args) {
out = minim.getLineOut(Minim.MONO);
double one = (float) (Math.PI / 100);
- int sin_size = 1000;
+ int sin_size = 100;
float[] sin = new float[sin_size];
for(int i=0; i < sin_size; i++) {
sin[i] = (float) Math.sin(one * i);
}
- ns = new NeuronSignal(sin);
+ ns = new NeuronSignal(sin, 5, 50);
out.addSignal(ns);
+ out.addSignal(new PinkNoise(0.1f));
TracePanel panel = new TracePanel(out);
frame.setContentPane(panel);
@@ -0,0 +1,55 @@
+/**
+ *
+ */
+package napplelabs.dbssim.ui
+
+import javax.swing.JFrameimport java.awt.Dimensionimport javax.swing.SwingUtilitiesimport java.lang.Runnableimport com.explodingpixels.macwidgets.MacWidgetFactoryimport com.explodingpixels.macwidgets.TriAreaComponentimport java.awt.BorderLayoutimport com.explodingpixels.macwidgets.BottomBarSizeimport javax.swing.JLabelimport javax.swing.JPanelimport javax.swing.JButtonimport ddf.minim.Minimimport napplelabs.dbssim.NeuronSignalimport ddf.minim.signals.PinkNoiseimport napplelabs.dbssim.TracePanelimport ddf.minim.AudioOutputimport javax.swing.AbstractButtonimport javax.swing.JComponent/**
+ * @author zkim
+ *
+ */
+public class MacFrame{
+
+ JFrame frame
+ TriAreaComponent toolbar
+ TriAreaComponent bottombar
+ JPanel content;
+
+ public MacFrame() {
+
+
+ frame = new JFrame("DBS Simulator")
+ frame.defaultCloseOperation = JFrame.EXIT_ON_CLOSE
+ frame.size = new Dimension(500, 300)
+
+ toolbar = MacWidgetFactory.createUnifiedToolBar()
+ frame.contentPane.add(toolbar.component, BorderLayout.NORTH)
+
+ bottombar = MacWidgetFactory.createBottomBar(BottomBarSize.LARGE);
+ frame.contentPane.add(bottombar.component, BorderLayout.SOUTH)
+ content = new JPanel()
+ content.layout = new BorderLayout()
+ frame.contentPane.add(content, BorderLayout.CENTER)
+
+ frame.visible = true;
+
+ }
+
+ def revalidate() {
+ frame.contentPane.revalidate()
+ }
+
+ def addToolbarComponentRight(JComponent comp) {
+ toolbar.addComponentToRight(comp)
+ }
+
+ def addToolbarComponentCenter(JComponent comp) {
+ toolbar.addComponentToCenter(comp)
+ }
+
+ public static void main(String[] args) {
+ MacFrame mf = new MacFrame();
+
+
+
+ }
+}
@@ -0,0 +1,62 @@
+package napplelabs.dbssim.ui
+
+import ddf.minim.Minimimport ddf.minim.AudioOutputimport napplelabs.dbssim.NeuronSignalimport napplelabs.dbssim.TracePanelimport ddf.minim.signals.PinkNoiseimport java.awt.BorderLayoutimport com.explodingpixels.macwidgets.MacButtonFactoryimport javax.swing.AbstractButtonimport javax.swing.JButtonimport javax.swing.ImageIconimport javax.swing.JToggleButtonimport javax.swing.ButtonGroupimport com.explodingpixels.macwidgets.LabeledComponentGroupclass SimUI {
+ MacFrame mf
+ public SimUI() {
+ mf = new MacFrame()
+
+ Minim minim = new Minim(null);
+ AudioOutput out = minim.getLineOut(Minim.MONO);
+
+ double one = (float) (Math.PI / 100);
+ int sin_size = 100;
+ float[] sin = new float[sin_size];
+ for(int i=0; i < sin_size; i++) {
+ sin[i] = (float) Math.sin(one * i);
+ }
+
+ NeuronSignal ns = new NeuronSignal(sin, 5, 50);
+
+ out.addSignal(ns);
+ out.addSignal(new PinkNoise(0.1f));
+
+ TracePanel panel = new TracePanel(out);
+
+ mf.content.add(panel, BorderLayout.CENTER)
+
+ AbstractButton playButton =
+ MacButtonFactory.makeUnifiedToolBarButton(
+ new JButton("Play", new ImageIcon(SimUI.class.getResource(
+ "/napplelabs/resources/dotmac.png"))));
+
+ mf.addToolbarComponentRight(playButton)
+
+
+ JToggleButton leftButton = new JToggleButton("Control");
+
+ leftButton.putClientProperty("JButton.buttonType", "segmentedTextured");
+ leftButton.putClientProperty("JButton.segmentPosition", "first");
+ leftButton.setFocusable(false);
+
+ JToggleButton rightButton = new JToggleButton("Trace");
+ rightButton.putClientProperty("JButton.buttonType", "segmentedTextured");
+ rightButton.putClientProperty("JButton.segmentPosition", "last");
+ rightButton.setFocusable(false);
+
+ ButtonGroup group = new ButtonGroup();
+ group.add(leftButton);
+ group.add(rightButton);
+
+ LabeledComponentGroup viewButtons = new LabeledComponentGroup(null, leftButton, rightButton);
+
+ mf.addToolbarComponentCenter(viewButtons.component)
+
+ mf.revalidate()
+
+ new Thread(panel).start()
+ }
+
+ public static void main(String[] args) {
+ new SimUI()
+ }
+}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -8,44 +8,6 @@
@Test
public void testNeuronSignal() {
- double one = (float) (Math.PI / 100);
- float[] spike = new float[100];
- for(int i=0; i < 100; i++) {
- spike[i] = (float) Math.sin(one * i);
- }
-
- NeuronSignal ns = new NeuronSignal(spike);
-
- float[] out = new float[100];
- ns.generate(out);
-
- for(int i=0; i < out.length; i++) {
- assertEquals("dc spike[" + i + "]", spike[i], out[i]);
- }
-
- float[] pout_0 = new float[21];
- float[] pout_1 = new float[89];
-
- ns.generate(pout_0);
- ns.generate(pout_1);
-
- float[] pfinal = new float[110];
- for(int i=0; i < pout_0.length; i++) {
- pfinal[i] = pout_0[i];
- }
-
- for(int i=pout_0.length; i < pout_0.length + pout_1.length; i++) {
- pfinal[i] = pout_1[i-pout_0.length];
- }
-
- for(int i=0; i < pfinal.length-10; i++) {
- assertEquals("spike[" + i + "]", spike[i], pfinal[i]);
- }
-
- for(int i=0; i < 10; i++) {
- assertEquals(spike[i], pfinal[i+100]);
- }
-
}
}
Binary file not shown.
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.

0 comments on commit 742cf50

Please sign in to comment.