Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

Why do I get unexpected results when I use the setTransform method of Graphics2D to perform transformations?

0
Posted

Why do I get unexpected results when I use the setTransform method of Graphics2D to perform transformations?

0

Because the setTransform method is not intended for adding new coordinate transformations onto an existing transform. In fact, when you use setTransform, you are overwriting the Graphics2D object’s current transform, which might be needed for other purposes, such as applying a scaling transformation to adjust for printer resolution. The setTransform method should ONLY be used to restore the Graphics2D transform to an earlier saved state after performing some temporarily transformed rendering. To perform transformations, use these steps: • Use getTransform to get the current transform: AffineTransform aT = g2.getTransform(); • Use the transform, translate, scale, shear, or rotate methods to concatenate a transform: g2.transform(…); • Perform the rendering: g2.draw(…); • Restore the original transform using setTransform: g2.setTransform(aT); Related Links Popular Downloads – J2SE 5.0 – J2SE 1.4.

0

Because the setTransform method is not intended for adding new coordinate transformations onto an existing transform. In fact, when you use setTransform, you are overwriting the Graphics2D object’s current transform, which might be needed for other purposes, such as applying a scaling transformation to adjust for printer resolution. The setTransform method should ONLY be used to restore the Graphics2D transform to an earlier saved state after performing some temporarily transformed rendering. To perform transformations, use these steps: • Use getTransform to get the current transform: AffineTransform aT = g2.getTransform(); • Use the transform, translate, scale, shear, or rotate methods to concatenate a transform: g2.transform(…); • Perform the rendering: g2.draw(…); • Restore the original transform using setTransform: g2.setTransform(aT); Related Links Popular Downloads – J2SE 5.0 – J2SE 1.4.2 Products and Technologies – JFC/Swing – SVG and the Java 2D API – Java Advanced Imaging

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123