diff --git a/core/src/main/java/edu/umd/cs/piccolo/PCamera.java b/core/src/main/java/edu/umd/cs/piccolo/PCamera.java
index 4f8feb9..eeda20c 100644
--- a/core/src/main/java/edu/umd/cs/piccolo/PCamera.java
+++ b/core/src/main/java/edu/umd/cs/piccolo/PCamera.java
@@ -176,7 +176,8 @@
public void repaintFromLayer(final PBounds viewBounds, final PNode repaintedLayer) {
if (repaintedLayer instanceof PLayer) {
this.repaintFromLayer(viewBounds, (PLayer) repaintedLayer);
- } else {
+ }
+ else {
throw new RuntimeException("Passed non PLayer node to repaintFromLayer");
}
}
diff --git a/core/src/main/java/edu/umd/cs/piccolo/activities/PTransformActivity.java b/core/src/main/java/edu/umd/cs/piccolo/activities/PTransformActivity.java
index 14cae38..af27386 100644
--- a/core/src/main/java/edu/umd/cs/piccolo/activities/PTransformActivity.java
+++ b/core/src/main/java/edu/umd/cs/piccolo/activities/PTransformActivity.java
@@ -31,7 +31,6 @@
import java.awt.geom.AffineTransform;
import edu.umd.cs.piccolo.util.PAffineTransform;
-import edu.umd.cs.piccolo.util.PUtil;
/**
* PTransformActivity interpolates between two transforms setting its
@@ -112,7 +111,12 @@
* target when the transform activity stops stepping.
*/
public double[] getDestinationTransform() {
- return (destination == null) ? null : (double[]) destination.clone();
+ if (destination == null) {
+ return null;
+ }
+ else {
+ return (double[]) destination.clone();
+ }
}
/**
@@ -120,7 +124,12 @@
* target when the transform activity stops stepping.
*/
public void setDestinationTransform(final double[] newDestination) {
- destination = (newDestination == null) ? null : (double[]) newDestination.clone();
+ if (newDestination == null) {
+ destination = null;
+ }
+ else {
+ destination = (double[]) newDestination.clone();
+ }
}
protected void activityStarted() {
diff --git a/extras/src/main/java/edu/umd/cs/piccolox/PFrame.java b/extras/src/main/java/edu/umd/cs/piccolox/PFrame.java
index 15b3ae9..f2379bd 100644
--- a/extras/src/main/java/edu/umd/cs/piccolox/PFrame.java
+++ b/extras/src/main/java/edu/umd/cs/piccolox/PFrame.java
@@ -57,9 +57,6 @@
*/
public class PFrame extends JFrame {
- /**
- *
- */
private static final long serialVersionUID = 1L;
private PCanvas canvas;
private final GraphicsDevice graphicsDevice;
@@ -85,7 +82,8 @@
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
catch (final SecurityException e) {
- } // expected from applets
+ // expected from applets
+ }
if (aCanvas == null) {
canvas = new PCanvas();
diff --git a/extras/src/main/java/edu/umd/cs/piccolox/POffscreenCanvas.java b/extras/src/main/java/edu/umd/cs/piccolox/POffscreenCanvas.java
index 17d5e89..2f86323 100755
--- a/extras/src/main/java/edu/umd/cs/piccolox/POffscreenCanvas.java
+++ b/extras/src/main/java/edu/umd/cs/piccolox/POffscreenCanvas.java
@@ -143,27 +143,27 @@
}
/** {@inheritDoc} */
- public final void paintImmediately() {
+ public void paintImmediately() {
// empty
}
/** {@inheritDoc} */
- public final void popCursor() {
+ public void popCursor() {
// empty
}
/** {@inheritDoc} */
- public final void pushCursor(final Cursor cursor) {
+ public void pushCursor(final Cursor cursor) {
// empty
}
/** {@inheritDoc} */
- public final void repaint(final PBounds repaintBounds) {
+ public void repaint(final PBounds repaintBounds) {
// empty
}
/** {@inheritDoc} */
- public final void setInteracting(final boolean interacting) {
+ public void setInteracting(final boolean interacting) {
// empty
}
}
\ No newline at end of file
diff --git a/extras/src/main/java/edu/umd/cs/piccolox/nodes/PStyledText.java b/extras/src/main/java/edu/umd/cs/piccolox/nodes/PStyledText.java
index 9152099..007dd13 100644
--- a/extras/src/main/java/edu/umd/cs/piccolox/nodes/PStyledText.java
+++ b/extras/src/main/java/edu/umd/cs/piccolox/nodes/PStyledText.java
@@ -324,7 +324,7 @@
// is a newline
boolean lastNewLine = true;
- for (int i = 0; tokenizer.hasMoreTokens(); i++) {
+ while (tokenizer.hasMoreTokens()) {
final String token = tokenizer.nextToken();
// If the token
diff --git a/extras/src/main/java/edu/umd/cs/piccolox/swing/PViewport.java b/extras/src/main/java/edu/umd/cs/piccolox/swing/PViewport.java
index f67e7cb..a510b4d 100644
--- a/extras/src/main/java/edu/umd/cs/piccolox/swing/PViewport.java
+++ b/extras/src/main/java/edu/umd/cs/piccolox/swing/PViewport.java
@@ -49,10 +49,6 @@
* @author Lance Good
*/
public class PViewport extends JViewport {
-
- /**
- *
- */
private static final long serialVersionUID = 1L;
/**
* Controls what happens when scrolling occurs
@@ -203,20 +199,9 @@
}
/**
- * Notifies all ChangeListeners
when the views size, position,
- * or the viewports extent size has changed.
- */
- public void fireStateChanged() {
- super.fireStateChanged();
- }
-
- /**
* A simple layout manager to give the ZCanvas the same size as the Viewport
*/
public static class PViewportLayout extends ViewportLayout {
- /**
- *
- */
private static final long serialVersionUID = 1L;
/**
diff --git a/extras/src/main/java/edu/umd/cs/piccolox/util/PFixedWidthStroke.java b/extras/src/main/java/edu/umd/cs/piccolox/util/PFixedWidthStroke.java
index 119e89e..f04f33d 100644
--- a/extras/src/main/java/edu/umd/cs/piccolox/util/PFixedWidthStroke.java
+++ b/extras/src/main/java/edu/umd/cs/piccolox/util/PFixedWidthStroke.java
@@ -59,17 +59,9 @@
* @author Jesse Grosjean
* @author Marcus Rohrmoser
*/
-public class PFixedWidthStroke extends PSemanticStroke implements Serializable {
+public class PFixedWidthStroke extends PSemanticStroke implements Serializable {
- // make them public if required or delete when cleaning up for 2.0
- private static final int CAP_BUTT = BasicStroke.CAP_BUTT;
- private static final int CAP_ROUND = BasicStroke.CAP_ROUND;
- private static final int CAP_SQUARE = BasicStroke.CAP_SQUARE;
- private static final int JOIN_BEVEL = BasicStroke.JOIN_BEVEL;
- private static final int JOIN_MITER = BasicStroke.JOIN_MITER;
- private static final int JOIN_ROUND = BasicStroke.JOIN_ROUND;
-
- private static final long serialVersionUID = -2503357070350473610L;
+ private static final long serialVersionUID = 1L;
// avoid repeated cloning:
private transient final float dash[];
diff --git a/extras/src/main/java/edu/umd/cs/piccolox/util/POcclusionDetection.java b/extras/src/main/java/edu/umd/cs/piccolox/util/POcclusionDetection.java
index 4ce89af..f6de65d 100644
--- a/extras/src/main/java/edu/umd/cs/piccolox/util/POcclusionDetection.java
+++ b/extras/src/main/java/edu/umd/cs/piccolox/util/POcclusionDetection.java
@@ -49,37 +49,38 @@
detectOcclusions(n, new PPickPath(null, parentBounds));
}
- public void detectOcclusions(final PNode n, final PPickPath pickPath) {
- if (n.fullIntersects(pickPath.getPickBounds())) {
- pickPath.pushTransform(n.getTransformReference(false));
-
- final int count = n.getChildrenCount();
- for (int i = count - 1; i >= 0; i--) {
- final PNode each = n.getChild(i);
- if (n.getOccluded()) {
- // if n has been occuded by a previous decendent then
- // this child must also be occuded
- each.setOccluded(true);
- }
- else {
- // see if child each occludes n
- detectOcclusions(each, pickPath);
- }
- }
-
- // see if n occudes it's parents
- if (!n.getOccluded()) {
- if (n.intersects(pickPath.getPickBounds())) {
- if (n.isOpaque(pickPath.getPickBounds())) {
- final PNode p = n.getParent();
- while (p != null && !p.getOccluded()) {
- p.setOccluded(true);
- }
- }
- }
- }
-
- pickPath.popTransform(n.getTransformReference(false));
+ public void detectOcclusions(final PNode node, final PPickPath pickPath) {
+ if (!node.fullIntersects(pickPath.getPickBounds())) {
+ return;
}
+
+ pickPath.pushTransform(node.getTransformReference(false));
+
+ final int count = node.getChildrenCount();
+ for (int i = count - 1; i >= 0; i--) {
+ final PNode each = node.getChild(i);
+ if (node.getOccluded()) {
+ // if n has been occuded by a previous decendent then
+ // this child must also be occuded
+ each.setOccluded(true);
+ }
+ else {
+ // see if child each occludes n
+ detectOcclusions(each, pickPath);
+ }
+ }
+
+ if (nodeOccludesParents(node, pickPath)) {
+ final PNode parent = node.getParent();
+ while (parent != null && !parent.getOccluded()) {
+ parent.setOccluded(true);
+ }
+ }
+
+ pickPath.popTransform(node.getTransformReference(false));
+ }
+
+ private boolean nodeOccludesParents(final PNode n, final PPickPath pickPath) {
+ return !n.getOccluded() && n.intersects(pickPath.getPickBounds()) && n.isOpaque(pickPath.getPickBounds());
}
}
diff --git a/swt/src/main/java/edu/umd/cs/piccolox/swt/PSWTBoundsHandle.java b/swt/src/main/java/edu/umd/cs/piccolox/swt/PSWTBoundsHandle.java
index f677741..c91f212 100644
--- a/swt/src/main/java/edu/umd/cs/piccolox/swt/PSWTBoundsHandle.java
+++ b/swt/src/main/java/edu/umd/cs/piccolox/swt/PSWTBoundsHandle.java
@@ -116,14 +116,17 @@
public void mouseExited(final PInputEvent aEvent) {
final PPickPath focus = aEvent.getInputManager().getMouseFocus();
- if (cursorPushed) {
- if (focus == null || focus.getPickedNode() != PSWTBoundsHandle.this) {
- aEvent.popCursor();
- cursorPushed = false;
- }
+
+ if (cursorPushed && isNewFocus(focus)) {
+ aEvent.popCursor();
+ cursorPushed = false;
}
}
+ private boolean isNewFocus(final PPickPath focus) {
+ return (focus == null || focus.getPickedNode() != PSWTBoundsHandle.this);
+ }
+
public void mouseReleased(final PInputEvent event) {
if (cursorPushed) {
event.popCursor();
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 cee6c1b..3f657d1 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
@@ -44,6 +44,7 @@
import edu.umd.cs.piccolo.PNode;
import edu.umd.cs.piccolo.nodes.PPath;
import edu.umd.cs.piccolo.util.PAffineTransform;
+import edu.umd.cs.piccolo.util.PAffineTransformException;
import edu.umd.cs.piccolo.util.PBounds;
import edu.umd.cs.piccolo.util.PPaintContext;
@@ -196,6 +197,7 @@
inverseXForm = internalXForm.createInverse();
}
catch (final Exception e) {
+ throw new PAffineTransformException("unable to invert transform", internalXForm);
}
}
diff --git a/swt/src/main/java/edu/umd/cs/piccolox/swt/SWTTimerQueue.java b/swt/src/main/java/edu/umd/cs/piccolox/swt/SWTTimerQueue.java
index acf69b2..840b04f 100644
--- a/swt/src/main/java/edu/umd/cs/piccolox/swt/SWTTimerQueue.java
+++ b/swt/src/main/java/edu/umd/cs/piccolox/swt/SWTTimerQueue.java
@@ -190,6 +190,7 @@
timer.postOverride(); // have timer post an event
}
catch (final SecurityException e) {
+ throw new RuntimeException("Could not post event", e);
}
// Remove the timer from the queue