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/12/08 19:47:55 UTC
svn commit: r1817553 - in /pivot/trunk:
wtk-terra/src/org/apache/pivot/wtk/skin/terra/
wtk/src/org/apache/pivot/wtk/ wtk/src/org/apache/pivot/wtk/skin/
Author: rwhitcomb
Date: Fri Dec 8 19:47:55 2017
New Revision: 1817553
URL: http://svn.apache.org/viewvc?rev=1817553&view=rev
Log:
PIVOT-1014, PIVOT-1011, PIVOT-1012, PIVOT-999: Do all the recent changes in the
Separator and its skin classes. Add the default styles (which had/have some
conflicts) to the "terra_theme_defaults.json" file. Add a setter method for
"padding" using a Sequence.
Move the SeparatorListenerList into the interface (and rename to "Listeners"),
and change to use "forEach" for the iteration.
Modified:
pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraSeparatorSkin.java
pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/terra_theme_defaults.json
pivot/trunk/wtk/src/org/apache/pivot/wtk/Separator.java
pivot/trunk/wtk/src/org/apache/pivot/wtk/SeparatorListener.java
pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/SeparatorSkin.java
Modified: pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraSeparatorSkin.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraSeparatorSkin.java?rev=1817553&r1=1817552&r2=1817553&view=diff
==============================================================================
--- pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraSeparatorSkin.java (original)
+++ pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraSeparatorSkin.java Fri Dec 8 19:47:55 2017
@@ -24,8 +24,6 @@ import org.apache.pivot.wtk.skin.Separat
*/
public class TerraSeparatorSkin extends SeparatorSkin {
public TerraSeparatorSkin() {
- setColor(7);
- setHeadingColor(12);
}
public void setColor(int color) {
Modified: pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/terra_theme_defaults.json
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/terra_theme_defaults.json?rev=1817553&r1=1817552&r2=1817553&view=diff
==============================================================================
--- pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/terra_theme_defaults.json (original)
+++ pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/terra_theme_defaults.json Fri Dec 8 19:47:55 2017
@@ -39,6 +39,21 @@
headingToggles : true
},
+ TerraSeparatorSkin : {
+ // TODO: conflicts between SeparatorSkin and TerraSeparatorSkin
+
+ // color = defaultForegroundColor();
+ // headingColor = defaultForegroundColor();
+
+ font : { bold : true },
+ thickness : 1,
+ padding : [ 4, 0, 4, 4 ],
+
+ // These are from TerraSeparatorSkin
+ color : 7,
+ headingColor : 12
+ },
+
TerraTextAreaSkin : {
// TODO: conflicts here b/w TextAreaSkin and TerraTextAreaSkin:
// This is what TextAreaSkin says right now:
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/Separator.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/Separator.java?rev=1817553&r1=1817552&r2=1817553&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/Separator.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/Separator.java Fri Dec 8 19:47:55 2017
@@ -22,19 +22,9 @@ import org.apache.pivot.util.ListenerLis
* Component representing a horizontal divider.
*/
public class Separator extends Component {
- private static class SeparatorListenerList extends ListenerList<SeparatorListener> implements
- SeparatorListener {
- @Override
- public void headingChanged(Separator separator, String previousHeading) {
- for (SeparatorListener listener : this) {
- listener.headingChanged(separator, previousHeading);
- }
- }
- }
-
private String heading = null;
- private SeparatorListenerList separatorListeners = new SeparatorListenerList();
+ private SeparatorListener.Listeners separatorListeners = new SeparatorListener.Listeners();
public Separator() {
this(null);
@@ -48,7 +38,7 @@ public class Separator extends Component
/**
* Returns the separator's heading.
*
- * @return The separator's heading, or <tt>null</tt> if no heading is set.
+ * @return The separator's heading, or {@code null} if no heading is set.
*/
public String getHeading() {
return heading;
@@ -57,7 +47,7 @@ public class Separator extends Component
/**
* Sets the separator's heading.
*
- * @param heading The new heading, or <tt>null</tt> for no heading.
+ * @param heading The new heading, or {@code null} for no heading.
*/
public void setHeading(String heading) {
String previousHeading = this.heading;
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/SeparatorListener.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/SeparatorListener.java?rev=1817553&r1=1817552&r2=1817553&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/SeparatorListener.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/SeparatorListener.java Fri Dec 8 19:47:55 2017
@@ -16,11 +16,24 @@
*/
package org.apache.pivot.wtk;
+import org.apache.pivot.util.ListenerList;
+
/**
* Separator listener interface.
*/
public interface SeparatorListener {
/**
+ * Separator listener listeners list.
+ */
+ public static class Listeners extends ListenerList<SeparatorListener> implements
+ SeparatorListener {
+ @Override
+ public void headingChanged(Separator separator, String previousHeading) {
+ forEach(listener -> listener.headingChanged(separator, previousHeading));
+ }
+ }
+
+ /**
* Called when a separator's heading has changed.
*
* @param separator The separator that changed.
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/SeparatorSkin.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/SeparatorSkin.java?rev=1817553&r1=1817552&r2=1817553&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/SeparatorSkin.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/SeparatorSkin.java Fri Dec 8 19:47:55 2017
@@ -27,6 +27,8 @@ import java.awt.geom.Area;
import java.awt.geom.Rectangle2D;
import org.apache.pivot.collections.Dictionary;
+import org.apache.pivot.collections.Sequence;
+import org.apache.pivot.util.Utils;
import org.apache.pivot.wtk.Component;
import org.apache.pivot.wtk.Dimensions;
import org.apache.pivot.wtk.GraphicsUtilities;
@@ -47,20 +49,15 @@ public class SeparatorSkin extends Compo
private Insets padding;
public SeparatorSkin() {
- Theme theme = Theme.getTheme();
- font = theme.getFont().deriveFont(Font.BOLD);
-
- color = defaultForegroundColor();
- headingColor = defaultForegroundColor();
-
- thickness = 1;
- padding = new Insets(4, 0, 4, 4);
}
@Override
public void install(Component component) {
super.install(component);
+ Theme theme = currentTheme();
+ theme.setDefaultStyles(this);
+
Separator separator = (Separator) component;
separator.getSeparatorListeners().add(this);
}
@@ -75,8 +72,7 @@ public class SeparatorSkin extends Compo
if (heading != null && heading.length() > 0) {
FontRenderContext fontRenderContext = Platform.getFontRenderContext();
Rectangle2D headingBounds = font.getStringBounds(heading, fontRenderContext);
- preferredWidth = (int) Math.ceil(headingBounds.getWidth())
- + (padding.left + padding.right);
+ preferredWidth = (int) Math.ceil(headingBounds.getWidth()) + padding.getWidth();
}
return preferredWidth;
@@ -97,7 +93,7 @@ public class SeparatorSkin extends Compo
preferredHeight);
}
- preferredHeight += (padding.top + padding.bottom);
+ preferredHeight += padding.getHeight();
return preferredHeight;
}
@@ -120,8 +116,8 @@ public class SeparatorSkin extends Compo
preferredHeight);
}
- preferredHeight += (padding.top + padding.bottom);
- preferredWidth += (padding.left + padding.right);
+ preferredHeight += padding.getHeight();
+ preferredWidth += padding.getWidth();
return new Dimensions(preferredWidth, preferredHeight);
}
@@ -181,9 +177,7 @@ public class SeparatorSkin extends Compo
* @param font The new font for the heading.
*/
public void setFont(Font font) {
- if (font == null) {
- throw new IllegalArgumentException("font is null.");
- }
+ Utils.checkNull(font, "font");
this.font = font;
invalidateComponent();
@@ -195,10 +189,6 @@ public class SeparatorSkin extends Compo
* @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));
}
@@ -208,10 +198,6 @@ public class SeparatorSkin extends Compo
* @param font A dictionary {@link 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));
}
@@ -228,9 +214,7 @@ public class SeparatorSkin extends Compo
* @param color The new color for the horizontal rule.
*/
public void setColor(Color color) {
- if (color == null) {
- throw new IllegalArgumentException("color is null.");
- }
+ Utils.checkNull(color, "color");
this.color = color;
repaintComponent();
@@ -243,11 +227,7 @@ public class SeparatorSkin extends Compo
* values recognized by Pivot}.
*/
public final void setColor(String color) {
- if (color == null) {
- throw new IllegalArgumentException("color is null.");
- }
-
- setColor(GraphicsUtilities.decodeColor(color));
+ setColor(GraphicsUtilities.decodeColor(color, "color"));
}
/**
@@ -263,9 +243,7 @@ public class SeparatorSkin extends Compo
* @param headingColor The new color for the heading text.
*/
public void setHeadingColor(Color headingColor) {
- if (headingColor == null) {
- throw new IllegalArgumentException("headingColor is null.");
- }
+ Utils.checkNull(headingColor, "headingColor");
this.headingColor = headingColor;
repaintComponent();
@@ -278,11 +256,7 @@ public class SeparatorSkin extends Compo
* color values recognized by Pivot}.
*/
public final void setHeadingColor(String headingColor) {
- if (headingColor == null) {
- throw new IllegalArgumentException("headingColor is null.");
- }
-
- setHeadingColor(GraphicsUtilities.decodeColor(headingColor));
+ setHeadingColor(GraphicsUtilities.decodeColor(headingColor, "headingColor"));
}
/**
@@ -298,9 +272,8 @@ public class SeparatorSkin extends Compo
* @param thickness The new rule 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();
}
@@ -311,9 +284,7 @@ public class SeparatorSkin extends Compo
* @param thickness The new integer value for the rule thickness (in pixels).
*/
public final void setThickness(Number thickness) {
- if (thickness == null) {
- throw new IllegalArgumentException("thickness is null.");
- }
+ Utils.checkNull(thickness, "thickness");
setThickness(thickness.intValue());
}
@@ -333,9 +304,7 @@ public class SeparatorSkin extends Compo
* @param padding The new padding values.
*/
public void setPadding(Insets padding) {
- if (padding == null) {
- throw new IllegalArgumentException("padding is null.");
- }
+ Utils.checkNull(padding, "padding");
this.padding = padding;
invalidateComponent();
@@ -349,10 +318,10 @@ public class SeparatorSkin extends Compo
* right}.
*/
public final void setPadding(Dictionary<String, ?> padding) {
- if (padding == null) {
- throw new IllegalArgumentException("padding is null.");
- }
+ setPadding(new Insets(padding));
+ }
+ public final void setPadding(Sequence<?> padding) {
setPadding(new Insets(padding));
}
@@ -373,11 +342,7 @@ public class SeparatorSkin extends Compo
* @param padding The new integer value to use for padding in all areas.
*/
public final void setPadding(Number padding) {
- if (padding == null) {
- throw new IllegalArgumentException("padding is null.");
- }
-
- setPadding(padding.intValue());
+ setPadding(new Insets(padding));
}
/**
@@ -388,10 +353,6 @@ public class SeparatorSkin extends Compo
* 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));
}
@@ -400,4 +361,5 @@ public class SeparatorSkin extends Compo
public void headingChanged(Separator separator, String previousHeading) {
invalidateComponent();
}
+
}