Class GlowFilter

  • All Implemented Interfaces:
    java.awt.image.BufferedImageOp

    public final class GlowFilter
    extends AbstractImageFilter
    A filter that applies a glow effect around the edge defined by the non-transparent parts of an image.

    If either the number of blurring iterations or the effect strength is zero, the glow effect will not be visible.

    Since:
    3.0
    Author:
    Chris Jennings
    • Constructor Summary

      Constructors 
      Constructor Description
      GlowFilter()
      Creates a new glow filter with a yellow-white glow, width of 2, blur radius of 4, 1 iteration, strength of 2, and an outer glow.
      GlowFilter​(int color, int blurRadius, boolean outerGlow, int strength)
      Creates a new glow filter.
      GlowFilter​(int color, int strokeWidth, int blurRadius, int iterations, boolean outerGlow, int strength)
      Creates a new glow filter.
      GlowFilter​(java.awt.Color color, int blurRadius, boolean outerGlow, int strength)
      Creates a new glow filter.
      GlowFilter​(java.awt.Color color, int strokeWidth, int blurRadius, int iterations, boolean outerGlow, int strength)
      Creates a new glow filter.
    • Constructor Detail

      • GlowFilter

        public GlowFilter()
        Creates a new glow filter with a yellow-white glow, width of 2, blur radius of 4, 1 iteration, strength of 2, and an outer glow.
      • GlowFilter

        public GlowFilter​(int color,
                          int blurRadius,
                          boolean outerGlow,
                          int strength)
        Creates a new glow filter.
        Parameters:
        color - the color, specified as an sRGB integer
        blurRadius - the blur radius for the glow
        outerGlow - if true, the filter produces an outer glow
        strength - the strength of the glow effect
      • GlowFilter

        public GlowFilter​(java.awt.Color color,
                          int blurRadius,
                          boolean outerGlow,
                          int strength)
        Creates a new glow filter.
        Parameters:
        color - the color, specified as an sRGB integer
        blurRadius - the blur radius for the glow
        outerGlow - if true, the filter produces an outer glow
        strength - the strength of the glow effect
      • GlowFilter

        public GlowFilter​(int color,
                          int strokeWidth,
                          int blurRadius,
                          int iterations,
                          boolean outerGlow,
                          int strength)
        Creates a new glow filter.
        Parameters:
        color - the color, specified as an sRGB integer
        strokeWidth - the width of the glow, exclusive of blurring
        blurRadius - the blur radius for the glow
        iterations - the number of iterations of the blurring effect
        outerGlow - if true, the filter produces an outer glow
        strength - the strength of the glow effect
      • GlowFilter

        public GlowFilter​(java.awt.Color color,
                          int strokeWidth,
                          int blurRadius,
                          int iterations,
                          boolean outerGlow,
                          int strength)
        Creates a new glow filter.
        Parameters:
        color - the color, specified as an sRGB integer
        strokeWidth - the width of the glow, exclusive of blurring
        blurRadius - the blur radius for the glow
        iterations - the number of iterations of the blurring effect
        outerGlow - if true, the filter produces an outer glow
        strength - the strength of the glow effect
    • Method Detail

      • getColorRGB

        public int getColorRGB()
        Returns the current glow colour as an ARGB integer value.
        Returns:
        the glow colour in 0xAARRGGBB format
      • setColorRGB

        public void setColorRGB​(int color)
        Sets the current glow colour using an ARGB integer.
        Parameters:
        color - the glow colour in 0xAARRGGBB format
      • getColor

        public java.awt.Color getColor()
        Returns the current glow colour as an ARGB integer value.
        Returns:
        the glow colour
      • setColor

        public void setColor​(java.awt.Color color)
        Sets the current glow colour using a Color instance.
        Parameters:
        color - the glow color
      • setBlurRadius

        public void setBlurRadius​(int radius)
        Sets the blurring radius of the glow effect.
        Parameters:
        radius - the blur radius of the glow effect, in pixels
      • getBlurRadius

        public int getBlurRadius()
        Returns the radius of the blurring applied to the glow effect.
        Returns:
        the blur radius of the glow effect, in pixels
      • setDistance

        @Deprecated
        public void setDistance​(int blurRadius)
        Deprecated.
        Replaced by setBlurRadius(int).
        Sets the blurring radius of the glow effect.
        Parameters:
        blurRadius - the blur radius of the glow effect, in pixels
      • getDistance

        @Deprecated
        public int getDistance()
        Deprecated.
        Replaced by getBlurRadius().
        Returns the radius of the blurring applied to the glow effect.
        Returns:
        the blur radius of the glow effect, in pixels
      • setWidth

        public void setWidth​(int size)
        The size of glow, exclusive of blurring.
        Parameters:
        size - the glow size, in pixels
      • getWidth

        public int getWidth()
        Returns the glow size, exclusive of blurring.
        Returns:
        the glow size, in pixels
      • isOuterGlow

        public boolean isOuterGlow()
        Returns true if the filter will produce an outer glow, or false if the filter will produce an inner glow.
        Returns:
        true for an outer glow type; false for an inner glow type
      • setOuterGlow

        public void setOuterGlow​(boolean outerGlow)
        Sets the type of glow effect to grow inward from the edge, outward from the edge, or both.
        Parameters:
        outerGlow - true for an outer glow type; false for an inner glow type
      • getStrength

        public int getStrength()
        Returns the strength of the glow effect. Higher values produce a more intense glow.
        Returns:
        the positive glow effect strength
      • setStrength

        public void setStrength​(int strength)
        Sets the strength of the glow effect. Any non-negative value is valid, but typical values are in the range 1 to 8. Higher values will produce a more intense (less translucent) glow.
        Parameters:
        strength - the positive intensity of the glow effect
      • setIterations

        public void setIterations​(int iterations)
        Sets the number of blurring iterations that will be applied to the glow effect. This value may be 0, but cannot be negative. The default is one; higher values will produce a smoother glow effect but will also increase the extent of the glow.
      • getIterations

        public int getIterations()
        Returns the number of blurring iterations that will be applied to the glow effect. This value may be 0, but cannot be negative.
        Returns:
        the number of times the blur effect is applied
      • setSourceImagePainted

        public void setSourceImagePainted​(boolean paintSource)
        Sets whether the original image will be included in the output. If true, the glow effect will be combined with the original image.
        Parameters:
        paintSource - true to include the image the effect applies to, false to produce the glow effect only
      • isSourceImagePainted

        public boolean isSourceImagePainted()
        Returns true if the original source image appears in the destination.
        Returns:
        true to include the image the effect applies to, false to produce the glow effect only
      • filter

        public java.awt.image.BufferedImage filter​(java.awt.image.BufferedImage src,
                                                   java.awt.image.BufferedImage dest)