Posted by linuxhippy
on October 17, 2008 at 2:21 AM PDT
Is it possible to translate an AffineTransform with untransformed parameters?
What I would like to do is to translate a rotation/shear/whatever AffineTransform with untransformed coordinates:
Graphics2D g2d = (Graphics2D) g;<br />
AffineTransform trx = AffineTransform.getTranslateInstance(200, 200);<br />
trx.rotate(0.5, 200, 200);</p>
<p>g2d.translate(100, 100);<br />
trx.translate(-100, -100); //Trying to compensate the g2d-translation</p>
<p>g2d.drawImage(img, trx, null);<br />
So I would like to move the AffineTransform by untransformed coordinates, in this case e.g. to compensate the 100/100 translate Graphics2D has set.
Of course this does not work, "trx.translate(-100, -100)" is transformed first.
I also tried inverse-transforming -100/-100 first but that didn't work too, also I tried modifying m02/m05 directly but that gave totally weird results.
Is there a correct way of doing this, which also preserves all properties of the AffineTransformation?
Thank you in advance, Clemens
PS: The Graphics2D stuff was just an example, in my real-world use-case I can't simply call g2d.translate(-100,-100) ;)