diff --git a/core/src/main/java/edu/umd/cs/piccolo/PNode.java b/core/src/main/java/edu/umd/cs/piccolo/PNode.java index 646ae09..6aaadc5 100644 --- a/core/src/main/java/edu/umd/cs/piccolo/PNode.java +++ b/core/src/main/java/edu/umd/cs/piccolo/PNode.java @@ -915,7 +915,11 @@ */ public PAffineTransform getGlobalToLocalTransform(PAffineTransform dest) { dest = getLocalToGlobalTransform(dest); - dest.setTransform(dest.createInverse()); + try { + dest.setTransform(dest.createInverse()); + } catch (NoninvertibleTransformException e) { + throw new PAffineTransformException(e, dest); + } return dest; } @@ -2121,7 +2125,11 @@ return new PAffineTransform(); } - return new PAffineTransform(transform.createInverse()); + try { + return new PAffineTransform(transform.createInverse()); + } catch (NoninvertibleTransformException e) { + throw new PAffineTransformException(e, transform); + } } /** diff --git a/core/src/main/java/edu/umd/cs/piccolo/util/PAffineTransform.java b/core/src/main/java/edu/umd/cs/piccolo/util/PAffineTransform.java index 6d64dc5..35fe133 100644 --- a/core/src/main/java/edu/umd/cs/piccolo/util/PAffineTransform.java +++ b/core/src/main/java/edu/umd/cs/piccolo/util/PAffineTransform.java @@ -333,17 +333,5 @@ } } aRectangle.setRect(minX, minY, maxX - minX, maxY - minY); - } - /** - * Creates an inverse transform of this PAffineTransform - * - * If it's not possible then it throws a PAffineTransformException - */ - public AffineTransform createInverse() { - try { - return super.createInverse(); - } catch (NoninvertibleTransformException e) { - throw new PAffineTransformException(e, this); - } - } + } } diff --git a/core/src/test/java/edu/umd/cs/piccolo/PerformanceTests.java b/core/src/test/java/edu/umd/cs/piccolo/PerformanceTests.java index 6f88723..7d469b6 100644 --- a/core/src/test/java/edu/umd/cs/piccolo/PerformanceTests.java +++ b/core/src/test/java/edu/umd/cs/piccolo/PerformanceTests.java @@ -55,9 +55,9 @@ } public void testRunPerformanceTests() { - if (1==1) + if (1 == 1) return; - + // three times to warm up JVM for (int i = 0; i < 3; i++) { addNodes(); @@ -189,7 +189,7 @@ log.startTest(); // parent.validateFullBounds(); now protected. parent.getFullBoundsReference(); // calls validateFullBounds as a side - // effect. + // effect. log.endTest("Validate Layout after translate " + NUMBER_NODES + " nodes"); log.startTest(); @@ -213,7 +213,7 @@ // parent.validateFullBounds(); // now protected parent.getFullBoundsReference(); // calls validateFullBounds as a side - // effect. + // effect. log.startTest(); for (int i = 0; i < NUMBER_NODES; i++) { @@ -297,18 +297,18 @@ } - public void renderSpeed() { + public void renderSpeed() throws NoninvertibleTransformException { Random r = new Random(); PAffineTransform at = new PAffineTransform(); at.setScale(r.nextFloat()); at.translate(r.nextFloat(), r.nextFloat()); - + log.startTest(); for (int i = 0; i < NUMBER_NODES; i++) { at.createInverse(); } log.endTest("Create inverse transform " + NUMBER_NODES + " times"); - + int height = 400; int width = 400; diff --git a/extras/src/main/java/edu/umd/cs/piccolox/pswing/PSwingEventHandler.java b/extras/src/main/java/edu/umd/cs/piccolox/pswing/PSwingEventHandler.java index 7d19f5d..a4d83e4 100644 --- a/extras/src/main/java/edu/umd/cs/piccolox/pswing/PSwingEventHandler.java +++ b/extras/src/main/java/edu/umd/cs/piccolox/pswing/PSwingEventHandler.java @@ -33,6 +33,7 @@ import edu.umd.cs.piccolo.PNode; import edu.umd.cs.piccolo.event.PInputEvent; import edu.umd.cs.piccolo.event.PInputEventListener; +import edu.umd.cs.piccolo.util.PAffineTransformException; import javax.swing.*; import java.awt.*; @@ -359,7 +360,12 @@ } private void cameraToLocal(PCamera topCamera, Point2D pt, PNode node) { - AffineTransform inverse = topCamera.getViewTransform().createInverse(); + AffineTransform inverse; + try { + inverse = topCamera.getViewTransform().createInverse(); + } catch (NoninvertibleTransformException e) { + throw new PAffineTransformException(e, topCamera.getViewTransform()); + } /* * Only apply the camera's view transform when this node is a descendant