R
Rick
Hi,
I'm drawing a hexagon in the center of a JPanel. I am then drawing
squares on each side of the polygon. To map the edges of the square onto
the sides of the polygon, I am transforming the co-ordinates of the
squares and rotating them so that their sides map onto the sides of the
polygon. When I try doing this in a JFrame where there's only one
JPanel, everything works fine.. however, when I put this JPanel onto one
side of a JSplitpane (or even if I add another JPAnel onto the JFrame),
the transformed squares fall elsewhere, on the left side of the polygon
when they should actually transform and map onto the sides of the polygon.
It seems that the AffineTransform.getRotateInstance() method is taking
the wrong set of co-ordinates. It is taking the center of the "JFrame"
for some reason. Can anyone please help me identify the problem here?
Why isnt AffineTransform.getRotateInstance() not working properly?
Eventhough I'm giving it the same set of co-ordinates I used for drawing
the polygon (in the center of the JPanel - which seems to work fine), it
just won't transform the squares at the right place. If I comment out
the following line where I am setting the transform object:
g2.setTransform(rotate45);
The squares are drawn at the correct co-ordinates, except that they
aren't rotated. How can I fix this? thanks a lot!
Cheers
Rick
I'm drawing a hexagon in the center of a JPanel. I am then drawing
squares on each side of the polygon. To map the edges of the square onto
the sides of the polygon, I am transforming the co-ordinates of the
squares and rotating them so that their sides map onto the sides of the
polygon. When I try doing this in a JFrame where there's only one
JPanel, everything works fine.. however, when I put this JPanel onto one
side of a JSplitpane (or even if I add another JPAnel onto the JFrame),
the transformed squares fall elsewhere, on the left side of the polygon
when they should actually transform and map onto the sides of the polygon.
It seems that the AffineTransform.getRotateInstance() method is taking
the wrong set of co-ordinates. It is taking the center of the "JFrame"
for some reason. Can anyone please help me identify the problem here?
Why isnt AffineTransform.getRotateInstance() not working properly?
Eventhough I'm giving it the same set of co-ordinates I used for drawing
the polygon (in the center of the JPanel - which seems to work fine), it
just won't transform the squares at the right place. If I comment out
the following line where I am setting the transform object:
g2.setTransform(rotate45);
The squares are drawn at the correct co-ordinates, except that they
aren't rotated. How can I fix this? thanks a lot!
Cheers
Rick