diff options
author | unknown <am29567@.open.ac.uk> | 2011-09-02 11:09:46 +0100 |
---|---|---|
committer | unknown <am29567@.open.ac.uk> | 2011-09-02 11:09:46 +0100 |
commit | f5f7d3ca20f102e704f8d0705158ea58a3e4c305 (patch) | |
tree | 06bc7958aff35130a2ae889ea2092c5dd7dda188 | |
parent | 1d7fd079f80ad6b097aae795d74dd19e10b2e14e (diff) | |
download | punchingbag-f5f7d3ca20f102e704f8d0705158ea58a3e4c305.tar punchingbag-f5f7d3ca20f102e704f8d0705158ea58a3e4c305.tar.gz |
Changed stuff. Like things.
-rw-r--r-- | PunchingBag/.classpath | 2 | ||||
-rw-r--r-- | PunchingBag/bin/PunchingBag$Colour.class | bin | 0 -> 1030 bytes | |||
-rw-r--r-- | PunchingBag/bin/PunchingBag$Ripple.class | bin | 0 -> 1157 bytes | |||
-rw-r--r-- | PunchingBag/bin/PunchingBag.class | bin | 755 -> 1804 bytes | |||
-rw-r--r-- | PunchingBag/bin/PunchingBagGUI$Ripple.class | bin | 1614 -> 1618 bytes | |||
-rw-r--r-- | PunchingBag/bin/PunchingBagGUI.class | bin | 3613 -> 3613 bytes | |||
-rw-r--r-- | PunchingBag/src/PunchingBag.java | 99 | ||||
-rw-r--r-- | PunchingBag/src/PunchingBagGUI.java | 1 |
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 Binary files differnew file mode 100644 index 0000000..75ff538 --- /dev/null +++ b/PunchingBag/bin/PunchingBag$Colour.class diff --git a/PunchingBag/bin/PunchingBag$Ripple.class b/PunchingBag/bin/PunchingBag$Ripple.class Binary files differnew file mode 100644 index 0000000..3988003 --- /dev/null +++ b/PunchingBag/bin/PunchingBag$Ripple.class diff --git a/PunchingBag/bin/PunchingBag.class b/PunchingBag/bin/PunchingBag.class Binary files differindex 65f48c7..e8616d9 100644 --- a/PunchingBag/bin/PunchingBag.class +++ b/PunchingBag/bin/PunchingBag.class diff --git a/PunchingBag/bin/PunchingBagGUI$Ripple.class b/PunchingBag/bin/PunchingBagGUI$Ripple.class Binary files differindex b824480..491ecf3 100644 --- a/PunchingBag/bin/PunchingBagGUI$Ripple.class +++ b/PunchingBag/bin/PunchingBagGUI$Ripple.class diff --git a/PunchingBag/bin/PunchingBagGUI.class b/PunchingBag/bin/PunchingBagGUI.class Binary files differindex 362e5e7..fb8d093 100644 --- a/PunchingBag/bin/PunchingBagGUI.class +++ b/PunchingBag/bin/PunchingBagGUI.class 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;
|