| java.lang.Object org.jdesktop.beans.AbstractBean org.jdesktop.swingx.painter.AbstractPainter
All known Subclasses: org.jdesktop.swingx.painter.gradient.AbstractGradientPainter, org.jdesktop.swingx.painter.ShapePainter, org.jdesktop.swingx.painter.BackgroundPainter, org.jdesktop.swingx.painter.CompoundPainter, org.jdesktop.swingx.painter.MattePainter, org.jdesktop.swingx.painter.ImagePainter, org.jdesktop.swingx.painter.RectanglePainter, org.jdesktop.swingx.painter.CheckerboardPainter, org.jdesktop.swingx.painter.PinstripePainter, org.jdesktop.swingx.painter.TextPainter, org.jdesktop.swingx.painter.GlossPainter,
AbstractPainter | abstract public class AbstractPainter extends AbstractBean implements Painter<T>(Code) | | A convenient base class from which concrete Painter implementations may
extend. It extends JavaBean and thus provides property change notification
(which is crucial for the Painter implementations to be available in a
GUI builder). It also saves off the Graphics2D state in its "saveState" method,
and restores that state in the "restoreState" method. Sublasses simply need
to extend AbstractPainter and implement the paintBackground method.
For example, here is the paintBackground method of BackgroundPainter:
public void paintBackground(Graphics2D g, JComponent component) {
g.setColor(component.getBackground());
g.fillRect(0, 0, component.getWidth(), component.getHeight());
}
AbstractPainter provides a very useful default implementation of
the paint method. It:
- Saves off the old state
- Sets any specified rendering hints
- Sets the Clip if there is one
- Sets the Composite if there is one
- Delegates to paintBackground
- Restores the original Graphics2D state
Specifying rendering hints can greatly improve the visual impact of your
applications. For example, by default Swing doesn't do much in the way of
antialiasing (except for Fonts, but that's another story). Pinstripes don't
look so good without antialiasing. So if I were going to paint pinstripes, I
might do it like this:
PinstripePainter p = new PinstripePainter();
p.setAntialiasing(RenderingHints.VALUE_ANTIALIAS_ON);
You can read more about antialiasing and other rendering hints in the
java.awt.RenderingHints documentation. By nature, changing the rendering
hints may have an impact on performance. Certain hints require more
computation, others require less
author: rbair |
AbstractPainter | public AbstractPainter()(Code) | | Creates a new instance of AbstractPainter
|
getAlphaInterpolation | public Object getAlphaInterpolation()(Code) | | the technique used for interpolating alpha values. May be oneof:- RenderingHints.VALUE_ALPHA_INTERPOLATION_SPEED
- RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY
- RenderingHints.VALUE_ALPHA_INTERPOLATION_DEFAULT
|
getAntialiasing | public Object getAntialiasing()(Code) | | whether or not to antialiasMay be one of:- RenderingHints.VALUE_ANTIALIAS_DEFAULT
- RenderingHints.VALUE_ANTIALIAS_OFF
- RenderingHints.VALUE_ANTIALIAS_ON
|
getColorRendering | public Object getColorRendering()(Code) | | the technique to use for rendering colorsMay be one of:- RenderingHints.VALUE_COLOR_RENDER_DEFAULT
- RenderingHints.VALUE_RENDER_QUALITY
- RenderingHints.VALUE_RENDER_SPEED
|
getDithering | public Object getDithering()(Code) | | whether or not to ditherMay be one of:- RenderingHints.VALUE_DITHER_DEFAULT
- RenderingHints.VALUE_DITHER_ENABLE
- RenderingHints.VALUE_DITHER_DISABLE
|
getEffects | public Effect[] getEffects()(Code) | | effects a defensive copy of the Effects to apply to the resultsof the AbstractPainter's painting operation. Will never null |
getFractionalMetrics | public Object getFractionalMetrics()(Code) | | whether or not to use fractional metricsMay be one of:- RenderingHints.VALUE_FRACTIONALMETRICS_DEFAULT
- RenderingHints.VALUE_FRACTIONALMETRICS_OFF
- RenderingHints.VALUE_FRACTIONALMETRICS_ON
|
getInterpolation | public Object getInterpolation()(Code) | | the technique to use for interpolation (used esp. when scaling)May be one of:- RenderingHints.VALUE_INTERPOLATION_BICUBIC
- RenderingHints.VALUE_INTERPOLATION_BILINEAR
- RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR
|
getRendering | public Object getRendering()(Code) | | a hint as to techniques to use with regards to rendering quality vs. speedMay be one of:- RenderingHints.VALUE_RENDER_QUALITY
- RenderingHints.VALUE_RENDER_SPEED
- RenderingHints.VALUE_RENDER_DEFAULT
|
getRenderingHints | public Map<RenderingHints.Key, Object> getRenderingHints()(Code) | | a copy of the map of rendering hints held by this class. Thisreturned value will never be null |
getResizeClip | public Resize getResizeClip()(Code) | | value indication whether/how to resize the clip. Will never be null |
getStrokeControl | public Object getStrokeControl()(Code) | | technique for rendering strokesMay be one of:- RenderingHints.VALUE_STROKE_DEFAULT
- RenderingHints.VALUE_STROKE_NORMALIZE
- RenderingHints.VALUE_STROKE_PURE
|
getTextAntialiasing | public Object getTextAntialiasing()(Code) | | technique for anti-aliasing text.(TODO this needs to be updated for Mustang. You may use thenew Mustang values, and everything will work, but support inthe GUI builder and documentation need to be added once webranch for Mustang) May be one of:- RenderingHints.VALUE_TEXT_ANTIALIAS_DEFAULT
- RenderingHints.VALUE_TEXT_ANTIALIAS_OFF
- RenderingHints.VALUE_TEXT_ANTIALIAS_ON
|
isUseCache | public boolean isUseCache()(Code) | | whether or not the cache should be used |
paintBackground | abstract protected void paintBackground(Graphics2D g, T component)(Code) | | Subclasses should implement this method and perform custom painting operations
here. Common behavior, such as setting the clip and composite, saving and restoring
state, is performed in the "paint" method automatically, and then delegated here.
Parameters: g - The Graphics2D object in which to paint Parameters: component - The JComponent that the Painter is delegate for. |
restoreState | protected void restoreState(Graphics2D g)(Code) | | Restores previously saved state. A call to saveState must have occured
prior to calling restoreState, or an IllegalStateException will be thrown.
Parameters: g - the Graphics2D object to restore previously saved state to |
saveState | protected void saveState(Graphics2D g)(Code) | | Saves the state in the given Graphics2D object so that it may be
restored later.
Parameters: g - the Graphics2D object who's state will be saved |
setAlphaInterpolation | public void setAlphaInterpolation(Object alphaInterpolation)(Code) | | Sets the technique used for interpolating alpha values.
Parameters: alphaInterpolation - May be one of:- RenderingHints.VALUE_ALPHA_INTERPOLATION_SPEED
- RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY
- RenderingHints.VALUE_ALPHA_INTERPOLATION_DEFAULT
|
setAntialiasing | public void setAntialiasing(Object antialiasing)(Code) | | Sets whether or not to antialias
Parameters: antialiasing - May be one of:- RenderingHints.VALUE_ANTIALIAS_DEFAULT
- RenderingHints.VALUE_ANTIALIAS_OFF
- RenderingHints.VALUE_ANTIALIAS_ON
|
setClip | public void setClip(Shape clip)(Code) | | Specifies the Shape to use for clipping the painting area. This
may be null
Parameters: clip - the Shape to use to clip the area. Whatever is inside thisshape will be kept, everything else "clipped". May be null. Ifnull, the clipping is not set on the graphics object |
setColorRendering | public void setColorRendering(Object colorRendering)(Code) | | Sets the technique to use for rendering colors
Parameters: colorRendering - May be one of:- RenderingHints.VALUE_COLOR_RENDER_DEFAULT
- RenderingHints.VALUE_RENDER_QUALITY
- RenderingHints.VALUE_RENDER_SPEED
|
setComposite | public void setComposite(Composite c)(Code) | | Sets the Composite to use. For example, you may specify a specific
AlphaComposite so that when this Painter paints, any content in the
drawing area is handled properly
Parameters: c - The composite to use. If null, then no composite will bespecified on the graphics object |
setDithering | public void setDithering(Object dithering)(Code) | | Sets whether or not to dither
Parameters: dithering - May be one of:- RenderingHints.VALUE_DITHER_DEFAULT
- RenderingHints.VALUE_DITHER_ENABLE
- RenderingHints.VALUE_DITHER_DISABLE
|
setEffects | public void setEffects(Effect... effects)(Code) | | Sets the effects to apply to the results of the AbstractPainter's
painting operation. Some common effects include blurs, shadows, embossing,
and so forth. If the given effects is a null array, no effects will be used
Parameters: effects - the Effects to apply to the results of the AbstractPainter'spainting operation |
setEffects | public void setEffects(BufferedImageOp... filters)(Code) | | A convenience method for specifying the effects to use based on
BufferedImageOps. These will each be individually wrapped by an ImageEffect
and then setEffects(Effect... effects) will be called with the resulting
array
Parameters: filters - the BufferedImageOps to wrap as effects |
setFractionalMetrics | public void setFractionalMetrics(Object fractionalMetrics)(Code) | | Sets whether or not to use fractional metrics
Parameters: fractionalMetrics - May be one of:- RenderingHints.VALUE_FRACTIONALMETRICS_DEFAULT
- RenderingHints.VALUE_FRACTIONALMETRICS_OFF
- RenderingHints.VALUE_FRACTIONALMETRICS_ON
|
setInterpolation | public void setInterpolation(Object interpolation)(Code) | | Sets the technique to use for interpolation (used esp. when scaling)
Parameters: interpolation - May be one of:- RenderingHints.VALUE_INTERPOLATION_BICUBIC
- RenderingHints.VALUE_INTERPOLATION_BILINEAR
- RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR
|
setRendering | public void setRendering(Object rendering)(Code) | | Specifies a hint as to techniques to use with regards to rendering quality vs. speed
Parameters: rendering - May be one of:- RenderingHints.VALUE_RENDER_QUALITY
- RenderingHints.VALUE_RENDER_SPEED
- RenderingHints.VALUE_RENDER_DEFAULT
|
setRenderingHint | public void setRenderingHint(RenderingHints.Key key, Object hint)(Code) | | Set the given hint for the given key. This will end up firing the appropriate
property change event if the key is recognized. For example, if the key is
RenderingHints.KEY_ANTIALIASING, then the setAntialiasing method will be
called firing an "antialiasing" property change event if necessary. If
the key is not recognized, no event will be fired but the key will be saved.
The key must not be null
Parameters: key - cannot be null Parameters: hint - must be a hint compatible with the given key |
setRenderingHints | public void setRenderingHints(Map<RenderingHints.Key, Object> renderingHints)(Code) | | Sets the rendering hints to use. This will replace the
rendering hints entirely, clearing any hints that were previously set.
Parameters: renderingHints - map of hints. May be null. I null, a new Map ofrendering hints will be created |
setResizeClip | public void setResizeClip(Resize r)(Code) | | Specifies the resize behavior of the clip. As with all other properties
that rely on Resize, the value of the width/height of the shape will
represent a percentage of the width/height of the component, as a value
between 0 and 1
Parameters: r - value indication whether/how to resize the clip. If null,Resize.NONE will be used |
setStrokeControl | public void setStrokeControl(Object strokeControl)(Code) | | Specifies a technique for rendering strokes
Parameters: strokeControl - May be one of:- RenderingHints.VALUE_STROKE_DEFAULT
- RenderingHints.VALUE_STROKE_NORMALIZE
- RenderingHints.VALUE_STROKE_PURE
|
setTextAntialiasing | public void setTextAntialiasing(Object textAntialiasing)(Code) | | Sets the technique for anti-aliasing text.
(TODO this needs to be updated for Mustang. You may use the
new Mustang values, and everything will work, but support in
the GUI builder and documentation need to be added once we
branch for Mustang)
Parameters: textAntialiasing - May be one of:- RenderingHints.VALUE_TEXT_ANTIALIAS_DEFAULT
- RenderingHints.VALUE_TEXT_ANTIALIAS_OFF
- RenderingHints.VALUE_TEXT_ANTIALIAS_ON
|
setUseCache | public void setUseCache(boolean b)(Code) | | Sets whether to cache the painted image with a SoftReference in a BufferedImage
between calls. If true, and if the size of the component hasn't changed,
then the cached image will be used rather than causing a painting operation.
This should be considered a hint, rather than absolute. Several factors may
force repainting, including low memory, different component sizes, or possibly
new rendering hint settings, etc.
Parameters: b - whether or not to use the cache |
Methods inherited from org.jdesktop.beans.AbstractBean | final public void addPropertyChangeListener(PropertyChangeListener listener)(Code)(Java Doc) final public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener)(Code)(Java Doc) final public void addVetoableChangeListener(VetoableChangeListener listener)(Code)(Java Doc) final public void addVetoableChangeListener(String propertyName, VetoableChangeListener listener)(Code)(Java Doc) public Object clone() throws CloneNotSupportedException(Code)(Java Doc) final protected void fireIndexedPropertyChange(String propertyName, int index, Object oldValue, Object newValue)(Code)(Java Doc) final protected void firePropertyChange(String propertyName, Object oldValue, Object newValue)(Code)(Java Doc) final protected void firePropertyChange(PropertyChangeEvent evt)(Code)(Java Doc) final protected void fireVetoableChange(String propertyName, Object oldValue, Object newValue) throws PropertyVetoException(Code)(Java Doc) final protected void fireVetoableChange(PropertyChangeEvent evt) throws PropertyVetoException(Code)(Java Doc) final public PropertyChangeListener[] getPropertyChangeListeners()(Code)(Java Doc) final public PropertyChangeListener[] getPropertyChangeListeners(String propertyName)(Code)(Java Doc) final public VetoableChangeListener[] getVetoableChangeListeners()(Code)(Java Doc) final public VetoableChangeListener[] getVetoableChangeListeners(String propertyName)(Code)(Java Doc) final protected boolean hasPropertyChangeListeners(String propertyName)(Code)(Java Doc) final protected boolean hasVetoableChangeListeners(String propertyName)(Code)(Java Doc) final public void removePropertyChangeListener(PropertyChangeListener listener)(Code)(Java Doc) final public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener)(Code)(Java Doc) final public void removeVetoableChangeListener(VetoableChangeListener listener)(Code)(Java Doc) final public void removeVetoableChangeListener(String propertyName, VetoableChangeListener listener)(Code)(Java Doc)
|
|
|