Package org.faceless.pdf2
Class LayoutBox.Box
- java.lang.Object
-
- org.faceless.pdf2.LayoutBox.Box
-
- Direct Known Subclasses:
LayoutBox.Text
- Enclosing class:
- LayoutBox
public class LayoutBox.Box extends java.lang.Object
A class representing a Box, several of which make up the visible content of a LayoutBox. Boxs on their own represent nothing but a space in the LayoutBox layout - if the rectangle is to be filled with some content (an image, for example), that has to be done separately.
The
LayoutBox.Text
class is a subclass of Box which is used to specifically display a phrase of text.- Since:
- 1.2
- See Also:
LayoutBox.getBoxes()
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description float
getBottom()
Return the bottom edge of this Box relative to the parent LayoutBox, in points.float[]
getCorners(float x, float y)
Return an array of n * 8 points, the coordinates of the corners of this Box and any subsequent Boxes created by the same item.PDFImage
getImage()
Return the optional image set by thesetImage
method, ornull
if no image was defined.float
getLeft()
Return the left edge of this Box relative to the parent LayoutBox, in pointsfloat
getLineBottom()
Return the bottom edge of the line this Box sits on, relative to the parent LayoutBox, in points.int
getLineNumber()
Return which line number this text belongs to.float
getLineTop()
Return the top edge of the line this Box sits on, relative to the parent LayoutBox, in points.java.lang.Object
getLinkedObject()
Return the object set viasetLinkedObject(java.lang.Object)
LayoutBox
getParent()
Return the LayoutBox that this Box is a child offloat
getRight()
Return the right edge of this Box relative to the parent LayoutBox, in pointsfloat
getTop()
Return the top edge of this Box relative to the parent LayoutBox, in points.protected void
setBottom(float bottom)
void
setImage(PDFImage image)
Set an optional image which goes with this Box.protected void
setLeft(float left)
protected void
setLineCoords(float top, float bottom, int linenumber)
void
setLinkedObject(java.lang.Object o)
Associate an object with this Box.protected void
setTop(float top)
protected void
setWidth(float width)
java.lang.String
toString()
-
-
-
Method Detail
-
setLeft
protected void setLeft(float left)
-
setWidth
protected void setWidth(float width)
-
setTop
protected void setTop(float top)
-
setBottom
protected void setBottom(float bottom)
-
setLineCoords
protected void setLineCoords(float top, float bottom, int linenumber)
-
getLineNumber
public final int getLineNumber()
Return which line number this text belongs to. The first line of text in the LayoutBox has line number 0, the next 1 and so on. Blank lines created by one or more calls toLayoutBox.addLineBreak(org.faceless.pdf2.PDFStyle)
do not count as lines. Left or right floating boxes will have the same line number as the text next to the top of the box. If the LayoutBox has not been flushed then this method may return -1, indicating the line number hasn't been set yet.- Since:
- 1.2.1
-
getLeft
public final float getLeft()
Return the left edge of this Box relative to the parent LayoutBox, in points
-
getRight
public final float getRight()
Return the right edge of this Box relative to the parent LayoutBox, in points
-
getTop
public final float getTop()
Return the top edge of this Box relative to the parent LayoutBox, in points. Note that in standard PDF geometry, (0,0) is at the bottom left of the page, so this value will usually be negative, indicating the top is below the top of the LayoutBox on the page.- See Also:
getBottom()
,getLineTop()
-
getBottom
public final float getBottom()
Return the bottom edge of this Box relative to the parent LayoutBox, in points.- See Also:
getTop()
,getLineBottom()
-
getLineTop
public final float getLineTop()
Return the top edge of the line this Box sits on, relative to the parent LayoutBox, in points. Note that in standard PDF geometry, (0,0) is at the bottom left of the page, so this value will usually be negative, indicating the top is below the top of the LayoutBox on the page. The LayoutBox should be flushed before this method is called to ensure the correct result- Since:
- 1.2.1
- See Also:
getLineBottom()
,getTop()
-
getLineBottom
public final float getLineBottom()
Return the bottom edge of the line this Box sits on, relative to the parent LayoutBox, in points. Note that in standard PDF geometry, (0,0) is at the bottom left of the page, so this value will usually be negative, indicating the top is below the top of the LayoutBox on the page. The LayoutBox should be flushed before this method is called to ensure the correct result- Since:
- 1.2.1
- See Also:
getLineTop()
,getTop()
-
getCorners
public final float[] getCorners(float x, float y)
Return an array of n * 8 points, the coordinates of the corners of this Box and any subsequent Boxes created by the same item. Can be passed directly intoAnnotationLink.setCorners()
orAnnotationMarkup.setCorners()
, for exampleLayoutBox box = ...; LayoutBox.Text[] text = box.addText("Some text here", style, null); box.flush(); box.drawLayoutBox(box, x, y); AnnotationLink link = new AnnotationLink(); link.setCorners(text[0].getCorners(x, y));
- Parameters:
x
- the X co-ordinate the LayoutBox was drawn aty
- the Y co-ordinate the LayoutBox was drawn at- Since:
- 2.16
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
setImage
public void setImage(PDFImage image)
Set an optional image which goes with this Box. The image will be automatically drawn when the LayoutBox is drawn to a page.
-
getImage
public PDFImage getImage()
Return the optional image set by thesetImage
method, ornull
if no image was defined.
-
getParent
public LayoutBox getParent()
Return the LayoutBox that this Box is a child of- Since:
- 2.1.2
-
getLinkedObject
public final java.lang.Object getLinkedObject()
Return the object set viasetLinkedObject(java.lang.Object)
- Since:
- 2.1.2
-
setLinkedObject
public final void setLinkedObject(java.lang.Object o)
Associate an object with this Box. This can be for any purpose, but would typically be used for complicated layout requirements, such as knowing which boxes have been moved after aLayoutBox.splitAt(float)
call. Used in the Report Generator, but probably not much use for most end users.- Since:
- 2.1.2
-
-