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 da8415e..462f308 100644 --- a/core/src/main/java/edu/umd/cs/piccolo/PCamera.java +++ b/core/src/main/java/edu/umd/cs/piccolo/PCamera.java @@ -69,6 +69,12 @@ public class PCamera extends PNode { /** + * Allows for future serialization code to understand versioned binary + * formats. + */ + private static final long serialVersionUID = 1L; + + /** * The property name that identifies a change in the set of this camera's * layers (see {@link #getLayer getLayer}, {@link #getLayerCount * getLayerCount}, {@link #getLayersReference getLayersReference}). A @@ -158,16 +164,17 @@ repaintFrom(TEMP_REPAINT_RECT, repaintedLayer); } } - + /** * @deprecated since a more specific repaintFromLayer method is available * - * Repaint from one of the cameras layers. The repaint region needs to be - * transformed from view to local in this case. Unlike most repaint methods - * in piccolo this one must not modify the viewBounds parameter. + * Repaint from one of the cameras layers. The repaint region + * needs to be transformed from view to local in this case. + * Unlike most repaint methods in piccolo this one must not + * modify the viewBounds parameter. */ - public void repaintFromLayer(PBounds viewBounds, PNode repaintedLayer) { - this.repaintFromLayer(viewBounds, (PLayer)repaintedLayer); + public void repaintFromLayer(PBounds viewBounds, PNode repaintedLayer) { + this.repaintFromLayer(viewBounds, (PLayer) repaintedLayer); } // **************************************************************** @@ -640,6 +647,9 @@ layerBounds.setRect(layerBounds.getCenterX(), layerBounds.getCenterY(), 0, 0); constraintDelta = viewBounds.deltaRequiredToContain(layerBounds); break; + default: + + throw new RuntimeException("Invalid View Constraint"); } viewTransform.translate(-constraintDelta.width, -constraintDelta.height); @@ -685,8 +695,8 @@ * camera's view coordinate system. The given point is modified by this * method. */ - public Point2D localToView(Point2D localPoint) { - return viewTransform.inverseTransform(localPoint, localPoint); + public Point2D localToView(Point2D localPoint) { + return viewTransform.inverseTransform(localPoint, localPoint); } /** @@ -694,8 +704,8 @@ * camera's view coordinate system. The given dimension is modified by this * method. */ - public Dimension2D localToView(Dimension2D localDimension) { - return viewTransform.inverseTransform(localDimension, localDimension); + public Dimension2D localToView(Dimension2D localDimension) { + return viewTransform.inverseTransform(localDimension, localDimension); } /** diff --git a/core/src/main/java/edu/umd/cs/piccolo/PCanvas.java b/core/src/main/java/edu/umd/cs/piccolo/PCanvas.java index 8d5ef4b..8a9778e 100644 --- a/core/src/main/java/edu/umd/cs/piccolo/PCanvas.java +++ b/core/src/main/java/edu/umd/cs/piccolo/PCanvas.java @@ -70,7 +70,12 @@ * @author Jesse Grosjean */ public class PCanvas extends JComponent implements PComponent { - + /** + * Allows for future serialization code to understand versioned binary + * formats. + */ + private static final long serialVersionUID = 1L; + /** * @deprecated this is a typo and clients should change their code to * reflect the correct spelling @@ -90,10 +95,10 @@ private PZoomEventHandler zoomEventHandler; private boolean paintingImmediately; private boolean animatingOnLastPaint; - private MouseListener mouseListener; - private KeyEventPostProcessor keyEventPostProcessor; - private MouseWheelListener mouseWheelListener; - private MouseMotionListener mouseMotionListener; + private transient MouseListener mouseListener; + private transient KeyEventPostProcessor keyEventPostProcessor; + private transient MouseWheelListener mouseWheelListener; + private transient MouseMotionListener mouseMotionListener; /** * Construct a canvas with the basic scene graph consisting of a root, diff --git a/core/src/main/java/edu/umd/cs/piccolo/PLayer.java b/core/src/main/java/edu/umd/cs/piccolo/PLayer.java index 0ed503a..42ab7b0 100644 --- a/core/src/main/java/edu/umd/cs/piccolo/PLayer.java +++ b/core/src/main/java/edu/umd/cs/piccolo/PLayer.java @@ -54,7 +54,12 @@ * @author Jesse Grosjean */ public class PLayer extends PNode { - + /** + * Allows for future serialization code to understand versioned binary + * formats. + */ + private static final long serialVersionUID = 1L; + /** * The property name that identifies a change in the set of this layer's * cameras (see {@link #getCamera getCamera}, {@link #getCameraCount 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 41756d2..b10fb5b 100644 --- a/core/src/main/java/edu/umd/cs/piccolo/PNode.java +++ b/core/src/main/java/edu/umd/cs/piccolo/PNode.java @@ -98,6 +98,11 @@ * @author Jesse Grosjean */ public class PNode implements Cloneable, Serializable, Printable { + /** + * Allows for future serialization code to understand versioned binary + * formats. + */ + private static final long serialVersionUID = 1L; /** * The property name that identifies a change in this node's client @@ -536,7 +541,7 @@ }; PColorActivity ca = new PColorActivity(duration, PUtil.DEFAULT_ACTIVITY_STEP_RATE, t, destColor); - addActivity(ca); + addActivity(ca); return ca; } } @@ -761,7 +766,7 @@ } catch (ClassNotFoundException e) { return null; - } + } } // **************************************************************** @@ -856,8 +861,8 @@ public Point2D parentToLocal(Point2D parentPoint) { if (transform == null) return parentPoint; - - return transform.inverseTransform(parentPoint, parentPoint); + + return transform.inverseTransform(parentPoint, parentPoint); } /** @@ -1022,14 +1027,15 @@ * @return The inverse of the concatenation of transforms from the root down * to this node. */ - public PAffineTransform getGlobalToLocalTransform(PAffineTransform dest) { + public PAffineTransform getGlobalToLocalTransform(PAffineTransform dest) { dest = getLocalToGlobalTransform(dest); try { dest.setTransform(dest.createInverse()); - } catch (NoninvertibleTransformException e) { + } + catch (NoninvertibleTransformException e) { throw new PAffineTransformException(e, dest); } - return dest; + return dest; } // **************************************************************** @@ -1245,8 +1251,9 @@ /** * Notify this node that you will begin to repeatedly call setBounds - * . When you are done call endResizeBounds to let the - * node know that you are done. + * . When you + * are done call endResizeBounds to let the node know that you + * are done. */ public void startResizeBounds() { } @@ -2130,8 +2137,9 @@ Point2D pt1, pt2; if (parent == null) { - return null; - } else { + return null; + } + else { // First compute translation amount in global coordinates Rectangle2D srcBounds = getGlobalFullBounds(); srcx = lerp(srcPt.getX(), srcBounds.getX(), srcBounds.getX() + srcBounds.getWidth()); @@ -2153,32 +2161,34 @@ return animateToTransform(at, millis); } } - + /** * @deprecated in favor of animateToRelativePosition * - * It will calculate the necessary transform in order to make this node - * appear at a particular position relative to the specified bounding box. - * The source point specifies a point in the unit square (0, 0) - (1, 1) - * that represents an anchor point on the corresponding node to this - * transform. The destination point specifies an anchor point on the - * reference node. The position method then computes the transform that - * results in transforming this node so that the source anchor point - * coincides with the reference anchor point. This can be useful for layout - * algorithms as it is straightforward to position one object relative to - * another. - *

- * For example, If you have two nodes, A and B, and you call + * It will calculate the necessary transform in order to make + * this node appear at a particular position relative to the + * specified bounding box. The source point specifies a point in + * the unit square (0, 0) - (1, 1) that represents an anchor + * point on the corresponding node to this transform. The + * destination point specifies an anchor point on the reference + * node. The position method then computes the transform that + * results in transforming this node so that the source anchor + * point coincides with the reference anchor point. This can be + * useful for layout algorithms as it is straightforward to + * position one object relative to another. + *

+ * For example, If you have two nodes, A and B, and you call * - *

+     *             
      * Point2D srcPt = new Point2D.Double(1.0, 0.0);
      * Point2D destPt = new Point2D.Double(0.0, 0.0);
      * A.position(srcPt, destPt, B.getGlobalBounds(), 750, null);
      * 
* - * The result is that A will move so that its upper-right corner is at the - * same place as the upper-left corner of B, and the transition will be - * smoothly animated over a period of 750 milliseconds. + * The result is that A will move so that its upper-right corner + * is at the same place as the upper-left corner of B, and the + * transition will be smoothly animated over a period of 750 + * milliseconds. * * @param srcPt The anchor point on this transform's node (normalized to a * unit square) @@ -2233,10 +2243,11 @@ if (transform == null) { return new PAffineTransform(); } - + try { return new PAffineTransform(transform.createInverse()); - } catch (NoninvertibleTransformException e) { + } + catch (NoninvertibleTransformException e) { throw new PAffineTransformException(e, transform); } } @@ -2568,16 +2579,16 @@ * @param height pixel height of the resulting image * @return a new image representing this node and its descendents */ - public Image toImage(int width, int height, Paint backGroundPaint) { + public Image toImage(int width, int height, Paint backGroundPaint) { BufferedImage result; - + if (GraphicsEnvironment.isHeadless()) { result = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); - } + } else { GraphicsConfiguration graphicsConfiguration = GraphicsEnvironment.getLocalGraphicsEnvironment() - .getDefaultScreenDevice().getDefaultConfiguration(); - result = graphicsConfiguration.createCompatibleImage(width, height, Transparency.TRANSLUCENT); + .getDefaultScreenDevice().getDefaultConfiguration(); + result = graphicsConfiguration.createCompatibleImage(width, height, Transparency.TRANSLUCENT); } return toImage(result, backGroundPaint); @@ -2777,7 +2788,7 @@ boolean thisPickable = getPickable() && pickPath.acceptsNode(this); if (thisPickable && pick(pickPath)) { - return true; + return true; } if (getChildrenPickable()) { @@ -2790,7 +2801,7 @@ } if (thisPickable && pickAfterChildren(pickPath)) { - return true; + return true; } pickPath.popTransform(transform); @@ -3267,15 +3278,15 @@ protected final String paramString() { return "this Method (paramString) is deprecated and will go away in the next release."; } - + public PInputEventListener[] getInputEventListeners() { if (listenerList == null || listenerList.getListenerCount() == 0) return new PInputEventListener[] {}; - + EventListener[] listeners = listenerList.getListeners(PInputEventListener.class); - + PInputEventListener[] result = new PInputEventListener[listeners.length]; - for (int i=0; i