public abstract class AbstractLayoutPainter<T> extends AbstractPainter<T>
ImagePainter p = new ImagePainter(null);
p.setVerticalAlignment(AbstractLayoutPainter.VerticalAlignment.BOTTOM);
p.setHorizontalAlignment(AbstractLayoutPainter.HorizontalAlignment.RIGHT);
p.setInsets(new Insets(0,0,5,5));
For something which is resizable, like a RectanglePainter, you can use the fill properties
to make it resize along with the paintable area. For example, to make a rectangle with 20 px
rounded corners, and which resizes with the paintable area but is inset
by 10 pixels on all sides, you could do
the following:
RectanglePainter p = new RectanglePainter();
p.setRoundHeight(20);
p.setRoundWidth(20);
p.setInsets(new Insets(10,10,10,10));
p.setFillHorizontal(true);
p.setFillVertical(true);
Modifier and Type | Class and Description |
---|---|
static class |
AbstractLayoutPainter.HorizontalAlignment
An enum which controls horizontalAlignment alignment
|
static class |
AbstractLayoutPainter.VerticalAlignment
An enum which controls verticalAlignment alignment
|
AbstractPainter.Interpolation
Modifier and Type | Field and Description |
---|---|
private boolean |
fillHorizontal |
private boolean |
fillVertical |
private AbstractLayoutPainter.HorizontalAlignment |
horizontalAlignment |
private Insets |
insets |
private AbstractLayoutPainter.VerticalAlignment |
verticalAlignment
Specifies how to draw the image, i.e. what kind of Style to use
when drawing
|
Constructor and Description |
---|
AbstractLayoutPainter()
Creates a new instance of AbstractLayoutPainter
|
Modifier and Type | Method and Description |
---|---|
protected Rectangle |
calculateLayout(int contentWidth,
int contentHeight,
int width,
int height)
A protected method used by subclasses to calculate the final position of the
content.
|
private int |
calculateX(int imgWidth,
int width) |
private int |
calculateY(int imgHeight,
int height) |
AbstractLayoutPainter.HorizontalAlignment |
getHorizontalAlignment()
Gets the current horizontalAlignment alignment.
|
Insets |
getInsets()
Gets the current whitespace insets.
|
AbstractLayoutPainter.VerticalAlignment |
getVerticalAlignment()
gets the current verticalAlignment alignment
|
boolean |
isFillHorizontal()
indicates if the painter content is stretched horizontally
|
boolean |
isFillVertical()
indicates if the painter content is stretched vertically
|
void |
setFillHorizontal(boolean fillHorizontal)
Sets if the content should be stretched horizontally to fill all available horizontalAlignment
space (minus the left and right insets).
|
void |
setFillVertical(boolean verticalStretch)
Sets if the content should be stretched vertically to fill all available verticalAlignment
space (minus the top and bottom insets).
|
void |
setHorizontalAlignment(AbstractLayoutPainter.HorizontalAlignment horizontal)
Sets a new horizontalAlignment alignment.
|
void |
setInsets(Insets insets)
Sets the current whitespace insets.
|
void |
setVerticalAlignment(AbstractLayoutPainter.VerticalAlignment vertical)
Sets a new verticalAlignment alignment.
|
clearCache, configureGraphics, doPaint, getFilters, getInterpolation, isAntialiasing, isCacheable, isCacheCleared, isDirty, isInPaintContext, isVisible, paint, setAntialiasing, setCacheable, setDirty, setFilters, setInPaintContext, setInterpolation, setVisible, shouldUseCache, validate
addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, addVetoableChangeListener, clone, fireIndexedPropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, fireVetoableChange, getPropertyChangeListeners, getPropertyChangeListeners, getVetoableChangeListeners, getVetoableChangeListeners, hasPropertyChangeListeners, hasVetoableChangeListeners, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, removeVetoableChangeListener
private AbstractLayoutPainter.VerticalAlignment verticalAlignment
private AbstractLayoutPainter.HorizontalAlignment horizontalAlignment
private boolean fillVertical
private boolean fillHorizontal
public AbstractLayoutPainter()
public AbstractLayoutPainter.HorizontalAlignment getHorizontalAlignment()
public AbstractLayoutPainter.VerticalAlignment getVerticalAlignment()
public boolean isFillHorizontal()
public boolean isFillVertical()
public void setHorizontalAlignment(AbstractLayoutPainter.HorizontalAlignment horizontal)
horizontal
- new horizontalAlignment alignmentpublic void setFillHorizontal(boolean fillHorizontal)
fillHorizontal
- new horizontal stretch valuepublic void setInsets(Insets insets)
insets
- new insetspublic void setVerticalAlignment(AbstractLayoutPainter.VerticalAlignment vertical)
vertical
- new verticalAlignment alignmentpublic void setFillVertical(boolean verticalStretch)
verticalStretch
- new verticalAlignment stretch valueprotected final Rectangle calculateLayout(int contentWidth, int contentHeight, int width, int height)
contentWidth
- The width of the content to be paintedcontentHeight
- The height of the content to be paintedwidth
- the width of the area that the content will be positioned inheight
- the height of the area that the content will be positioned inprivate int calculateY(int imgHeight, int height)
private int calculateX(int imgWidth, int width)
WebARTS Library Licensed Under the GNU - General Public License. Other Libraries licensed under their respective Open Source Licenses