Hi, I'm using affineTransform to rescale a polygon to fit in the
screens area. If the shape is 25% smaller than the drawing area, then
the shape is increased by 25%. Each side of the shapes length in
inches is initially the same as the length of the side in pixels.
I need the lengths to stay the same when I re-scale the polygon... To
acheive this, I'm storing the "factor" that I'm supplying to
AffineTransform... Then, in my getLength() method I divide by this
same number to "reverse" the transform and get the real edge length.
Sometimes it works great (less than half) but usually it is off. It's
usually off by less than 1, but occasionally by some huge amount like
30%.
I was thinking this was a casting problem, but it seems to be something
a little trickier. It seems that the affineTransform scale is actually
not using the same scaling factor all the time.. Does anyone knw
what variables might throw this off and how I might be able to control
it?
Thanks!
Graham Street
Knute Johnson - 29 Dec 2005 04:03 GMT
> Hi, I'm using affineTransform to rescale a polygon to fit in the
> screens area. If the shape is 25% smaller than the drawing area, then
[quoted text clipped - 17 lines]
> Thanks!
> Graham Street
Does it appear to change as you run your program? Is it possible that
you aren't resetting the transform back to the original when you are
done and you are transforming the transform?
public void paint(Graphics g) {
AffineTransform at = g.getTransform();
g.scale(x,y);
g.draw(something);
g.setTransform(at);

Signature
Knute Johnson
email s/nospam/knute/