@JavaBean public class ImagePainter extends AbstractAreaPainter<Object>
A Painter instance that paints an image. Any Image is acceptable. This Painter also allows the developer to specify a "Style" -- CENTERED, TILED, SCALED, POSITIONED, and CSS_POSITIONED; with the following meanings:
| Modifier and Type | Class and Description |
|---|---|
static class |
ImagePainter.ScaleType |
AbstractAreaPainter.StyleAbstractLayoutPainter.HorizontalAlignment, AbstractLayoutPainter.VerticalAlignmentAbstractPainter.Interpolation| Constructor and Description |
|---|
ImagePainter()
Create a new ImagePainter.
|
ImagePainter(BufferedImage image)
Create a new ImagePainter with the specified image and the Style
Style.CENTERED
|
ImagePainter(BufferedImage image,
AbstractLayoutPainter.HorizontalAlignment horizontal,
AbstractLayoutPainter.VerticalAlignment vertical)
Create a new ImagePainter with the specified image and alignment.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
doPaint(Graphics2D g,
Object component,
int width,
int height)
Subclasses must implement this method and perform custom painting operations
here.
|
BufferedImage |
getImage()
Gets the current image used for painting.
|
double |
getImageScale()
Gets the current scaling factor used when drawing an image.
|
ImagePainter.ScaleType |
getScaleType() |
boolean |
isHorizontalRepeat()
Indicates if the image will be repeated horizontally.
|
boolean |
isScaleToFit() |
boolean |
isVerticalRepeat()
Indicates if the image will be repeated vertically.
|
protected Shape |
provideShape(Graphics2D g,
Object comp,
int width,
int height)
Returns the outline shape of this painter.
|
void |
setHorizontalRepeat(boolean horizontalRepeat)
Sets if the image should be repeated horizontally.
|
void |
setImage(BufferedImage image)
Sets the image to paint with.
|
void |
setImageScale(double imageScale)
Sets the scaling factor used when drawing the image
|
void |
setScaleToFit(boolean scaleToFit) |
void |
setScaleType(ImagePainter.ScaleType scaleType) |
void |
setVerticalRepeat(boolean verticalRepeat)
Sets if the image should be repeated vertically.
|
String |
toString() |
getAreaEffects, getBorderPaint, getBorderWidth, getFillPaint, getStyle, isPaintStretched, setAreaEffects, setBorderPaint, setBorderWidth, setFillPaint, setPaintStretched, setStylecalculateLayout, getHorizontalAlignment, getInsets, getVerticalAlignment, isFillHorizontal, isFillVertical, setFillHorizontal, setFillVertical, setHorizontalAlignment, setInsets, setVerticalAlignmentclearCache, configureGraphics, getFilters, getInterpolation, isAntialiasing, isCacheable, isDirty, isVisible, paint, setAntialiasing, setCacheable, setDirty, setFilters, setInterpolation, setVisible, shouldUseCache, validateaddPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, addVetoableChangeListener, clone, fireIndexedPropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, fireVetoableChange, getPropertyChangeListeners, getPropertyChangeListeners, getVetoableChangeListeners, getVetoableChangeListeners, hasPropertyChangeListeners, hasVetoableChangeListeners, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, removeVetoableChangeListenerpublic ImagePainter()
public ImagePainter(BufferedImage image)
image - the image to be paintedpublic ImagePainter(BufferedImage image, AbstractLayoutPainter.HorizontalAlignment horizontal, AbstractLayoutPainter.VerticalAlignment vertical)
horizontal - the horizontal alignmentvertical - the vertical alignmentimage - the image to be paintedpublic void setImage(BufferedImage image)
image - if null, clears the image. Otherwise, this will set the
image to be painted.public BufferedImage getImage()
protected void doPaint(Graphics2D g, Object component, int width, int height)
doPaint in class AbstractPainter<Object>g - The Graphics2D object in which to paintpublic boolean isScaleToFit()
public void setScaleToFit(boolean scaleToFit)
public ImagePainter.ScaleType getScaleType()
public void setScaleType(ImagePainter.ScaleType scaleType)
public double getImageScale()
public void setImageScale(double imageScale)
imageScale - the new image scaling factorpublic boolean isHorizontalRepeat()
public void setHorizontalRepeat(boolean horizontalRepeat)
horizontalRepeat - the new horizontal repeat valuepublic boolean isVerticalRepeat()
public void setVerticalRepeat(boolean verticalRepeat)
verticalRepeat - new value for the vertical repeatprotected Shape provideShape(Graphics2D g, Object comp, int width, int height)
AbstractAreaPainterprovideShape in class AbstractAreaPainter<Object>g - graphicscomp - The Object this painter will be painted on.width - the width to paintheight - the height to paintCopyright © 2017. All Rights Reserved.