Class Transparency

  • All Implemented Interfaces:
    ImageFilter

    public class Transparency
    extends java.lang.Object
    implements ImageFilter
    An image filter which will make an image transparent.

    The resulting image will always have an image type of BufferedImage.TYPE_INT_ARGB.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.awt.AlphaComposite composite
      The alpha composite to use when drawing the transparent image.
    • Constructor Summary

      Constructors 
      Constructor Description
      Transparency​(double alpha)
      Instantiates a Transparency filter with the specified opacity.
      Transparency​(float alpha)
      Instantiates a Transparency filter with the specified opacity.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.awt.image.BufferedImage apply​(java.awt.image.BufferedImage img)
      Applies a image filtering operation on an image.
      float getAlpha()
      Returns the opacity of this filter.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • composite

        private final java.awt.AlphaComposite composite
        The alpha composite to use when drawing the transparent image.
    • Constructor Detail

      • Transparency

        public Transparency​(float alpha)
        Instantiates a Transparency filter with the specified opacity.
        Parameters:
        alpha - The opacity of the resulting image. The value should be between 0.0f (transparent) to 1.0f (opaque), inclusive.
        Throws:
        java.lang.IllegalArgumentException - If the specified opacity is outside of the range specified above.
      • Transparency

        public Transparency​(double alpha)
        Instantiates a Transparency filter with the specified opacity.

        This is a convenience constructor for the Transparency(float) constructor.

        Parameters:
        alpha - The opacity of the resulting image. The value should be between 0.0f (transparent) to 1.0f (opaque), inclusive.
        Throws:
        java.lang.IllegalArgumentException - If the specified opacity is outside of the range specified above.
    • Method Detail

      • apply

        public java.awt.image.BufferedImage apply​(java.awt.image.BufferedImage img)
        Description copied from interface: ImageFilter
        Applies a image filtering operation on an image.
        Specified by:
        apply in interface ImageFilter
        Parameters:
        img - The image to apply the filtering on.
        Returns:
        The resulting image after applying this filter.
      • getAlpha

        public float getAlpha()
        Returns the opacity of this filter.
        Returns:
        The opacity in the range of 0.0f (transparent) to 1.0f (opaque).