You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by no...@apache.org on 2009/10/15 16:30:12 UTC
svn commit: r825505 - in
/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk: ./ skin/
skin/obsidian/ skin/terra/
Author: noelgrandin
Date: Thu Oct 15 14:30:11 2009
New Revision: 825505
URL: http://svn.apache.org/viewvc?rev=825505&view=rev
Log:
PIVOT-173 Add bounds checks on skin styles
Modified:
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/CornerRadii.java
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Insets.java
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/BorderSkin.java
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/BoxPaneSkin.java
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/FlowPaneSkin.java
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/SeparatorSkin.java
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/obsidian/ObsidianRadioButtonSkin.java
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraCheckboxSkin.java
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraFormSkin.java
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraMenuButtonSkin.java
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraMeterSkin.java
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraRadioButtonSkin.java
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraRollupSkin.java
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraSliderSkin.java
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraSplitPaneSkin.java
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraTreeViewSkin.java
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/CornerRadii.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/CornerRadii.java?rev=825505&r1=825504&r2=825505&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/CornerRadii.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/CornerRadii.java Thu Oct 15 14:30:11 2009
@@ -59,6 +59,14 @@
}
public CornerRadii(int topLeft, int topRight, int bottomLeft, int bottomRight) {
+ if (topLeft < 0)
+ throw new IllegalStateException("corner radii negative, topLeft=" + topLeft);
+ if (topRight < 0)
+ throw new IllegalStateException("corner radii negative, topRight=" + topRight);
+ if (bottomLeft < 0)
+ throw new IllegalStateException("corner radii negative, bottom=" + bottomLeft);
+ if (bottomRight < 0)
+ throw new IllegalStateException("corner radii negative, bottomRight=" + bottomRight);
this.topLeft = topLeft;
this.topRight = topRight;
this.bottomLeft = bottomLeft;
@@ -93,6 +101,14 @@
} else {
bottomRight = 0;
}
+ if (topLeft < 0)
+ throw new IllegalStateException("corner radii negative, topLeft=" + topLeft);
+ if (topRight < 0)
+ throw new IllegalStateException("corner radii negative, topRight=" + topRight);
+ if (bottomLeft < 0)
+ throw new IllegalStateException("corner radii negative, bottom=" + bottomLeft);
+ if (bottomRight < 0)
+ throw new IllegalStateException("corner radii negative, bottomRight=" + bottomRight);
}
@Override
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Insets.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Insets.java?rev=825505&r1=825504&r2=825505&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Insets.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Insets.java Thu Oct 15 14:30:11 2009
@@ -44,13 +44,24 @@
public static final Insets NONE = new Insets(0);
public Insets(int inset) {
- top = inset;
- left = inset;
- bottom = inset;
- right = inset;
+ if (inset < 0)
+ throw new IllegalStateException("an inset can never be < 0, inset=" + inset);
+ this.top = inset;
+ this.left = inset;
+ this.bottom = inset;
+ this.right = inset;
}
public Insets(int top, int left, int bottom, int right) {
+ if (top < 0)
+ throw new IllegalStateException("an inset can never be < 0, top=" + top);
+ if (left < 0)
+ throw new IllegalStateException("an inset can never be < 0, left=" + left);
+ if (bottom < 0)
+ throw new IllegalStateException("an inset can never be < 0, bottom=" + bottom);
+ if (right < 0)
+ throw new IllegalStateException("an inset can never be < 0, right=" + right);
+
this.top = top;
this.left = left;
this.bottom = bottom;
@@ -74,28 +85,37 @@
}
if (insets.containsKey(TOP_KEY)) {
- top = ((Number)insets.get(TOP_KEY)).intValue();
+ top = ((Number) insets.get(TOP_KEY)).intValue();
} else {
top = 0;
}
if (insets.containsKey(LEFT_KEY)) {
- left = ((Number)insets.get(LEFT_KEY)).intValue();
+ left = ((Number) insets.get(LEFT_KEY)).intValue();
} else {
left = 0;
}
if (insets.containsKey(BOTTOM_KEY)) {
- bottom = ((Number)insets.get(BOTTOM_KEY)).intValue();
+ bottom = ((Number) insets.get(BOTTOM_KEY)).intValue();
} else {
bottom = 0;
}
if (insets.containsKey(RIGHT_KEY)) {
- right = ((Number)insets.get(RIGHT_KEY)).intValue();
+ right = ((Number) insets.get(RIGHT_KEY)).intValue();
} else {
right = 0;
}
+
+ if (top < 0)
+ throw new IllegalStateException("an inset can never be < 0, top=" + top);
+ if (left < 0)
+ throw new IllegalStateException("an inset can never be < 0, left=" + left);
+ if (bottom < 0)
+ throw new IllegalStateException("an inset can never be < 0, bottom=" + bottom);
+ if (right < 0)
+ throw new IllegalStateException("an inset can never be < 0, right=" + right);
}
@Override
@@ -103,11 +123,8 @@
boolean equals = false;
if (object instanceof Insets) {
- Insets insets = (Insets)object;
- equals = (top == insets.top
- && left == insets.left
- && bottom == insets.bottom
- && right == insets.right);
+ Insets insets = (Insets) object;
+ equals = (top == insets.top && left == insets.left && bottom == insets.bottom && right == insets.right);
}
return equals;
@@ -121,8 +138,7 @@
@Override
public String toString() {
- return getClass().getName() + " [" + top + ", " + left + ", "
- + bottom + ", " + right + "]";
+ return getClass().getName() + " [" + top + ", " + left + ", " + bottom + ", " + right + "]";
}
public static Insets decode(String value) {
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/BorderSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/BorderSkin.java?rev=825505&r1=825504&r2=825505&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/BorderSkin.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/BorderSkin.java Thu Oct 15 14:30:11 2009
@@ -370,6 +370,9 @@
}
public void setThickness(int thickness) {
+ if (thickness < 0) {
+ throw new IllegalArgumentException("thickness is negative.");
+ }
this.thickness = thickness;
repaintComponent();
}
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/BoxPaneSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/BoxPaneSkin.java?rev=825505&r1=825504&r2=825505&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/BoxPaneSkin.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/BoxPaneSkin.java Thu Oct 15 14:30:11 2009
@@ -465,6 +465,9 @@
}
public void setSpacing(int spacing) {
+ if (spacing < 0) {
+ throw new IllegalArgumentException("spacing is negative.");
+ }
this.spacing = spacing;
invalidateComponent();
}
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/FlowPaneSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/FlowPaneSkin.java?rev=825505&r1=825504&r2=825505&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/FlowPaneSkin.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/FlowPaneSkin.java Thu Oct 15 14:30:11 2009
@@ -362,6 +362,9 @@
}
public void setHorizontalSpacing(int horizontalSpacing) {
+ if (horizontalSpacing < 0) {
+ throw new IllegalArgumentException("horizontalSpacing is negative.");
+ }
this.horizontalSpacing = horizontalSpacing;
invalidateComponent();
}
@@ -379,6 +382,9 @@
}
public void setVerticalSpacing(int verticalSpacing) {
+ if (verticalSpacing < 0) {
+ throw new IllegalArgumentException("verticalSpacing is negative.");
+ }
this.verticalSpacing = verticalSpacing;
invalidateComponent();
}
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/SeparatorSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/SeparatorSkin.java?rev=825505&r1=825504&r2=825505&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/SeparatorSkin.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/SeparatorSkin.java Thu Oct 15 14:30:11 2009
@@ -240,6 +240,9 @@
}
public void setThickness(int thickness) {
+ if (thickness < 0) {
+ throw new IllegalArgumentException("thickness is negative.");
+ }
this.thickness = thickness;
invalidateComponent();
}
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/obsidian/ObsidianRadioButtonSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/obsidian/ObsidianRadioButtonSkin.java?rev=825505&r1=825504&r2=825505&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/obsidian/ObsidianRadioButtonSkin.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/obsidian/ObsidianRadioButtonSkin.java Thu Oct 15 14:30:11 2009
@@ -252,6 +252,9 @@
}
public void setSpacing(int spacing) {
+ if (spacing < 0) {
+ throw new IllegalArgumentException("spacing is negative.");
+ }
this.spacing = spacing;
invalidateComponent();
}
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraCheckboxSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraCheckboxSkin.java?rev=825505&r1=825504&r2=825505&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraCheckboxSkin.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraCheckboxSkin.java Thu Oct 15 14:30:11 2009
@@ -335,6 +335,9 @@
}
public void setSpacing(int spacing) {
+ if (spacing < 0) {
+ throw new IllegalArgumentException("spacing is negative.");
+ }
this.spacing = spacing;
invalidateComponent();
}
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraFormSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraFormSkin.java?rev=825505&r1=825504&r2=825505&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraFormSkin.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraFormSkin.java Thu Oct 15 14:30:11 2009
@@ -362,6 +362,9 @@
}
public void setHorizontalSpacing(int horizontalSpacing) {
+ if (horizontalSpacing < 0) {
+ throw new IllegalArgumentException("horizontalSpacing is negative.");
+ }
this.horizontalSpacing = horizontalSpacing;
invalidateComponent();
}
@@ -379,6 +382,9 @@
}
public void setVerticalSpacing(int verticalSpacing) {
+ if (verticalSpacing < 0) {
+ throw new IllegalArgumentException("verticalSpacing is negative.");
+ }
this.verticalSpacing = verticalSpacing;
invalidateComponent();
}
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraMenuButtonSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraMenuButtonSkin.java?rev=825505&r1=825504&r2=825505&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraMenuButtonSkin.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraMenuButtonSkin.java Thu Oct 15 14:30:11 2009
@@ -435,6 +435,9 @@
}
public void setSpacing(int spacing) {
+ if (spacing < 0) {
+ throw new IllegalArgumentException("spacing is negative.");
+ }
this.spacing = spacing;
invalidateComponent();
}
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraMeterSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraMeterSkin.java?rev=825505&r1=825504&r2=825505&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraMeterSkin.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraMeterSkin.java Thu Oct 15 14:30:11 2009
@@ -154,6 +154,9 @@
}
public void setGridFrequency(float gridFrequency) {
+ if (gridFrequency <= 0 || gridFrequency > 1) {
+ throw new IllegalArgumentException("gridFrequency must be > 0 and <= 1");
+ }
this.gridFrequency = gridFrequency;
repaintComponent();
}
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraRadioButtonSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraRadioButtonSkin.java?rev=825505&r1=825504&r2=825505&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraRadioButtonSkin.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraRadioButtonSkin.java Thu Oct 15 14:30:11 2009
@@ -297,6 +297,9 @@
}
public void setSpacing(int spacing) {
+ if (spacing < 0) {
+ throw new IllegalArgumentException("spacing is negative.");
+ }
this.spacing = spacing;
invalidateComponent();
}
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraRollupSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraRollupSkin.java?rev=825505&r1=825504&r2=825505&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraRollupSkin.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraRollupSkin.java Thu Oct 15 14:30:11 2009
@@ -364,6 +364,9 @@
}
public void setSpacing(int spacing) {
+ if (spacing < 0) {
+ throw new IllegalArgumentException("spacing is negative.");
+ }
this.spacing = spacing;
Rollup rollup = (Rollup)getComponent();
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraSliderSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraSliderSkin.java?rev=825505&r1=825504&r2=825505&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraSliderSkin.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraSliderSkin.java Thu Oct 15 14:30:11 2009
@@ -341,6 +341,9 @@
}
public void setTrackWidth(int trackWidth) {
+ if (trackWidth < 0) {
+ throw new IllegalArgumentException("trackWidth is negative.");
+ }
this.trackWidth = trackWidth;
repaintComponent();
}
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraSplitPaneSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraSplitPaneSkin.java?rev=825505&r1=825504&r2=825505&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraSplitPaneSkin.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraSplitPaneSkin.java Thu Oct 15 14:30:11 2009
@@ -415,6 +415,9 @@
}
public void setSplitterThickness(int splitterThickness) {
+ if (splitterThickness < 0) {
+ throw new IllegalArgumentException("splitterThickness is negative.");
+ }
this.splitterThickness = splitterThickness;
invalidateComponent();
}
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraTreeViewSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraTreeViewSkin.java?rev=825505&r1=825504&r2=825505&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraTreeViewSkin.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraTreeViewSkin.java Thu Oct 15 14:30:11 2009
@@ -970,6 +970,9 @@
}
public void setSpacing(int spacing) {
+ if (spacing < 0) {
+ throw new IllegalArgumentException("spacing is negative.");
+ }
this.spacing = spacing;
invalidateComponent();
}
@@ -987,6 +990,9 @@
}
public void setIndent(int indent) {
+ if (indent < 0) {
+ throw new IllegalArgumentException("indent is negative.");
+ }
this.indent = indent;
invalidateComponent();
}
Re: svn commit: r825505 - in
/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk: ./ skin/ skin/obsidian/
skin/terra/
Posted by Greg Brown <gk...@mac.com>.
Also, we should be throwing IllegalArgumentException in these cases rather than IllegalStateException.
G
On Thursday, October 15, 2009, at 11:01AM, "Todd Volkert" <tv...@gmail.com> wrote:
>Noel,
>
>Thanks for doing this. Can you also add curly braces around the new if
>statements in Insets and CornerRadii? Having brace-less block statements
>breaks our coding conventions.
>
>Thanks,
>-T
>
>
Re: svn commit: r825505 - in /incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk:
./ skin/ skin/obsidian/ skin/terra/
Posted by Todd Volkert <tv...@gmail.com>.
Noel,
Thanks for doing this. Can you also add curly braces around the new if
statements in Insets and CornerRadii? Having brace-less block statements
breaks our coding conventions.
Thanks,
-T