|
|
|
|
|
|
|
|
|
|
|
|
|
|
package grafik; |
|
|
package grafik; |
|
|
|
|
|
|
|
|
|
|
|
import grafik.logger.OhmLogger; |
|
|
import java.awt.BasicStroke; |
|
|
import java.awt.BasicStroke; |
|
|
import java.awt.Color; |
|
|
import java.awt.Color; |
|
|
import java.awt.Graphics; |
|
|
import java.awt.Graphics; |
|
|
import java.awt.Graphics2D; |
|
|
import java.awt.Graphics2D; |
|
|
import java.awt.RenderingHints; |
|
|
import java.awt.RenderingHints; |
|
|
|
|
|
import java.awt.geom.AffineTransform; |
|
|
import java.awt.geom.Ellipse2D; |
|
|
import java.awt.geom.Ellipse2D; |
|
|
import java.awt.geom.Line2D; |
|
|
import java.awt.geom.Line2D; |
|
|
import java.util.logging.Logger; |
|
|
import java.util.logging.Logger; |
|
|
|
|
|
|
|
|
private Thread thd; |
|
|
private Thread thd; |
|
|
private long sleepTime; |
|
|
private long sleepTime; |
|
|
private static final float DICKE = 8f; |
|
|
private static final float DICKE = 8f; |
|
|
private static Logger lg = Logger.getLogger("grafik"); |
|
|
|
|
|
|
|
|
private static Logger lg = OhmLogger.getLogger(); |
|
|
|
|
|
|
|
|
|
|
|
private float x1, x2, y1, y2; |
|
|
|
|
|
|
|
|
public Gerade(long sleepTime) |
|
|
public Gerade(long sleepTime) |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
radius = 100; |
|
|
radius = 100; |
|
|
pinsel = new BasicStroke(DICKE); |
|
|
pinsel = new BasicStroke(DICKE); |
|
|
thd = null; |
|
|
thd = null; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
start(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public void start() |
|
|
public void start() |
|
|
{ |
|
|
{ |
|
|
if (thd == null) |
|
|
if (thd == null) |
|
|
{ |
|
|
{ |
|
|
|
|
|
lg.info("start"); |
|
|
thd = new Thread(this); |
|
|
thd = new Thread(this); |
|
|
thd.start(); |
|
|
thd.start(); |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int breite = this.getWidth() - 1; |
|
|
int breite = this.getWidth() - 1; |
|
|
int hoehe = this.getHeight() - 1; |
|
|
int hoehe = this.getHeight() - 1; |
|
|
|
|
|
|
|
|
float x1 = breite/2f; |
|
|
|
|
|
float y1 = hoehe/2f; |
|
|
|
|
|
|
|
|
|
|
|
float x2 = (float) Math.sin(angle); |
|
|
|
|
|
float y2 = 2; |
|
|
|
|
|
|
|
|
x1 = breite/2f; |
|
|
|
|
|
y1 = hoehe/2f; |
|
|
|
|
|
|
|
|
|
|
|
/** Rotate with Angle, sin and cos */ |
|
|
|
|
|
// x2 = (float) (radius * Math.cos((2 * Math.PI * angle) / 360) + x1); |
|
|
|
|
|
// y2 = (float) (radius * Math.sin((2 * Math.PI * angle) / 360) + y1); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
line.setLine(x1, y1, x2, y2); |
|
|
line.setLine(x1, y1, x2, y2); |
|
|
|
|
|
/** Rotate with transforms */ |
|
|
|
|
|
|
|
|
|
|
|
g2.translate(x1, y1); |
|
|
|
|
|
g2.rotate(Math.toRadians(angle)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
g2.setStroke(pinsel); |
|
|
g2.setStroke(pinsel); |
|
|
g2.setPaint(Color.RED); |
|
|
g2.setPaint(Color.RED); |