Browse Source

Impl mit Translate

TranslateOption
Jens Schuhmann 11 months ago
parent
commit
9f880d55e2

+ 3
- 0
Aufgabe8_Grafik2D/manifest.mf View File

@@ -0,0 +1,3 @@
Manifest-Version: 1.0
X-COMMENT: Main-Class will be added automatically by build


+ 2
- 0
Aufgabe8_Grafik2D/nbproject/private/private.properties View File

@@ -0,0 +1,2 @@
compile.on.save=true
user.properties.file=C:\\Users\\Js-Sc\\AppData\\Roaming\\NetBeans\\19\\build.properties

+ 17
- 18
src/aufgabe8_grafik2d/Zeiger.java View File

@@ -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);
}
}



Loading…
Cancel
Save