From 55e4f4dfdc5b111187401cb61fb4853aaf29e2bc Mon Sep 17 00:00:00 2001 From: Holt59 Date: Wed, 28 Feb 2018 23:03:02 +0100 Subject: [PATCH] Set default transform to ZoomAndPanListener to avoid bunch of exceptions. --- src/main/org/insa/graphics/drawing/BasicDrawing.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/org/insa/graphics/drawing/BasicDrawing.java b/src/main/org/insa/graphics/drawing/BasicDrawing.java index 889c79e..ac55f29 100644 --- a/src/main/org/insa/graphics/drawing/BasicDrawing.java +++ b/src/main/org/insa/graphics/drawing/BasicDrawing.java @@ -8,6 +8,7 @@ import java.awt.Image; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; +import java.awt.geom.AffineTransform; import java.awt.geom.NoninvertibleTransformException; import java.awt.geom.Point2D; import java.awt.image.BufferedImage; @@ -288,6 +289,9 @@ public class BasicDrawing extends JPanel implements Drawing { this.addMouseListener(zoomAndPanListener); this.addMouseMotionListener(zoomAndPanListener); this.addMouseWheelListener(zoomAndPanListener); + + // Avoid bunch of NullPointerException + this.zoomAndPanListener.setCoordTransform(new AffineTransform()); } @Override