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/07/31 23:49:37 UTC
svn commit: r1803600 - /pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/
Author: rwhitcomb
Date: Mon Jul 31 23:49:36 2017
New Revision: 1803600
URL: http://svn.apache.org/viewvc?rev=1803600&view=rev
Log:
Simplify and cleanup Decorator classes:
* Add new default implementations (in "Decorator.java") for
"getBounds()" and "getTransform()" methods, and remove these
methods in subclasses that just did the default operation.
* Same for the "update()" method.
* Use the new Bounds(Dimensions) constructor where possible.
* Do parameter checking using "Utils.checkNull()" (and maybe
its friends).
* Rename some parameters from "xxxArgument" to "xxxValue" as was
done in other places (seems less artificial to me).
Modified:
pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/BaselineDecorator.java
pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/BlurDecorator.java
pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/ClipDecorator.java
pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/Decorator.java
pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/DropShadowDecorator.java
pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/FadeDecorator.java
pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/GrayscaleDecorator.java
pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/OverlayDecorator.java
pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/ReflectionDecorator.java
pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/RotationDecorator.java
pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/SaturationDecorator.java
pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/ShadeDecorator.java
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/BaselineDecorator.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/BaselineDecorator.java?rev=1803600&r1=1803599&r2=1803600&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/BaselineDecorator.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/BaselineDecorator.java Mon Jul 31 23:49:36 2017
@@ -33,11 +33,11 @@ public class BaselineDecorator implement
private Graphics2D graphics = null;
@Override
- public Graphics2D prepare(Component componentArgument, Graphics2D graphicsArgument) {
- this.component = componentArgument;
- this.graphics = graphicsArgument;
+ public Graphics2D prepare(Component componentValue, Graphics2D graphicsValue) {
+ this.component = componentValue;
+ this.graphics = graphicsValue;
- return graphicsArgument;
+ return graphicsValue;
}
@Override
@@ -63,14 +63,4 @@ public class BaselineDecorator implement
graphics = null;
}
- @Override
- public Bounds getBounds(Component componentArgument) {
- return new Bounds(0, 0, componentArgument.getWidth(), componentArgument.getHeight());
- }
-
- @Override
- public AffineTransform getTransform(Component componentArgument) {
- return new AffineTransform();
- }
-
}
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/BlurDecorator.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/BlurDecorator.java?rev=1803600&r1=1803599&r2=1803600&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/BlurDecorator.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/BlurDecorator.java Mon Jul 31 23:49:36 2017
@@ -67,8 +67,8 @@ public class BlurDecorator implements De
}
@Override
- public Graphics2D prepare(Component component, Graphics2D graphicsArgument) {
- this.graphics = graphicsArgument;
+ public Graphics2D prepare(Component component, Graphics2D graphicsValue) {
+ this.graphics = graphicsValue;
int width = component.getWidth();
int height = component.getHeight();
@@ -79,7 +79,7 @@ public class BlurDecorator implements De
}
bufferedImageGraphics = bufferedImage.createGraphics();
- bufferedImageGraphics.setClip(graphicsArgument.getClip());
+ bufferedImageGraphics.setClip(graphicsValue.getClip());
return bufferedImageGraphics;
}
@@ -106,13 +106,4 @@ public class BlurDecorator implements De
graphics = null;
}
- @Override
- public Bounds getBounds(Component component) {
- return new Bounds(0, 0, component.getWidth(), component.getHeight());
- }
-
- @Override
- public AffineTransform getTransform(Component component) {
- return new AffineTransform();
- }
}
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/ClipDecorator.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/ClipDecorator.java?rev=1803600&r1=1803599&r2=1803600&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/ClipDecorator.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/ClipDecorator.java Mon Jul 31 23:49:36 2017
@@ -38,7 +38,7 @@ public class ClipDecorator implements De
}
public void setX(int x) {
- setOrigin(x, y);
+ this.x = x;
}
public int getY() {
@@ -46,7 +46,7 @@ public class ClipDecorator implements De
}
public void setY(int y) {
- setOrigin(x, y);
+ this.y = y;
}
public void setOrigin(int x, int y) {
@@ -63,7 +63,7 @@ public class ClipDecorator implements De
}
public void setWidth(int width) {
- setSize(width, height);
+ this.width = width;
}
public int getHeight() {
@@ -71,7 +71,7 @@ public class ClipDecorator implements De
}
public void setHeight(int height) {
- setSize(width, height);
+ this.height = height;
}
public void setSize(int width, int height) {
@@ -90,17 +90,8 @@ public class ClipDecorator implements De
}
@Override
- public void update() {
- // No-op
- }
-
- @Override
public Bounds getBounds(Component component) {
return new Bounds(x, y, width, height);
}
- @Override
- public AffineTransform getTransform(Component component) {
- return new AffineTransform();
- }
}
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/Decorator.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/Decorator.java?rev=1803600&r1=1803599&r2=1803600&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/Decorator.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/Decorator.java Mon Jul 31 23:49:36 2017
@@ -62,23 +62,34 @@ public interface Decorator {
* was painted. This method is called immediately after
* {@link Component#paint(Graphics2D)}; decorators are called in ascending
* order.
+ * <p> This default version simply returns, without doing anything (often
+ * the appropriate thing to do).
*/
- public void update();
+ public default void update() {
+ // Do nothing
+ }
/**
* Returns the bounding area of the decorator.
+ * <p> This default simply returns the bounds of the component's size.
*
* @param component The component that the decorator is attached to.
* @return The decorator's bounds, relative to the component's origin.
*/
- public Bounds getBounds(Component component);
+ public default Bounds getBounds(Component component) {
+ return new Bounds(component.getSize());
+ }
/**
* Returns the transformation the decorator applies to the component's
* coordinate space.
+ * <p> This default simply returns a new {@link AffineTransform}.
*
* @param component The component the decorator is attached to.
* @return The decorator's transform.
*/
- public AffineTransform getTransform(Component component);
+ public default AffineTransform getTransform(Component component) {
+ return new AffineTransform();
+ }
+
}
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/DropShadowDecorator.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/DropShadowDecorator.java?rev=1803600&r1=1803599&r2=1803600&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/DropShadowDecorator.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/DropShadowDecorator.java Mon Jul 31 23:49:36 2017
@@ -24,12 +24,13 @@ import java.awt.image.BufferedImage;
import java.awt.image.Raster;
import java.awt.image.WritableRaster;
+import org.apache.pivot.util.Utils;
import org.apache.pivot.wtk.Bounds;
import org.apache.pivot.wtk.Component;
import org.apache.pivot.wtk.GraphicsUtilities;
/**
- * Decorator that adds a drop shadows to a component.
+ * Decorator that adds a drop shadow to a component.
*/
public class DropShadowDecorator implements Decorator {
private int blurRadius;
@@ -54,8 +55,6 @@ public class DropShadowDecorator impleme
}
/**
- * Returns the color used to draw the shadow.
- *
* @return The color used to draw the shadow.
*/
public Color getShadowColor() {
@@ -79,9 +78,7 @@ public class DropShadowDecorator impleme
* Pivot}.
*/
public final void setShadowColor(String shadowColor) {
- if (shadowColor == null) {
- throw new IllegalArgumentException("shadowColor is null.");
- }
+ Utils.checkNull(shadowColor, "shadowColor");
setShadowColor(GraphicsUtilities.decodeColor(shadowColor));
}
@@ -105,8 +102,6 @@ public class DropShadowDecorator impleme
}
/**
- * Returns the blur radius used to draw the shadow.
- *
* @return The blur radius used to draw the shadow.
*/
public int getBlurRadius() {
@@ -125,7 +120,7 @@ public class DropShadowDecorator impleme
/**
* Returns the amount that the drop shadow will be offset along the x axis.
*
- * @return The x offset used to draw the shadow
+ * @return The x offset used to draw the shadow.
*/
public int getXOffset() {
return xOffset;
@@ -134,7 +129,7 @@ public class DropShadowDecorator impleme
/**
* Sets the amount that the drop shadow will be offset along the x axis.
*
- * @param xOffset The x offset used to draw the shadow
+ * @param xOffset The x offset used to draw the shadow.
*/
public void setXOffset(int xOffset) {
this.xOffset = xOffset;
@@ -143,7 +138,7 @@ public class DropShadowDecorator impleme
/**
* Returns the amount that the drop shadow will be offset along the y axis.
*
- * @return The y offset used to draw the shadow
+ * @return The y offset used to draw the shadow.
*/
public int getYOffset() {
return yOffset;
@@ -152,7 +147,7 @@ public class DropShadowDecorator impleme
/**
* Sets the amount that the drop shadow will be offset along the y axis.
*
- * @param yOffset The y offset used to draw the shadow
+ * @param yOffset The y offset used to draw the shadow.
*/
public void setYOffset(int yOffset) {
this.yOffset = yOffset;
@@ -176,8 +171,7 @@ public class DropShadowDecorator impleme
shadowImage = createShadow(rectangleImage);
}
- // Avoid drawing shadow if it will be covered by the component
- // itself:
+ // Avoid drawing shadow if it will be covered by the component itself:
Bounds paintBounds = new Bounds(0, 0, width, height);
if (!component.isOpaque()
|| !paintBounds.contains(new Bounds(graphics.getClipBounds()))) {
@@ -191,21 +185,11 @@ public class DropShadowDecorator impleme
}
@Override
- public void update() {
- // No-op
- }
-
- @Override
public Bounds getBounds(Component component) {
return new Bounds(xOffset - blurRadius, yOffset - blurRadius, component.getWidth()
+ blurRadius * 2, component.getHeight() + blurRadius * 2);
}
- @Override
- public AffineTransform getTransform(Component component) {
- return new AffineTransform();
- }
-
/**
* Generates the shadow for a given picture and the current properties of
* the decorator. The generated image dimensions are computed as follows:
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/FadeDecorator.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/FadeDecorator.java?rev=1803600&r1=1803599&r2=1803600&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/FadeDecorator.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/FadeDecorator.java Mon Jul 31 23:49:36 2017
@@ -44,7 +44,7 @@ public class FadeDecorator implements De
public void setOpacity(float opacity) {
if (opacity < 0f || opacity > 1f) {
throw new IllegalArgumentException(
- "opacity must be a value between 0 and 1, inclusive.");
+ "opacity must be a value between 0.0 and 1.0, inclusive.");
}
this.opacity = opacity;
@@ -56,18 +56,4 @@ public class FadeDecorator implements De
return graphics;
}
- @Override
- public void update() {
- // No-op
- }
-
- @Override
- public Bounds getBounds(Component component) {
- return new Bounds(0, 0, component.getWidth(), component.getHeight());
- }
-
- @Override
- public AffineTransform getTransform(Component component) {
- return new AffineTransform();
- }
}
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/GrayscaleDecorator.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/GrayscaleDecorator.java?rev=1803600&r1=1803599&r2=1803600&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/GrayscaleDecorator.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/GrayscaleDecorator.java Mon Jul 31 23:49:36 2017
@@ -38,8 +38,8 @@ public class GrayscaleDecorator implemen
private Graphics2D bufferedImageGraphics = null;
@Override
- public Graphics2D prepare(Component component, Graphics2D graphicsArgument) {
- this.graphics = graphicsArgument;
+ public Graphics2D prepare(Component component, Graphics2D graphicsValue) {
+ this.graphics = graphicsValue;
int width = component.getWidth();
int height = component.getHeight();
@@ -63,7 +63,7 @@ public class GrayscaleDecorator implemen
}
bufferedImageGraphics = bufferedImage.createGraphics();
- bufferedImageGraphics.setClip(graphicsArgument.getClip());
+ bufferedImageGraphics.setClip(graphicsValue.getClip());
return bufferedImageGraphics;
}
@@ -81,13 +81,4 @@ public class GrayscaleDecorator implemen
graphics = null;
}
- @Override
- public Bounds getBounds(Component component) {
- return new Bounds(0, 0, component.getWidth(), component.getHeight());
- }
-
- @Override
- public AffineTransform getTransform(Component component) {
- return new AffineTransform();
- }
}
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/OverlayDecorator.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/OverlayDecorator.java?rev=1803600&r1=1803599&r2=1803600&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/OverlayDecorator.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/OverlayDecorator.java Mon Jul 31 23:49:36 2017
@@ -47,13 +47,13 @@ public class OverlayDecorator implements
}
@Override
- public Graphics2D prepare(Component component, Graphics2D graphicsArgument) {
- this.graphics = graphicsArgument;
+ public Graphics2D prepare(Component component, Graphics2D graphicsValue) {
+ this.graphics = graphicsValue;
overlay.setSize(component.getSize());
overlay.validate();
- return graphicsArgument;
+ return graphicsValue;
}
@Override
@@ -63,13 +63,4 @@ public class OverlayDecorator implements
graphics = null;
}
- @Override
- public Bounds getBounds(Component component) {
- return new Bounds(0, 0, component.getWidth(), component.getHeight());
- }
-
- @Override
- public AffineTransform getTransform(Component component) {
- return new AffineTransform();
- }
}
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/ReflectionDecorator.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/ReflectionDecorator.java?rev=1803600&r1=1803599&r2=1803600&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/ReflectionDecorator.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/ReflectionDecorator.java Mon Jul 31 23:49:36 2017
@@ -38,12 +38,12 @@ public class ReflectionDecorator impleme
private Graphics2D componentImageGraphics = null;
@Override
- public Graphics2D prepare(Component componentArgument, Graphics2D graphicsArgument) {
- this.component = componentArgument;
- this.graphics = graphicsArgument;
+ public Graphics2D prepare(Component componentValue, Graphics2D graphicsValue) {
+ this.component = componentValue;
+ this.graphics = graphicsValue;
- int width = componentArgument.getWidth();
- int height = componentArgument.getHeight();
+ int width = componentValue.getWidth();
+ int height = componentValue.getHeight();
componentImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
componentImageGraphics = componentImage.createGraphics();
@@ -88,14 +88,14 @@ public class ReflectionDecorator impleme
}
@Override
- public Bounds getBounds(Component componentArgument) {
- return new Bounds(0, 0, componentArgument.getWidth(), componentArgument.getHeight() * 2);
+ public Bounds getBounds(Component componentValue) {
+ return new Bounds(0, 0, componentValue.getWidth(), componentValue.getHeight() * 2);
}
@Override
- public AffineTransform getTransform(Component componentArgument) {
+ public AffineTransform getTransform(Component componentValue) {
AffineTransform transform = AffineTransform.getScaleInstance(1.0, -1.0);
- transform.translate(0, -(componentArgument.getHeight() * 2));
+ transform.translate(0, -(componentValue.getHeight() * 2));
return transform;
}
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/RotationDecorator.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/RotationDecorator.java?rev=1803600&r1=1803599&r2=1803600&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/RotationDecorator.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/RotationDecorator.java Mon Jul 31 23:49:36 2017
@@ -73,14 +73,6 @@ public class RotationDecorator implement
* {@inheritDoc}
*/
@Override
- public void update() {
- // No-op
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
public Bounds getBounds(Component component) {
int width = component.getWidth();
int height = component.getHeight();
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/SaturationDecorator.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/SaturationDecorator.java?rev=1803600&r1=1803599&r2=1803600&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/SaturationDecorator.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/SaturationDecorator.java Mon Jul 31 23:49:36 2017
@@ -26,6 +26,7 @@ import java.awt.geom.AffineTransform;
import java.awt.image.BufferedImage;
import java.awt.image.WritableRaster;
+import org.apache.pivot.util.Utils;
import org.apache.pivot.wtk.Bounds;
import org.apache.pivot.wtk.Component;
@@ -57,21 +58,19 @@ public class SaturationDecorator impleme
}
public void setMultiplier(Number multiplier) {
- if (multiplier == null) {
- throw new IllegalArgumentException("Multiplier is null.");
- }
+ Utils.checkNull(multiplier, "Multiplier");
setMultiplier(multiplier.floatValue());
}
@Override
- public Graphics2D prepare(Component component, Graphics2D graphicsArgument) {
+ public Graphics2D prepare(Component component, Graphics2D graphicsValue) {
int x = 0;
int y = 0;
int width = component.getWidth();
int height = component.getHeight();
- java.awt.Rectangle clipBounds = graphicsArgument.getClipBounds();
+ java.awt.Rectangle clipBounds = graphicsValue.getClipBounds();
if (clipBounds != null) {
x = clipBounds.x;
y = clipBounds.y;
@@ -81,11 +80,11 @@ public class SaturationDecorator impleme
componentImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
- this.graphics = graphicsArgument;
+ this.graphics = graphicsValue;
componentGraphics = componentImage.createGraphics();
componentGraphics.translate(-x, -y);
- componentGraphics.setClip(graphicsArgument.getClip());
+ componentGraphics.setClip(graphicsValue.getClip());
return componentGraphics;
}
@@ -142,13 +141,4 @@ public class SaturationDecorator impleme
graphics = null;
}
- @Override
- public Bounds getBounds(Component component) {
- return new Bounds(0, 0, component.getWidth(), component.getHeight());
- }
-
- @Override
- public AffineTransform getTransform(Component component) {
- return new AffineTransform();
- }
}
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/ShadeDecorator.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/ShadeDecorator.java?rev=1803600&r1=1803599&r2=1803600&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/ShadeDecorator.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/ShadeDecorator.java Mon Jul 31 23:49:36 2017
@@ -45,28 +45,29 @@ public class ShadeDecorator implements D
this(0.33f, Color.BLACK);
}
+ private void checkOpacity(float opacityValue) {
+ if (opacityValue <= 0.0f || opacityValue >= 1.0f) {
+ throw new IllegalArgumentException("opacity must be between 0.0 and 1.0, exclusive.");
+ }
+ }
+
/**
* Creates a new <tt>ShadeDecorator</tt> with the specified opacity and
* shade color.
*
- * @param opacity The opacity of the shade, between 0 and 1, exclusive.
+ * @param opacity The opacity of the shade, between 0.0 and 1.0, exclusive.
* @param color The color of the shade.
*/
public ShadeDecorator(float opacity, Color color) {
- if (opacity <= 0 || opacity >= 1) {
- throw new IllegalArgumentException("opacity must be between 0 and 1, exclusive.");
- }
-
- if (color == null) {
- throw new IllegalArgumentException("color is null.");
- }
+ checkOpacity(opacity);
+ Utils.checkNull(color, "color");
this.opacity = opacity;
this.color = color;
}
/**
- * @return The opacity of the decorator, in [0,1].
+ * @return The opacity of the decorator, in [0.0,1.0].
*/
public float getOpacity() {
return opacity;
@@ -75,21 +76,21 @@ public class ShadeDecorator implements D
/**
* Sets the opacity of the decorator.
*
- * @param opacity A number between 0 (transparent) and 1 (opaque)
+ * @param opacity A number between 0.0 (transparent) and 1.0 (opaque), exclusive.
*/
public void setOpacity(float opacity) {
+ checkOpacity(opacity);
+
this.opacity = opacity;
}
/**
* Sets the opacity of the decorator.
*
- * @param opacity A number between 0 (transparent) and 1 (opaque)
+ * @param opacity A number between 0.0 (transparent) and 1.0 (opaque), exclusive.
*/
public void setOpacity(Number opacity) {
- if (opacity == null) {
- throw new IllegalArgumentException("opacity is null.");
- }
+ Utils.checkNull(opacity, "opacity");
setOpacity(opacity.floatValue());
}
@@ -107,9 +108,7 @@ public class ShadeDecorator implements D
* @param color The new color for the decorator.
*/
public void setColor(Color color) {
- if (color == null) {
- throw new IllegalArgumentException("color is null.");
- }
+ Utils.checkNull(color, "color");
this.color = color;
}
@@ -121,19 +120,17 @@ public class ShadeDecorator implements D
* values recognized by Pivot}.
*/
public final void setColor(String color) {
- if (color == null) {
- throw new IllegalArgumentException("color is null.");
- }
+ Utils.checkNull(color, "color");
setColor(GraphicsUtilities.decodeColor(color));
}
@Override
- public Graphics2D prepare(Component componentArgument, Graphics2D graphicsArgument) {
- this.component = componentArgument;
- this.graphics = graphicsArgument;
+ public Graphics2D prepare(Component componentValue, Graphics2D graphicsValue) {
+ this.component = componentValue;
+ this.graphics = graphicsValue;
- return graphicsArgument;
+ return graphicsValue;
}
@Override
@@ -147,8 +144,8 @@ public class ShadeDecorator implements D
}
@Override
- public Bounds getBounds(Component componentArgument) {
- return new Bounds(0, 0, componentArgument.getWidth(), componentArgument.getHeight());
+ public Bounds getBounds(Component componentValue) {
+ return new Bounds(componentValue.getSize());
}
@Override
@@ -157,3 +154,4 @@ public class ShadeDecorator implements D
}
}
+
\ No newline at end of file