Package org.jdesktop.swingx.graphics
Class FilterComposite
- java.lang.Object
-
- org.jdesktop.swingx.graphics.FilterComposite
-
- All Implemented Interfaces:
java.awt.Composite
public class FilterComposite extends java.lang.Object implements java.awt.Composite
AFilterComposite
allows the inclusion of arbitrary image filters during the paint processing ofGraphics2D
events. By adding a filter composite, the src and destination images are render using a delegatedComposite
, then post-processed with the filters before returning the result back to the graphics context. This process adds overhead to the painting both is terms of time (the actual processing time) and memory (as a temporary raster must be created to store the intermediate state). Since it is possible to delegate to a filter composite from a filter composite, this may result slow or unresponsive painting. If you are attempting to render with many different filters, it may be better to have one filter composite with many filters (using a compound filter).It was decided to use
BufferedImageOp
as the filter because many of these filters already exist. This gives high reusability to code.- See Also:
AbstractFilter
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
FilterComposite.FilterContext
-
Constructor Summary
Constructors Constructor Description FilterComposite(java.awt.Composite composite)
Creates an empty filter composite for the specified composite.FilterComposite(java.awt.Composite composite, java.awt.image.BufferedImageOp filter)
Creates a filter for the specified composite.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.awt.CompositeContext
createContext(java.awt.image.ColorModel srcColorModel, java.awt.image.ColorModel dstColorModel, java.awt.RenderingHints hints)
java.awt.image.BufferedImageOp
getFilter()
The filter to apply to the graphics context.void
setFilter(java.awt.image.BufferedImageOp filter)
Sets the filter for manipulating the graphics composites.
-
-
-
Constructor Detail
-
FilterComposite
public FilterComposite(java.awt.Composite composite)
Creates an empty filter composite for the specified composite.- Parameters:
composite
- the composite operation to perform prior to filtering- Throws:
java.lang.NullPointerException
- ifcomposite
isnull
-
FilterComposite
public FilterComposite(java.awt.Composite composite, java.awt.image.BufferedImageOp filter)
Creates a filter for the specified composite.- Parameters:
composite
- the composite operation to perform prior to filteringfilter
- the filter to apply to the composite result- Throws:
java.lang.NullPointerException
- ifcomposite
isnull
-
-
Method Detail
-
getFilter
public java.awt.image.BufferedImageOp getFilter()
The filter to apply to the graphics context.- Returns:
- the current filter
-
setFilter
public void setFilter(java.awt.image.BufferedImageOp filter)
Sets the filter for manipulating the graphics composites.A
null
filter will result in no filtering.- Parameters:
filter
- the new filter
-
createContext
public java.awt.CompositeContext createContext(java.awt.image.ColorModel srcColorModel, java.awt.image.ColorModel dstColorModel, java.awt.RenderingHints hints)
- Specified by:
createContext
in interfacejava.awt.Composite
-
-