Permalink
Browse files

click handling, dragging, seeking

  • Loading branch information...
1 parent 263fb35 commit 0b8858a5f20fd20feb919579a1914998653c71e0 @else else committed Nov 20, 2011
@@ -0,0 +1,21 @@
+package de.raumzeitlabor.pr0nwall.ds;
+
+import java.util.ArrayList;
+
+
+public class Frame {
+ private ArrayList<LED> leds;
+
+ public Frame(int dots) {
+ leds = new ArrayList<LED>(dots);
+
+ for (int i = 0; i < dots; i++) {
+ leds.add(new LED());
+ }
+ }
+
+ public ArrayList<LED> getLEDs() {
+ return leds;
+ }
+
+}
@@ -0,0 +1,44 @@
+package de.raumzeitlabor.pr0nwall.ds;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.LinkedList;
+import java.util.List;
+
+public class FrameList {
+ private final int dots;
+ private final LinkedList<Frame> framelist;
+
+ public FrameList(int dots) {
+ this(dots, 1);
+ }
+
+ public FrameList(int dots, int frames) {
+ this.dots = dots;
+
+ framelist = new LinkedList<Frame>();
+ for (int i = 0; i < frames; i++) {
+ framelist.add(new Frame(dots));
+ }
+ }
+
+ public int getDots() {
+ return dots;
+ }
+
+ public List<Frame> getFrames() {
+ return framelist;
+ }
+
+ public void addFrame() {
+ framelist.add(new Frame(dots));
+ }
+
+ public void addFrame(int pos) {
+ framelist.add(pos - 1, new Frame(dots));
+ }
+
+ public void deleteFrame(int i) {
+ framelist.remove(i);
+ }
+}
@@ -0,0 +1,33 @@
+package de.raumzeitlabor.pr0nwall.ds;
+
+import java.awt.Shape;
+
+
+public class LED {
+ private boolean enabled = false;
+ private Shape shape;
+
+ public boolean isEnabled() {
+ return enabled;
+ }
+
+ public void setEnabled(boolean enabled) {
+ this.enabled = enabled;
+ }
+
+ public void toggleEnabled() {
+ this.enabled = !this.enabled;
+ }
+
+ public boolean hasShape() {
+ return shape != null;
+ }
+
+ public void setShape(Shape s) {
+ this.shape = s;
+ }
+
+ public Shape getShape() {
+ return shape;
+ }
+}
@@ -1,36 +1,56 @@
package de.raumzeitlabor.pr0nwall.gui;
import java.awt.Color;
-import java.awt.Frame;
-import java.util.ArrayList;
+import java.awt.event.MouseWheelEvent;
+import java.awt.event.MouseWheelListener;
import javax.swing.BorderFactory;
import javax.swing.JSlider;
import javax.swing.border.CompoundBorder;
import javax.swing.border.EmptyBorder;
-public class FrameSeeker extends JSlider {
+import de.raumzeitlabor.pr0nwall.ds.FrameList;
+
+public class FrameSeeker extends JSlider implements MouseWheelListener {
/**
*
*/
private static final long serialVersionUID = 3975074419073256219L;
- private ArrayList<Frame> framelist = null;
+ private LEDPanel panel;
- public FrameSeeker(ArrayList<Frame> framelist) {
+ public FrameSeeker(LEDPanel panel) {
setMajorTickSpacing(5);
setMinorTickSpacing(1);
setSnapToTicks(true);
setPaintTicks(true);
-// setPaintLabels(true);
+ setPaintLabels(true);
setMinimum(1);
- setMaximum(framelist.size());
+ setValue(1);
+ setMaximum(panel.getNumberOfFrames());
setBackground(Color.WHITE);
setBorder(new CompoundBorder(BorderFactory.createMatteBorder(
0, 0, 0, 1, Color.gray),
new EmptyBorder(5, 10, 5, 10)));
- this.framelist = framelist;
+ addMouseWheelListener(this);
+
+ this.panel = panel;
+ }
+
+ public void refresh() {
+ setValue(panel.getCurrentFrameNumber());
+ setMaximum(panel.getNumberOfFrames());
+ }
+
+ @Override
+ public void mouseWheelMoved(MouseWheelEvent e) {
+ int newVal = getValue() + e.getWheelRotation();
+
+ if (newVal >= 1 && newVal <= panel.getNumberOfFrames()) {
+ panel.seekToFrame(newVal);
+ refresh();
+ }
}
}
Oops, something went wrong.

0 comments on commit 0b8858a

Please sign in to comment.