Impl mit Translate
This commit is contained in:
parent
53c8ddabb9
commit
9f880d55e2
3
Aufgabe8_Grafik2D/manifest.mf
Normal file
3
Aufgabe8_Grafik2D/manifest.mf
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
Manifest-Version: 1.0
|
||||||
|
X-COMMENT: Main-Class will be added automatically by build
|
||||||
|
|
2
Aufgabe8_Grafik2D/nbproject/private/private.properties
Normal file
2
Aufgabe8_Grafik2D/nbproject/private/private.properties
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
compile.on.save=true
|
||||||
|
user.properties.file=C:\\Users\\Js-Sc\\AppData\\Roaming\\NetBeans\\19\\build.properties
|
@ -17,6 +17,7 @@ import java.util.concurrent.Executors;
|
|||||||
import java.util.concurrent.Future;
|
import java.util.concurrent.Future;
|
||||||
import javax.swing.JComponent;
|
import javax.swing.JComponent;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author ahren
|
* @author ahren
|
||||||
@ -26,7 +27,7 @@ public class Zeiger extends JComponent implements Runnable
|
|||||||
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;
|
||||||
@ -36,7 +37,7 @@ public class Zeiger extends JComponent implements Runnable
|
|||||||
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;
|
||||||
@ -57,8 +58,6 @@ public class Zeiger extends JComponent implements Runnable
|
|||||||
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
|
||||||
@ -84,28 +83,28 @@ public class Zeiger extends JComponent implements Runnable
|
|||||||
{
|
{
|
||||||
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;
|
radius = (min(hoehe, breite)/2 * 0.9) * 1/ zeigerlaenge;
|
||||||
|
|
||||||
xMitte = breite/2;
|
g2.translate(breite/2, hoehe/2);
|
||||||
yMitte = hoehe/2;
|
g2.rotate(alpha);
|
||||||
xAussen = xMitte +cos(2*PI*alpha) * radius;
|
|
||||||
yAussen = yMitte + sin(2*PI*alpha) * radius;
|
|
||||||
|
xAussen = radius;
|
||||||
linie.setLine(xMitte, yMitte, xAussen, yAussen);
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user