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