Class TintCache


  • public class TintCache
    extends java.lang.Object
    A tint cache applies a TintFilter to an image. It caches its most recent result, and if a tinted image is requested with the same parameters it returns the cached version instead of reapplying the filter.
    Author:
    Chris Jennings
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected float b  
      protected java.awt.image.BufferedImage cache  
      protected TintingFilter filter  
      protected float h  
      protected float s  
      protected java.awt.image.BufferedImage source  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      float getBFactor()  
      TintingFilter getFilter()
      Returns the filter invoked by this cache.
      float getHFactor()  
      java.awt.image.BufferedImage getImage()
      Returns the current source image.
      float getSFactor()  
      java.awt.image.BufferedImage getTintedImage()
      Returns a tinted version of the current image, using a cached result if possible.
      boolean isIdentity()  
      void setFactors​(float h, float s, float b)
      Indirectly set the adjustment factors of the filter.
      void setImage​(java.awt.image.BufferedImage im)
      Update the source image to use for tinting.
      • Methods inherited from class java.lang.Object

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

      • source

        protected java.awt.image.BufferedImage source
      • cache

        protected java.awt.image.BufferedImage cache
      • h

        protected float h
      • s

        protected float s
      • b

        protected float b
    • Constructor Detail

      • TintCache

        public TintCache​(TintingFilter filter,
                         java.awt.image.BufferedImage sourceImage)
    • Method Detail

      • getTintedImage

        public java.awt.image.BufferedImage getTintedImage()
        Returns a tinted version of the current image, using a cached result if possible.
        Returns:
        a tinted version of the current image
      • getFilter

        public TintingFilter getFilter()
        Returns the filter invoked by this cache.
        Returns:
        the filter used to create result images
      • getImage

        public java.awt.image.BufferedImage getImage()
        Returns the current source image.
        Returns:
        the source image
      • setImage

        public void setImage​(java.awt.image.BufferedImage im)
        Update the source image to use for tinting. If im is different from the current image, it replaces the current image and invalidates the cache.
        Parameters:
        im - the new source image
      • setFactors

        public final void setFactors​(float h,
                                     float s,
                                     float b)
        Indirectly set the adjustment factors of the filter. This is a convenience. It does not matter if you set the factors directly on the filter or through this method.
        Parameters:
        h - the hue adjustment
        s - the saturation adjustment
        b - the brightness adjustment
      • getHFactor

        public float getHFactor()
      • getSFactor

        public float getSFactor()
      • getBFactor

        public float getBFactor()
      • isIdentity

        public boolean isIdentity()