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.Style
AbstractLayoutPainter.HorizontalAlignment, AbstractLayoutPainter.VerticalAlignment
AbstractPainter.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.
|
ImagePainter(URL url)
Deprecated.
(pre-1.6.2) no replacement, see Issue 1023
|
ImagePainter(URL url,
AbstractLayoutPainter.HorizontalAlignment horizontal,
AbstractLayoutPainter.VerticalAlignment vertical)
Deprecated.
(pre-1.6.2) no replacement, see Issue 1023
|
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.
|
String |
getImageString()
Deprecated.
(pre-1.6.2) no replacement, see Issue 1023
|
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 |
setImageString(String imageString)
Deprecated.
(pre-1.6.2) no replacement, see Issue 1023
|
void |
setScaleToFit(boolean scaleToFit) |
void |
setScaleType(ImagePainter.ScaleType scaleType) |
void |
setVerticalRepeat(boolean verticalRepeat)
Sets if the image should be repeated vertically.
|
getAreaEffects, getBorderPaint, getBorderWidth, getFillPaint, getStyle, isPaintStretched, setAreaEffects, setBorderPaint, setBorderWidth, setFillPaint, setPaintStretched, setStyle
calculateLayout, getHorizontalAlignment, getInsets, getVerticalAlignment, isFillHorizontal, isFillVertical, setFillHorizontal, setFillVertical, setHorizontalAlignment, setInsets, setVerticalAlignment
clearCache, configureGraphics, getFilters, getInterpolation, isAntialiasing, isCacheable, isDirty, isVisible, paint, setAntialiasing, setCacheable, setDirty, setFilters, setInterpolation, setVisible, shouldUseCache, validate
addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, addVetoableChangeListener, clone, fireIndexedPropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, fireVetoableChange, getPropertyChangeListeners, getPropertyChangeListeners, getVetoableChangeListeners, getVetoableChangeListeners, hasPropertyChangeListeners, hasVetoableChangeListeners, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, removeVetoableChangeListener
public 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 painted@Deprecated public ImagePainter(URL url) throws IOException
IOException
@Deprecated public ImagePainter(URL url, AbstractLayoutPainter.HorizontalAlignment horizontal, AbstractLayoutPainter.VerticalAlignment vertical) throws IOException
IOException
public 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 void setScaleToFit(boolean scaleToFit)
public boolean isScaleToFit()
public void setImageScale(double imageScale)
imageScale
- the new image scaling factorpublic double getImageScale()
@Deprecated public String getImageString()
@Deprecated public void setImageString(String imageString)
public 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)
AbstractAreaPainter
provideShape
in class AbstractAreaPainter<Object>
g
- graphicscomp
- The Object this painter will be painted on.width
- the width to paintheight
- the height to paintpublic ImagePainter.ScaleType getScaleType()
public void setScaleType(ImagePainter.ScaleType scaleType)
Copyright © 2014. All rights reserved.