|
|
@@ -11,6 +11,7 @@ import java.awt.Graphics; |
|
|
|
import java.awt.Graphics2D; |
|
|
|
import java.awt.RenderingHints; |
|
|
|
import java.awt.geom.Line2D; |
|
|
|
import static java.lang.Math.*; |
|
|
|
import java.util.concurrent.ExecutorService; |
|
|
|
import java.util.concurrent.Executors; |
|
|
|
import java.util.concurrent.Future; |
|
|
@@ -26,19 +27,23 @@ public class Zeiger extends JComponent implements Runnable |
|
|
|
private Line2D.Float linie; |
|
|
|
private BasicStroke stift; |
|
|
|
private volatile float radius; |
|
|
|
private volatile float minRadius; |
|
|
|
private volatile float maxRadius; |
|
|
|
private volatile float xMitte; |
|
|
|
private volatile float yMitte; |
|
|
|
private volatile double xAussen; |
|
|
|
private volatile double yAussen; |
|
|
|
private volatile double alpha; |
|
|
|
private long schlafzeit; |
|
|
|
private int zeigerlaenge; |
|
|
|
private ExecutorService eService; |
|
|
|
private Future task; |
|
|
|
|
|
|
|
public Zeiger(long schlafzeit) |
|
|
|
public Zeiger(long schlafzeit, int zeigerlaenge) |
|
|
|
{ |
|
|
|
this.schlafzeit = schlafzeit; |
|
|
|
this.zeigerlaenge = zeigerlaenge; |
|
|
|
linie = new Line2D.Float(); |
|
|
|
stift = new BasicStroke(DICKE); |
|
|
|
radius = 100; |
|
|
|
minRadius = DICKE; |
|
|
|
alpha = 0; |
|
|
|
eService = Executors.newSingleThreadExecutor(); |
|
|
|
task = null; |
|
|
|
} |
|
|
@@ -51,9 +56,9 @@ public class Zeiger extends JComponent implements Runnable |
|
|
|
{ |
|
|
|
synchronized(this) |
|
|
|
{ |
|
|
|
if (radius > maxRadius) delta = -1f; |
|
|
|
if (radius < minRadius) delta = +1f; |
|
|
|
radius += delta; |
|
|
|
alpha += 0.1; |
|
|
|
xAussen = xMitte +cos(2*PI*alpha) * radius; |
|
|
|
yAussen = yMitte + sin(2*PI*alpha) * radius; |
|
|
|
} |
|
|
|
this.repaint(); |
|
|
|
try |
|
|
@@ -86,20 +91,18 @@ public class Zeiger extends JComponent implements Runnable |
|
|
|
float breite = this.getWidth() - 1; |
|
|
|
float hoehe = this.getHeight() - 1; |
|
|
|
|
|
|
|
synchronized(this) |
|
|
|
{ |
|
|
|
maxRadius = -DICKE/2 + Math.min(breite, hoehe) / 2; |
|
|
|
} |
|
|
|
|
|
|
|
float radius = (min(hoehe, breite)/2 - 50) * 1/ zeigerlaenge; |
|
|
|
|
|
|
|
float x = breite/2 - radius; |
|
|
|
float y = hoehe/2 - radius; |
|
|
|
xMitte = breite/2; |
|
|
|
yMitte = hoehe/2; |
|
|
|
xAussen = xMitte +cos(2*PI*alpha) * radius; |
|
|
|
yAussen = yMitte + sin(2*PI*alpha) * radius; |
|
|
|
|
|
|
|
linie.setFrame(x, y, 2*radius, 2*radius); |
|
|
|
linie.setLine(xMitte, yMitte, xAussen, yAussen); |
|
|
|
|
|
|
|
g2.setStroke(stift); |
|
|
|
g2.setPaint(Color.RED); |
|
|
|
// g2.fill(ellipse); |
|
|
|
// g2.setPaint(Color.BLACK); |
|
|
|
g2.draw(linie); |
|
|
|
} |
|
|
|
|