You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by rw...@apache.org on 2017/10/16 16:16:55 UTC

svn commit: r1812302 [2/2] - in /pivot/trunk: wtk-terra/src/org/apache/pivot/wtk/skin/terra/ wtk/src/org/apache/pivot/wtk/skin/

Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/BorderSkin.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/BorderSkin.java?rev=1812302&r1=1812301&r2=1812302&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/BorderSkin.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/BorderSkin.java Mon Oct 16 16:16:54 2017
@@ -29,6 +29,7 @@ import java.awt.geom.Rectangle2D;
 import java.awt.geom.RoundRectangle2D;
 
 import org.apache.pivot.collections.Dictionary;
+import org.apache.pivot.util.Utils;
 import org.apache.pivot.wtk.Border;
 import org.apache.pivot.wtk.BorderListener;
 import org.apache.pivot.wtk.Component;
@@ -92,14 +93,14 @@ public class BorderSkin extends Containe
         if (content != null) {
             int heightUpdated = height;
             if (heightUpdated != -1) {
-                heightUpdated = Math.max(heightUpdated - (topThickness + thickness) - padding.top
-                    - padding.bottom, 0);
+                heightUpdated = Math.max(heightUpdated - (topThickness + thickness)
+                    - padding.getHeight(), 0);
             }
 
             preferredWidth = Math.max(preferredWidth, content.getPreferredWidth(heightUpdated));
         }
 
-        preferredWidth += (padding.left + padding.right) + (thickness * 2);
+        preferredWidth += padding.getWidth() + (thickness * 2);
 
         return preferredWidth;
     }
@@ -122,14 +123,14 @@ public class BorderSkin extends Containe
         if (content != null) {
             int widthUpdated = width;
             if (widthUpdated != -1) {
-                widthUpdated = Math.max(widthUpdated - (thickness * 2) - padding.left
-                    - padding.right, 0);
+                widthUpdated = Math.max(widthUpdated - (thickness * 2)
+                    - padding.getWidth(), 0);
             }
 
             preferredHeight = content.getPreferredHeight(widthUpdated);
         }
 
-        preferredHeight += (padding.top + padding.bottom) + (topThickness + thickness);
+        preferredHeight += padding.getHeight() + (topThickness + thickness);
 
         return preferredHeight;
     }
@@ -159,8 +160,8 @@ public class BorderSkin extends Containe
             preferredHeight += preferredSize.height;
         }
 
-        preferredWidth += (padding.left + padding.right) + (thickness * 2);
-        preferredHeight += (padding.top + padding.bottom) + (topThickness + thickness);
+        preferredWidth += padding.getWidth() + (thickness * 2);
+        preferredHeight += padding.getHeight() + (topThickness + thickness);
 
         return new Dimensions(preferredWidth, preferredHeight);
     }
@@ -182,9 +183,9 @@ public class BorderSkin extends Containe
                 topThickness = Math.max((int) Math.ceil(lm.getHeight()), topThickness);
             }
 
-            int clientWidth = Math.max(width - (thickness * 2) - (padding.left + padding.right), 0);
+            int clientWidth = Math.max(width - (thickness * 2) - padding.getWidth(), 0);
             int clientHeight = Math.max(height - (topThickness + thickness)
-                - (padding.top + padding.bottom), 0);
+                - padding.getHeight(), 0);
 
             baseline = content.getBaseline(clientWidth, clientHeight);
         }
@@ -216,9 +217,9 @@ public class BorderSkin extends Containe
         if (content != null) {
             content.setLocation(padding.left + thickness, padding.top + topThickness);
 
-            int contentWidth = Math.max(width - (padding.left + padding.right + (thickness * 2)), 0);
+            int contentWidth = Math.max(width - (padding.getWidth() + (thickness * 2)), 0);
             int contentHeight = Math.max(height
-                - (padding.top + padding.bottom + (topThickness + thickness)), 0);
+                - (padding.getHeight() + (topThickness + thickness)), 0);
 
             content.setSize(contentWidth, contentHeight);
         }
@@ -328,9 +329,7 @@ public class BorderSkin extends Containe
      * @param font The new font to use for the border title.
      */
     public void setFont(Font font) {
-        if (font == null) {
-            throw new IllegalArgumentException("font is null.");
-        }
+        Utils.checkNull(font, "font");
 
         this.font = font;
         invalidateComponent();
@@ -342,10 +341,6 @@ public class BorderSkin extends Containe
      * @param font A {@linkplain ComponentSkin#decodeFont(String) font specification}.
      */
     public final void setFont(String font) {
-        if (font == null) {
-            throw new IllegalArgumentException("font is null.");
-        }
-
         setFont(decodeFont(font));
     }
 
@@ -355,10 +350,6 @@ public class BorderSkin extends Containe
      * @param font A dictionary {@linkplain Theme#deriveFont describing a font}.
      */
     public final void setFont(Dictionary<String, ?> font) {
-        if (font == null) {
-            throw new IllegalArgumentException("font is null.");
-        }
-
         setFont(Theme.deriveFont(font));
     }
 
@@ -375,9 +366,7 @@ public class BorderSkin extends Containe
      * @param color The new color for the border.
      */
     public void setColor(Color color) {
-        if (color == null) {
-            throw new IllegalArgumentException("color is null.");
-        }
+        Utils.checkNull(color, "color");
 
         this.color = color;
         repaintComponent();
@@ -390,10 +379,6 @@ public class BorderSkin extends Containe
      * values recognized by Pivot}.
      */
     public final void setColor(String color) {
-        if (color == null) {
-            throw new IllegalArgumentException("color is null.");
-        }
-
         setColor(GraphicsUtilities.decodeColor(color));
     }
 
@@ -402,19 +387,13 @@ public class BorderSkin extends Containe
     }
 
     public void setTitleColor(Color titleColor) {
-        if (titleColor == null) {
-            throw new IllegalArgumentException("titleColor is null.");
-        }
+        Utils.checkNull(titleColor, "titleColor");
 
         this.titleColor = titleColor;
         repaintComponent();
     }
 
     public final void setTitleColor(String titleColor) {
-        if (titleColor == null) {
-            throw new IllegalArgumentException("titleColor is null.");
-        }
-
         setTitleColor(GraphicsUtilities.decodeColor(titleColor));
     }
 
@@ -431,9 +410,7 @@ public class BorderSkin extends Containe
      * @param thickness The border thickness (in pixels).
      */
     public void setThickness(int thickness) {
-        if (thickness < 0) {
-            throw new IllegalArgumentException("thickness is negative.");
-        }
+        Utils.checkNonNegative(thickness, "thickness");
 
         this.thickness = thickness;
         invalidateComponent();
@@ -445,9 +422,7 @@ public class BorderSkin extends Containe
      * @param thickness The border thickness (integer value in pixels).
      */
     public void setThickness(Number thickness) {
-        if (thickness == null) {
-            throw new IllegalArgumentException("thickness is null.");
-        }
+        Utils.checkNull(thickness, "thickness");
 
         setThickness(thickness.intValue());
     }
@@ -467,9 +442,7 @@ public class BorderSkin extends Containe
      * @param padding The set of padding values.
      */
     public void setPadding(Insets padding) {
-        if (padding == null) {
-            throw new IllegalArgumentException("padding is null.");
-        }
+        Utils.checkNull(padding, "padding");
 
         this.padding = padding;
         invalidateComponent();
@@ -483,10 +456,6 @@ public class BorderSkin extends Containe
      * right}.
      */
     public final void setPadding(Dictionary<String, ?> padding) {
-        if (padding == null) {
-            throw new IllegalArgumentException("padding is null.");
-        }
-
         setPadding(new Insets(padding));
     }
 
@@ -507,11 +476,7 @@ public class BorderSkin extends Containe
      * @param padding The padding value (integer value in pixels) to use for all four sides.
      */
     public void setPadding(Number padding) {
-        if (padding == null) {
-            throw new IllegalArgumentException("padding is null.");
-        }
-
-        setPadding(padding.intValue());
+        setPadding(new Insets(padding));
     }
 
     /**
@@ -522,10 +487,6 @@ public class BorderSkin extends Containe
      * keys left, top, bottom, and/or right.
      */
     public final void setPadding(String padding) {
-        if (padding == null) {
-            throw new IllegalArgumentException("padding is null.");
-        }
-
         setPadding(Insets.decode(padding));
     }
 
@@ -543,9 +504,7 @@ public class BorderSkin extends Containe
      * @param cornerRadii The radii for each of the corners.
      */
     public void setCornerRadii(CornerRadii cornerRadii) {
-        if (cornerRadii == null) {
-            throw new IllegalArgumentException("cornerRadii is null.");
-        }
+        Utils.checkNull(cornerRadii, "cornerRadii");
 
         this.cornerRadii = cornerRadii;
         repaintComponent();
@@ -558,10 +517,6 @@ public class BorderSkin extends Containe
      * {@linkplain CornerRadii#CornerRadii(Dictionary) specifying the four corners}.
      */
     public final void setCornerRadii(Dictionary<String, ?> cornerRadii) {
-        if (cornerRadii == null) {
-            throw new IllegalArgumentException("cornerRadii is null.");
-        }
-
         setCornerRadii(new CornerRadii(cornerRadii));
     }
 
@@ -580,11 +535,7 @@ public class BorderSkin extends Containe
      * @param cornerRadii The value for the radii (integer value in pixels).
      */
     public final void setCornerRadii(Number cornerRadii) {
-        if (cornerRadii == null) {
-            throw new IllegalArgumentException("cornerRadii is null.");
-        }
-
-        setCornerRadii(cornerRadii.intValue());
+        setCornerRadii(new CornerRadii(cornerRadii));
     }
 
     /**
@@ -594,10 +545,6 @@ public class BorderSkin extends Containe
      * {@linkplain CornerRadii#CornerRadii(Dictionary) specifying the four corners}.
      */
     public final void setCornerRadii(String cornerRadii) {
-        if (cornerRadii == null) {
-            throw new IllegalArgumentException("cornerRadii is null.");
-        }
-
         setCornerRadii(CornerRadii.decode(cornerRadii));
     }
 

Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/LabelSkin.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/LabelSkin.java?rev=1812302&r1=1812301&r2=1812302&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/LabelSkin.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/LabelSkin.java Mon Oct 16 16:16:54 2017
@@ -565,7 +565,8 @@ public class LabelSkin extends Component
     /**
      * Sets the background color of the label.
      *
-     * @param backgroundColor The new background color for the label.
+     * @param backgroundColor The new background color for the label
+     * (can be <tt>null</tt> to let the parent background show through).
      */
     public void setBackgroundColor(Color backgroundColor) {
         this.backgroundColor = backgroundColor;
@@ -580,8 +581,6 @@ public class LabelSkin extends Component
      * Pivot}.
      */
     public final void setBackgroundColor(String backgroundColor) {
-        Utils.checkNull(backgroundColor, "backgroundColor");
-
         setBackgroundColor(GraphicsUtilities.decodeColor(backgroundColor));
     }
 

Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/MovieViewSkin.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/MovieViewSkin.java?rev=1812302&r1=1812301&r2=1812302&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/MovieViewSkin.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/MovieViewSkin.java Mon Oct 16 16:16:54 2017
@@ -20,6 +20,7 @@ import java.awt.Color;
 import java.awt.Graphics2D;
 import java.awt.Transparency;
 
+import org.apache.pivot.util.Utils;
 import org.apache.pivot.wtk.Component;
 import org.apache.pivot.wtk.Dimensions;
 import org.apache.pivot.wtk.GraphicsUtilities;
@@ -50,8 +51,10 @@ public class MovieViewSkin extends Compo
 
         @Override
         public void regionUpdated(Movie movie, int x, int y, int width, int height) {
-            repaintComponent(movieX + (int) Math.floor(x * scale),
-                movieY + (int) Math.floor(y * scale), (int) Math.ceil(width * scale) + 1,
+            repaintComponent(
+                movieX + (int) Math.floor(x * scale),
+                movieY + (int) Math.floor(y * scale),
+                (int) Math.ceil(width * scale) + 1,
                 (int) Math.ceil(height * scale) + 1);
         }
     };
@@ -90,8 +93,9 @@ public class MovieViewSkin extends Compo
         MovieView movieView = (MovieView) getComponent();
         Movie movie = movieView.getMovie();
 
-        return (movie == null) ? new Dimensions(0, 0) : new Dimensions(Math.round(movie.getWidth()
-            * scale), Math.round(movie.getHeight() * scale));
+        return (movie == null) ? Dimensions.ZERO :
+            new Dimensions(Math.round(movie.getWidth() * scale),
+                           Math.round(movie.getHeight() * scale));
     }
 
     @Override
@@ -173,15 +177,12 @@ public class MovieViewSkin extends Compo
     }
 
     public void setBackgroundColor(Color backgroundColor) {
+        // Note: null background allowed here
         this.backgroundColor = backgroundColor;
         repaintComponent();
     }
 
     public final void setBackgroundColor(String backgroundColor) {
-        if (backgroundColor == null) {
-            throw new IllegalArgumentException("backgroundColor is null.");
-        }
-
         setBackgroundColor(GraphicsUtilities.decodeColor(backgroundColor));
     }
 
@@ -203,9 +204,7 @@ public class MovieViewSkin extends Compo
     }
 
     public void setHorizontalAlignment(HorizontalAlignment horizontalAlignment) {
-        if (horizontalAlignment == null) {
-            throw new IllegalArgumentException("horizontalAlignment is null.");
-        }
+        Utils.checkNull(horizontalAlignment, "horizontalAlignment");
 
         if (this.horizontalAlignment != horizontalAlignment) {
             this.horizontalAlignment = horizontalAlignment;
@@ -220,9 +219,7 @@ public class MovieViewSkin extends Compo
     }
 
     public void setVerticalAlignment(VerticalAlignment verticalAlignment) {
-        if (verticalAlignment == null) {
-            throw new IllegalArgumentException("verticalAlignment is null.");
-        }
+        Utils.checkNull(verticalAlignment, "verticalAlignment");
 
         if (this.verticalAlignment != verticalAlignment) {
             this.verticalAlignment = verticalAlignment;

Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextAreaSkin.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextAreaSkin.java?rev=1812302&r1=1812301&r2=1812302&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextAreaSkin.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextAreaSkin.java Mon Oct 16 16:16:54 2017
@@ -151,7 +151,7 @@ public class TextAreaSkin extends Compon
     private static final int SCROLL_RATE = 30;
 
     public TextAreaSkin() {
-        Theme theme = Theme.getTheme();
+        Theme theme = currentTheme();
         font = theme.getFont();
 
         color = defaultForegroundColor();
@@ -585,15 +585,12 @@ public class TextAreaSkin extends Compon
     }
 
     public void setBackgroundColor(Color backgroundColor) {
+        // Null background is allowed here
         this.backgroundColor = backgroundColor;
         repaintComponent();
     }
 
     public final void setBackgroundColor(String backgroundColor) {
-        if (backgroundColor == null) {
-            throw new IllegalArgumentException("backgroundColor is null");
-        }
-
         setBackgroundColor(GraphicsUtilities.decodeColor(backgroundColor));
     }
 
@@ -602,19 +599,13 @@ public class TextAreaSkin extends Compon
     }
 
     public void setInactiveColor(Color inactiveColor) {
-        if (inactiveColor == null) {
-            throw new IllegalArgumentException("inactiveColor is null.");
-        }
+        Utils.checkNull(inactiveColor, "inactiveColor");
 
         this.inactiveColor = inactiveColor;
         repaintComponent();
     }
 
     public final void setInactiveColor(String inactiveColor) {
-        if (inactiveColor == null) {
-            throw new IllegalArgumentException("inactiveColor is null.");
-        }
-
         setColor(GraphicsUtilities.decodeColor(inactiveColor));
     }
 
@@ -632,10 +623,6 @@ public class TextAreaSkin extends Compon
     }
 
     public final void setSelectionColor(String selectionColor) {
-        if (selectionColor == null) {
-            throw new IllegalArgumentException("selectionColor is null.");
-        }
-
         setSelectionColor(GraphicsUtilities.decodeColor(selectionColor));
     }
 

Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkinImageNodeView.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkinImageNodeView.java?rev=1812302&r1=1812301&r2=1812302&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkinImageNodeView.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkinImageNodeView.java Mon Oct 16 16:16:54 2017
@@ -71,9 +71,9 @@ class TextPaneSkinImageNodeView extends
         Image image = imageNode.getImage();
 
         if (image == null) {
-            return new Dimensions(0, 0);
+            return Dimensions.ZERO;
         }
-        return new Dimensions(image.getWidth(), image.getHeight());
+        return image.getSize();
     }
 
     @Override

Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkinNodeView.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkinNodeView.java?rev=1812302&r1=1812301&r2=1812302&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkinNodeView.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkinNodeView.java Mon Oct 16 16:16:54 2017
@@ -101,12 +101,7 @@ abstract class TextPaneSkinNodeView impl
         return new Dimensions(width, height);
     }
 
-    protected void setSize(Dimensions size) {
-        Utils.checkNull(size, "size");
-        setSize(size.width, size.height);
-    }
-
-    protected void setSize(int width, int height) {
+    public void setSize(int width, int height) {
         assert (width >= 0);
         assert (height >= 0);
 
@@ -120,6 +115,11 @@ abstract class TextPaneSkinNodeView impl
         repaint();
     }
 
+    public void setSize(Dimensions size) {
+        Utils.checkNull(size, "size");
+        setSize(size.width, size.height);
+    }
+
     public int getX() {
         return x;
     }

Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkinSpanView.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkinSpanView.java?rev=1812302&r1=1812301&r2=1812302&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkinSpanView.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkinSpanView.java Mon Oct 16 16:16:54 2017
@@ -57,7 +57,7 @@ class TextPaneSkinSpanView extends TextP
     @Override
     public Dimensions getPreferredSize(int breakWidth) {
         if (getLength() == 0) {
-            return new Dimensions(0, 0);
+            return Dimensions.ZERO;
         }
 
         TextPaneSkinNodeView nodeView = get(0);