import java.awt.geom.*; static AutoCloseable tempGraphicsTransform(final Graphics2D g) { final AffineTransform t = g.getTransform(); ret new AutoCloseable { public void close() { g.setTransform(t); } }; }