|
|
|
|
|
|
|
|
import java.awt.Graphics2D; |
|
|
import java.awt.Graphics2D; |
|
|
import java.awt.RenderingHints; |
|
|
import java.awt.RenderingHints; |
|
|
import java.awt.geom.Line2D; |
|
|
import java.awt.geom.Line2D; |
|
|
|
|
|
import static java.lang.Math.*; |
|
|
import java.util.concurrent.ExecutorService; |
|
|
import java.util.concurrent.ExecutorService; |
|
|
import java.util.concurrent.Executors; |
|
|
import java.util.concurrent.Executors; |
|
|
import java.util.concurrent.Future; |
|
|
import java.util.concurrent.Future; |
|
|
|
|
|
|
|
|
private Line2D.Float linie; |
|
|
private Line2D.Float linie; |
|
|
private BasicStroke stift; |
|
|
private BasicStroke stift; |
|
|
private volatile float radius; |
|
|
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 long schlafzeit; |
|
|
|
|
|
private int zeigerlaenge; |
|
|
private ExecutorService eService; |
|
|
private ExecutorService eService; |
|
|
private Future task; |
|
|
private Future task; |
|
|
|
|
|
|
|
|
public Zeiger(long schlafzeit) |
|
|
|
|
|
|
|
|
public Zeiger(long schlafzeit, int zeigerlaenge) |
|
|
{ |
|
|
{ |
|
|
this.schlafzeit = schlafzeit; |
|
|
this.schlafzeit = schlafzeit; |
|
|
|
|
|
this.zeigerlaenge = zeigerlaenge; |
|
|
linie = new Line2D.Float(); |
|
|
linie = new Line2D.Float(); |
|
|
stift = new BasicStroke(DICKE); |
|
|
stift = new BasicStroke(DICKE); |
|
|
radius = 100; |
|
|
|
|
|
minRadius = DICKE; |
|
|
|
|
|
|
|
|
alpha = 0; |
|
|
eService = Executors.newSingleThreadExecutor(); |
|
|
eService = Executors.newSingleThreadExecutor(); |
|
|
task = null; |
|
|
task = null; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
{ |
|
|
{ |
|
|
synchronized(this) |
|
|
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(); |
|
|
this.repaint(); |
|
|
try |
|
|
try |
|
|
|
|
|
|
|
|
float breite = this.getWidth() - 1; |
|
|
float breite = this.getWidth() - 1; |
|
|
float hoehe = this.getHeight() - 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.setStroke(stift); |
|
|
g2.setPaint(Color.RED); |
|
|
g2.setPaint(Color.RED); |
|
|
// g2.fill(ellipse); |
|
|
|
|
|
// g2.setPaint(Color.BLACK); |
|
|
|
|
|
g2.draw(linie); |
|
|
g2.draw(linie); |
|
|
} |
|
|
} |
|
|
|
|
|
|