auto-scaling polygons using affinetransform but maintaining unscaled lenghts



Hi,
I've been tackling this problem for some time and am not having much
luck. I'm hoping someone has some experience with this and can shed
some light.

I have build a shape drawing program where edge lengths correspond to
inches - so the 1 pixel to 1 inch relationship is an important one that
I must be able to "get back to" - however, at times the shape is not
effectively using the most screen real estate.

I'm trying to rescale the thing by:

a. coming up with a scaling factor that will make better use of the
screen (e.g. 1.2 for 120%)
b. apply that scaling factor using an AffineTransform
af.scale(factor,factor)
c. change the individial edges in my shape to reflect the transform by
iterating through a transformed version of the polygon, replacing the
edge coordinates with the coordinates from the transformed polygon.

this works ok, although the lengths dont end up being exactly 120% of
what they were-- a length of 100 might become 118.251535 or some
strange number like that.

But my real challenge is maintaining the original lengths for display
as inches (in spite of the auto-scaling) My latest approach was to
keep a copy of the transform around and use inverseTransform (passing
in the current points and expecting to get modified "unscaled " ones
back, then getting the distance between those returned points.) I
dont get my original lengths back though. they are sometimes close,
sometimes not close.

To further complicate things, the rescale can occur multiple time,
altering the same edge more than one times. To account for this, I
stored all of the transforms in a vector and in my getDistance method
(which converts back to inches) I iterate through each transform,
calling inverseTransform, hoping to arrive back at my original points
by the end.

Maybe it's simply a problem with the way I'm trying to transform the
lengths-- here's what I'm doing:

Point2D a = new Point (new_x, a);
Point2D b = new Point (new_y, b);
AffineTransform at = (AffineTransform) getLastTransform();
a = at.inverseTransform(new_x,a);
b = at.inverseTransform(new_y,b);
double originalDist = getDistance(a,b)

When I instantiate a transform object like that, do I need to "reset"
something after I'm finished to prevent some cumulative transformation?
I was thinking I only had to do that if I was applying the transform
to the current Graphics context.

I'm wondering if there is some easier way to maintain two independent
coordinate systems-- one set that represents the "inches" coordinates,
and another that is scaled and represents what is displayed on the
screen. This would be tricky, as the edges can be dragged, moved,
eleminated, etc.

I would really value any experience or ideas! thanks!
Graham

.