Package ca.cgjennings.graphics.filters
Class TintCache
- java.lang.Object
-
- ca.cgjennings.graphics.filters.TintCache
-
public class TintCache extends java.lang.ObjectA tint cache applies aTintFilterto 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
-
-
Constructor Summary
Constructors Constructor Description TintCache(TintingFilter filter)TintCache(TintingFilter filter, java.awt.image.BufferedImage sourceImage)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description floatgetBFactor()TintingFiltergetFilter()Returns the filter invoked by this cache.floatgetHFactor()java.awt.image.BufferedImagegetImage()Returns the current source image.floatgetSFactor()java.awt.image.BufferedImagegetTintedImage()Returns a tinted version of the current image, using a cached result if possible.booleanisIdentity()voidsetFactors(float h, float s, float b)Indirectly set the adjustment factors of the filter.voidsetImage(java.awt.image.BufferedImage im)Update the source image to use for tinting.
-
-
-
Field Detail
-
filter
protected TintingFilter filter
-
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)
-
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. Ifimis 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 adjustments- the saturation adjustmentb- the brightness adjustment
-
getHFactor
public float getHFactor()
-
getSFactor
public float getSFactor()
-
getBFactor
public float getBFactor()
-
isIdentity
public boolean isIdentity()
-
-