rotating a polygon?
From: Chuck (farviewFILTER_at_earthlink.net)
Date: 11/04/03
- Next message: Stewart Gordon: "Re: Increasing the stack?"
- Previous message: Jonas Kongslund: "Re: DateFormat problem"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 4 Nov 2003 08:47:37 -0700
Hi - self studying Java here so I'm in a bit of a vacuum with limited books.
Having trouble understanding Affine Transform.
The following simple snippet plots a line on a chart. Polygon "a" in the
shape of an arrow pointing up (north) is translated along the datapoints an
appended to a General Path "arrow".
When they are drawn there is a north arrow at each apex of the line.
I want to rotate the arrow at each apex to indicate a direction. I have had
no success doing this.
There is no rotate method for Shapes I guess. I could translate and rotate
the original coords each time and create a new polygon arrow I guess, but
there must be an easier way.
Can someone help? Thanks - Chuck
public void paint( Graphics g )
{
super.paint( g );
Graphics2D g2 = (Graphics2D) g;
line.moveTo(BASEX, BASEY - yData[0]);
a.translate(BASEX, BASEY - yData[0]);
arrow.append(a,false);
for(int i = 1; i < yData.length; i++){
line.lineTo(BASEX+i*25, BASEY - yData[i]);
a.translate(25, -yData[i] + yData[i-1]);
arrow.append(a,false);
}
g2.draw(line);
g2.draw(arrow);
}
- Next message: Stewart Gordon: "Re: Increasing the stack?"
- Previous message: Jonas Kongslund: "Re: DateFormat problem"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|