rotating a polygon?

From: Chuck (farviewFILTER_at_earthlink.net)
Date: 11/04/03


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



Relevant Pages

  • Re: screen flipped SIDEWAYS when I hit a wrong combination of bu
    ... I used to know how to rotate the screen but had forgotten, ... But ctrl alt and arrow don't do anything as far as I can tell, ... even some employees at a college I work for. ...
    (microsoft.public.windowsxp.general)
  • Re: Draw a scaled arrow
    ... the normal concatenation of operations in AffineTransorm applies the transformations in reverse order. ... In the example below, each arrow is rotated about its tip, then scaled, then translated to its destination. ... Suppose you wanted to rotate each arrow about its center. ... Test AffineTransform ...
    (comp.lang.java.programmer)
  • Dynamic AutoShape
    ... flow data in a row. ... If B is greater than A, so Right Arrow could be rotate 315 degree. ... Mut ...
    (microsoft.public.excel.programming)
  • Rotation Of Bitmap
    ... I'm making a compass and need to rotate the arrow. ... rotation algorithms on Google so reformatted it as a 256 Color Bitmap. ... spoils it with this large pixelated arrow in the corner. ...
    (comp.lang.basic.visual.misc)