Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / December 2005

Tip: Looking for answers? Try searching our database.

rescale using affineTransform, but scaling factor isn't quite honored?

Thread view: 
Graham Street - 28 Dec 2005 23:09 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
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/



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.