Class 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.BufferedImage filter​(java.awt.image.BufferedImage src, java.awt.image.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.
      java.awt.geom.Rectangle2D getBounds2D​(java.awt.image.BufferedImage src)  
      float getDistance()
      Get the distance of the shadow.
      float getOpacity()
      Get the opacity of the shadow.
      java.awt.geom.Point2D getPoint2D​(java.awt.geom.Point2D srcPt, java.awt.geom.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.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • 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 shadow
        xOffset - the X offset of the shadow
        yOffset - the Y offset of the shadow
        opacity - 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:
        getBounds2D in interface java.awt.image.BufferedImageOp
        Overrides:
        getBounds2D in class AbstractBufferedImageOp
      • getPoint2D

        public java.awt.geom.Point2D getPoint2D​(java.awt.geom.Point2D srcPt,
                                                java.awt.geom.Point2D dstPt)
        Specified by:
        getPoint2D in interface java.awt.image.BufferedImageOp
        Overrides:
        getPoint2D in class AbstractBufferedImageOp
      • filter

        public java.awt.image.BufferedImage filter​(java.awt.image.BufferedImage src,
                                                   java.awt.image.BufferedImage dst)
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object