|
|
@@ -17,6 +17,7 @@ import java.util.concurrent.Executors; |
|
|
|
import java.util.concurrent.Future; |
|
|
|
import javax.swing.JComponent; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* |
|
|
|
* @author ahren |
|
|
@@ -26,7 +27,7 @@ public class Zeiger extends JComponent implements Runnable |
|
|
|
private static final float DICKE = 4f; |
|
|
|
private Line2D.Float linie; |
|
|
|
private BasicStroke stift; |
|
|
|
private volatile float radius; |
|
|
|
private volatile double radius; |
|
|
|
private volatile float xMitte; |
|
|
|
private volatile float yMitte; |
|
|
|
private volatile double xAussen; |
|
|
@@ -36,7 +37,7 @@ public class Zeiger extends JComponent implements Runnable |
|
|
|
private int zeigerlaenge; |
|
|
|
private ExecutorService eService; |
|
|
|
private Future task; |
|
|
|
|
|
|
|
|
|
|
|
public Zeiger(long schlafzeit, int zeigerlaenge) |
|
|
|
{ |
|
|
|
this.schlafzeit = schlafzeit; |
|
|
@@ -57,8 +58,6 @@ public class Zeiger extends JComponent implements Runnable |
|
|
|
synchronized(this) |
|
|
|
{ |
|
|
|
alpha += 0.1; |
|
|
|
xAussen = xMitte +cos(2*PI*alpha) * radius; |
|
|
|
yAussen = yMitte + sin(2*PI*alpha) * radius; |
|
|
|
} |
|
|
|
this.repaint(); |
|
|
|
try |
|
|
@@ -84,28 +83,28 @@ public class Zeiger extends JComponent implements Runnable |
|
|
|
{ |
|
|
|
super.paintComponent(g); |
|
|
|
Graphics2D g2 = (Graphics2D)g; |
|
|
|
|
|
|
|
|
|
|
|
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, |
|
|
|
RenderingHints.VALUE_ANTIALIAS_ON); |
|
|
|
|
|
|
|
|
|
|
|
float breite = this.getWidth() - 1; |
|
|
|
float hoehe = this.getHeight() - 1; |
|
|
|
|
|
|
|
|
|
|
|
float radius = (min(hoehe, breite)/2 - 50) * 1/ zeigerlaenge; |
|
|
|
|
|
|
|
xMitte = breite/2; |
|
|
|
yMitte = hoehe/2; |
|
|
|
xAussen = xMitte +cos(2*PI*alpha) * radius; |
|
|
|
yAussen = yMitte + sin(2*PI*alpha) * radius; |
|
|
|
|
|
|
|
linie.setLine(xMitte, yMitte, xAussen, yAussen); |
|
|
|
|
|
|
|
|
|
|
|
radius = (min(hoehe, breite)/2 * 0.9) * 1/ zeigerlaenge; |
|
|
|
|
|
|
|
g2.translate(breite/2, hoehe/2); |
|
|
|
g2.rotate(alpha); |
|
|
|
|
|
|
|
|
|
|
|
xAussen = radius; |
|
|
|
yAussen = 0; |
|
|
|
|
|
|
|
linie.setLine(0, 0, xAussen, yAussen); |
|
|
|
g2.setStroke(stift); |
|
|
|
g2.setPaint(Color.RED); |
|
|
|
g2.draw(linie); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|