Permalink
Browse files

seeking

  • Loading branch information...
else committed Nov 21, 2011
1 parent 0b8858a commit bbb563b3e7804d9a995bb94cd1490f1f16ce33fc
@@ -1,7 +1,5 @@
package de.raumzeitlabor.pr0nwall.ds;
-import java.util.ArrayList;
-import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
@@ -5,7 +5,6 @@
public class LED {
private boolean enabled = false;
- private Shape shape;
public boolean isEnabled() {
return enabled;
@@ -15,19 +14,8 @@ public void setEnabled(boolean enabled) {
this.enabled = enabled;
}
- public void toggleEnabled() {
+ public boolean toggleEnabled() {
this.enabled = !this.enabled;
- }
-
- public boolean hasShape() {
- return shape != null;
- }
-
- public void setShape(Shape s) {
- this.shape = s;
- }
-
- public Shape getShape() {
- return shape;
+ return this.enabled;
}
}
@@ -8,10 +8,12 @@
import javax.swing.JSlider;
import javax.swing.border.CompoundBorder;
import javax.swing.border.EmptyBorder;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
import de.raumzeitlabor.pr0nwall.ds.FrameList;
-public class FrameSeeker extends JSlider implements MouseWheelListener {
+public class FrameSeeker extends JSlider implements MouseWheelListener, ChangeListener {
/**
*
@@ -21,7 +23,7 @@
private LEDPanel panel;
public FrameSeeker(LEDPanel panel) {
- setMajorTickSpacing(5);
+ setMajorTickSpacing(1);
setMinorTickSpacing(1);
setSnapToTicks(true);
setPaintTicks(true);
@@ -35,22 +37,24 @@ public FrameSeeker(LEDPanel panel) {
new EmptyBorder(5, 10, 5, 10)));
addMouseWheelListener(this);
+ addChangeListener(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();
- }
+ panel.seekToFrame(newVal);
+ }
+
+ @Override
+ public void stateChanged(ChangeEvent arg0) {
+ int newVal = getValue();
+ panel.seekToFrame(newVal);
}
}
@@ -1,98 +0,0 @@
-package de.raumzeitlabor.pr0nwall.gui;
-
-import java.awt.BasicStroke;
-import java.awt.Color;
-import java.awt.Cursor;
-import java.awt.Graphics;
-import java.awt.Graphics2D;
-import java.awt.RenderingHints;
-import java.awt.Shape;
-import java.awt.event.MouseEvent;
-import java.awt.event.MouseListener;
-import java.awt.event.MouseMotionListener;
-import java.awt.geom.Ellipse2D;
-
-import javax.swing.JComponent;
-
-public class LED extends JComponent implements MouseListener, MouseMotionListener {
-
- /**
- *
- */
- private static final long serialVersionUID = -5698663633870675134L;
-
- final static BasicStroke stroke = new BasicStroke(2.0f);
-
- private Shape ellipsis;
- private boolean enabled = false;
- private LEDPanel ledpanel;
-
- public LED(LEDPanel parent) {
- ledpanel = parent;
- addMouseListener(this);
- addMouseMotionListener(this);
- }
-
- public void paint(Graphics g) {
- Graphics2D g2 = (Graphics2D) g;
-
- g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
- RenderingHints.VALUE_ANTIALIAS_ON);
-
- int posX = getWidth()/4;
- int posY = getHeight()/4;
-
- int radius = (int) (getWidth()*0.5);
- ellipsis = new Ellipse2D.Double(posX, posY, radius, radius);
-
- if (!enabled) {
- g2.setPaint(new Color(255, 191, 207));
- } else {
- g2.setPaint(Color.RED);
- }
-
- g2.fill(ellipsis);
- g2.setPaint(Color.GRAY);
- g2.draw(ellipsis);
- }
-
- @Override
- public void mouseClicked(MouseEvent e) {}
-
- @Override
- public void mouseEntered(MouseEvent e) {}
-
- @Override
- public void mouseExited(MouseEvent e) {}
-
- @Override
- public void mousePressed(MouseEvent e) {
- ledpanel.mousePressed = true;
-
- if (ellipsis.contains(e.getX(), e.getY())) {
- enabled = !enabled;
- repaint();
- }
- }
-
- @Override
- public void mouseReleased(MouseEvent e) {
- ledpanel.mousePressed = false;
- }
-
- @Override
- public void mouseDragged(MouseEvent e) {}
-
- @Override
- public void mouseMoved(MouseEvent e) {
- if (ellipsis.contains(e.getX(), e.getY())) {
- setCursor(new Cursor(Cursor.HAND_CURSOR));
- } else {
- setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
- }
- }
-
- public boolean isEnabled() {
- return enabled;
- }
-}
Oops, something went wrong.

0 comments on commit bbb563b

Please sign in to comment.