Why do I get unexpected results when I use the setTransform method of Graphics2D to perform transformations?
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.
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
- When doing a gingival graft, do you get better results when using the patients own tissue or cadaver tissue? Which method do you use on a regular basis?
- How do I perform model-fit analysis in order to assure that my projection results are accurately reflecting my actual experience?
- Why do I get unexpected results when I use the setTransform method of Graphics2D to perform transformations?