aboutsummaryrefslogtreecommitdiff
path: root/PunchingBag/src/PunchingBag.java
diff options
context:
space:
mode:
authorunknown <am29567@.open.ac.uk>2011-09-02 11:09:46 +0100
committerunknown <am29567@.open.ac.uk>2011-09-02 11:09:46 +0100
commitf5f7d3ca20f102e704f8d0705158ea58a3e4c305 (patch)
tree06bc7958aff35130a2ae889ea2092c5dd7dda188 /PunchingBag/src/PunchingBag.java
parent1d7fd079f80ad6b097aae795d74dd19e10b2e14e (diff)
downloadpunchingbag-f5f7d3ca20f102e704f8d0705158ea58a3e4c305.tar
punchingbag-f5f7d3ca20f102e704f8d0705158ea58a3e4c305.tar.gz
Changed stuff. Like things.
Diffstat (limited to 'PunchingBag/src/PunchingBag.java')
-rw-r--r--PunchingBag/src/PunchingBag.java99
1 files changed, 82 insertions, 17 deletions
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 ) ;
}