public class Frame extends Object implements Element, Drawable, WidthRespecting, Dividable
Drawable, that allows to add margin,
padding, border and background to the contained drawable. The size (width and
height) is either given, or calculated based on the dimensions of the
contained item. The size available for the inner element is reduced by the
margin, padding and border width.Dividable.Divided| Constructor and Description |
|---|
Frame(Drawable inner)
Creates a frame containing the inner element.
|
Frame(Drawable inner,
Float width,
Float height)
Creates a frame containing the inner element, optionally constraint by
the given dimensions.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
copyAllButInnerAndSizeTo(Frame other)
Copies all attributes but the inner drawable and size to the given frame.
|
Dividable.Divided |
divide(float remainingHeight,
float nextPageHeight)
Divides the drawable vetically into pieces where the first part is to
respect the given remaining height.
|
void |
draw(org.apache.pdfbox.pdmodel.PDDocument pdDocument,
org.apache.pdfbox.pdmodel.PDPageContentStream contentStream,
Position upperLeft,
DrawListener drawListener)
Draws the object at the given position.
|
Position |
getAbsolutePosition()
If an absolute position is given, the drawable will be drawn at this
position ignoring any
Layout. |
Color |
getBackgroundColor() |
Color |
getBorderColor() |
Stroke |
getBorderStroke()
The stroke to use to draw the border.
|
protected float |
getBorderWidth() |
protected Float |
getGivenHeight() |
protected Float |
getGivenWidth() |
float |
getHeight() |
protected float |
getHorizontalShapeSpacing() |
protected float |
getHorizontalSpacing() |
float |
getMarginBottom() |
float |
getMarginLeft() |
float |
getMarginRight() |
float |
getMarginTop() |
float |
getMaxWidth() |
float |
getPaddingBottom() |
float |
getPaddingLeft() |
float |
getPaddingRight() |
float |
getPaddingTop() |
Shape |
getShape() |
protected float |
getVerticalShapeSpacing() |
protected float |
getVerticalSpacing() |
float |
getWidth() |
protected boolean |
hasBorder() |
Drawable |
removeLeadingEmptyVerticalSpace() |
void |
setAbsolutePosition(Position absolutePosition)
Sets th absolute position.
|
void |
setBackgroundColor(Color backgroundColor)
Sets the color to use to draw the background.
|
void |
setBorder(Color borderColor,
Stroke borderStroke)
Convenience method for setting both border color and stroke.
|
void |
setBorderColor(Color borderColor)
Sets the color to use to draw the border.
|
void |
setBorderStroke(Stroke borderStroke)
Sets the stroke to use to draw the border.
|
protected void |
setInnerMaxWidthIfNecessary()
Propagates the max width to the inner item if there is a given size, but
no absolute position.
|
void |
setMargin(float left,
float right,
float top,
float bottom)
Sets the margin.
|
void |
setMarginBottom(float marginBottom)
Sets the bottom margin.
|
void |
setMarginLeft(float marginLeft)
Sets the left margin.
|
void |
setMarginRight(float marginRight)
Sets the right margin.
|
void |
setMarginTop(float marginTop)
Sets the top margin.
|
void |
setMaxWidth(float maxWidth)
Sets the max width to respect.
|
void |
setPadding(float left,
float right,
float top,
float bottom)
Sets the padding.
|
void |
setPaddingBottom(float paddingBottom)
Sets the bottom padding.
|
void |
setPaddingLeft(float paddingLeft)
Sets the left padding.
|
void |
setPaddingRight(float paddingRight)
Sets the right padding.
|
void |
setPaddingTop(float paddingTop)
Sets the top padding.
|
void |
setShape(Shape shape)
Sets the shape to use as border and/or background.
|
public Frame(Drawable inner)
inner - the item to contain.public Frame(Drawable inner, Float width, Float height)
inner - the item to contain.width - the width to constrain the border-box of the frame to, or null.height - the height to constrain the border-box of the frame to, or null.public Shape getShape()
public void setShape(Shape shape)
shape - the shape to use.public Stroke getBorderStroke()
public void setBorderStroke(Stroke borderStroke)
borderStroke - the stroke to use.protected float getBorderWidth()
getBorderStroke() or 0.public Color getBorderColor()
public void setBorderColor(Color borderColor)
borderColor - the border color.public void setBorder(Color borderColor, Stroke borderStroke)
borderColor - the border color.borderStroke - the stroke to use.public Color getBackgroundColor()
public void setBackgroundColor(Color backgroundColor)
backgroundColor - the background color.protected void copyAllButInnerAndSizeTo(Frame other)
other - the frame to copy the attributes to.public float getPaddingLeft()
public void setPaddingLeft(float paddingLeft)
paddingLeft - left padding.public float getPaddingRight()
public void setPaddingRight(float paddingRight)
paddingRight - right padding.public float getPaddingTop()
public void setPaddingTop(float paddingTop)
paddingTop - top padding.public float getPaddingBottom()
public void setPaddingBottom(float paddingBottom)
paddingBottom - bottom padding.public void setPadding(float left,
float right,
float top,
float bottom)
left - left padding.right - right padding.top - top padding.bottom - bottom padding.public float getMarginLeft()
public void setMarginLeft(float marginLeft)
marginLeft - left margin.public float getMarginRight()
public void setMarginRight(float marginRight)
marginRight - right margin.public float getMarginTop()
public void setMarginTop(float marginTop)
marginTop - top margin.public float getMarginBottom()
public void setMarginBottom(float marginBottom)
marginBottom - bottom margin.public void setMargin(float left,
float right,
float top,
float bottom)
left - left margin.right - right margin.top - top margin.bottom - bottom margin.protected float getHorizontalShapeSpacing()
protected float getVerticalShapeSpacing()
protected float getHorizontalSpacing()
protected float getVerticalSpacing()
protected Float getGivenHeight()
protected Float getGivenWidth()
public float getWidth()
throws IOException
getWidth in interface DrawableIOException - by pdfboxpublic float getHeight()
throws IOException
getHeight in interface DrawableIOException - by pdfboxpublic Position getAbsolutePosition() throws IOException
DrawableLayout.getAbsolutePosition in interface DrawableIOException - by pdfboxpublic void setAbsolutePosition(Position absolutePosition)
absolutePosition - the absolute position to use, or null.public float getMaxWidth()
getMaxWidth in interface WidthRespectingpublic void setMaxWidth(float maxWidth)
WidthRespectingsetMaxWidth in interface WidthRespectingmaxWidth - the maximum width.protected void setInnerMaxWidthIfNecessary()
throws IOException
IOException - by pdfbox.public void draw(org.apache.pdfbox.pdmodel.PDDocument pdDocument,
org.apache.pdfbox.pdmodel.PDPageContentStream contentStream,
Position upperLeft,
DrawListener drawListener)
throws IOException
Drawabledraw in interface DrawablepdDocument - the underlying pdfbox document.contentStream - the stream to draw to.upperLeft - the upper left position to start drawing.drawListener - the listener to
notify on
drawn objects.IOException - by pdfboxpublic Drawable removeLeadingEmptyVerticalSpace() throws IOException
removeLeadingEmptyVerticalSpace in interface DrawableIOException - by pdfboxpublic Dividable.Divided divide(float remainingHeight, float nextPageHeight) throws IOException
Dividabledivide in interface DividableremainingHeight - the remaining height on the page dictating the height of the
first part.nextPageHeight - the height of the next page allows to make better decisions on
how to divide best, e.g. maybe the element fits completely on
the next page.IOException - by pdfbox.Copyright © 2022. All rights reserved.