I have a set of Java2D calls that draw vectors in a graphical context. I would like the image to be doubled in size and then rotated 90 degrees.
I am using the following code for this:
Graphics2D g2 =
AffineTransform oldTransform = g2.getTransform();
AffineTransform newTransform = (AffineTransform)oldTransform.clone();
newTransform.concatenate(AffineTransform.getTranslateInstance(x1, x2));
newTransform.concatenate(AffineTransform.getScaleInstance((double)newW/(double)iconW, (double)newH/(double)iconH));
newTransform.concatenate(AffineTransform.getRotateInstance(Math.toRadians(rotationAngle), (double)iconW/2.0d, (double)iconH/2.0d));
It rotates and scales, but the scale does not apply as we would like. It looks like it rotates before scaling, thereby making the image wider on the wrong axis.
Is there a better way to do this?
source
share