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/04/13 20:10:10 UTC

svn commit: r764547 - in /incubator/pivot/trunk/wtk/src/pivot/wtk: ./ skin/ skin/terra/

Author: gbrown
Date: Mon Apr 13 18:10:09 2009
New Revision: 764547

URL: http://svn.apache.org/viewvc?rev=764547&view=rev
Log:
Make pivot.wtk.Dimensions final; implement hashCode().

Modified:
    incubator/pivot/trunk/wtk/src/pivot/wtk/Dimensions.java
    incubator/pivot/trunk/wtk/src/pivot/wtk/skin/CalendarButtonSkin.java
    incubator/pivot/trunk/wtk/src/pivot/wtk/skin/CardPaneSkin.java
    incubator/pivot/trunk/wtk/src/pivot/wtk/skin/ListButtonSkin.java
    incubator/pivot/trunk/wtk/src/pivot/wtk/skin/MenuButtonSkin.java
    incubator/pivot/trunk/wtk/src/pivot/wtk/skin/TextAreaSkin.java
    incubator/pivot/trunk/wtk/src/pivot/wtk/skin/terra/TerraCalendarSkin.java
    incubator/pivot/trunk/wtk/src/pivot/wtk/skin/terra/TerraMenuItemSkin.java

Modified: incubator/pivot/trunk/wtk/src/pivot/wtk/Dimensions.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/pivot/wtk/Dimensions.java?rev=764547&r1=764546&r2=764547&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/pivot/wtk/Dimensions.java (original)
+++ incubator/pivot/trunk/wtk/src/pivot/wtk/Dimensions.java Mon Apr 13 18:10:09 2009
@@ -23,14 +23,15 @@
  *
  * @author gbrown
  */
-public class Dimensions {
-    public int width = 0;
-    public int height = 0;
+public final class Dimensions {
+    public final int width;
+    public final int height;
 
     public static final String WIDTH_KEY = "width";
     public static final String HEIGHT_KEY = "height";
 
     public Dimensions() {
+        this(0, 0);
     }
 
     public Dimensions(Dictionary<String, ?> dimensions) {
@@ -40,10 +41,14 @@
 
         if (dimensions.containsKey(WIDTH_KEY)) {
             width = (Integer)dimensions.get(WIDTH_KEY);
+        } else {
+            width = 0;
         }
 
         if (dimensions.containsKey(HEIGHT_KEY)) {
             height = (Integer)dimensions.get(HEIGHT_KEY);
+        } else {
+            height = 0;
         }
     }
 
@@ -73,6 +78,12 @@
         return equals;
     }
 
+    @Override
+    public int hashCode() {
+        // TODO This may not be the most optimal hashing function
+        return width * height;
+    }
+
     public String toString() {
         return getClass().getName() + " [" + width + "x" + height + "]";
     }

Modified: incubator/pivot/trunk/wtk/src/pivot/wtk/skin/CalendarButtonSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/pivot/wtk/skin/CalendarButtonSkin.java?rev=764547&r1=764546&r2=764547&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/pivot/wtk/skin/CalendarButtonSkin.java (original)
+++ incubator/pivot/trunk/wtk/src/pivot/wtk/skin/CalendarButtonSkin.java Mon Apr 13 18:10:09 2009
@@ -339,6 +339,7 @@
 
                 Dimensions displaySize = display.getSize();
                 Dimensions popupSize = content.getPreferredSize();
+                int popupHeight = popupSize.height;
 
                 int x = buttonLocation.x;
                 if (popupSize.width > width
@@ -351,14 +352,14 @@
                     if (buttonLocation.y - popupSize.height > 0) {
                         y = buttonLocation.y - popupSize.height + 1;
                     } else {
-                        popupSize.height = displaySize.height - y;
+                        popupHeight = displaySize.height - y;
                     }
                 } else {
-                    popupSize.height = -1;
+                    popupHeight = -1;
                 }
 
                 calendarPopup.setLocation(x, y);
-                calendarPopup.setPreferredSize(popupSize);
+                calendarPopup.setPreferredSize(popupSize.width, popupHeight);
                 calendarPopup.open(calendarButton.getWindow());
 
                 calendar.requestFocus();

Modified: incubator/pivot/trunk/wtk/src/pivot/wtk/skin/CardPaneSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/pivot/wtk/skin/CardPaneSkin.java?rev=764547&r1=764546&r2=764547&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/pivot/wtk/skin/CardPaneSkin.java (original)
+++ incubator/pivot/trunk/wtk/src/pivot/wtk/skin/CardPaneSkin.java Mon Apr 13 18:10:09 2009
@@ -259,7 +259,9 @@
                     preferredSize = selectedCard.getPreferredSize();
                 }
             } else {
-                preferredSize = new Dimensions(0, 0);
+                int preferredWidth = 0;
+                int preferredHeight = 0;
+
                 Orientation orientation = cardPane.getOrientation();
 
                 int selectedIndex = cardPane.getSelectedIndex();
@@ -268,14 +270,16 @@
 
                     if (selectedIndex != -1
                         || orientation == Orientation.HORIZONTAL) {
-                        preferredSize.width = Math.max(cardSize.width, preferredSize.width);
+                        preferredWidth = Math.max(cardSize.width, preferredWidth);
                     }
 
                     if (selectedIndex != -1
                         || orientation == Orientation.VERTICAL) {
-                        preferredSize.height = Math.max(cardSize.height, preferredSize.height);
+                        preferredHeight = Math.max(cardSize.height, preferredHeight);
                     }
                 }
+
+                preferredSize = new Dimensions(preferredWidth, preferredHeight);
             }
         } else {
             float percentComplete = selectionChangeTransition.getPercentComplete();

Modified: incubator/pivot/trunk/wtk/src/pivot/wtk/skin/ListButtonSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/pivot/wtk/skin/ListButtonSkin.java?rev=764547&r1=764546&r2=764547&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/pivot/wtk/skin/ListButtonSkin.java (original)
+++ incubator/pivot/trunk/wtk/src/pivot/wtk/skin/ListButtonSkin.java Mon Apr 13 18:10:09 2009
@@ -356,6 +356,7 @@
 
                     Dimensions displaySize = display.getSize();
                     Dimensions popupSize = content.getPreferredSize();
+                    int popupHeight = popupSize.height;
 
                     int x = buttonLocation.x;
                     if (popupSize.width > width
@@ -368,14 +369,14 @@
                         if (buttonLocation.y - popupSize.height > 0) {
                             y = buttonLocation.y - popupSize.height + 1;
                         } else {
-                            popupSize.height = displaySize.height - y;
+                            popupHeight = displaySize.height - y;
                         }
                     } else {
-                        popupSize.height = -1;
+                        popupHeight = -1;
                     }
 
                     listViewPopup.setLocation(x, y);
-                    listViewPopup.setPreferredSize(popupSize);
+                    listViewPopup.setPreferredSize(popupSize.width, popupHeight);
                     listViewPopup.open(listButton.getWindow());
 
                     if (listView.getFirstSelectedIndex() == -1

Modified: incubator/pivot/trunk/wtk/src/pivot/wtk/skin/MenuButtonSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/pivot/wtk/skin/MenuButtonSkin.java?rev=764547&r1=764546&r2=764547&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/pivot/wtk/skin/MenuButtonSkin.java (original)
+++ incubator/pivot/trunk/wtk/src/pivot/wtk/skin/MenuButtonSkin.java Mon Apr 13 18:10:09 2009
@@ -271,6 +271,7 @@
 
                 Dimensions displaySize = display.getSize();
                 Dimensions popupSize = content.getPreferredSize();
+                int popupHeight = popupSize.height;
 
                 int x = buttonLocation.x;
                 if (popupSize.width > width
@@ -283,14 +284,14 @@
                     if (buttonLocation.y - popupSize.height > 0) {
                         y = buttonLocation.y - popupSize.height + 1;
                     } else {
-                        popupSize.height = displaySize.height - y;
+                        popupHeight = displaySize.height - y;
                     }
                 } else {
-                    popupSize.height = -1;
+                    popupHeight = -1;
                 }
 
                 menuPopup.setLocation(x, y);
-                menuPopup.setPreferredSize(popupSize);
+                menuPopup.setPreferredSize(popupSize.width, popupHeight);
                 menuPopup.open(menuButton);
 
                 menuPopup.requestFocus();

Modified: incubator/pivot/trunk/wtk/src/pivot/wtk/skin/TextAreaSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/pivot/wtk/skin/TextAreaSkin.java?rev=764547&r1=764546&r2=764547&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/pivot/wtk/skin/TextAreaSkin.java (original)
+++ incubator/pivot/trunk/wtk/src/pivot/wtk/skin/TextAreaSkin.java Mon Apr 13 18:10:09 2009
@@ -1261,18 +1261,20 @@
     }
 
     public Dimensions getPreferredSize() {
-        Dimensions preferredSize;
+        int preferredWidth;
+        int preferredHeight;
 
         if (documentView == null) {
-            preferredSize = new Dimensions(0, 0);
+            preferredWidth = 0;
+            preferredHeight = 0;
         } else {
             documentView.setBreakWidth(Integer.MAX_VALUE);
-            preferredSize = documentView.getSize();
-            preferredSize.width += margin.left + margin.right;
-            preferredSize.height += margin.top + margin.bottom;
+            Dimensions preferredSize = documentView.getSize();
+            preferredWidth = preferredSize.width + (margin.left + margin.right);
+            preferredHeight = preferredSize.height + (margin.top + margin.bottom);
         }
 
-        return preferredSize;
+        return new Dimensions(preferredWidth, preferredHeight);
     }
 
     public void layout() {

Modified: incubator/pivot/trunk/wtk/src/pivot/wtk/skin/terra/TerraCalendarSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/pivot/wtk/skin/terra/TerraCalendarSkin.java?rev=764547&r1=764546&r2=764547&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/pivot/wtk/skin/terra/TerraCalendarSkin.java (original)
+++ incubator/pivot/trunk/wtk/src/pivot/wtk/skin/terra/TerraCalendarSkin.java Mon Apr 13 18:10:09 2009
@@ -127,10 +127,8 @@
 
             Dimensions preferredSize = dataRenderer.getPreferredSize();
 
-            preferredSize.width += padding * 2;
-            preferredSize.height += padding * 2;
-
-            return preferredSize;
+            return new Dimensions(preferredSize.width + padding * 2,
+                preferredSize.height + padding * 2);
         }
 
         public void paint(Graphics2D graphics) {

Modified: incubator/pivot/trunk/wtk/src/pivot/wtk/skin/terra/TerraMenuItemSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/pivot/wtk/skin/terra/TerraMenuItemSkin.java?rev=764547&r1=764546&r2=764547&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/pivot/wtk/skin/terra/TerraMenuItemSkin.java (original)
+++ incubator/pivot/trunk/wtk/src/pivot/wtk/skin/terra/TerraMenuItemSkin.java Mon Apr 13 18:10:09 2009
@@ -111,10 +111,8 @@
 
         Dimensions preferredSize = dataRenderer.getPreferredSize();
 
-        preferredSize.width += EXPANDER_SIZE;
-        preferredSize.height = Math.max(preferredSize.height, EXPANDER_SIZE);
-
-        return preferredSize;
+        return new Dimensions(preferredSize.width + EXPANDER_SIZE,
+            Math.max(preferredSize.height, EXPANDER_SIZE));
     }
 
     public void layout() {