com.jhlabs.image

Class ShadowFilter

Implemented Interfaces:
BufferedImageOp, Cloneable

public class ShadowFilter
extends AbstractBufferedImageOp

A filter which draws a drop shadow based on the alpha channel of the image.

Constructor Summary

ShadowFilter()
Construct a ShadowFilter.
ShadowFilter(float radius, float xOffset, float yOffset, float opacity)
Construct a ShadowFilter.

Method Summary

BufferedImage
filter(BufferedImage src, BufferedImage dst)
boolean
getAddMargins()
Get whether to increase the size of the output image to accomodate the shadow.
float
getAngle()
Returns the angle of the shadow.
Rectangle2D
getBounds2D(BufferedImage src)
float
getDistance()
Get the distance of the shadow.
float
getOpacity()
Get the opacity of the shadow.
Point2D
getPoint2D(Point2D srcPt, Point2D dstPt)
float
getRadius()
Get the radius of the kernel.
int
getShadowColor()
Get the color of the shadow.
boolean
getShadowOnly()
Get whether to only draw the shadow without the original image.
void
setAddMargins(boolean addMargins)
Set whether to increase the size of the output image to accomodate the shadow.
void
setAngle(float angle)
Specifies the angle of the shadow.
void
setDistance(float distance)
Set the distance of the shadow.
void
setOpacity(float opacity)
Set the opacity of the shadow.
void
setRadius(float radius)
Set the radius of the kernel, and hence the amount of blur.
void
setShadowColor(int shadowColor)
Set the color of the shadow.
void
setShadowOnly(boolean shadowOnly)
Set whether to only draw the shadow without the original image.
String
toString()

Methods inherited from class com.jhlabs.image.AbstractBufferedImageOp

clone, createCompatibleDestImage, getBounds2D, getPoint2D, getRGB, getRenderingHints, setRGB

Constructor Details

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 shadow
xOffset - the X offset of the shadow
yOffset - the Y offset of the shadow
opacity - the opacity of the shadow

Method Details

filter

public BufferedImage filter(BufferedImage src,
                            BufferedImage dst)

getAddMargins

public boolean getAddMargins()
Get whether to increase the size of the output image to accomodate the shadow.
Returns:
true to add margins.

getAngle

public float getAngle()
Returns the angle of the shadow.
Returns:
the angle of the shadow.

getBounds2D

public Rectangle2D getBounds2D(BufferedImage src)
Overrides:
getBounds2D in interface AbstractBufferedImageOp

getDistance

public float getDistance()
Get the distance of the shadow.
Returns:
the distance.

getOpacity

public float getOpacity()
Get the opacity of the shadow.
Returns:
the opacity.

getPoint2D

public Point2D getPoint2D(Point2D srcPt,
                          Point2D dstPt)
Overrides:
getPoint2D in interface AbstractBufferedImageOp

getRadius

public float getRadius()
Get the radius of the kernel.
Returns:
the radius

getShadowColor

public int getShadowColor()
Get the color of the shadow.
Returns:
the color.

getShadowOnly

public boolean getShadowOnly()
Get whether to only draw the shadow without the original image.
Returns:
true to only draw the shadow.

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.

setAngle

public void setAngle(float angle)
Specifies the angle of the shadow.
Parameters:
angle - the angle of the shadow.

setDistance

public void setDistance(float distance)
Set the distance of the shadow.
Parameters:
distance - the distance.

setOpacity

public void setOpacity(float opacity)
Set the opacity of the shadow.
Parameters:
opacity - the opacity.

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.

setShadowColor

public void setShadowColor(int shadowColor)
Set the color of the shadow.
Parameters:
shadowColor - the color.

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.

toString

public String toString()