aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--PunchingBag/.classpath2
-rw-r--r--PunchingBag/bin/PunchingBag$Colour.classbin0 -> 1030 bytes
-rw-r--r--PunchingBag/bin/PunchingBag$Ripple.classbin0 -> 1157 bytes
-rw-r--r--PunchingBag/bin/PunchingBag.classbin755 -> 1804 bytes
-rw-r--r--PunchingBag/bin/PunchingBagGUI$Ripple.classbin1614 -> 1618 bytes
-rw-r--r--PunchingBag/bin/PunchingBagGUI.classbin3613 -> 3613 bytes
-rw-r--r--PunchingBag/src/PunchingBag.java99
-rw-r--r--PunchingBag/src/PunchingBagGUI.java1
8 files changed, 84 insertions, 18 deletions
diff --git a/PunchingBag/.classpath b/PunchingBag/.classpath
index 3b45536..4cb0e3c 100644
--- a/PunchingBag/.classpath
+++ b/PunchingBag/.classpath
@@ -2,6 +2,6 @@
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
- <classpathentry kind="lib" path="/usr/share/java/RXTXcomm.jar"/>
+ <classpathentry kind="lib" path="C:/Documents and Settings/am29567/punchingbag/PunchingBag/RXTXcomm.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
diff --git a/PunchingBag/bin/PunchingBag$Colour.class b/PunchingBag/bin/PunchingBag$Colour.class
new file mode 100644
index 0000000..75ff538
--- /dev/null
+++ b/PunchingBag/bin/PunchingBag$Colour.class
Binary files differ
diff --git a/PunchingBag/bin/PunchingBag$Ripple.class b/PunchingBag/bin/PunchingBag$Ripple.class
new file mode 100644
index 0000000..3988003
--- /dev/null
+++ b/PunchingBag/bin/PunchingBag$Ripple.class
Binary files differ
diff --git a/PunchingBag/bin/PunchingBag.class b/PunchingBag/bin/PunchingBag.class
index 65f48c7..e8616d9 100644
--- a/PunchingBag/bin/PunchingBag.class
+++ b/PunchingBag/bin/PunchingBag.class
Binary files differ
diff --git a/PunchingBag/bin/PunchingBagGUI$Ripple.class b/PunchingBag/bin/PunchingBagGUI$Ripple.class
index b824480..491ecf3 100644
--- a/PunchingBag/bin/PunchingBagGUI$Ripple.class
+++ b/PunchingBag/bin/PunchingBagGUI$Ripple.class
Binary files differ
diff --git a/PunchingBag/bin/PunchingBagGUI.class b/PunchingBag/bin/PunchingBagGUI.class
index 362e5e7..fb8d093 100644
--- a/PunchingBag/bin/PunchingBagGUI.class
+++ b/PunchingBag/bin/PunchingBagGUI.class
Binary files differ
diff --git a/PunchingBag/src/PunchingBag.java b/PunchingBag/src/PunchingBag.java
index 278a8fc..7629afe 100644
--- a/PunchingBag/src/PunchingBag.java
+++ b/PunchingBag/src/PunchingBag.java
@@ -1,24 +1,89 @@
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-
-import javax.swing.JButton;
import javax.swing.event.EventListenerList;
-
public class PunchingBag {
protected EventListenerList listenerList = new EventListenerList();
-
- /**
- * Adds an <code>ActionListener</code> to the button.
- * @param l the <code>ActionListener</code> to be added
- */
- public void addButtonListener(ButtonListener l) {
- listenerList.add(ButtonListener.class, l);
- }
-
- public void setLED(byte x, byte y, byte intensity) {
-
-
+
+ enum Colour {
+ None, Red, Yellow, Green
+ };
+
+ /**
+ * Adds an <code>ActionListener</code> to the button.
+ *
+ * @param l
+ * the <code>ActionListener</code> to be added
+ */
+ public void addButtonListener(ButtonListener l) {
+ listenerList.add(ButtonListener.class, l);
+ }
+
+ public void setLED(byte x, byte y, byte intensity) {
+
+ }
+
+ public void drawRipple(byte x, byte y, byte intensity) {
+ new Ripple(x, y, intensity);
}
+ class Ripple implements Runnable {
+ double currentWidth;
+ final byte x;
+ final byte y;
+ byte intensity;
+
+ public Ripple(byte x, byte y, byte intensity) {
+ this.x = x;
+ this.y = y;
+ this.intensity = intensity;
+ new Thread(this).start();
+ }
+
+ @Override
+ public void run() {
+ Colour colour;
+ boolean drawnSomething = true;
+
+ while (drawnSomething) {
+
+ if (intensity >= 10) {
+ colour = Colour.Red;
+ } else if (intensity >= 5) {
+ colour = Colour.Yellow;
+ } else {
+ colour = Colour.Green;
+ }
+
+ drawnSomething = false;
+
+ for (double i = 0; i < 360; i++) {
+ int x = x + (int) Math.round(currentWidth * Math.cos(i));
+ int y = y + (int) Math.round(currentWidth * Math.sin(i));
+
+ if (x >= 0 && x <= 8 && y >= 0 && y <= 19) {
+ // setLED(x, y, colour);
+ drawnSomething = true;
+ }
+
+ }
+
+ currentWidth += 0.1 + (currentWidth / 10);
+ try {
+ Thread.sleep(1000/60);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ }
+
+}
+
+void CirclePulsate (int x, int y)
+{
+for ( int i= 0 ; i<= 15 ; i++ ) {
+matrix. Clear ( ) ;
+matrix. DrawEllipse ( AS1107:: Maxx / x , y ,i,i ) ;
+matrix. Update ( ) ;
+delay ( d ) ;
}
diff --git a/PunchingBag/src/PunchingBagGUI.java b/PunchingBag/src/PunchingBagGUI.java
index 1bd1415..180beed 100644
--- a/PunchingBag/src/PunchingBagGUI.java
+++ b/PunchingBag/src/PunchingBagGUI.java
@@ -74,6 +74,7 @@ public class PunchingBagGUI implements MouseListener, MouseMotionListener, Butto
}
class Ripple extends JPanel {
+ // TODO Make this not shit.
final Contact contact;
double currentWidth;