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 / January 2006

Tip: Looking for answers? Try searching our database.

AffineTransform rotated text goes haywire when window focus lost

Thread view: 
Graham Street - 03 Jan 2006 19:08 GMT
Hi,
I am using affinetransform to rotate some text to paint on my
subclassed jpanel.    this looks fine until another window gets focus
and you move something over my window-- at that point the rotated text
(and only the rotated text) loses it's position, and goes to some off
the wall place.   It quickly fixes itself when the window gets focus
again.

I'm not sure why this is happening- i'm using affinetransform on some
images and this doesnt happen- only on the text.      One difference
though is that with the text, im using at.InverseTransform to get the
point where I am drawing the text- this wasn't necessary when I was
drawing images.

for example, my code of the text looks like this (below) - if anyone
has any ideas I would greatly appreciate them.  Thanks,  Graham

int[] label_location = line.getMidpoint(); // (returns x,y of desired
label position)
java.awt.geom.AffineTransform at = new java.awt.geom.AffineTransform();
java.awt.geom.Point2D P=null;
java.awt.geom.Point2D newP = null;
newP = new java.awt.Point(label_location[0],label_location[1]);

P = new java.awt.Point(label_location[0],label_location[1]);

at.rotate(Math.toRadians(90));
try{
                   at.inverseTransform(P,newP);
                  g2D.setTransform(at);
                  g2D.drawString("string",
(int)newP.getX(),(int)newP.getY());
} catch (Exception r){
                   r.printStackTrace();
}
Andrey Kuznetsov - 06 Jan 2006 10:22 GMT
> for example, my code of the text looks like this (below) - if anyone
> has any ideas I would greatly appreciate them.  Thanks,  Graham
[quoted text clipped - 17 lines]
>                    r.printStackTrace();
> }

please post SSCCE or at least complete code of paintComponent()

Signature

Andrey Kuznetsov
http://uio.imagero.com Unified I/O for Java
http://reader.imagero.com Java image reader
http://jgui.imagero.com Java GUI components and utilities



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.