You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by gb...@apache.org on 2009/09/15 17:48:10 UTC

svn commit: r815374 - in /incubator/pivot/trunk/wtk: src/org/apache/pivot/wtk/ src/org/apache/pivot/wtk/media/drawing/ test/org/apache/pivot/wtk/test/

Author: gbrown
Date: Tue Sep 15 15:48:09 2009
New Revision: 815374

URL: http://svn.apache.org/viewvc?rev=815374&view=rev
Log:
Fix bug in calculating a shape's transformed bounds; clear the selection in ListButton, ListView, and Spinner when an invalid item is passed to setSelectedItem() instead of throwing.

Modified:
    incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/ListButton.java
    incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/ListView.java
    incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Spinner.java
    incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/media/drawing/Group.java
    incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/media/drawing/Shape.java
    incubator/pivot/trunk/wtk/test/org/apache/pivot/wtk/test/DrawingTest.java
    incubator/pivot/trunk/wtk/test/org/apache/pivot/wtk/test/drawing_test.wtkx

Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/ListButton.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/ListButton.java?rev=815374&r1=815373&r2=815374&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/ListButton.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/ListButton.java Tue Sep 15 15:48:09 2009
@@ -260,16 +260,7 @@
 
     @SuppressWarnings("unchecked")
     public void setSelectedItem(Object item) {
-        int index = -1;
-
-        if (item != null) {
-            index = ((List<Object>)listData).indexOf(item);
-            if (index == -1) {
-                throw new IllegalArgumentException("\"" + item + "\" is not a valid selection.");
-            }
-        }
-
-        setSelectedIndex(index);
+        setSelectedIndex((item == null) ? -1 : ((List<Object>)listData).indexOf(item));
     }
 
     /**

Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/ListView.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/ListView.java?rev=815374&r1=815373&r2=815374&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/ListView.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/ListView.java Tue Sep 15 15:48:09 2009
@@ -852,16 +852,7 @@
 
     @SuppressWarnings("unchecked")
     public void setSelectedItem(Object item) {
-        int index = -1;
-
-        if (item != null) {
-            index = ((List<Object>)listData).indexOf(item);
-            if (index == -1) {
-                throw new IllegalArgumentException("\"" + item + "\" is not a valid selection.");
-            }
-        }
-
-        setSelectedIndex(index);
+        setSelectedIndex((item == null) ? -1 : ((List<Object>)listData).indexOf(item));
     }
 
     public Sequence<?> getSelectedItems() {
@@ -881,6 +872,10 @@
 
     @SuppressWarnings("unchecked")
     public void setSelectedItems(Sequence<Object> items) {
+        if (items == null) {
+            throw new IllegalArgumentException();
+        }
+
         ArrayList<Span> selectedRanges = new ArrayList<Span>();
 
         for (int i = 0, n = items.getLength(); i < n; i++) {

Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Spinner.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Spinner.java?rev=815374&r1=815373&r2=815374&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Spinner.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Spinner.java Tue Sep 15 15:48:09 2009
@@ -373,16 +373,7 @@
 
     @SuppressWarnings("unchecked")
     public void setSelectedItem(Object item) {
-        int index = -1;
-
-        if (item != null) {
-            index = ((List<Object>)spinnerData).indexOf(item);
-            if (index == -1) {
-                throw new IllegalArgumentException("\"" + item + "\" is not a valid selection.");
-            }
-        }
-
-        setSelectedIndex(index);
+        setSelectedIndex((item == null) ? -1 : ((List<Object>)spinnerData).indexOf(item));
     }
 
     /**

Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/media/drawing/Group.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/media/drawing/Group.java?rev=815374&r1=815373&r2=815374&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/media/drawing/Group.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/media/drawing/Group.java Tue Sep 15 15:48:09 2009
@@ -137,9 +137,7 @@
             if (shape.isVisible()) {
                 int x = shape.getX();
                 int y = shape.getY();
-
                 Bounds transformedBounds = shape.getTransformedBounds();
-                transformedBounds = transformedBounds.translate(x, y);
 
                 if (transformedBounds.intersects(clipBounds)) {
                     Graphics2D shapeGraphics = (Graphics2D)graphics.create();

Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/media/drawing/Shape.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/media/drawing/Shape.java?rev=815374&r1=815373&r2=815374&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/media/drawing/Shape.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/media/drawing/Shape.java Tue Sep 15 15:48:09 2009
@@ -478,10 +478,7 @@
         update();
 
         bounds = new Bounds(x, y, width, height);
-
-        transformedBounds = transform(0, 0, bounds.width, bounds.height);
-        transformedBounds = new Bounds(bounds.x + transformedBounds.x, bounds.y + transformedBounds.y,
-            transformedBounds.width, transformedBounds.height);
+        transformedBounds = transform(this.x + x, this.y + y, width, height);
 
         // Repaint the region currently occupied by this shape
         update();

Modified: incubator/pivot/trunk/wtk/test/org/apache/pivot/wtk/test/DrawingTest.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/test/org/apache/pivot/wtk/test/DrawingTest.java?rev=815374&r1=815373&r2=815374&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/test/org/apache/pivot/wtk/test/DrawingTest.java (original)
+++ incubator/pivot/trunk/wtk/test/org/apache/pivot/wtk/test/DrawingTest.java Tue Sep 15 15:48:09 2009
@@ -33,7 +33,6 @@
 public class DrawingTest implements Application {
     private Window window = null;
     private ImageView imageView = null;
-
     private ComponentMouseButtonListener imageViewMouseButtonListener = new ComponentMouseButtonListener.Adapter() {
         @Override
         public boolean mouseDown(Component component, Mouse.Button button, int x, int y) {

Modified: incubator/pivot/trunk/wtk/test/org/apache/pivot/wtk/test/drawing_test.wtkx
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/test/org/apache/pivot/wtk/test/drawing_test.wtkx?rev=815374&r1=815373&r2=815374&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/test/org/apache/pivot/wtk/test/drawing_test.wtkx (original)
+++ incubator/pivot/trunk/wtk/test/org/apache/pivot/wtk/test/drawing_test.wtkx Tue Sep 15 15:48:09 2009
@@ -29,14 +29,12 @@
                         <drawing:Canvas>
                             <drawing:Rectangle x="0" y="0" width="120" height="60"
                                 fill="#ff0000" stroke=""/>
-                            <drawing:Ellipse x="60" y="30" width="120" height="60"
-                                fill="#00ff00" stroke="#000000" strokeThickness="10">
-                                <!--
+                            <drawing:Ellipse x="60" y="30" width="120" height="120"
+                                fill="#00ff00" stroke="#000000" strokeThickness="20">
                                 <transforms>
                                     <drawing:Shape.Translate x="40" y="40"/>
                                     <drawing:Shape.Scale x="0.5" y="0.5"/>
                                 </transforms>
-                                -->
                             </drawing:Ellipse>
                         </drawing:Canvas>
                     </canvas>