From 50bc843365f65bc6b84a57baa429e32f53fa26e5 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 3 Oct 2013 23:39:43 +0200 Subject: AWTTilePainter: Avoid NPE if Graphic2D's AffineTransform is null, use identity tranform in such case. --- src/jogl/classes/jogamp/opengl/awt/AWTTilePainter.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/jogl/classes/jogamp/opengl/awt/AWTTilePainter.java b/src/jogl/classes/jogamp/opengl/awt/AWTTilePainter.java index 2b921f799..fbf6faf08 100644 --- a/src/jogl/classes/jogamp/opengl/awt/AWTTilePainter.java +++ b/src/jogl/classes/jogamp/opengl/awt/AWTTilePainter.java @@ -88,10 +88,14 @@ public class AWTTilePainter { System.err.println("Hint["+count+"]: "+rEntry.getKey()+" -> "+rEntry.getValue()); } final AffineTransform aTrans = g2d.getTransform(); - System.err.println(" type "+aTrans.getType()); - System.err.println(" scale "+aTrans.getScaleX()+" x "+aTrans.getScaleY()); - System.err.println(" move "+aTrans.getTranslateX()+" x "+aTrans.getTranslateY()); - System.err.println(" mat "+aTrans); + if( null != aTrans ) { + System.err.println(" type "+aTrans.getType()); + System.err.println(" scale "+aTrans.getScaleX()+" x "+aTrans.getScaleY()); + System.err.println(" move "+aTrans.getTranslateX()+" x "+aTrans.getTranslateY()); + System.err.println(" mat "+aTrans); + } else { + System.err.println(" null transform"); + } } /** @@ -188,6 +192,9 @@ public class AWTTilePainter { public void setupGraphics2DAndClipBounds(Graphics2D g2d, int width, int height) throws NoninvertibleTransformException { this.g2d = g2d; saveAT = g2d.getTransform(); + if( null == saveAT ) { + saveAT = new AffineTransform(); // use identity + } // We use double precision for scaling // // Setup original rectangles @@ -201,7 +208,7 @@ public class AWTTilePainter { { final AffineTransform scaledATI; { - final AffineTransform scaledAT = g2d.getTransform(); + final AffineTransform scaledAT = new AffineTransform(saveAT); scaledAT.scale(scaleMatX, scaleMatY); scaledATI = scaledAT.createInverse(); // -> NoninvertibleTransformException } -- cgit v1.2.3