Revision: 744
Author: allain.lalonde
Date: Mon Oct 19 09:11:29 2009
Log: CheckStyle fixes on SWT.
http://code.google.com/p/piccolo2d/source/detail?r=744

Modified:
  /piccolo2d.java/trunk/swt/src/build/conf/checkstyle.xml
   
/piccolo2d.java/trunk/swt/src/main/java/edu/umd/cs/piccolox/swt/PSWTCanvas.java
   
/piccolo2d.java/trunk/swt/src/main/java/edu/umd/cs/piccolox/swt/PSWTHandle.java
   
/piccolo2d.java/trunk/swt/src/main/java/edu/umd/cs/piccolox/swt/PSWTKeyEvent.java
   
/piccolo2d.java/trunk/swt/src/main/java/edu/umd/cs/piccolox/swt/PSWTMouseEvent.java
   
/piccolo2d.java/trunk/swt/src/main/java/edu/umd/cs/piccolox/swt/PSWTRoot.java
   
/piccolo2d.java/trunk/swt/src/main/java/edu/umd/cs/piccolox/swt/PSWTSelectionEventHandler.java
   
/piccolo2d.java/trunk/swt/src/main/java/edu/umd/cs/piccolox/swt/PSWTStickyHandleManager.java
   
/piccolo2d.java/trunk/swt/src/main/java/edu/umd/cs/piccolox/swt/SWTShapeManager.java
   
/piccolo2d.java/trunk/swt/src/main/java/edu/umd/cs/piccolox/swt/SWTTimer.java
   
/piccolo2d.java/trunk/swt/src/main/java/edu/umd/cs/piccolox/swt/SWTTimerQueue.java

=======================================
--- /piccolo2d.java/trunk/swt/src/build/conf/checkstyle.xml     Fri Oct  9  
10:19:05 2009
+++ /piccolo2d.java/trunk/swt/src/build/conf/checkstyle.xml     Mon Oct 19  
09:11:29 2009
@@ -3,174 +3,167 @@
      "-//Puppy Crawl//DTD Check Configuration 1.2//EN"
      "http://www.puppycrawl.com/dtds/configuration_1_2.dtd";>

-<!--
-
-  Checkstyle configuration that checks the sun coding conventions from:
-
-    - the Java Language Specification at
-      http://java.sun.com/docs/books/jls/second_edition/html/index.html
-
-    - the Sun Code Conventions at http://java.sun.com/docs/codeconv/
-
-    - the Javadoc guidelines at
-      http://java.sun.com/j2se/javadoc/writingdoccomments/index.html
-
-    - the JDK Api documentation  
http://java.sun.com/j2se/docs/api/index.html
-
-    - some best practices
-
-  Checkstyle is very configurable. Be sure to read the documentation at
-  http://checkstyle.sf.net (or in your downloaded distribution).
-
-  Most Checks are configurable, be sure to consult the documentation.
-
-  To completely disable a check, just comment it out or delete it from the  
file.
-
-  Finally, it is worth reading the documentation.
-
--->
+       <!--
+
+               Checkstyle configuration that checks the sun coding conventions 
from:
+
+               - the Java Language Specification at
+               
http://java.sun.com/docs/books/jls/second_edition/html/index.html -
+               the Sun Code Conventions at http://java.sun.com/docs/codeconv/ 
- the
+               Javadoc guidelines at
+               http://java.sun.com/j2se/javadoc/writingdoccomments/index.html 
- the
+               JDK Api documentation 
http://java.sun.com/j2se/docs/api/index.html -
+               some best practices Checkstyle is very configurable. Be sure to 
read
+               the documentation at http://checkstyle.sf.net (or in your 
downloaded
+               distribution). Most Checks are configurable, be sure to consult 
the
+               documentation. To completely disable a check, just comment it 
out or
+               delete it from the file. Finally, it is worth reading the
+               documentation.
+       -->

  <module name="Checker">

-    <!-- Checks that a package.html file exists for each package.     -->
-    <!-- See http://checkstyle.sf.net/config_javadoc.html#PackageHtml -->
-    <module name="PackageHtml"/>
-
-    <!-- Checks that property files contain the same keys.         -->
-    <!-- See http://checkstyle.sf.net/config_misc.html#Translation -->
-    <module name="Translation"/>
+       <!-- Checks that a package.html file exists for each package.     -->
+       <!-- See http://checkstyle.sf.net/config_javadoc.html#PackageHtml -->
+       <module name="PackageHtml" />
+
+       <!-- Checks that property files contain the same keys.         -->
+       <!-- See http://checkstyle.sf.net/config_misc.html#Translation -->
+       <module name="Translation" />


-    <module name="TreeWalker">
-
-        <!-- Checks for Javadoc comments.                     -->
-        <!-- See http://checkstyle.sf.net/config_javadoc.html -->
-        <module name="JavadocMethod">
-               <property name="scope" value="protected"/>
-        </module>
-        <module name="JavadocType">
-               <property name="scope" value="public"/>
-        </module>
-        <module name="JavadocVariable">
-            <property name="scope" value="protected" />
-        </module>
-        <module name="JavadocStyle"/>
+       <module name="TreeWalker">
+
+               <!-- Checks for Javadoc comments.                     -->
+               <!-- See http://checkstyle.sf.net/config_javadoc.html -->
+               <module name="JavadocMethod">
+                       <property name="scope" value="protected" />
+               </module>
+               <module name="JavadocType">
+                       <property name="scope" value="public" />
+               </module>
+               <module name="JavadocVariable">
+                       <property name="scope" value="protected" />
+               </module>
+               <module name="JavadocStyle" />


-        <!-- Checks for Naming Conventions.                  -->
-        <!-- See http://checkstyle.sf.net/config_naming.html -->
-        <module name="ConstantName"/>
-        <module name="LocalFinalVariableName"/>
-        <module name="LocalVariableName"/>
-        <module name="MemberName"/>
-        <module name="MethodName"/>
-        <module name="PackageName"/>
-        <module name="ParameterName"/>
-        <module name="StaticVariableName"/>
-        <module name="TypeName"/>
+               <!-- Checks for Naming Conventions.                  -->
+               <!-- See http://checkstyle.sf.net/config_naming.html -->
+               <module name="ConstantName" />
+               <module name="LocalFinalVariableName" />
+               <module name="LocalVariableName" />
+               <module name="MemberName" />
+               <module name="MethodName" />
+               <module name="PackageName" />
+               <module name="ParameterName" />
+               <module name="StaticVariableName" />
+               <module name="TypeName" />


-        <!-- Checks for Headers                                -->
-        <!-- See http://checkstyle.sf.net/config_header.html   -->
-        <!-- <module name="Header">                            -->
-            <!-- The follow property value demonstrates the ability     -->
-            <!-- to have access to ANT properties. In this case it uses -->
-            <!-- the ${basedir} property to allow Checkstyle to be run  -->
-            <!-- from any directory within a project. See property      -->
-            <!-- expansion,                                             -->
-            <!-- http://checkstyle.sf.net/config.html#properties        -->
-            <!-- <property                                              -->
-            <!--     name="headerFile"                                  -->
-            <!--     value="${basedir}/java.header"/>                   -->
-        <!-- </module> -->
-
-        <!-- Following interprets the header file as regular expressions.  
-->
-        <!-- <module name="RegexpHeader"/>                                 
-->
+               <!-- Checks for Headers                                -->
+               <!-- See http://checkstyle.sf.net/config_header.html   -->
+               <!-- <module name="Header">                            -->
+               <!-- The follow property value demonstrates the ability     -->
+               <!-- to have access to ANT properties. In this case it uses -->
+               <!-- the ${basedir} property to allow Checkstyle to be run  -->
+               <!-- from any directory within a project. See property      -->
+               <!-- expansion,                                             -->
+               <!-- http://checkstyle.sf.net/config.html#properties        -->
+               <!-- <property                                              -->
+               <!--     name="headerFile"                                  -->
+               <!--     value="${basedir}/java.header"/>                   -->
+               <!-- </module> -->
+
+               <!-- Following interprets the header file as regular 
expressions. -->
+               <!-- <module name="RegexpHeader"/>                              
  -->


-        <!-- Checks for imports                              -->
-        <!-- See http://checkstyle.sf.net/config_import.html -->
-        <module name="AvoidStarImport"/>
-        <module name="IllegalImport"/> <!-- defaults to sun.* packages -->
-        <module name="RedundantImport"/>
-        <module name="UnusedImports"/>
+               <!-- Checks for imports                              -->
+               <!-- See http://checkstyle.sf.net/config_import.html -->
+               <module name="AvoidStarImport" />
+               <module name="IllegalImport" /> <!-- defaults to sun.* packages 
-->
+               <module name="RedundantImport" />
+               <module name="UnusedImports" />


-        <!-- Checks for Size Violations.                    -->
-        <!-- See http://checkstyle.sf.net/config_sizes.html -->
-        <module name="FileLength"/>
-        <module name="LineLength">
-            <property name="max" value="120"/>
-        </module>
-        <module name="MethodLength"/>
-        <module name="ParameterNumber"/>
+               <!-- Checks for Size Violations.                    -->
+               <!-- See http://checkstyle.sf.net/config_sizes.html -->
+               <module name="FileLength" />
+               <module name="LineLength">
+                       <property name="max" value="120" />
+               </module>
+               <module name="MethodLength" />
+               <module name="ParameterNumber" />


-        <!-- Checks for whitespace                               -->
-        <!-- See http://checkstyle.sf.net/config_whitespace.html -->
-        <module name="EmptyForIteratorPad"/>
-        <module name="MethodParamPad"/>
-        <module name="NoWhitespaceAfter"/>
-        <module name="NoWhitespaceBefore"/>
-        <module name="OperatorWrap"/>
-        <module name="ParenPad"/>
-        <module name="TypecastParenPad"/>
-        <module name="TabCharacter"/>
-        <module name="WhitespaceAfter"/>
-        <module name="WhitespaceAround"/>
+               <!-- Checks for whitespace                               -->
+               <!-- See http://checkstyle.sf.net/config_whitespace.html -->
+               <module name="EmptyForIteratorPad" />
+               <module name="MethodParamPad" />
+               <module name="NoWhitespaceAfter" />
+               <module name="NoWhitespaceBefore" />
+               <module name="OperatorWrap" />
+               <module name="ParenPad" />
+               <module name="TypecastParenPad" />
+               <module name="TabCharacter" />
+               <module name="WhitespaceAfter" />
+               <module name="WhitespaceAround" />


-        <!-- Modifier Checks                                    -->
-        <!-- See http://checkstyle.sf.net/config_modifiers.html -->
-        <module name="ModifierOrder"/>
-        <module name="RedundantModifier"/>
+               <!-- Modifier Checks                                    -->
+               <!-- See http://checkstyle.sf.net/config_modifiers.html -->
+               <module name="ModifierOrder" />
+               <module name="RedundantModifier" />


-        <!-- Checks for blocks. You know, those {}'s         -->
-        <!-- See http://checkstyle.sf.net/config_blocks.html -->
-        <module name="AvoidNestedBlocks"/>
-        <module name="EmptyBlock"/>
-        <module name="LeftCurly"/>
-        <module name="NeedBraces"/>
-        <module name="RightCurly">
-            <property name="option" value="alone"/>
-        </module>
+               <!-- Checks for blocks. You know, those {}'s         -->
+               <!-- See http://checkstyle.sf.net/config_blocks.html -->
+               <module name="AvoidNestedBlocks" />
+               <module name="EmptyBlock" />
+               <module name="LeftCurly" />
+               <module name="NeedBraces" />
+               <module name="RightCurly">
+                       <property name="option" value="alone" />
+               </module>


-        <!-- Checks for common coding problems               -->
-        <!-- See http://checkstyle.sf.net/config_coding.html -->
-        <module name="AvoidInlineConditionals"/>
-        <module name="DoubleCheckedLocking"/>    <!-- MY FAVOURITE -->
-        <module name="EmptyStatement"/>
-        <module name="EqualsHashCode"/>
-        <module name="HiddenField">
-               <property name="ignoreConstructorParameter" value="true"/>
-               <property name="ignoreSetter" value="true"/>
-        </module>
-        <module name="IllegalInstantiation"/>
-        <module name="InnerAssignment"/>
-        <module name="MagicNumber"/>
-        <module name="MissingSwitchDefault"/>
-        <module name="RedundantThrows"/>
-        <module name="SimplifyBooleanExpression"/>
-        <module name="SimplifyBooleanReturn"/>
-
-        <!-- Checks for class design                         -->
-        <!-- See http://checkstyle.sf.net/config_design.html -->
-        <!-- For P2d 2.0: <module name="DesignForExtension"/> -->
-        <module name="FinalClass"/>
-        <module name="HideUtilityClassConstructor"/>
-        <module name="InterfaceIsType"/>
-        <!-- For P2d 2.0: <module name="VisibilityModifier"/> -->
+               <!-- Checks for common coding problems               -->
+               <!-- See http://checkstyle.sf.net/config_coding.html -->
+               <module name="AvoidInlineConditionals" />
+               <module name="DoubleCheckedLocking" />    <!-- MY FAVOURITE -->
+               <module name="EmptyStatement" />
+               <module name="EqualsHashCode" />
+               <module name="HiddenField">
+                       <property name="ignoreConstructorParameter" 
value="true" />
+                       <property name="ignoreSetter" value="true" />
+               </module>
+               <module name="IllegalInstantiation" />
+               <module name="InnerAssignment" />
+               <module name="MagicNumber">
+                       <property name="ignoreNumbers" value="0, 0.5, 2, 1, -1, 
1000" />
+               </module>
+               <module name="MissingSwitchDefault" />
+               <module name="RedundantThrows" />
+               <module name="SimplifyBooleanExpression" />
+               <module name="SimplifyBooleanReturn" />
+
+               <!-- Checks for class design                         -->
+               <!-- See http://checkstyle.sf.net/config_design.html -->
+               <!-- For P2d 2.0: <module name="DesignForExtension"/> -->
+               <module name="FinalClass" />
+               <module name="HideUtilityClassConstructor" />
+               <module name="InterfaceIsType" />
+               <!-- For P2d 2.0: <module name="VisibilityModifier"/> -->


-        <!-- Miscellaneous other checks.                   -->
-        <!-- See http://checkstyle.sf.net/config_misc.html -->
-        <module name="ArrayTypeStyle"/>
-        <module name="FinalParameters"/>
-        <module name="TodoComment"/>
-        <module name="UpperEll"/>
-
-    </module>
+               <!-- Miscellaneous other checks.                   -->
+               <!-- See http://checkstyle.sf.net/config_misc.html -->
+               <module name="ArrayTypeStyle" />
+               <module name="FinalParameters" />
+               <module name="TodoComment" />
+               <module name="UpperEll" />
+
+       </module>

  </module>
=======================================
---  
/piccolo2d.java/trunk/swt/src/main/java/edu/umd/cs/piccolox/swt/PSWTCanvas.java 
 
Mon Oct 19 08:03:51 2009
+++  
/piccolo2d.java/trunk/swt/src/main/java/edu/umd/cs/piccolox/swt/PSWTCanvas.java 
 
Mon Oct 19 09:11:29 2009
@@ -72,6 +72,10 @@
   * @author Jesse Grosjean
   */
  public class PSWTCanvas extends Composite implements PComponent {
+    private static final int SWT_BUTTON1 = 1;
+    private static final int SWT_BUTTON2 = 2;
+    private static final int SWT_BUTTON3 = 3;
+
      /**
       * Terrible Singleton instance of the PSWTCanvas. Falsely assumes you  
will
       * only have one of these per application.
@@ -505,11 +509,13 @@
      }

      private boolean backBufferNeedsResizing(final int newWidth, final int  
newHeight) {
-        if (!doubleBuffered)
+        if (!doubleBuffered) {
              return false;
-
-        if (backBuffer == null)
+        }
+
+        if (backBuffer == null) {
              return true;
+        }

          return backBuffer.getBounds().width < newWidth ||  
backBuffer.getBounds().height < newHeight;
      }
@@ -655,19 +661,19 @@
              boolean shouldBalanceEvent = false;

              switch (mouseEvent.button) {
-                case 1:
+                case SWT_BUTTON1:
                      if (isButton1Pressed) {
                          shouldBalanceEvent = true;
                      }
                      isButton1Pressed = true;
                      break;
-                case 2:
+                case SWT_BUTTON2:
                      if (isButton2Pressed) {
                          shouldBalanceEvent = true;
                      }
                      isButton2Pressed = true;
                      break;
-                case 3:
+                case SWT_BUTTON3:
                      if (isButton3Pressed) {
                          shouldBalanceEvent = true;
                      }
@@ -691,19 +697,19 @@
              boolean shouldBalanceEvent = false;

              switch (me.button) {
-                case 1:
+                case SWT_BUTTON1:
                      if (!isButton1Pressed) {
                          shouldBalanceEvent = true;
                      }
                      isButton1Pressed = false;
                      break;
-                case 2:
+                case SWT_BUTTON2:
                      if (!isButton2Pressed) {
                          shouldBalanceEvent = true;
                      }
                      isButton2Pressed = false;
                      break;
-                case 3:
+                case SWT_BUTTON3:
                      if (!isButton3Pressed) {
                          shouldBalanceEvent = true;
                      }
=======================================
---  
/piccolo2d.java/trunk/swt/src/main/java/edu/umd/cs/piccolox/swt/PSWTHandle.java 
 
Fri Oct 16 12:15:32 2009
+++  
/piccolo2d.java/trunk/swt/src/main/java/edu/umd/cs/piccolox/swt/PSWTHandle.java 
 
Mon Oct 19 09:11:29 2009
@@ -59,13 +59,12 @@
   * @author Jesse Grosjean
   */
  public class PSWTHandle extends PSWTPath {
-
-    /**
-     *
-     */
      private static final long serialVersionUID = 1L;
+    /** The Default Size of a handle not including its border. */
      public static float DEFAULT_HANDLE_SIZE = 8;
+    /** The default shape to use when drawing handles. Default is an  
ellipse. */
      public static Shape DEFAULT_HANDLE_SHAPE = new Ellipse2D.Float(0f, 0f,  
DEFAULT_HANDLE_SIZE, DEFAULT_HANDLE_SIZE);
+    /** The default color to use when drawing a handle. (white) */
      public static Color DEFAULT_COLOR = Color.white;

      private PLocator locator;
@@ -74,6 +73,8 @@
      /**
       * Construct a new handle that will use the given locator to locate  
itself
       * on its parent node.
+     *
+     * @param aLocator locator to use when positioning this handle
       */
      public PSWTHandle(final PLocator aLocator) {
          super(DEFAULT_HANDLE_SHAPE);
@@ -82,26 +83,12 @@
          installHandleEventHandlers();
      }

+    /**
+     * Installs the handler that will reposition the handle when it is  
dragged,
+     * and invoke appropriate call backs.
+     */
      protected void installHandleEventHandlers() {
-        handleDragger = new PDragSequenceEventHandler() {
-            protected void startDrag(final PInputEvent event) {
-                super.startDrag(event);
-                 
startHandleDrag(event.getPositionRelativeTo(PSWTHandle.this), event);
-            }
-
-            protected void drag(final PInputEvent event) {
-                super.drag(event);
-                final PDimension aDelta =  
event.getDeltaRelativeTo(PSWTHandle.this);
-                if (aDelta.getWidth() != 0 || aDelta.getHeight() != 0) {
-                    dragHandle(aDelta, event);
-                }
-            }
-
-            protected void endDrag(final PInputEvent event) {
-                super.endDrag(event);
-                 
endHandleDrag(event.getPositionRelativeTo(PSWTHandle.this), event);
-            }
-        };
+        handleDragger = new HandleDragHandler();

          addPropertyChangeListener(PNode.PROPERTY_TRANSFORM, new  
PropertyChangeListener() {
              public void propertyChange(final PropertyChangeEvent evt) {
@@ -109,12 +96,6 @@
              }
          });

-        handleDragger.setEventFilter(new  
PInputEventFilter(InputEvent.BUTTON1_MASK));
-         
handleDragger.getEventFilter().setMarksAcceptedEventsAsHandled(true);
-        handleDragger.getEventFilter().setAcceptsMouseEntered(false);
-        handleDragger.getEventFilter().setAcceptsMouseExited(false);
-        // no need for moved events for handle interaction,
-        handleDragger.getEventFilter().setAcceptsMouseMoved(false);
          // so reject them so we don't consume them
          addInputEventListener(handleDragger);
      }
@@ -122,6 +103,8 @@
      /**
       * Return the event handler that is responsible for the drag handle
       * interaction.
+     *
+     * @return handler responsible for responding to drag events
       */
      public PDragSequenceEventHandler getHandleDraggerHandler() {
          return handleDragger;
@@ -130,6 +113,8 @@
      /**
       * Get the locator that this handle uses to position itself on its  
parent
       * node.
+     *
+     * @return locator used to position this handle
       */
      public PLocator getLocator() {
          return locator;
@@ -138,6 +123,8 @@
      /**
       * Set the locator that this handle uses to position itself on its  
parent
       * node.
+     *
+     * @param aLocator used to position this handle
       */
      public void setLocator(final PLocator aLocator) {
          locator = aLocator;
@@ -153,12 +140,20 @@
      /**
       * Override this method to get notified when the handle starts to get
       * dragged.
+     *
+     * @param aLocalPoint point at which dragging was started relative to  
the
+     *            handle's coordinate system
+     * @param aEvent event representing the start of the drag
       */
      public void startHandleDrag(final Point2D aLocalPoint, final  
PInputEvent aEvent) {
      }

      /**
       * Override this method to get notified as the handle is dragged.
+     *
+     * @param aLocalDimension magnitude of the dragHandle event in the
+     *            dimensions of the handle's coordinate system.
+     * @param aEvent event representing the drag
       */
      public void dragHandle(final PDimension aLocalDimension, final  
PInputEvent aEvent) {
      }
@@ -166,6 +161,10 @@
      /**
       * Override this method to get notified when the handle stops getting
       * dragged.
+     *
+     * @param aLocalPoint point at which dragging was ended relative to the
+     *            handle's coordinate system
+     * @param aEvent event representing the end of the drag
       */
      public void endHandleDrag(final Point2D aLocalPoint, final PInputEvent  
aEvent) {
      }
@@ -179,7 +178,7 @@

      /** {...@inheritdoc} */
      public void setParent(final PNode newParent) {
-        super.setParent(newParent);
+        super.setParent(newParent);
          relocateHandle();
      }

@@ -225,4 +224,33 @@
          in.defaultReadObject();
          installHandleEventHandlers();
      }
-}
+
+    private final class HandleDragHandler extends  
PDragSequenceEventHandler {
+        public HandleDragHandler() {
+            final PInputEventFilter filter = new  
PInputEventFilter(InputEvent.BUTTON1_MASK);
+            setEventFilter(filter);
+            filter.setMarksAcceptedEventsAsHandled(true);
+            filter.setAcceptsMouseEntered(false);
+            filter.setAcceptsMouseExited(false);
+            filter.setAcceptsMouseMoved(false);
+        }
+
+        protected void startDrag(final PInputEvent event) {
+            super.startDrag(event);
+            startHandleDrag(event.getPositionRelativeTo(PSWTHandle.this),  
event);
+        }
+
+        protected void drag(final PInputEvent event) {
+            super.drag(event);
+            final PDimension aDelta =  
event.getDeltaRelativeTo(PSWTHandle.this);
+            if (aDelta.getWidth() != 0 || aDelta.getHeight() != 0) {
+                dragHandle(aDelta, event);
+            }
+        }
+
+        protected void endDrag(final PInputEvent event) {
+            super.endDrag(event);
+            endHandleDrag(event.getPositionRelativeTo(PSWTHandle.this),  
event);
+        }
+    }
+}
=======================================
---  
/piccolo2d.java/trunk/swt/src/main/java/edu/umd/cs/piccolox/swt/PSWTKeyEvent.java
        
Tue Jul 28 12:46:54 2009
+++  
/piccolo2d.java/trunk/swt/src/main/java/edu/umd/cs/piccolox/swt/PSWTKeyEvent.java
        
Mon Oct 19 09:11:29 2009
@@ -37,49 +37,52 @@
  import org.eclipse.swt.widgets.Widget;

  /**
- * Overridden to wrap an SWT KeyEvent
+ * Overridden to wrap an SWT KeyEvent as a swing KeyEvent.
   *
   * @author Lance Good
   */
  public class PSWTKeyEvent extends KeyEvent {
-
-    /**
-     *
-     */
      private static final long serialVersionUID = 1L;

-    static Component fakeSrc = new Component() {
-
-        /**
-         *
-         */
-        private static final long serialVersionUID = 1L;
+    private static Component fakeSrc = new Component() {
      };

-    org.eclipse.swt.events.KeyEvent swtEvent;
-
+    private org.eclipse.swt.events.KeyEvent swtEvent;
+
+    /**
+     * Creates an object that wraps a SWT Key event. Making it queriable  
from
+     * Piccolo2d as though it were a Swing one.
+     *
+     * @param ke key event object
+     * @param eventType type of key event
+     */
      public PSWTKeyEvent(final org.eclipse.swt.events.KeyEvent ke, final  
int eventType) {
          super(fakeSrc, eventType, ke.time, 0, ke.keyCode, ke.character,  
KeyEvent.KEY_LOCATION_STANDARD);

          swtEvent = ke;
      }

+    /** {...@inheritdoc} */
      public Object getSource() {
          return swtEvent.getSource();
      }

+    /** {...@inheritdoc} */
      public boolean isShiftDown() {
          return (swtEvent.stateMask & SWT.SHIFT) != 0;
      }

+    /** {...@inheritdoc} */
      public boolean isControlDown() {
          return (swtEvent.stateMask & SWT.CONTROL) != 0;
      }

+    /** {...@inheritdoc} */
      public boolean isAltDown() {
          return (swtEvent.stateMask & SWT.ALT) != 0;
      }

+    /** {...@inheritdoc} */
      public int getModifiers() {
          int modifiers = 0;

@@ -98,6 +101,7 @@
          return modifiers;
      }

+    /** {...@inheritdoc} */
      public int getModifiersEx() {
          int modifiers = 0;

@@ -116,22 +120,34 @@
          return modifiers;
      }

+    /** {...@inheritdoc} */
      public boolean isActionKey() {
          return false;
      }

-    // /////////////////////////
-    // THE SWT SPECIFIC EVENTS
-    // /////////////////////////
-
+    /**
+     * Returns the widget from which the event was emitted.
+     *
+     * @return source widget
+     */
      public Widget getWidget() {
          return swtEvent.widget;
      }

+    /**
+     * Return the display on which the interaction occurred.
+     *
+     * @return display on which the interaction occurred
+     */
      public Display getDisplay() {
          return swtEvent.display;
      }

+    /**
+     * Return the associated SWT data for the event.
+     *
+     * @return data associated to the SWT event
+     */
      public Object getData() {
          return swtEvent.data;
      }
=======================================
---  
/piccolo2d.java/trunk/swt/src/main/java/edu/umd/cs/piccolox/swt/PSWTMouseEvent.java
      
Tue Jul 28 12:46:54 2009
+++  
/piccolo2d.java/trunk/swt/src/main/java/edu/umd/cs/piccolox/swt/PSWTMouseEvent.java
      
Mon Oct 19 09:11:29 2009
@@ -37,69 +37,81 @@
  import org.eclipse.swt.widgets.Widget;

  /**
- * Overridden to wrap an SWT MouseEvent
+ * Overridden to wrap an SWT MouseEvent as a Swing MouseEvent.
   *
   * @author Lance Good
   */
  public class PSWTMouseEvent extends MouseEvent {
-
-    /**
-     *
-     */
+    private static final int SWT_BUTTON1 = 1;
+    private static final int SWT_BUTTON2 = 2;
+    private static final int SWT_BUTTON3 = 3;
+
      private static final long serialVersionUID = 1L;

-    static Component fakeSrc = new Component() {
-
-        /**
-         *
-         */
-        private static final long serialVersionUID = 1L;
+    private static Component fakeSrc = new Component() {
      };

+    /** Event being wrapped. */
      protected org.eclipse.swt.events.MouseEvent swtEvent;

+    /** Number times the mouse was clicked in relation to the wrapped  
event. */
      protected int clickCount;

+    /**
+     * Constructs a PSWTMouseEvent that wraps the provided SWT MouseEvent  
as a
+     * Swing one.
+     *
+     * @param me Mouse Event being wrapped
+     * @param type event type
+     * @param clickCount number of times the mouse has been clicked
+     */
      public PSWTMouseEvent(final org.eclipse.swt.events.MouseEvent me,  
final int type, final int clickCount) {
-        super(fakeSrc, type, me.time, 0, me.x, me.y, clickCount, me.button  
== 3, me.button);
+        super(fakeSrc, type, me.time, 0, me.x, me.y, clickCount, me.button  
== SWT_BUTTON3, me.button);

          swtEvent = me;
          this.clickCount = clickCount;
      }

+    /** {...@inheritdoc} */
      public Object getSource() {
          return swtEvent.getSource();
      }

+    /** {...@inheritdoc} */
      public int getClickCount() {
          return clickCount;
      }

+    /** {...@inheritdoc} */
      public int getButton() {
          switch (swtEvent.button) {
-            case 1:
+            case SWT_BUTTON1:
                  return MouseEvent.BUTTON1;
-            case 2:
+            case SWT_BUTTON2:
                  return MouseEvent.BUTTON2;
-            case 3:
+            case SWT_BUTTON3:
                  return MouseEvent.BUTTON3;
              default:
                  return MouseEvent.NOBUTTON;
          }
      }

+    /** {...@inheritdoc} */
      public boolean isShiftDown() {
          return (swtEvent.stateMask & SWT.SHIFT) != 0;
      }

+    /** {...@inheritdoc} */
      public boolean isControlDown() {
          return (swtEvent.stateMask & SWT.CONTROL) != 0;
      }

+    /** {...@inheritdoc} */
      public boolean isAltDown() {
          return (swtEvent.stateMask & SWT.ALT) != 0;
      }

+    /** {...@inheritdoc} */
      public int getModifiers() {
          int modifiers = 0;

@@ -113,13 +125,13 @@
              if ((swtEvent.stateMask & SWT.SHIFT) != 0) {
                  modifiers = modifiers | InputEvent.SHIFT_MASK;
              }
-            if (swtEvent.button == 1 || (swtEvent.stateMask &  
SWT.BUTTON1) != 0) {
+            if (swtEvent.button == SWT_BUTTON1 || (swtEvent.stateMask &  
SWT.BUTTON1) != 0) {
                  modifiers = modifiers | InputEvent.BUTTON1_MASK;
              }
-            if (swtEvent.button == 2 || (swtEvent.stateMask &  
SWT.BUTTON2) != 0) {
+            if (swtEvent.button == SWT_BUTTON2 || (swtEvent.stateMask &  
SWT.BUTTON2) != 0) {
                  modifiers = modifiers | InputEvent.BUTTON2_MASK;
              }
-            if (swtEvent.button == 3 || (swtEvent.stateMask &  
SWT.BUTTON3) != 0) {
+            if (swtEvent.button == SWT_BUTTON3 || (swtEvent.stateMask &  
SWT.BUTTON3) != 0) {
                  modifiers = modifiers | InputEvent.BUTTON3_MASK;
              }
          }
@@ -127,6 +139,7 @@
          return modifiers;
      }

+    /** {...@inheritdoc} */
      public int getModifiersEx() {
          int modifiers = 0;

@@ -140,13 +153,13 @@
              if ((swtEvent.stateMask & SWT.SHIFT) != 0) {
                  modifiers = modifiers | InputEvent.SHIFT_DOWN_MASK;
              }
-            if (swtEvent.button == 1 || (swtEvent.stateMask &  
SWT.BUTTON1) != 0) {
+            if (swtEvent.button == SWT_BUTTON1 || (swtEvent.stateMask &  
SWT.BUTTON1) != 0) {
                  modifiers = modifiers | InputEvent.BUTTON1_DOWN_MASK;
              }
-            if (swtEvent.button == 2 || (swtEvent.stateMask &  
SWT.BUTTON2) != 0) {
+            if (swtEvent.button == SWT_BUTTON2 || (swtEvent.stateMask &  
SWT.BUTTON2) != 0) {
                  modifiers = modifiers | InputEvent.BUTTON2_DOWN_MASK;
              }
-            if (swtEvent.button == 3 || (swtEvent.stateMask &  
SWT.BUTTON3) != 0) {
+            if (swtEvent.button == SWT_BUTTON3 || (swtEvent.stateMask &  
SWT.BUTTON3) != 0) {
                  modifiers = modifiers | InputEvent.BUTTON3_DOWN_MASK;
              }
          }
@@ -154,18 +167,29 @@
          return modifiers;
      }

-    // /////////////////////////
-    // THE SWT SPECIFIC EVENTS
-    // /////////////////////////
-
+    /**
+     * Returns the widget from which the event was emitted.
+     *
+     * @return source widget
+     */
      public Widget getWidget() {
          return swtEvent.widget;
      }

+    /**
+     * Return the display on which the interaction occurred.
+     *
+     * @return display on which the interaction occurred
+     */
      public Display getDisplay() {
          return swtEvent.display;
      }

+    /**
+     * Return the associated SWT data for the event.
+     *
+     * @return data associated to the SWT event
+     */
      public Object getData() {
          return swtEvent.data;
      }
=======================================
---  
/piccolo2d.java/trunk/swt/src/main/java/edu/umd/cs/piccolox/swt/PSWTRoot.java   
 
Tue Jul 28 12:46:54 2009
+++  
/piccolo2d.java/trunk/swt/src/main/java/edu/umd/cs/piccolox/swt/PSWTRoot.java   
 
Mon Oct 19 09:11:29 2009
@@ -47,21 +47,33 @@
   * @author Jesse Grosjean
   */
  public class PSWTRoot extends PRoot {
+    private static final long serialVersionUID = 1L;
+    private final Composite composite;

      /**
+     * Constructs a PSWTRoot attached to the provided composite.
       *
+     * @param composite composite PSWTRoot is responsible for
       */
-    private static final long serialVersionUID = 1L;
-    private final Composite composite;
-
      public PSWTRoot(final Composite composite) {
          this.composite = composite;
      }

+    /**
+     * Creates a timer that will fire the listener every delay  
milliseconds.
+     *
+     * @param delay time in milliseconds between firings of listener
+     * @param listener listener to be fired
+     *
+     * @return the created timer
+     */
      public Timer createTimer(final int delay, final ActionListener  
listener) {
          return new SWTTimer(composite.getDisplay(), delay, listener);
      }

+    /**
+     * Processes Inputs if any kind of IO needs to be done.
+     */
      public void scheduleProcessInputsIfNeeded() {
          if  
(!Thread.currentThread().equals(composite.getDisplay().getThread())) {
              return;
=======================================
---  
/piccolo2d.java/trunk/swt/src/main/java/edu/umd/cs/piccolox/swt/PSWTSelectionEventHandler.java
   
Tue Jul 28 12:46:54 2009
+++  
/piccolo2d.java/trunk/swt/src/main/java/edu/umd/cs/piccolox/swt/PSWTSelectionEventHandler.java
   
Mon Oct 19 09:11:29 2009
@@ -43,7 +43,7 @@
  import edu.umd.cs.piccolox.event.PSelectionEventHandler;

  /**
- * Modified to use SWT paths instead of normal paths
+ * Modified to use SWT paths instead of normal paths.
   *
   * @version 1.0
   * @author Lance Good
@@ -81,20 +81,32 @@
          this.marqueeParent = marqueeParent;
      }

+    /**
+     * Modifies the provided node so that it is displayed as selected.
+     *
+     * @param node node to be decorated
+     */
      public void decorateSelectedNode(final PNode node) {
          PSWTBoundsHandle.addBoundsHandlesTo(node);
      }

+    /**
+     * Undoes any modifications to the provided node so that it is not  
displayed as selected.
+     *
+     * @param node node to be undecorated
+     */
      public void undecorateSelectedNode(final PNode node) {
          PSWTBoundsHandle.removeBoundsHandlesFrom(node);
      }

+    /** {...@inheritdoc} */
      protected void initializeSelection(final PInputEvent pie) {
          super.initializeSelection(pie);
          pressPt = pie.getPosition();
          canvasPressPt = pie.getCanvasPosition();
      }

+    /** {...@inheritdoc} */
      protected void initializeMarquee(final PInputEvent e) {
          super.initializeMarquee(e);

@@ -116,6 +128,7 @@
          marqueeParent.addChild(marquee);
      }

+    /** {...@inheritdoc} */
      protected void updateMarquee(final PInputEvent pie) {
          super.updateMarquee(pie);

@@ -136,6 +149,7 @@
          b.add(pie.getPosition());
      }

+    /** {...@inheritdoc} */
      protected PBounds getMarqueeBounds() {
          if (marquee != null) {
              return marquee.getBounds();
@@ -143,18 +157,15 @@
          return new PBounds();
      }

+    /** {...@inheritdoc} */
      protected void endMarqueeSelection(final PInputEvent e) {
          super.endMarqueeSelection(e);

-        // Remove marquee
          marquee.removeFromParent();
          marquee = null;
      }

-    /**
-     * This gets called continuously during the drag, and is used to  
animate the
-     * marquee
-     */
+    /** {...@inheritdoc} */
      protected void dragActivityStep(final PInputEvent aEvent) {
      }
  }
=======================================
---  
/piccolo2d.java/trunk/swt/src/main/java/edu/umd/cs/piccolox/swt/PSWTStickyHandleManager.java
     
Tue Jul 28 12:46:54 2009
+++  
/piccolo2d.java/trunk/swt/src/main/java/edu/umd/cs/piccolox/swt/PSWTStickyHandleManager.java
     
Mon Oct 19 09:11:29 2009
@@ -33,26 +33,39 @@
  import edu.umd.cs.piccolo.util.PBounds;
  import edu.umd.cs.piccolo.util.PPickPath;

+/**
+ * A class for managing the position of a sticky handle.
+ */
  public class PSWTStickyHandleManager extends PNode {
-
-    /**
-     *
-     */
      private static final long serialVersionUID = 1L;
      private PNode target;
      private PCamera camera;

-    public PSWTStickyHandleManager(final PCamera newCamera, final PNode  
newTarget) {
-        setCameraTarget(newCamera, newTarget);
+    /**
+     * Creates a sticky handle that will be displayed on the given camera  
and
+     * will update the provided target.
+     *
+     * @param camera camera on which to display the sticky handle
+     * @param target target being controlled by the handle
+     */
+    public PSWTStickyHandleManager(final PCamera camera, final PNode  
target) {
+        setCameraTarget(camera, target);
          PSWTBoundsHandle.addBoundsHandlesTo(this);
      }

+    /**
+     * Changes the associated camera and target for this sticky handle.
+     *
+     * @param newCamera new camera onto which this handle should appear
+     * @param newTarget new target which this handle will control
+     */
      public void setCameraTarget(final PCamera newCamera, final PNode  
newTarget) {
          camera = newCamera;
          camera.addChild(this);
          target = newTarget;
      }

+    /** {...@inheritdoc} */
      public boolean setBounds(final double x, final double y, final double  
width, final double height) {
          final PBounds b = new PBounds(x, y, width, height);
          camera.localToGlobal(b);
@@ -62,10 +75,17 @@
          return super.setBounds(x, y, width, height);
      }

+    /**
+     * Always returns true to ensure that they will always be displayed
+     * appropriately.
+     *
+     * @return true
+     */
      protected boolean getBoundsVolatile() {
          return true;
      }

+    /** {...@inheritdoc} */
      public PBounds getBoundsReference() {
          final PBounds targetBounds = target.getFullBounds();
          camera.viewToLocal(targetBounds);
@@ -75,16 +95,27 @@
          return super.getBoundsReference();
      }

+    /** {...@inheritdoc} */
      public void startResizeBounds() {
          super.startResizeBounds();
          target.startResizeBounds();
      }

+    /** {...@inheritdoc} */
      public void endResizeBounds() {
          super.endResizeBounds();
          target.endResizeBounds();
      }

+    /**
+     * Since PSWTStickyHandle manager is not visible on screen, it just  
returns
+     * false when it is asked to be repainted.
+     *
+     * @param pickPath path of this node in which the interaction occurred  
that
+     *            required the repaint
+     *
+     * @return always false
+     */
      public boolean pickAfterChildren(final PPickPath pickPath) {
          return false;
      }
=======================================
---  
/piccolo2d.java/trunk/swt/src/main/java/edu/umd/cs/piccolox/swt/SWTShapeManager.java
     
Tue Jul 28 12:46:54 2009
+++  
/piccolo2d.java/trunk/swt/src/main/java/edu/umd/cs/piccolox/swt/SWTShapeManager.java
     
Mon Oct 19 09:11:29 2009
@@ -41,11 +41,10 @@
   * @author Lance Good
   */
  public class SWTShapeManager {
-
-    static AffineTransform IDENTITY_XFORM = new AffineTransform();
-    static Point2D aPoint = new Point2D.Double();
-    static ArrayList segList = new ArrayList();
-    static double[] pts = new double[8];
+    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];

      /**
       * Apply the specified transform to the specified rectangle, modifying  
the
@@ -89,6 +88,13 @@
          rect.setRect(minX, minY, maxX - minX, maxY - minY);
      }

+    /**
+     * Populates the SWT rectangle with the provided Swing Rectangle2D's
+     * coordinates. Rounding up to the nearest integer.
+     *
+     * @param aRect awt rectangle to extract coordinates from
+     * @param sRect swt rectangle to populate
+     */
      public static void awtToSWT(final Rectangle2D aRect, final Rectangle  
sRect) {
          sRect.x = (int) (aRect.getX() + 0.5);
          sRect.y = (int) (aRect.getY() + 0.5);
@@ -96,11 +102,19 @@
          sRect.height = (int) (aRect.getHeight() + 0.5);
      }

-    public static double[] shapeToPolyline(final Shape s) {
+    /**
+     * Converts the provided shape into an array of point coordinates  
given as
+     * one dimensional array with this format: x1,y1,x2,y3,....
+     *
+     * @param shape shape to convert
+     * @return point coordinates given as one dimensional array with this
+     *         format: x1,y1,x2,y3,...
+     */
+    public static double[] shapeToPolyline(final Shape shape) {
          segList.clear();
          aPoint.setLocation(0, 0);

-        final PathIterator pi = s.getPathIterator(IDENTITY_XFORM,  
0.000000001);
+        final PathIterator pi = shape.getPathIterator(IDENTITY_XFORM,  
0.000000001);
          while (!pi.isDone()) {
              final int segType = pi.currentSegment(pts);
              switch (segType) {
@@ -128,6 +142,14 @@
          return polyObj;
      }

+    /**
+     * Transforms the given points by the transform provided, leaving the
+     * original points untouched.
+     *
+     * @param pts points to transform
+     * @param at transform to apply
+     * @return transformed coordinates given in format x1,y2,x2,y2,...
+     */
      public static int[] transform(final double[] pts, final  
AffineTransform at) {
          final int[] intPts = new int[pts.length];
          for (int i = 0; i < pts.length / 2; i++) {
=======================================
---  
/piccolo2d.java/trunk/swt/src/main/java/edu/umd/cs/piccolox/swt/SWTTimer.java   
 
Wed Oct 14 19:17:06 2009
+++  
/piccolo2d.java/trunk/swt/src/main/java/edu/umd/cs/piccolox/swt/SWTTimer.java   
 
Mon Oct 19 09:11:29 2009
@@ -324,7 +324,7 @@
      /**
       * @param running the running to set
       */
-    public void setRunning(boolean running) {
+    public void setRunning(final boolean running) {
          this.running = running;
      }

=======================================
---  
/piccolo2d.java/trunk/swt/src/main/java/edu/umd/cs/piccolox/swt/SWTTimerQueue.java
       
Wed Oct 14 19:17:06 2009
+++  
/piccolo2d.java/trunk/swt/src/main/java/edu/umd/cs/piccolox/swt/SWTTimerQueue.java
       
Mon Oct 19 09:11:29 2009
@@ -212,8 +212,14 @@
          return null;
      }

+    /**
+     * Returns true if this timer queue contains the given timer.
+     *
+     * @param timer timer being checked
+     * @return true if timer is scheduled in this queue
+     */
      synchronized boolean containsTimer(final SWTTimer timer) {
-        //TODO: making this use isRunning without causing an infinite loop
+        // TODO: making this use isRunning without causing an infinite loop
          return timer.running;
      }

@@ -221,8 +227,11 @@
       * If there are a ton of timers, this method may never return. It loops
       * checking to see if the head of the Timer list has expired. If it  
has, it
       * posts the Timer and reschedules it if necessary.
+     *
+     * @return how long the app can take before it should invoke this  
method
+     *         again.
       */
-    synchronized long postExpiredTimers() {
+    private synchronized long postExpiredTimers() {
          SWTTimer timer;
          long currentTime;
          long timeToWait;
@@ -265,14 +274,17 @@
                      wait(1);
                  }
                  catch (final InterruptedException e) {
-
+                    // Nothing to do
                  }
              }
          } while (timeToWait <= 0);

          return timeToWait;
      }
-
+
+    /**
+     * Dispatches work to timers until the queue is told to stop running.
+     */
      public synchronized void run() {
          long timeToWait;

@@ -283,6 +295,7 @@
                      wait(timeToWait);
                  }
                  catch (final InterruptedException e) {
+                    // Nothing to do
                  }
              }
          }
@@ -335,15 +348,24 @@

          private final Display display;

+        /**
+         * Constructs a QueueRestart Runnable that will message the Timer  
Queue
+         * to Restart.
+         *
+         * @param display display associated with the SWTTimerQueue
+         */
          public SWTTimerQueueRestart(final Display display) {
              this.display = display;
          }

-        public synchronized void run() {
+        /**
+         * Attempts to restart the queue associated with the display.
+         */
+        public synchronized void run() {
              if (attemptedStart) {
                  return;
              }
-
+
              final SWTTimerQueue q = SWTTimerQueue.sharedInstance(display);

              synchronized (q) {

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

Reply via email to