Hi
I want to have something like a speedometer. I draw it with Java2D
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| Graphics2D g2d = ( Graphics2D ) new Graphics; GeneralPath filledPolygon = new GeneralPath();
filledPolygon.moveTo( x, yo1 ); filledPolygon.lineTo( x, yu1 ); filledPolygon.lineTo( x1, yu1 ); filledPolygon.lineTo( x1, yu2 ); filledPolygon.lineTo( x2, y ); filledPolygon.lineTo( x1, yo2 ); filledPolygon.lineTo( x1, yo1 ); filledPolygon.lineTo( x, yo1 );
AffineTransform af = new AffineTransform(); af.translate(676, 75); af.rotate( Math.PI ); af.scale(0.5, 0.6);
filledPolygon.transform(af);
g2d.setPaint( Color.white ); g2d.fill( filledPolygon ); |
If I have now an event, then I want to change to position of "filledPolygon". How can I do that?
I found out, that i can translate the Graphics2D-Object, but this does not affect on my already created "filledPolygon" !
Any ideas?
Thanks, Flavio