Package com.jhlabs.image
Class ShadowFilter
- java.lang.Object
-
- com.jhlabs.image.AbstractBufferedImageOp
-
- com.jhlabs.image.ShadowFilter
-
- All Implemented Interfaces:
java.awt.image.BufferedImageOp,java.lang.Cloneable
public class ShadowFilter extends AbstractBufferedImageOp
A filter which draws a drop shadow based on the alpha channel of the image.
-
-
Constructor Summary
Constructors Constructor Description ShadowFilter()Construct a ShadowFilter.ShadowFilter(float radius, float xOffset, float yOffset, float opacity)Construct a ShadowFilter.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.awt.image.BufferedImagefilter(java.awt.image.BufferedImage src, java.awt.image.BufferedImage dst)booleangetAddMargins()Get whether to increase the size of the output image to accomodate the shadow.floatgetAngle()Returns the angle of the shadow.java.awt.geom.Rectangle2DgetBounds2D(java.awt.image.BufferedImage src)floatgetDistance()Get the distance of the shadow.floatgetOpacity()Get the opacity of the shadow.java.awt.geom.Point2DgetPoint2D(java.awt.geom.Point2D srcPt, java.awt.geom.Point2D dstPt)floatgetRadius()Get the radius of the kernel.intgetShadowColor()Get the color of the shadow.booleangetShadowOnly()Get whether to only draw the shadow without the original image.voidsetAddMargins(boolean addMargins)Set whether to increase the size of the output image to accomodate the shadow.voidsetAngle(float angle)Specifies the angle of the shadow.voidsetDistance(float distance)Set the distance of the shadow.voidsetOpacity(float opacity)Set the opacity of the shadow.voidsetRadius(float radius)Set the radius of the kernel, and hence the amount of blur.voidsetShadowColor(int shadowColor)Set the color of the shadow.voidsetShadowOnly(boolean shadowOnly)Set whether to only draw the shadow without the original image.java.lang.StringtoString()-
Methods inherited from class com.jhlabs.image.AbstractBufferedImageOp
clone, createCompatibleDestImage, getRenderingHints, getRGB, setRGB, stringToColor
-
-
-
-
Constructor Detail
-
ShadowFilter
public ShadowFilter()
Construct a ShadowFilter.
-
ShadowFilter
public ShadowFilter(float radius, float xOffset, float yOffset, float opacity)Construct a ShadowFilter.- Parameters:
radius- the radius of the shadowxOffset- the X offset of the shadowyOffset- the Y offset of the shadowopacity- the opacity of the shadow
-
-
Method Detail
-
setAngle
public void setAngle(float angle)
Specifies the angle of the shadow.- Parameters:
angle- the angle of the shadow.- See Also:
getAngle()
-
getAngle
public float getAngle()
Returns the angle of the shadow.- Returns:
- the angle of the shadow.
- See Also:
setAngle(float)
-
setDistance
public void setDistance(float distance)
Set the distance of the shadow.- Parameters:
distance- the distance.- See Also:
getDistance()
-
getDistance
public float getDistance()
Get the distance of the shadow.- Returns:
- the distance.
- See Also:
setDistance(float)
-
setRadius
public void setRadius(float radius)
Set the radius of the kernel, and hence the amount of blur. The bigger the radius, the longer this filter will take.- Parameters:
radius- the radius of the blur in pixels.- See Also:
getRadius()
-
getRadius
public float getRadius()
Get the radius of the kernel.- Returns:
- the radius
- See Also:
setRadius(float)
-
setOpacity
public void setOpacity(float opacity)
Set the opacity of the shadow.- Parameters:
opacity- the opacity.- See Also:
getOpacity()
-
getOpacity
public float getOpacity()
Get the opacity of the shadow.- Returns:
- the opacity.
- See Also:
setOpacity(float)
-
setShadowColor
public void setShadowColor(int shadowColor)
Set the color of the shadow.- Parameters:
shadowColor- the color.- See Also:
getShadowColor()
-
getShadowColor
public int getShadowColor()
Get the color of the shadow.- Returns:
- the color.
- See Also:
setShadowColor(int)
-
setAddMargins
public void setAddMargins(boolean addMargins)
Set whether to increase the size of the output image to accomodate the shadow.- Parameters:
addMargins- true to add margins.- See Also:
getAddMargins()
-
getAddMargins
public boolean getAddMargins()
Get whether to increase the size of the output image to accomodate the shadow.- Returns:
- true to add margins.
- See Also:
setAddMargins(boolean)
-
setShadowOnly
public void setShadowOnly(boolean shadowOnly)
Set whether to only draw the shadow without the original image.- Parameters:
shadowOnly- true to only draw the shadow.- See Also:
getShadowOnly()
-
getShadowOnly
public boolean getShadowOnly()
Get whether to only draw the shadow without the original image.- Returns:
- true to only draw the shadow.
- See Also:
setShadowOnly(boolean)
-
getBounds2D
public java.awt.geom.Rectangle2D getBounds2D(java.awt.image.BufferedImage src)
- Specified by:
getBounds2Din interfacejava.awt.image.BufferedImageOp- Overrides:
getBounds2Din classAbstractBufferedImageOp
-
getPoint2D
public java.awt.geom.Point2D getPoint2D(java.awt.geom.Point2D srcPt, java.awt.geom.Point2D dstPt)- Specified by:
getPoint2Din interfacejava.awt.image.BufferedImageOp- Overrides:
getPoint2Din classAbstractBufferedImageOp
-
filter
public java.awt.image.BufferedImage filter(java.awt.image.BufferedImage src, java.awt.image.BufferedImage dst)
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-