Revision: 629
Author: allain.lalonde
Date: Thu Jul 30 14:59:39 2009
Log: PMD bugs attack.
http://code.google.com/p/piccolo2d/source/detail?r=629

Modified:
  /piccolo2d.java/trunk/core/src/main/java/edu/umd/cs/piccolo/PCamera.java
   
/piccolo2d.java/trunk/core/src/main/java/edu/umd/cs/piccolo/activities/PTransformActivity.java
  /piccolo2d.java/trunk/extras/src/main/java/edu/umd/cs/piccolox/PFrame.java
   
/piccolo2d.java/trunk/extras/src/main/java/edu/umd/cs/piccolox/POffscreenCanvas.java
   
/piccolo2d.java/trunk/extras/src/main/java/edu/umd/cs/piccolox/nodes/PStyledText.java
   
/piccolo2d.java/trunk/extras/src/main/java/edu/umd/cs/piccolox/swing/PViewport.java
   
/piccolo2d.java/trunk/extras/src/main/java/edu/umd/cs/piccolox/util/PFixedWidthStroke.java
   
/piccolo2d.java/trunk/extras/src/main/java/edu/umd/cs/piccolox/util/POcclusionDetection.java
   
/piccolo2d.java/trunk/swt/src/main/java/edu/umd/cs/piccolox/swt/PSWTBoundsHandle.java
   
/piccolo2d.java/trunk/swt/src/main/java/edu/umd/cs/piccolox/swt/PSWTPath.java
   
/piccolo2d.java/trunk/swt/src/main/java/edu/umd/cs/piccolox/swt/SWTTimerQueue.java

=======================================
---  
/piccolo2d.java/trunk/core/src/main/java/edu/umd/cs/piccolo/PCamera.java        
 
Thu Jul 30 12:36:17 2009
+++  
/piccolo2d.java/trunk/core/src/main/java/edu/umd/cs/piccolo/PCamera.java        
 
Thu Jul 30 14:59:39 2009
@@ -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");
          }
      }
=======================================
---  
/piccolo2d.java/trunk/core/src/main/java/edu/umd/cs/piccolo/activities/PTransformActivity.java
   
Thu Jul 30 12:36:17 2009
+++  
/piccolo2d.java/trunk/core/src/main/java/edu/umd/cs/piccolo/activities/PTransformActivity.java
   
Thu Jul 30 14:59:39 2009
@@ -31,7 +31,6 @@
  import java.awt.geom.AffineTransform;

  import edu.umd.cs.piccolo.util.PAffineTransform;
-import edu.umd.cs.piccolo.util.PUtil;

  /**
   * <b>PTransformActivity</b> 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() {
=======================================
---  
/piccolo2d.java/trunk/extras/src/main/java/edu/umd/cs/piccolox/PFrame.java      
 
Tue Jul 28 12:46:54 2009
+++  
/piccolo2d.java/trunk/extras/src/main/java/edu/umd/cs/piccolox/PFrame.java      
 
Thu Jul 30 14:59:39 2009
@@ -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();
=======================================
---  
/piccolo2d.java/trunk/extras/src/main/java/edu/umd/cs/piccolox/POffscreenCanvas.java
     
Tue Jul 28 12:46:54 2009
+++  
/piccolo2d.java/trunk/extras/src/main/java/edu/umd/cs/piccolox/POffscreenCanvas.java
     
Thu Jul 30 14:59:39 2009
@@ -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
      }
  }
=======================================
---  
/piccolo2d.java/trunk/extras/src/main/java/edu/umd/cs/piccolox/nodes/PStyledText.java
    
Thu Jul 30 12:36:17 2009
+++  
/piccolo2d.java/trunk/extras/src/main/java/edu/umd/cs/piccolox/nodes/PStyledText.java
    
Thu Jul 30 14:59:39 2009
@@ -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
=======================================
---  
/piccolo2d.java/trunk/extras/src/main/java/edu/umd/cs/piccolox/swing/PViewport.java
      
Thu Jul 30 12:36:17 2009
+++  
/piccolo2d.java/trunk/extras/src/main/java/edu/umd/cs/piccolox/swing/PViewport.java
      
Thu Jul 30 14:59:39 2009
@@ -49,10 +49,6 @@
   * @author Lance Good
   */
  public class PViewport extends JViewport {
-
-    /**
-     *
-     */
      private static final long serialVersionUID = 1L;
      /**
       * Controls what happens when scrolling occurs
@@ -201,22 +197,11 @@
      public Dimension getViewSize(final Rectangle2D r) {
          return scrollDirector.getViewSize(r);
      }
-
-    /**
-     * Notifies all <code>ChangeListeners</code> 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;

          /**
=======================================
---  
/piccolo2d.java/trunk/extras/src/main/java/edu/umd/cs/piccolox/util/PFixedWidthStroke.java
       
Fri Jan 23 12:29:37 2009
+++  
/piccolo2d.java/trunk/extras/src/main/java/edu/umd/cs/piccolox/util/PFixedWidthStroke.java
       
Thu Jul 30 14:59:39 2009
@@ -59,17 +59,9 @@
   * @author Jesse Grosjean
   * @author Marcus Rohrmoser
   */
-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;
+public class PFixedWidthStroke extends PSemanticStroke implements  
Serializable {
+
+    private static final long serialVersionUID = 1L;

      // avoid repeated cloning:
      private transient final float dash[];
=======================================
---  
/piccolo2d.java/trunk/extras/src/main/java/edu/umd/cs/piccolox/util/POcclusionDetection.java
     
Tue Jul 28 12:46:54 2009
+++  
/piccolo2d.java/trunk/extras/src/main/java/edu/umd/cs/piccolox/util/POcclusionDetection.java
     
Thu Jul 30 14:59:39 2009
@@ -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());
      }
  }
=======================================
---  
/piccolo2d.java/trunk/swt/src/main/java/edu/umd/cs/piccolox/swt/PSWTBoundsHandle.java
    
Tue Jul 28 12:46:54 2009
+++  
/piccolo2d.java/trunk/swt/src/main/java/edu/umd/cs/piccolox/swt/PSWTBoundsHandle.java
    
Thu Jul 30 14:59:39 2009
@@ -116,13 +116,16 @@

              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) {
=======================================
---  
/piccolo2d.java/trunk/swt/src/main/java/edu/umd/cs/piccolox/swt/PSWTPath.java   
 
Tue Jul 28 13:58:25 2009
+++  
/piccolo2d.java/trunk/swt/src/main/java/edu/umd/cs/piccolox/swt/PSWTPath.java   
 
Thu Jul 30 14:59:39 2009
@@ -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);
          }
      }

=======================================
---  
/piccolo2d.java/trunk/swt/src/main/java/edu/umd/cs/piccolox/swt/SWTTimerQueue.java
       
Tue Jul 28 12:46:54 2009
+++  
/piccolo2d.java/trunk/swt/src/main/java/edu/umd/cs/piccolox/swt/SWTTimerQueue.java
       
Thu Jul 30 14:59:39 2009
@@ -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

--~--~---------~--~----~------------~-------~--~----~
Piccolo2D Developers Group: http://groups.google.com/group/piccolo2d-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to