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 bf73332..c629f30 100644 --- a/core/src/main/java/edu/umd/cs/piccolo/PNode.java +++ b/core/src/main/java/edu/umd/cs/piccolo/PNode.java @@ -2580,8 +2580,7 @@ printJob.print(); } catch (final PrinterException e) { - System.out.println("Error Printing"); - e.printStackTrace(); + throw new RuntimeException("Error Printing", e); } } } diff --git a/core/src/main/java/edu/umd/cs/piccolo/activities/PColorActivity.java b/core/src/main/java/edu/umd/cs/piccolo/activities/PColorActivity.java index e8faf16..6ca1a63 100644 --- a/core/src/main/java/edu/umd/cs/piccolo/activities/PColorActivity.java +++ b/core/src/main/java/edu/umd/cs/piccolo/activities/PColorActivity.java @@ -121,10 +121,10 @@ public void setRelativeTargetValue(final float zeroToOne) { super.setRelativeTargetValue(zeroToOne); - final float red = (source.getRed() + zeroToOne * (destination.getRed() - source.getRed())); - final float green = (source.getGreen() + zeroToOne * (destination.getGreen() - source.getGreen())); - final float blue = (source.getBlue() + zeroToOne * (destination.getBlue() - source.getBlue())); - final float alpha = (source.getAlpha() + zeroToOne * (destination.getAlpha() - source.getAlpha())); + final float red = source.getRed() + zeroToOne * (destination.getRed() - source.getRed()); + final float green = source.getGreen() + zeroToOne * (destination.getGreen() - source.getGreen()); + final float blue = source.getBlue() + zeroToOne * (destination.getBlue() - source.getBlue()); + final float alpha = source.getAlpha() + zeroToOne * (destination.getAlpha() - source.getAlpha()); target.setColor(new Color(red / 255, green / 255, blue / 255, alpha / 255)); } diff --git a/core/src/test/java/edu/umd/cs/piccolo/PCanvasTest.java b/core/src/test/java/edu/umd/cs/piccolo/PCanvasTest.java index baad8ae..16776a8 100644 --- a/core/src/test/java/edu/umd/cs/piccolo/PCanvasTest.java +++ b/core/src/test/java/edu/umd/cs/piccolo/PCanvasTest.java @@ -106,7 +106,7 @@ final PInputEventListener[] listeners = canvas.getInputEventListeners(); assertNotNull(listeners); assertEquals(3, listeners.length); // 3 since pan and zoom are attached - // by default + // by default } public void testRemoveInputEventListenersIsHonoured() { @@ -115,7 +115,7 @@ final PInputEventListener[] listeners = canvas.getInputEventListeners(); assertNotNull(listeners); assertEquals(2, listeners.length); // 3 since pan and zoom are attached - // by default + // by default } public void testMemoryLeak() throws InterruptedException { diff --git a/examples/src/main/java/edu/umd/cs/piccolo/examples/swt/SWTBenchTest.java b/examples/src/main/java/edu/umd/cs/piccolo/examples/swt/SWTBenchTest.java index f59dcfb..b54ca4a 100644 --- a/examples/src/main/java/edu/umd/cs/piccolo/examples/swt/SWTBenchTest.java +++ b/examples/src/main/java/edu/umd/cs/piccolo/examples/swt/SWTBenchTest.java @@ -409,8 +409,7 @@ results = new int[NUM_CONTEXTS][NUM_TESTS]; } catch (final IOException e) { - e.printStackTrace(); - System.exit(1); + throw new RuntimeException(e); } } diff --git a/extras/src/main/java/edu/umd/cs/piccolox/event/PNotificationCenter.java b/extras/src/main/java/edu/umd/cs/piccolox/event/PNotificationCenter.java index a71a6b6..c4c62dc 100644 --- a/extras/src/main/java/edu/umd/cs/piccolox/event/PNotificationCenter.java +++ b/extras/src/main/java/edu/umd/cs/piccolox/event/PNotificationCenter.java @@ -267,7 +267,9 @@ catch (final InvocationTargetException e) { // Since this is how Swing handles Exceptions that get // thrown on listeners, it's probably ok to do it here. - e.printStackTrace(); + // mro: disagree. Now matter how Swing does it, either + // handle or rethrow. + throw new RuntimeException(e); } } } 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 e401fb0..5706b57 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 @@ -412,8 +412,8 @@ } } else { - new Exception("PInputEvent.getSourceSwingEvent was not a MouseEvent. Actual event: " - + sourceSwingEvent + ", class=" + sourceSwingEvent.getClass().getName()).printStackTrace(); + throw new RuntimeException("PInputEvent.getSourceSwingEvent was not a MouseEvent. Actual event: " + + sourceSwingEvent + ", class=" + sourceSwingEvent.getClass().getName()); } } } diff --git a/swt/src/main/java/edu/umd/cs/piccolox/swt/PSWTPath.java b/swt/src/main/java/edu/umd/cs/piccolox/swt/PSWTPath.java index 78e50a8..71ee5de 100644 --- a/swt/src/main/java/edu/umd/cs/piccolox/swt/PSWTPath.java +++ b/swt/src/main/java/edu/umd/cs/piccolox/swt/PSWTPath.java @@ -390,7 +390,8 @@ return new Line2D.Double(l2.getP1(), l2.getP2()); } else { - new Exception().printStackTrace(); + // again: either throw or don't - but nothing in between please. + // new Exception().printStackTrace(); final GeneralPath aPath = new GeneralPath(); aPath.append(aShape, false); return aPath; diff --git a/swt/src/main/java/edu/umd/cs/piccolox/swt/SWTGraphics2D.java b/swt/src/main/java/edu/umd/cs/piccolox/swt/SWTGraphics2D.java index 2ed7147..94d8ce4 100644 --- a/swt/src/main/java/edu/umd/cs/piccolox/swt/SWTGraphics2D.java +++ b/swt/src/main/java/edu/umd/cs/piccolox/swt/SWTGraphics2D.java @@ -121,7 +121,7 @@ SWTShapeManager.transform(aRect, transform.createInverse()); } catch (final Exception e) { - e.printStackTrace(); + throw new RuntimeException(e); } return aRect; } @@ -182,7 +182,7 @@ SWTShapeManager.transform(aRect, transform.createInverse()); } catch (final Exception e) { - e.printStackTrace(); + throw new RuntimeException(e); } return aRect; } @@ -311,7 +311,7 @@ sizeInt = Integer.parseInt(size.substring(size.indexOf("=") + 1, size.length())); } catch (final Exception e) { - e.printStackTrace(); + throw new RuntimeException(e); } cachedFont = new org.eclipse.swt.graphics.Font(device,