Revision: 680
Author: allain.lalonde
Date: Thu Oct  8 14:40:54 2009
Log: Killing more CheckStyle and a Couple PMD complaints.
http://code.google.com/p/piccolo2d/source/detail?r=680

Modified:
  /piccolo2d.java/trunk/examples/src/build/conf/checkstyle.xml
   
/piccolo2d.java/trunk/examples/src/main/java/edu/umd/cs/piccolo/examples/OffscreenCanvasExample.java
   
/piccolo2d.java/trunk/examples/src/main/java/edu/umd/cs/piccolo/examples/PrintExample.java
   
/piccolo2d.java/trunk/examples/src/main/java/edu/umd/cs/piccolo/examples/ScrollingExample.java
   
/piccolo2d.java/trunk/examples/src/main/java/edu/umd/cs/piccolo/examples/swt/SWTBenchTest.java
  /piccolo2d.java/trunk/extras/src/main/java/edu/umd/cs/piccolox/PApplet.java
  /piccolo2d.java/trunk/extras/src/main/java/edu/umd/cs/piccolox/PFrame.java

=======================================
--- /piccolo2d.java/trunk/examples/src/build/conf/checkstyle.xml        Thu Oct 
 8  
11:29:42 2009
+++ /piccolo2d.java/trunk/examples/src/build/conf/checkstyle.xml        Thu Oct 
 8  
14:40:54 2009
@@ -92,7 +92,8 @@

          <!-- Checks for Size Violations.                    -->
          <!-- See http://checkstyle.sf.net/config_sizes.html -->
-        <module name="FileLength"/>
+        <module name="FileLength" />
+
          <module name="LineLength">
              <property name="max" value="120"/>
          </module>
=======================================
---  
/piccolo2d.java/trunk/examples/src/main/java/edu/umd/cs/piccolo/examples/OffscreenCanvasExample.java
     
Thu Aug 20 14:13:09 2009
+++  
/piccolo2d.java/trunk/examples/src/main/java/edu/umd/cs/piccolo/examples/OffscreenCanvasExample.java
     
Thu Oct  8 14:40:54 2009
@@ -93,8 +93,8 @@
          final PActivity toRight =  
canvas.getCamera().animateViewToCenterBounds(right, true, 5000);
          final PActivity toLeft =  
canvas.getCamera().animateViewToCenterBounds(left, true, 5000);
          final PActivity toStart =  
canvas.getCamera().animateViewToCenterBounds(start, true, 5000);
-        toLeft.setStartTime(toLeft.getStartTime() + 5000);
-        toStart.setStartTime(toStart.getStartTime() + 10000);
+        toLeft.startAfter(toRight);
+        toStart.startAfter(toLeft);
      }

      /**
@@ -125,7 +125,7 @@
          final GraphicsEnvironment environment =  
GraphicsEnvironment.getLocalGraphicsEnvironment();
          final GraphicsDevice device = environment.getDefaultScreenDevice();
          final OffscreenCanvasExample example = new  
OffscreenCanvasExample(device);
-
+
          final boolean done = false;
          while (!done) {
              example.render();
=======================================
---  
/piccolo2d.java/trunk/examples/src/main/java/edu/umd/cs/piccolo/examples/PrintExample.java
       
Tue Jul 28 12:46:54 2009
+++  
/piccolo2d.java/trunk/examples/src/main/java/edu/umd/cs/piccolo/examples/PrintExample.java
       
Thu Oct  8 14:40:54 2009
@@ -42,6 +42,7 @@
  import java.awt.print.PrinterException;
  import java.awt.print.PrinterJob;
  import java.util.Iterator;
+import java.util.List;

  import javax.swing.ButtonGroup;
  import javax.swing.JButton;
@@ -69,9 +70,6 @@
   */
  public class PrintExample extends PFrame {

-    /**
-     *
-     */
      private static final long serialVersionUID = 1L;

      public PrintExample() {
@@ -89,23 +87,7 @@
          final PScrollDirector windowSD = viewport.getScrollDirector();
          final PScrollDirector documentSD = new DocumentScrollDirector();

-        // Make some rectangles on the surface so we can see where we are
-        for (int x = 0; x < 20; x++) {
-            for (int y = 0; y < 20; y++) {
-                if ((x + y) % 2 == 0) {
-                    final PPath path = PPath.createRectangle(50 * x, 50 *  
y, 40, 40);
-                    path.setPaint(Color.blue);
-                    path.setStrokePaint(Color.black);
-                    canvas.getLayer().addChild(path);
-                }
-                else if ((x + y) % 2 == 1) {
-                    final PPath path = PPath.createEllipse(50 * x, 50 * y,  
40, 40);
-                    path.setPaint(Color.blue);
-                    path.setStrokePaint(Color.black);
-                    canvas.getLayer().addChild(path);
-                }
-            }
-        }
+        addBackgroundShapes(canvas);

          // Now, create the toolbar
          final JToolBar toolBar = new JToolBar();
@@ -154,6 +136,27 @@
          setContentPane(contentPane);
          validate();
      }
+
+    private void addBackgroundShapes(final PCanvas canvas) {
+        for (int shapeCount = 0; shapeCount < 440; shapeCount++) {
+            int x = shapeCount % 21;
+            int y = (shapeCount - x) / 21;
+
+            if (shapeCount % 2 == 0) {
+                final PPath path = PPath.createRectangle(50 * x, 50 * y,  
40, 40);
+                path.setPaint(Color.blue);
+                path.setStrokePaint(Color.black);
+                canvas.getLayer().addChild(path);
+            }
+            else if (shapeCount % 2 == 1) {
+                final PPath path = PPath.createEllipse(50 * x, 50 * y, 40,  
40);
+                path.setPaint(Color.blue);
+                path.setStrokePaint(Color.black);
+                canvas.getLayer().addChild(path);
+            }
+
+        }
+    }

      /**
       * A modified scroll director that performs document based scroling  
rather
@@ -216,54 +219,55 @@
           * @param y The new y position
           */
          public void setViewPosition(final double x, final double y) {
-            if (camera != null) {
-                // If a scroll is in progress - we ignore new scrolls -
-                // if we didn't, since the scrollbars depend on the camera
-                // location
-                // we can end up with an infinite loop
-                if (!scrollInProgress) {
-                    scrollInProgress = true;
-
-                    // Get the union of all the layers' bounds
-                    final PBounds layerBounds = new PBounds();
-                    final java.util.List layers =  
camera.getLayersReference();
-                    for (final Iterator i = layers.iterator();  
i.hasNext();) {
-                        final PLayer layer = (PLayer) i.next();
-                        layerBounds.add(layer.getFullBoundsReference());
-                    }
-
-                    final PAffineTransform at = camera.getViewTransform();
-                    at.transform(layerBounds, layerBounds);
-
-                    // Union the camera view bounds
-                    final PBounds viewBounds = camera.getBoundsReference();
-                    layerBounds.add(viewBounds);
-
-                    // Now find the new view position in view coordinates -
-                    // This is basically the distance from the lower right
-                    // corner of the window to the upper left corner of the
-                    // document
-                    // We then measure the offset from the lower right  
corner
-                    // of the document
-                    final Point2D newPoint = new  
Point2D.Double(layerBounds.getX() + layerBounds.getWidth()
-                            - (x + viewBounds.getWidth()),  
layerBounds.getY() + layerBounds.getHeight()
-                            - (y + viewBounds.getHeight()));
-
-                    // Now transform the new view position into global  
coords
-                    camera.localToView(newPoint);
-
-                    // Compute the new matrix values to put the camera at  
the
-                    // correct location
-                    final double newX = -(at.getScaleX() * newPoint.getX()  
+ at.getShearX() * newPoint.getY());
-                    final double newY = -(at.getShearY() * newPoint.getX()  
+ at.getScaleY() * newPoint.getY());
-
-                    at.setTransform(at.getScaleX(), at.getShearY(),  
at.getShearX(), at.getScaleY(), newX, newY);
-
-                    // Now actually set the camera's transform
-                    camera.setViewTransform(at);
-                    scrollInProgress = false;
-                }
-            }
+            if (camera == null)
+                return;
+
+            // If a scroll is in progress - we ignore new scrolls - if we
+            // didn't, since the scrollbars depend on the camera location
+            // we can end up with an infinite loop
+            if (scrollInProgress)
+                return;
+
+            scrollInProgress = true;
+
+            // Get the union of all the layers' bounds
+            final PBounds layerBounds = new PBounds();
+            final List layers = camera.getLayersReference();
+            for (final Iterator i = layers.iterator(); i.hasNext();) {
+                final PLayer layer = (PLayer) i.next();
+                layerBounds.add(layer.getFullBoundsReference());
+            }
+
+            final PAffineTransform at = camera.getViewTransform();
+            at.transform(layerBounds, layerBounds);
+
+            // Union the camera view bounds
+            final PBounds viewBounds = camera.getBoundsReference();
+            layerBounds.add(viewBounds);
+
+            // Now find the new view position in view coordinates -
+            // This is basically the distance from the lower right
+            // corner of the window to the upper left corner of the
+            // document
+            // We then measure the offset from the lower right corner
+            // of the document
+            final Point2D newPoint = new Point2D.Double(layerBounds.getX()  
+ layerBounds.getWidth()
+                    - (x + viewBounds.getWidth()), layerBounds.getY() +  
layerBounds.getHeight()
+                    - (y + viewBounds.getHeight()));
+
+            // Now transform the new view position into global coords
+            camera.localToView(newPoint);
+
+            // Compute the new matrix values to put the camera at the
+            // correct location
+            final double newX = -(at.getScaleX() * newPoint.getX() +  
at.getShearX() * newPoint.getY());
+            final double newY = -(at.getShearY() * newPoint.getX() +  
at.getScaleY() * newPoint.getY());
+
+            at.setTransform(at.getScaleX(), at.getShearY(),  
at.getShearX(), at.getScaleY(), newX, newY);
+
+            // Now actually set the camera's transform
+            camera.setViewTransform(at);
+            scrollInProgress = false;
          }
      }

=======================================
---  
/piccolo2d.java/trunk/examples/src/main/java/edu/umd/cs/piccolo/examples/ScrollingExample.java
   
Tue Jul 28 12:46:54 2009
+++  
/piccolo2d.java/trunk/examples/src/main/java/edu/umd/cs/piccolo/examples/ScrollingExample.java
   
Thu Oct  8 14:40:54 2009
@@ -88,23 +88,7 @@
          final PScrollDirector windowSD = viewport.getScrollDirector();
          final PScrollDirector documentSD = new DocumentScrollDirector();

-        // Make some rectangles on the surface so we can see where we are
-        for (int x = 0; x < 20; x++) {
-            for (int y = 0; y < 20; y++) {
-                if ((x + y) % 2 == 0) {
-                    final PPath path = PPath.createRectangle(50 * x, 50 *  
y, 40, 40);
-                    path.setPaint(Color.blue);
-                    path.setStrokePaint(Color.black);
-                    canvas.getLayer().addChild(path);
-                }
-                else if ((x + y) % 2 == 1) {
-                    final PPath path = PPath.createEllipse(50 * x, 50 * y,  
40, 40);
-                    path.setPaint(Color.blue);
-                    path.setStrokePaint(Color.black);
-                    canvas.getLayer().addChild(path);
-                }
-            }
-        }
+        addBackgroundShapes(canvas);

          // Now, create the toolbar
          final JToolBar toolBar = new JToolBar();
@@ -165,31 +149,32 @@
           */
          public Point getViewPosition(final Rectangle2D viewBounds) {
              final Point pos = new Point();
-            if (camera != null) {
-                // First we compute the union of all the layers
-                final PBounds layerBounds = new PBounds();
-                final java.util.List layers = camera.getLayersReference();
-                for (final Iterator i = layers.iterator(); i.hasNext();) {
-                    final PLayer layer = (PLayer) i.next();
-                    layerBounds.add(layer.getFullBoundsReference());
-                }
-
-                // Then we put the bounds into camera coordinates and
-                // union the camera bounds
-                camera.viewToLocal(layerBounds);
-                layerBounds.add(viewBounds);
-
-                // Rather than finding the distance from the upper left  
corner
-                // of the window to the upper left corner of the document -
-                // we instead find the distance from the lower right corner
-                // of the window to the upper left corner of the document
-                // THEN we measure the offset from the lower right corner
-                // of the document
-                pos.setLocation((int) (layerBounds.getWidth()
-                        - (viewBounds.getX() + viewBounds.getWidth() -  
layerBounds.getX()) + 0.5), (int) (layerBounds
-                        .getHeight()
-                        - (viewBounds.getY() + viewBounds.getHeight() -  
layerBounds.getY()) + 0.5));
-            }
+            if (camera == null)
+                return pos;
+
+            // First we compute the union of all the layers
+            final PBounds layerBounds = new PBounds();
+            final java.util.List layers = camera.getLayersReference();
+            for (final Iterator i = layers.iterator(); i.hasNext();) {
+                final PLayer layer = (PLayer) i.next();
+                layerBounds.add(layer.getFullBoundsReference());
+            }
+
+            // Then we put the bounds into camera coordinates and
+            // union the camera bounds
+            camera.viewToLocal(layerBounds);
+            layerBounds.add(viewBounds);
+
+            // Rather than finding the distance from the upper left corner
+            // of the window to the upper left corner of the document -
+            // we instead find the distance from the lower right corner
+            // of the window to the upper left corner of the document
+            // THEN we measure the offset from the lower right corner
+            // of the document
+            pos.setLocation((int) (layerBounds.getWidth()
+                    - (viewBounds.getX() + viewBounds.getWidth() -  
layerBounds.getX()) + 0.5), (int) (layerBounds
+                    .getHeight()
+                    - (viewBounds.getY() + viewBounds.getHeight() -  
layerBounds.getY()) + 0.5));

              return pos;

@@ -203,54 +188,75 @@
           * @param y The new y position
           */
          public void setViewPosition(final double x, final double y) {
-            if (camera != null) {
-                // If a scroll is in progress - we ignore new scrolls -
-                // if we didn't, since the scrollbars depend on the camera
-                // location
-                // we can end up with an infinite loop
-                if (!scrollInProgress) {
-                    scrollInProgress = true;
-
-                    // Get the union of all the layers' bounds
-                    final PBounds layerBounds = new PBounds();
-                    final java.util.List layers =  
camera.getLayersReference();
-                    for (final Iterator i = layers.iterator();  
i.hasNext();) {
-                        final PLayer layer = (PLayer) i.next();
-                        layerBounds.add(layer.getFullBoundsReference());
-                    }
-
-                    final PAffineTransform at = camera.getViewTransform();
-                    at.transform(layerBounds, layerBounds);
-
-                    // Union the camera view bounds
-                    final PBounds viewBounds = camera.getBoundsReference();
-                    layerBounds.add(viewBounds);
-
-                    // Now find the new view position in view coordinates -
-                    // This is basically the distance from the lower right
-                    // corner of the window to the upper left corner of the
-                    // document
-                    // We then measure the offset from the lower right  
corner
-                    // of the document
-                    final Point2D newPoint = new  
Point2D.Double(layerBounds.getX() + layerBounds.getWidth()
-                            - (x + viewBounds.getWidth()),  
layerBounds.getY() + layerBounds.getHeight()
-                            - (y + viewBounds.getHeight()));
-
-                    // Now transform the new view position into global  
coords
-                    camera.localToView(newPoint);
-
-                    // Compute the new matrix values to put the camera at  
the
-                    // correct location
-                    final double newX = -(at.getScaleX() * newPoint.getX()  
+ at.getShearX() * newPoint.getY());
-                    final double newY = -(at.getShearY() * newPoint.getX()  
+ at.getScaleY() * newPoint.getY());
-
-                    at.setTransform(at.getScaleX(), at.getShearY(),  
at.getShearX(), at.getScaleY(), newX, newY);
-
-                    // Now actually set the camera's transform
-                    camera.setViewTransform(at);
-                    scrollInProgress = false;
-                }
-            }
+            if (camera == null)
+                return;
+
+            // If a scroll is in progress - we ignore new scrolls - if we
+            // didn't, since the scrollbars depend on the camera
+            // location we can end up with an infinite loop
+            if (scrollInProgress)
+                return;
+
+            scrollInProgress = true;
+
+            // Get the union of all the layers' bounds
+            final PBounds layerBounds = new PBounds();
+            final java.util.List layers = camera.getLayersReference();
+            for (final Iterator i = layers.iterator(); i.hasNext();) {
+                final PLayer layer = (PLayer) i.next();
+                layerBounds.add(layer.getFullBoundsReference());
+            }
+
+            final PAffineTransform at = camera.getViewTransform();
+            at.transform(layerBounds, layerBounds);
+
+            // Union the camera view bounds
+            final PBounds viewBounds = camera.getBoundsReference();
+            layerBounds.add(viewBounds);
+
+            // Now find the new view position in view coordinates -
+            // This is basically the distance from the lower right
+            // corner of the window to the upper left corner of the
+            // document. We then measure the offset from the lower right  
corner
+            // of the document
+            final Point2D newPoint = new Point2D.Double(layerBounds.getX()  
+ layerBounds.getWidth()
+                    - (x + viewBounds.getWidth()), layerBounds.getY() +  
layerBounds.getHeight()
+                    - (y + viewBounds.getHeight()));
+
+            // Now transform the new view position into global coords
+            camera.localToView(newPoint);
+
+            // Compute the new matrix values to put the camera at the
+            // correct location
+            final double newX = -(at.getScaleX() * newPoint.getX() +  
at.getShearX() * newPoint.getY());
+            final double newY = -(at.getShearY() * newPoint.getX() +  
at.getScaleY() * newPoint.getY());
+
+            at.setTransform(at.getScaleX(), at.getShearY(),  
at.getShearX(), at.getScaleY(), newX, newY);
+
+            // Now actually set the camera's transform
+            camera.setViewTransform(at);
+            scrollInProgress = false;
+        }
+    }
+
+    private void addBackgroundShapes(final PCanvas canvas) {
+        for (int shapeCount = 0; shapeCount < 440; shapeCount++) {
+            int x = shapeCount % 21;
+            int y = (shapeCount - x) / 21;
+
+            if (shapeCount % 2 == 0) {
+                final PPath path = PPath.createRectangle(50 * x, 50 * y,  
40, 40);
+                path.setPaint(Color.blue);
+                path.setStrokePaint(Color.black);
+                canvas.getLayer().addChild(path);
+            }
+            else if (shapeCount % 2 == 1) {
+                final PPath path = PPath.createEllipse(50 * x, 50 * y, 40,  
40);
+                path.setPaint(Color.blue);
+                path.setStrokePaint(Color.black);
+                canvas.getLayer().addChild(path);
+            }
+
          }
      }

=======================================
---  
/piccolo2d.java/trunk/examples/src/main/java/edu/umd/cs/piccolo/examples/swt/SWTBenchTest.java
   
Tue Jul 28 13:41:36 2009
+++  
/piccolo2d.java/trunk/examples/src/main/java/edu/umd/cs/piccolo/examples/swt/SWTBenchTest.java
   
Thu Oct  8 14:40:54 2009
@@ -191,8 +191,9 @@
      }

      Image loadImage(final Display display, final String name) {
+        InputStream stream = null;
          try {
-            final InputStream stream =  
SWTBenchTest.class.getResourceAsStream(name);
+            stream = SWTBenchTest.class.getResourceAsStream(name);
              if (stream != null) {
                  final ImageData imageData = new ImageData(stream);
                  return new Image(display, imageData);
@@ -204,6 +205,7 @@
              }
          }
          catch (final Exception e) {
+            throw new RuntimeException(e);
          }
          return null;
      }
=======================================
---  
/piccolo2d.java/trunk/extras/src/main/java/edu/umd/cs/piccolox/PApplet.java     
 
Tue Aug  4 13:42:37 2009
+++  
/piccolo2d.java/trunk/extras/src/main/java/edu/umd/cs/piccolox/PApplet.java     
 
Thu Oct  8 14:40:54 2009
@@ -43,7 +43,7 @@
  public class PApplet extends JApplet {
      /** Used to allow versioned binary streams for serializations. */
      private static final long serialVersionUID = 1L;
-
+
      /** Canvas being displayed by this applet. */
      private PCanvas canvas;

@@ -91,7 +91,7 @@
          return new PCanvas();
      }

-     /**
+    /**
       * This method will be called before the initialize() method and will  
be
       * called on the thread that is constructing this object.
       */
=======================================
---  
/piccolo2d.java/trunk/extras/src/main/java/edu/umd/cs/piccolox/PFrame.java      
 
Wed Aug  5 09:16:51 2009
+++  
/piccolo2d.java/trunk/extras/src/main/java/edu/umd/cs/piccolox/PFrame.java      
 
Thu Oct  8 14:40:54 2009
@@ -109,7 +109,8 @@
              setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          }
          catch (final SecurityException e) {
-            // expected from applets
+            // expected from Applets
+            System.out.println("Ignoring security exception. Assuming  
Applet Context.");
          }

          if (aCanvas == null) {
@@ -126,9 +127,9 @@
          beforeInitialize();

          // Manipulation of Piccolo's scene graph should be done from Swings
-        // event dispatch thread since Piccolo is not thread safe. This  
code
+        // event dispatch thread since Piccolo2D is not thread safe. This  
code
          // calls initialize() from that thread once the PFrame is  
initialized,
-        // so you are safe to start working with Piccolo in the  
initialize()
+        // so you are safe to start working with Piccolo2D in the  
initialize()
          // method.
          SwingUtilities.invokeLater(new Runnable() {
              public void run() {
@@ -295,10 +296,10 @@
      }

      /**
-     * Subclasses should override this method and add their Piccolo
+     * Subclasses should override this method and add their Piccolo2D
       * initialization code there. This method will be called on the swing  
event
       * dispatch thread. Note that the constructors of PFrame subclasses  
may not
-     * be complete when this method is called. If you need to initailize  
some
+     * be complete when this method is called. If you need to initialize  
some
       * things in your class before this method is called place that code in
       * beforeInitialize();
       */

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

Reply via email to