From f5f7d3ca20f102e704f8d0705158ea58a3e4c305 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 2 Sep 2011 11:09:46 +0100 Subject: Changed stuff. Like things. --- PunchingBag/.classpath | 2 +- PunchingBag/bin/PunchingBag$Colour.class | Bin 0 -> 1030 bytes PunchingBag/bin/PunchingBag$Ripple.class | Bin 0 -> 1157 bytes PunchingBag/bin/PunchingBag.class | Bin 755 -> 1804 bytes PunchingBag/bin/PunchingBagGUI$Ripple.class | Bin 1614 -> 1618 bytes PunchingBag/bin/PunchingBagGUI.class | Bin 3613 -> 3613 bytes PunchingBag/src/PunchingBag.java | 99 +++++++++++++++++++++++----- PunchingBag/src/PunchingBagGUI.java | 1 + 8 files changed, 84 insertions(+), 18 deletions(-) create mode 100644 PunchingBag/bin/PunchingBag$Colour.class create mode 100644 PunchingBag/bin/PunchingBag$Ripple.class diff --git a/PunchingBag/.classpath b/PunchingBag/.classpath index 3b45536..4cb0e3c 100644 --- a/PunchingBag/.classpath +++ b/PunchingBag/.classpath @@ -2,6 +2,6 @@ - + diff --git a/PunchingBag/bin/PunchingBag$Colour.class b/PunchingBag/bin/PunchingBag$Colour.class new file mode 100644 index 0000000..75ff538 Binary files /dev/null and b/PunchingBag/bin/PunchingBag$Colour.class differ diff --git a/PunchingBag/bin/PunchingBag$Ripple.class b/PunchingBag/bin/PunchingBag$Ripple.class new file mode 100644 index 0000000..3988003 Binary files /dev/null and b/PunchingBag/bin/PunchingBag$Ripple.class differ diff --git a/PunchingBag/bin/PunchingBag.class b/PunchingBag/bin/PunchingBag.class index 65f48c7..e8616d9 100644 Binary files a/PunchingBag/bin/PunchingBag.class and b/PunchingBag/bin/PunchingBag.class differ diff --git a/PunchingBag/bin/PunchingBagGUI$Ripple.class b/PunchingBag/bin/PunchingBagGUI$Ripple.class index b824480..491ecf3 100644 Binary files a/PunchingBag/bin/PunchingBagGUI$Ripple.class and b/PunchingBag/bin/PunchingBagGUI$Ripple.class differ diff --git a/PunchingBag/bin/PunchingBagGUI.class b/PunchingBag/bin/PunchingBagGUI.class index 362e5e7..fb8d093 100644 Binary files a/PunchingBag/bin/PunchingBagGUI.class and b/PunchingBag/bin/PunchingBagGUI.class 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 ActionListener to the button. - * @param l the ActionListener 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 ActionListener to the button. + * + * @param l + * the ActionListener 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; -- cgit v1.2.3