|
|
|
|
|
|
|
|
import java.util.concurrent.Future; |
|
|
import java.util.concurrent.Future; |
|
|
import javax.swing.JComponent; |
|
|
import javax.swing.JComponent; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* |
|
|
* |
|
|
* @author ahren |
|
|
* @author ahren |
|
|
|
|
|
|
|
|
private static final float DICKE = 4f; |
|
|
private static final float DICKE = 4f; |
|
|
private Line2D.Float linie; |
|
|
private Line2D.Float linie; |
|
|
private BasicStroke stift; |
|
|
private BasicStroke stift; |
|
|
private volatile float radius; |
|
|
|
|
|
|
|
|
private volatile double radius; |
|
|
private volatile float xMitte; |
|
|
private volatile float xMitte; |
|
|
private volatile float yMitte; |
|
|
private volatile float yMitte; |
|
|
private volatile double xAussen; |
|
|
private volatile double xAussen; |
|
|
|
|
|
|
|
|
private int zeigerlaenge; |
|
|
private int zeigerlaenge; |
|
|
private ExecutorService eService; |
|
|
private ExecutorService eService; |
|
|
private Future task; |
|
|
private Future task; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public Zeiger(long schlafzeit, int zeigerlaenge) |
|
|
public Zeiger(long schlafzeit, int zeigerlaenge) |
|
|
{ |
|
|
{ |
|
|
this.schlafzeit = schlafzeit; |
|
|
this.schlafzeit = schlafzeit; |
|
|
|
|
|
|
|
|
synchronized(this) |
|
|
synchronized(this) |
|
|
{ |
|
|
{ |
|
|
alpha += 0.1; |
|
|
alpha += 0.1; |
|
|
xAussen = xMitte +cos(2*PI*alpha) * radius; |
|
|
|
|
|
yAussen = yMitte + sin(2*PI*alpha) * radius; |
|
|
|
|
|
} |
|
|
} |
|
|
this.repaint(); |
|
|
this.repaint(); |
|
|
try |
|
|
try |
|
|
|
|
|
|
|
|
{ |
|
|
{ |
|
|
super.paintComponent(g); |
|
|
super.paintComponent(g); |
|
|
Graphics2D g2 = (Graphics2D)g; |
|
|
Graphics2D g2 = (Graphics2D)g; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, |
|
|
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, |
|
|
RenderingHints.VALUE_ANTIALIAS_ON); |
|
|
RenderingHints.VALUE_ANTIALIAS_ON); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
float breite = this.getWidth() - 1; |
|
|
float breite = this.getWidth() - 1; |
|
|
float hoehe = this.getHeight() - 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.setStroke(stift); |
|
|
g2.setPaint(Color.RED); |
|
|
g2.setPaint(Color.RED); |
|
|
g2.draw(linie); |
|
|
g2.draw(linie); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|