Revision: 935
Author: allain.lalonde
Date: Tue Jan 19 13:09:08 2010
Log: Fixing issue #135 by making constants final in 2.0-spike branch.
http://code.google.com/p/piccolo2d/source/detail?r=935

Deleted:
/piccolo2d.java/branches/2.0-spike/core/src/test/java/org/piccolo2d/util/PUtilTest.java
Modified:
/piccolo2d.java/branches/2.0-spike/core/src/main/java/org/piccolo2d/POffscreenCanvas.java /piccolo2d.java/branches/2.0-spike/core/src/main/java/org/piccolo2d/event/PInputEventFilter.java /piccolo2d.java/branches/2.0-spike/core/src/main/java/org/piccolo2d/util/PPaintContext.java /piccolo2d.java/branches/2.0-spike/core/src/main/java/org/piccolo2d/util/PUtil.java /piccolo2d.java/branches/2.0-spike/core/src/test/java/org/piccolo2d/event/PInputEventFilterTest.java /piccolo2d.java/branches/2.0-spike/extras/src/main/java/org/piccolo2d/extras/event/PSelectionEventHandler.java /piccolo2d.java/branches/2.0-spike/extras/src/main/java/org/piccolo2d/extras/handles/PHandle.java /piccolo2d.java/branches/2.0-spike/extras/src/main/java/org/piccolo2d/extras/nodes/PLens.java /piccolo2d.java/branches/2.0-spike/extras/src/main/java/org/piccolo2d/extras/pswing/PSwingCanvas.java /piccolo2d.java/branches/2.0-spike/extras/src/main/java/org/piccolo2d/extras/util/PSemanticStroke.java /piccolo2d.java/branches/2.0-spike/swt/src/main/java/org/piccolo2d/swt/PSWTKeyEvent.java /piccolo2d.java/branches/2.0-spike/swt/src/main/java/org/piccolo2d/swt/PSWTMouseEvent.java /piccolo2d.java/branches/2.0-spike/swt/src/main/java/org/piccolo2d/swt/SWTGraphics2D.java /piccolo2d.java/branches/2.0-spike/swt/src/main/java/org/piccolo2d/swt/SWTShapeManager.java

=======================================
--- /piccolo2d.java/branches/2.0-spike/core/src/test/java/org/piccolo2d/util/PUtilTest.java Tue Jan 19 12:49:37 2010
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright (c) 2008-2010, Piccolo2D project, http://piccolo2d.org
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are permitted provided
- * that the following conditions are met:
- *
- * Redistributions of source code must retain the above copyright notice, this list of conditions
- * and the following disclaimer.
- *
- * Redistributions in binary form must reproduce the above copyright notice, this list of conditions - * and the following disclaimer in the documentation and/or other materials provided with the
- * distribution.
- *
- * None of the name of the University of Maryland, the name of the Piccolo2D project, or the names of its - * contributors may be used to endorse or promote products derived from this software without specific
- * prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR - * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.piccolo2d.util;
-
-import java.util.Enumeration;
-import java.util.Iterator;
-
-import junit.framework.TestCase;
-
-/**
- * Unit test for PUtil.
- */
-public class PUtilTest extends TestCase {
-
-    // see http://code.google.com/p/piccolo2d/issues/detail?id=116
-    public void testPreventCodeCleanFinal() {
-        final Enumeration ne = PUtil.NULL_ENUMERATION;
-        try {
-            PUtil.NULL_ENUMERATION = null;
-        }
-        finally {
-            PUtil.NULL_ENUMERATION = ne;
-        }
-
-        final Iterator ni = PUtil.NULL_ITERATOR;
-        try {
-            PUtil.NULL_ITERATOR = null;
-        }
-        finally {
-            PUtil.NULL_ITERATOR = ni;
-        }
-    }
-
-}
=======================================
--- /piccolo2d.java/branches/2.0-spike/core/src/main/java/org/piccolo2d/POffscreenCanvas.java Tue Jan 19 12:39:24 2010 +++ /piccolo2d.java/branches/2.0-spike/core/src/main/java/org/piccolo2d/POffscreenCanvas.java Tue Jan 19 13:09:08 2010
@@ -53,7 +53,7 @@
     private int renderQuality = DEFAULT_RENDER_QUALITY;

/** Default render quality, <code>PPaintContext.HIGH_QUALITY_RENDERING</code>. */ - static final int DEFAULT_RENDER_QUALITY = PPaintContext.HIGH_QUALITY_RENDERING; + public static final int DEFAULT_RENDER_QUALITY = PPaintContext.HIGH_QUALITY_RENDERING;


     /**
=======================================
--- /piccolo2d.java/branches/2.0-spike/core/src/main/java/org/piccolo2d/event/PInputEventFilter.java Tue Jan 19 12:39:24 2010 +++ /piccolo2d.java/branches/2.0-spike/core/src/main/java/org/piccolo2d/event/PInputEventFilter.java Tue Jan 19 13:09:08 2010
@@ -53,9 +53,9 @@
  */
 public class PInputEventFilter {
     /** Mask representing all possible modifiers. */
- public static int ALL_MODIFIERS_MASK = InputEvent.BUTTON1_MASK | InputEvent.BUTTON2_MASK | InputEvent.BUTTON3_MASK - | InputEvent.SHIFT_MASK | InputEvent.CTRL_MASK | InputEvent.ALT_MASK | InputEvent.ALT_GRAPH_MASK
-            | InputEvent.META_MASK;
+ public static final int ALL_MODIFIERS_MASK = InputEvent.BUTTON1_MASK | InputEvent.BUTTON2_MASK + | InputEvent.BUTTON3_MASK | InputEvent.SHIFT_MASK | InputEvent.CTRL_MASK | InputEvent.ALT_MASK
+            | InputEvent.ALT_GRAPH_MASK | InputEvent.META_MASK;

     /** If event modifiers don't match this exactly, event it filtered. */
     private int andMask;
@@ -429,9 +429,11 @@
     }

     /**
- * Sets the number of clicks that an incoming event must have to be accepted.
+     * Sets the number of clicks that an incoming event must have to be
+     * accepted.
      *
- * @param aClickCount number clicks that an incoming event must have to be accepted + * @param aClickCount number clicks that an incoming event must have to be
+     *            accepted
      */
     public void setAcceptClickCount(final short aClickCount) {
         clickCount = aClickCount;
=======================================
--- /piccolo2d.java/branches/2.0-spike/core/src/main/java/org/piccolo2d/util/PPaintContext.java Tue Jan 19 12:49:37 2010 +++ /piccolo2d.java/branches/2.0-spike/core/src/main/java/org/piccolo2d/util/PPaintContext.java Tue Jan 19 13:09:08 2010
@@ -57,10 +57,10 @@
     public static final int HIGH_QUALITY_RENDERING = 1;

     /** Font context to use while in low quality rendering. */
- public static FontRenderContext RENDER_QUALITY_LOW_FRC = new FontRenderContext(null, false, true); + public static final FontRenderContext RENDER_QUALITY_LOW_FRC = new FontRenderContext(null, false, true);

     /** Font context to use while in high quality rendering. */
- public static FontRenderContext RENDER_QUALITY_HIGH_FRC = new FontRenderContext(null, true, true); + public static final FontRenderContext RENDER_QUALITY_HIGH_FRC = new FontRenderContext(null, true, true);

     /** Used while calculating scale at which rendering is occurring. */
     private static final double[] PTS = new double[4];
=======================================
--- /piccolo2d.java/branches/2.0-spike/core/src/main/java/org/piccolo2d/util/PUtil.java Tue Jan 19 12:49:37 2010 +++ /piccolo2d.java/branches/2.0-spike/core/src/main/java/org/piccolo2d/util/PUtil.java Tue Jan 19 13:09:08 2010
@@ -57,13 +57,13 @@
* PActivities are broken into steps, this is how many milliseconds should
      * pass between steps.
      */
-    public static long DEFAULT_ACTIVITY_STEP_RATE = 20;
+    public static final long DEFAULT_ACTIVITY_STEP_RATE = 20;

/** Rate in milliseconds at which the activity timer will get invoked. */
-    public static int ACTIVITY_SCHEDULER_FRAME_DELAY = 10;
+    public static final int ACTIVITY_SCHEDULER_FRAME_DELAY = 10;

     /** An iterator that iterates over an empty collection. */
- public static Iterator NULL_ITERATOR = Collections.EMPTY_LIST.iterator(); + public static final Iterator NULL_ITERATOR = Collections.EMPTY_LIST.iterator();

     /**
* Used when persisting paths to an object stream. Used to mark the end of
@@ -72,7 +72,7 @@
     private static final int PATH_TERMINATOR = -1;

     /** A utility enumeration with no elements. */
-    public static Enumeration NULL_ENUMERATION = new Enumeration() {
+    public static final Enumeration NULL_ENUMERATION = new Enumeration() {
         public boolean hasMoreElements() {
             return false;
         }
=======================================
--- /piccolo2d.java/branches/2.0-spike/core/src/test/java/org/piccolo2d/event/PInputEventFilterTest.java Tue Jan 19 12:39:24 2010 +++ /piccolo2d.java/branches/2.0-spike/core/src/test/java/org/piccolo2d/event/PInputEventFilterTest.java Tue Jan 19 13:09:08 2010
@@ -47,18 +47,7 @@

     public void setUp() {
         filter = new PInputEventFilter();
-    }
-
-    // http://code.google.com/p/piccolo2d/issues/detail?id=116
-    public void testPreventCodeCleanFinal() {
-        final int pre = PInputEventFilter.ALL_MODIFIERS_MASK;
-        try {
-            PInputEventFilter.ALL_MODIFIERS_MASK = 0;
-        }
-        finally {
-            PInputEventFilter.ALL_MODIFIERS_MASK = pre;
-        }
-    }
+    }

     public void testAcceptsAlreadyHandledEventsFalseByDefault() {
         assertFalse(filter.getAcceptsAlreadyHandledEvents());
=======================================
--- /piccolo2d.java/branches/2.0-spike/extras/src/main/java/org/piccolo2d/extras/event/PSelectionEventHandler.java Tue Jan 19 12:39:24 2010 +++ /piccolo2d.java/branches/2.0-spike/extras/src/main/java/org/piccolo2d/extras/event/PSelectionEventHandler.java Tue Jan 19 13:09:08 2010
@@ -71,9 +71,9 @@
public static final String SELECTION_CHANGED_NOTIFICATION = "SELECTION_CHANGED_NOTIFICATION";

     /** The default dash width when displaying selection rectangle. */
-    static final int DASH_WIDTH = 5;
-
-    static final int NUM_STROKES = 10;
+    private static final int DASH_WIDTH = 5;
+
+    private static final int NUM_STROKES = 10;

     /** The current selection. */
     private HashMap selection = null;
=======================================
--- /piccolo2d.java/branches/2.0-spike/extras/src/main/java/org/piccolo2d/extras/handles/PHandle.java Tue Jan 19 12:39:24 2010 +++ /piccolo2d.java/branches/2.0-spike/extras/src/main/java/org/piccolo2d/extras/handles/PHandle.java Tue Jan 19 13:09:08 2010
@@ -83,12 +83,12 @@
     private static final long serialVersionUID = 1L;

     /** The default size for a handle. */
-    public static float DEFAULT_HANDLE_SIZE = 8;
+    public static final float DEFAULT_HANDLE_SIZE = 8;
     /** Default shape to use when drawing handles. */
- public static Shape DEFAULT_HANDLE_SHAPE = new Ellipse2D.Float(0f, 0f, DEFAULT_HANDLE_SIZE, DEFAULT_HANDLE_SIZE); + public static final Shape DEFAULT_HANDLE_SHAPE = new Ellipse2D.Float(0f, 0f, DEFAULT_HANDLE_SIZE, DEFAULT_HANDLE_SIZE);

     /** Default color to paint handles. */
-    public static Color DEFAULT_COLOR = Color.white;
+    public static final Color DEFAULT_COLOR = Color.white;

     private PLocator locator;
     private transient PDragSequenceEventHandler handleDragger;
=======================================
--- /piccolo2d.java/branches/2.0-spike/extras/src/main/java/org/piccolo2d/extras/nodes/PLens.java Tue Jan 19 12:39:24 2010 +++ /piccolo2d.java/branches/2.0-spike/extras/src/main/java/org/piccolo2d/extras/nodes/PLens.java Tue Jan 19 13:09:08 2010
@@ -70,13 +70,13 @@
     private final transient PDragEventHandler lensDragger;

     /** The height of the drag bar. */
-    public static double LENS_DRAGBAR_HEIGHT = 20;
+    public static final double LENS_DRAGBAR_HEIGHT = 20;

     /** Default paint to use for the drag bar. */
-    public static Paint DEFAULT_DRAGBAR_PAINT = Color.DARK_GRAY;
+    public static final Paint DEFAULT_DRAGBAR_PAINT = Color.DARK_GRAY;

     /** Default paint to use when drawing the background of the lens. */
-    public static Paint DEFAULT_LENS_PAINT = Color.LIGHT_GRAY;
+    public static final Paint DEFAULT_LENS_PAINT = Color.LIGHT_GRAY;

     /**
      * Constructs the default PLens.
=======================================
--- /piccolo2d.java/branches/2.0-spike/extras/src/main/java/org/piccolo2d/extras/pswing/PSwingCanvas.java Tue Jan 19 12:39:24 2010 +++ /piccolo2d.java/branches/2.0-spike/extras/src/main/java/org/piccolo2d/extras/pswing/PSwingCanvas.java Tue Jan 19 13:09:08 2010
@@ -80,7 +80,7 @@
     }

     /**
-     * JComponent wrapper for a PSwingCanvas. Used by PSwingRepaintManager.
+ * JComponent wrapper for a PSwingCanvas. Used by PSwingRepaintManager. So, do not make it private.
      */
     static class ChildWrapper extends JComponent {
         /**
=======================================
--- /piccolo2d.java/branches/2.0-spike/extras/src/main/java/org/piccolo2d/extras/util/PSemanticStroke.java Tue Jan 19 12:49:37 2010 +++ /piccolo2d.java/branches/2.0-spike/extras/src/main/java/org/piccolo2d/extras/util/PSemanticStroke.java Tue Jan 19 13:09:08 2010
@@ -30,8 +30,6 @@
 import java.awt.Shape;
 import java.awt.Stroke;

-import org.piccolo2d.util.PDebug;
-import org.piccolo2d.util.PPaintContext;
 import org.piccolo2d.util.PPickPath;

 /**
=======================================
--- /piccolo2d.java/branches/2.0-spike/swt/src/main/java/org/piccolo2d/swt/PSWTKeyEvent.java Tue Jan 19 12:39:24 2010 +++ /piccolo2d.java/branches/2.0-spike/swt/src/main/java/org/piccolo2d/swt/PSWTKeyEvent.java Tue Jan 19 13:09:08 2010
@@ -44,7 +44,7 @@
 public class PSWTKeyEvent extends KeyEvent {
     private static final long serialVersionUID = 1L;

-    private static Component fakeSrc = new Component() {
+    private static final Component fakeSrc = new Component() {
     };

     private org.eclipse.swt.events.KeyEvent swtEvent;
=======================================
--- /piccolo2d.java/branches/2.0-spike/swt/src/main/java/org/piccolo2d/swt/PSWTMouseEvent.java Tue Jan 19 12:39:24 2010 +++ /piccolo2d.java/branches/2.0-spike/swt/src/main/java/org/piccolo2d/swt/PSWTMouseEvent.java Tue Jan 19 13:09:08 2010
@@ -48,7 +48,7 @@

     private static final long serialVersionUID = 1L;

-    private static Component fakeSrc = new Component() {
+    private static final Component fakeSrc = new Component() {
     };

     /** Event being wrapped. */
=======================================
--- /piccolo2d.java/branches/2.0-spike/swt/src/main/java/org/piccolo2d/swt/SWTGraphics2D.java Tue Jan 19 12:49:37 2010 +++ /piccolo2d.java/branches/2.0-spike/swt/src/main/java/org/piccolo2d/swt/SWTGraphics2D.java Tue Jan 19 13:09:08 2010
@@ -92,29 +92,38 @@
      * incrementGCCount and decrementGCCount.
      */
     protected static int CACHE_COUNT = 0;
+
     /** Map from font names to Fonts. */
-    protected static HashMap FONT_CACHE = new HashMap();
+    protected static final HashMap FONT_CACHE = new HashMap();
+
     /** Map from awt colors to swt colors. */
-    protected static HashMap COLOR_CACHE = new HashMap();
+    protected static final HashMap COLOR_CACHE = new HashMap();
+
     /** Map from awt shapess to swt Paths. */
-    protected static HashMap SHAPE_CACHE = new HashMap();
+    protected static final HashMap SHAPE_CACHE = new HashMap();
+
     /** Buffer used to extract the graphics device. */
- protected static BufferedImage BUFFER = new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB);
-
-    private static Point TEMP_POINT = new Point();
-    private static Rectangle2D TEMP_RECT = new Rectangle2D.Double();
-    private static Rectangle2D TEMP_LINE_RECT = new Rectangle2D.Double();
- private static org.eclipse.swt.graphics.Rectangle SWT_RECT = new org.eclipse.swt.graphics.Rectangle(0, 0, 0, 0); + protected static final BufferedImage BUFFER = new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB);
+
+    private static final Point TEMP_POINT = new Point();
+    private static final Rectangle2D TEMP_RECT = new Rectangle2D.Double();
+ private static final Rectangle2D TEMP_LINE_RECT = new Rectangle2D.Double(); + private static final org.eclipse.swt.graphics.Rectangle SWT_RECT = new org.eclipse.swt.graphics.Rectangle(0, 0, 0, 0);

     /** The Underlying GraphicsContext provided by swt. */
     protected GC gc;
+
/** Device onto which all graphics operations will ultimately take place. */
     protected Device device;
+
     /** The current transform to apply to drawing operations. */
     protected AffineTransform transform = new AffineTransform();
+
     private final Transform swtTransform;
+
     /** The current font to use when drawing text. */
     protected org.eclipse.swt.graphics.Font curFont;
+
     /** The current stroke width to use when drawing lines. */
     protected double lineWidth = 1.0;

@@ -345,7 +354,7 @@

     /** {...@inheritdoc} */
     public void setFont(final Font font) {
-        // TODO:  prevent NPE
+        // TODO: prevent NPE
final String fontString = "name=" + font.getFamily() + ";bold=" + font.isBold() + ";italic=" + font.isItalic()
                 + ";size=" + font.getSize();

@@ -354,7 +363,7 @@

     /**
      * Set the font for this SWTGraphics2D to <code>font</code>.
-     *
+     *
      * @param font font for this SWTGraphics2D
      */
     public void setFont(final org.eclipse.swt.graphics.Font font) {
@@ -393,7 +402,7 @@
             FONT_CACHE.put(fontString, cachedFont);
         }
         return cachedFont;
-    }
+    }

     // /////////////////////////
     // AFFINE TRANSFORM METHODS
@@ -585,7 +594,7 @@

     /**
      * Draw a polyline from the specified double array of points.
-     *
+     *
      * @param pts double array of points
      */
     public void drawPolyline(final double[] pts) {
@@ -608,7 +617,7 @@

     /**
      * Fill a polyline from the specified double array of points.
-     *
+     *
      * @param pts double array of points
      */
     public void fillPolygon(final double[] pts) {
@@ -1179,7 +1188,7 @@
         SWTShapeManager.awtToSWT(TEMP_RECT, SWT_RECT);

gc.fillGradientRectangle(SWT_RECT.x, SWT_RECT.y, SWT_RECT.width, SWT_RECT.height, vertical);
-    }
+    }

     /**
* Returns the advance width of the character provided in the current font.
=======================================
--- /piccolo2d.java/branches/2.0-spike/swt/src/main/java/org/piccolo2d/swt/SWTShapeManager.java Tue Jan 19 12:39:24 2010 +++ /piccolo2d.java/branches/2.0-spike/swt/src/main/java/org/piccolo2d/swt/SWTShapeManager.java Tue Jan 19 13:09:08 2010
@@ -43,10 +43,10 @@
  * @author Lance Good
  */
 public class SWTShapeManager {
-    private static AffineTransform IDENTITY_XFORM = new AffineTransform();
-    private static Point2D aPoint = new Point2D.Double();
-    private static ArrayList segList = new ArrayList();
-    private static double[] pts = new double[8];
+ private static final AffineTransform IDENTITY_XFORM = new AffineTransform();
+    private static final Point2D aPoint = new Point2D.Double();
+    private static final ArrayList segList = new ArrayList();
+    private static final double[] pts = new double[8];

     /**
* Apply the specified transform to the specified rectangle, modifying the
-- 
Piccolo2D Developers Group: http://groups.google.com/group/piccolo2d-dev?hl=en

Reply via email to