Class ShadowFilter

All 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 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

    • setAngle

      public void setAngle(float angle)
      Specifies the angle of the shadow.
      Parameters:
      angle - the angle of the shadow.
      See Also:
    • getAngle

      public float getAngle()
      Returns the angle of the shadow.
      Returns:
      the angle of the shadow.
      See Also:
    • setDistance

      public void setDistance(float distance)
      Set the distance of the shadow.
      Parameters:
      distance - the distance.
      See Also:
    • getDistance

      public float getDistance()
      Get the distance of the shadow.
      Returns:
      the distance.
      See Also:
    • 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

      public float getRadius()
      Get the radius of the kernel.
      Returns:
      the radius
      See Also:
    • setOpacity

      public void setOpacity(float opacity)
      Set the opacity of the shadow.
      Parameters:
      opacity - the opacity.
      See Also:
    • getOpacity

      public float getOpacity()
      Get the opacity of the shadow.
      Returns:
      the opacity.
      See Also:
    • setShadowColor

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

      public int getShadowColor()
      Get the color of the shadow.
      Returns:
      the color.
      See Also:
    • 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

      public boolean getAddMargins()
      Get whether to increase the size of the output image to accomodate the shadow.
      Returns:
      true to add margins.
      See Also:
    • 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

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

      public Rectangle2D getBounds2D(BufferedImage src)
      Specified by:
      getBounds2D in interface BufferedImageOp
      Overrides:
      getBounds2D in class AbstractBufferedImageOp
    • getPoint2D

      public Point2D getPoint2D(Point2D srcPt, Point2D dstPt)
      Specified by:
      getPoint2D in interface BufferedImageOp
      Overrides:
      getPoint2D in class AbstractBufferedImageOp
    • filter

      public BufferedImage filter(BufferedImage src, BufferedImage dst)
    • toString

      public String toString()
      Overrides:
      toString in class Object