Package org.jdesktop.swingx.painter
Class MattePainter<T>
- java.lang.Object
-
- org.jdesktop.beans.AbstractBean
-
- org.jdesktop.swingx.painter.AbstractPainter<T>
-
- org.jdesktop.swingx.painter.AbstractLayoutPainter<T>
-
- org.jdesktop.swingx.painter.AbstractAreaPainter<T>
-
- org.jdesktop.swingx.painter.MattePainter<T>
-
- All Implemented Interfaces:
Painter<T>
public class MattePainter<T> extends AbstractAreaPainter<T>
A Painter implementation that uses a Paint to fill the entire background area. For example, if I wanted to paint the entire background of a panel green, I would:MattePainter p = new MattePainter(Color.GREEN); panel.setBackgroundPainter(p);
Since it accepts a Paint, it is also possible to paint a texture or use other more exotic Paint implementations. To paint a BufferedImage texture as the background:
TexturePaint paint = new TexturePaint(bufferedImage, new Rectangle2D.Double(0, 0, bufferedImage.getWidth(), bufferedImage.getHeight())); MattePainter p = new MattePainter(paint); panel.setBackgroundPainter(p);
If no paint is specified, then nothing is painted
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.jdesktop.swingx.painter.AbstractAreaPainter
AbstractAreaPainter.Style
-
Nested classes/interfaces inherited from class org.jdesktop.swingx.painter.AbstractLayoutPainter
AbstractLayoutPainter.HorizontalAlignment, AbstractLayoutPainter.VerticalAlignment
-
Nested classes/interfaces inherited from class org.jdesktop.swingx.painter.AbstractPainter
AbstractPainter.Interpolation
-
-
Constructor Summary
Constructors Constructor Description MattePainter()
Creates a new MattePainter with "null" as the paint usedMattePainter(java.awt.Paint paint)
Create a new MattePainter for the given Paint.MattePainter(java.awt.Paint paint, boolean paintStretched)
Create a new MattePainter for the given Paint.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
doPaint(java.awt.Graphics2D g, T component, int width, int height)
Subclasses must implement this method and perform custom painting operations here.java.awt.Shape
provideShape(java.awt.Graphics2D g, T comp, int width, int height)
Returns the outline shape of this painter.-
Methods inherited from class org.jdesktop.swingx.painter.AbstractAreaPainter
getAreaEffects, getBorderPaint, getBorderWidth, getFillPaint, getStyle, isPaintStretched, setAreaEffects, setBorderPaint, setBorderWidth, setFillPaint, setPaintStretched, setStyle
-
Methods inherited from class org.jdesktop.swingx.painter.AbstractLayoutPainter
calculateLayout, getHorizontalAlignment, getInsets, getVerticalAlignment, isFillHorizontal, isFillVertical, setFillHorizontal, setFillVertical, setHorizontalAlignment, setInsets, setVerticalAlignment
-
Methods inherited from class org.jdesktop.swingx.painter.AbstractPainter
clearCache, configureGraphics, getFilters, getInterpolation, isAntialiasing, isCacheable, isDirty, isVisible, paint, setAntialiasing, setCacheable, setDirty, setFilters, setInterpolation, setVisible, shouldUseCache, validate
-
Methods inherited from class org.jdesktop.beans.AbstractBean
addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, addVetoableChangeListener, clone, fireIndexedPropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, fireVetoableChange, getPropertyChangeListeners, getPropertyChangeListeners, getVetoableChangeListeners, getVetoableChangeListeners, hasPropertyChangeListeners, hasVetoableChangeListeners, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, removeVetoableChangeListener
-
-
-
-
Constructor Detail
-
MattePainter
public MattePainter()
Creates a new MattePainter with "null" as the paint used
-
MattePainter
public MattePainter(java.awt.Paint paint)
Create a new MattePainter for the given Paint. This can be a GradientPaint (the gradient will not grow when the component becomes larger unless you use the paintStretched boolean property), TexturePaint, Color, or other Paint instance.- Parameters:
paint
- Paint to fill with
-
MattePainter
public MattePainter(java.awt.Paint paint, boolean paintStretched)
Create a new MattePainter for the given Paint. This can be a GradientPaint (the gradient will not grow when the component becomes larger unless you use the paintStretched boolean property), TexturePaint, Color, or other Paint instance.- Parameters:
paint
- Paint to fill withpaintStretched
- indicates if the paint should be stretched
-
-
Method Detail
-
doPaint
public void doPaint(java.awt.Graphics2D g, T component, int width, int height)
Description copied from class:AbstractPainter
Subclasses must implement this method and perform custom painting operations here.- Specified by:
doPaint
in classAbstractPainter<T>
- Parameters:
g
- The Graphics2D object in which to paint
-
provideShape
public java.awt.Shape provideShape(java.awt.Graphics2D g, T comp, int width, int height)
Description copied from class:AbstractAreaPainter
Returns the outline shape of this painter. Subclasses must implement this method. This shape will be used for filling, stroking, and clipping.- Specified by:
provideShape
in classAbstractAreaPainter<T>
- Parameters:
g
- graphicscomp
- The Object this painter will be painted on.width
- the width to paintheight
- the height to paint- Returns:
- the outline shape of this painter
-
-