modules/graphics/src/main/java/com/sun/scenario/effect/BoxShadow.java
Print this page
@@ -31,10 +31,11 @@
import com.sun.javafx.geom.RectBounds;
import com.sun.javafx.geom.Rectangle;
import com.sun.javafx.geom.transform.BaseTransform;
import com.sun.scenario.effect.impl.Renderer;
import com.sun.scenario.effect.impl.state.BoxShadowState;
+import com.sun.scenario.effect.impl.state.LinearConvolveKernel;
/**
* A shadow effect using a box-shaped convolution kernel, with a configurable
* size for each dimension of the kernel and a number of passes to control
* the quality of the blur.
@@ -119,11 +120,11 @@
setColor(Color4f.BLACK);
setSpread(0f);
}
@Override
- Object getState() {
+ LinearConvolveKernel getState() {
return state;
}
/**
* Returns the input for this {@code Effect}.
@@ -149,11 +150,11 @@
/**
* Returns the horizontal size of the effect kernel.
*
* @return the horizontal size of the effect kernel
*/
- public int getHorizontalSize() {
+ public float getHorizontalSize() {
return state.getHsize();
}
/**
* Sets the horizontal size of the effect kernel.
@@ -166,21 +167,20 @@
*
* @param hsize the horizontal size of the effect kernel
* @throws IllegalArgumentException if {@code hsize}
* is outside the allowable range
*/
- public void setHorizontalSize(int hsize) {
- int old = state.getHsize();
+ public final void setHorizontalSize(float hsize) {
state.setHsize(hsize);
}
/**
* Returns the vertical size of the effect kernel.
*
* @return the vertical size of the effect kernel
*/
- public int getVerticalSize() {
+ public float getVerticalSize() {
return state.getVsize();
}
/**
* Sets the vertical size of the effect kernel.
@@ -193,12 +193,11 @@
*
* @param vsize the vertical size of the effect kernel
* @throws IllegalArgumentException if {@code vsize}
* is outside the allowable range
*/
- public void setVerticalSize(int vsize) {
- int old = state.getVsize();
+ public final void setVerticalSize(float vsize) {
state.setVsize(vsize);
}
/**
* Returns the number of passes of the effect kernel to control the
@@ -224,12 +223,11 @@
*
* @param passes
* @throws IllegalArgumentException if {@code passes} is outside the
* allowable range
*/
- public void setPasses(int passes) {
- int old = state.getBlurPasses();
+ public final void setPasses(int passes) {
state.setBlurPasses(passes);
}
/**
* Returns the shadow color.
@@ -250,12 +248,11 @@
* </pre>
*
* @param color the shadow color
* @throws IllegalArgumentException if {@code color} is null
*/
- public void setColor(Color4f color) {
- Color4f old = state.getShadowColor();
+ public final void setColor(Color4f color) {
state.setShadowColor(color);
}
/**
* Gets the spread of the shadow effect.
@@ -286,12 +283,11 @@
*
* @param spread the spread of the shadow effect
* @throws IllegalArgumentException if {@code spread} is outside the
* allowable range
*/
- public void setSpread(float spread) {
- float old = state.getSpread();
+ public final void setSpread(float spread) {
state.setSpread(spread);
}
public float getGaussianRadius() {
float d = (getHorizontalSize() + getVerticalSize()) / 2.0f;
@@ -383,43 +379,10 @@
r.intersectWith(outputClip);
return r;
}
@Override
- public ImageData filterImageDatas(FilterContext fctx,
- BaseTransform transform,
- Rectangle outputClip,
- ImageData... inputs)
- {
- return state.filterImageDatas(this, fctx, transform, outputClip, inputs);
- }
-
- @Override
- public boolean operatesInUserSpace() {
- return true;
- }
-
- @Override
- protected Rectangle getInputClip(int inputIndex,
- BaseTransform transform,
- Rectangle outputClip)
- {
- // A blur needs as much "fringe" data from its input as it creates
- // around its output so we use the same expansion as is used in the
- // result bounds.
- if (outputClip != null) {
- int hgrow = state.getKernelSize(0) / 2;
- int vgrow = state.getKernelSize(1) / 2;
- if ((hgrow | vgrow) != 0) {
- outputClip = new Rectangle(outputClip);
- outputClip.grow(hgrow, vgrow);
- }
- }
- return outputClip;
- }
-
- @Override
public boolean reducesOpaquePixels() {
return true;
}
@Override