Class Rectangle
java.lang.Object
com.gitlab.pdftk_java.com.lowagie.text.Rectangle
- All Implemented Interfaces:
Element
,MarkupAttributes
A
Rectangle
is the representation of a geometric figure.
Rectangles support constant width borders using
setBorderWidth(float)
and setBorder(int)
. They also
support borders that vary in width/color on each side using methods like
setBorderWidthLeft(float)
or
setBorderColorLeft(java.awt.Color)
.- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Color
This is the color of the background of this rectangle.protected int
This represents the status of the 4 sides of the rectangle.protected Color
The color of the bottom border of this rectangle.protected Color
The color of the left border of this rectangle.protected Color
The color of the right border of this rectangle.protected Color
The color of the top border of this rectangle.protected float
This is the width of the border around this rectangle.protected float
The width of the bottom border of this rectangle.protected float
The width of the left border of this rectangle.protected float
The width of the right border of this rectangle.protected float
The width of the top border of this rectangle.static final int
This represents one side of the border of theRectangle
.static final int
This represents a type of border.protected Color
The color of the border of this rectangle.protected float
This is the grayscale value of the background of this rectangle.static final int
This represents one side of the border of theRectangle
.protected float
the lower left x-coordinate.protected float
the lower left y-coordinate.protected Properties
Contains extra markupAttributesstatic final int
This represents a rectangle without borders.static final int
This represents one side of the border of theRectangle
.protected int
static final int
This represents one side of the border of theRectangle
.static final int
This is the value that will be used as undefined .protected float
the upper right x-coordinate.protected float
the upper right y-coordinate.protected boolean
Whether variable width borders are used.Fields inherited from interface com.gitlab.pdftk_java.com.lowagie.text.Element
ALIGN_BASELINE, ALIGN_BOTTOM, ALIGN_CENTER, ALIGN_JUSTIFIED, ALIGN_JUSTIFIED_ALL, ALIGN_LEFT, ALIGN_MIDDLE, ALIGN_RIGHT, ALIGN_TOP, ALIGN_UNDEFINED, ANCHOR, ANNOTATION, AUTHOR, CCITT_BLACKIS1, CCITT_ENCODEDBYTEALIGN, CCITT_ENDOFBLOCK, CCITT_ENDOFLINE, CCITTG3_1D, CCITTG3_2D, CCITTG4, CELL, CHAPTER, CHUNK, CREATIONDATE, CREATOR, GRAPHIC, HEADER, IMGRAW, IMGTEMPLATE, JPEG, KEYWORDS, LIST, LISTITEM, MULTI_COLUMN_TEXT, PARAGRAPH, PHRASE, PRODUCER, PTABLE, RECTANGLE, ROW, SECTION, SUBJECT, TABLE, TITLE
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGets the backgroundcolor.int
border()
Returns the exact type of the border.Gets the color of the border.float
Gets the borderwidth.float
bottom()
Returns the lower left y-coordinate.float
bottom
(float margin) Returns the lower left y-coordinate, considering a given margin.void
Copies all of the parameters from aRectangle
object except the position.void
disableBorderSide
(int side) Disables the border on the specified side.void
enableBorderSide
(int side) Enables the border on the specified side.Gets the color of a border.Gets the color of a border.Gets the color of a border.Gets the color of a border.float
Gets the width of a border.float
Gets the width of a border.float
Gets the width of a border.float
Gets the width of a border.float
Gets all the chunks in this element.float
float
getLeft()
getMarkupAttribute
(String name) Returns the value of the specified attribute.Returns aSet
ofString
attribute names for theMarkupAttributes
implementor.Return aProperties
-object containing all the markupAttributes.float
getRight()
int
Gets the rotation of the rectanglefloat
getTop()
private float
getVariableBorderWidth
(float variableWidthValue, int side) float
getWidth()
float
grayFill()
Gets the grayscale.boolean
hasBorder
(int type) Indicates if the table has a some type of border.boolean
Indicates if the table has borders.float
height()
Returns the height of the rectangle.boolean
Indicates whether variable width borders are being used.float
left()
Returns the lower left x-coordinate.float
left
(float margin) Returns the lower left x-coordinate, considering a given margin.void
Switches lowerleft with upperrightboolean
process
(ElementListener listener) Processes the element by adding it (or the different parts) to anElementListener
.rectangle
(float top, float bottom) Gets a Rectangle that is altered to fit on the page.float
right()
Returns the upper right x-coordinate.float
right
(float margin) Returns the upper right x-coordinate, considering a given margin.rotate()
Swaps the values of urx and ury and of lly and llx in order to rotate the rectangle.void
setBackgroundColor
(Color value) Sets the backgroundcolor of the rectangle.void
setBorder
(int value) Enables/Disables the border on the specified sides.void
setBorderColor
(Color value) Sets the color of the border.void
setBorderColorBottom
(Color value) Sets the value of the border colorvoid
setBorderColorLeft
(Color value) Sets the value of the border colorvoid
setBorderColorRight
(Color value) Sets the value of the border colorvoid
setBorderColorTop
(Color value) Sets the value of the border colorvoid
setBorderWidth
(float value) Sets the borderwidth of the table.void
setBorderWidthBottom
(float borderWidthBottom) Sets the width of a bordervoid
setBorderWidthLeft
(float borderWidthLeft) Sets the width of a bordervoid
setBorderWidthRight
(float borderWidthRight) Sets the width of a bordervoid
setBorderWidthTop
(float borderWidthTop) Sets the width of a bordervoid
setBottom
(float value) Sets the lower left y-coordinate.void
setGrayFill
(float value) Sets the grayscale of the rectangle.void
setLeft
(float value) Sets the lower left x-coordinate.void
setMarkupAttribute
(String name, String value) Sets the specified attribute.void
setMarkupAttributes
(Properties markupAttributes) Sets the markupAttributes.void
setRight
(float value) Sets the upper right x-coordinate.void
setTop
(float value) Sets the upper right y-coordinate.void
setUseVariableBorders
(boolean useVariableBorders) Sets a parameter indicating if the rectangle has variable bordersvoid
Copies all of the parameters from aRectangle
object except the position.float
top()
Returns the upper right y-coordinate.float
top
(float margin) Returns the upper right y-coordinate, considering a given margin.toString()
Gets the content of the text element.int
type()
Gets the type of the text element.private void
updateBorderBasedOnWidth
(float width, int side) Updates the border flag for a side based on the specified width.float
width()
Returns the width of the rectangle.
-
Field Details
-
UNDEFINED
public static final int UNDEFINEDThis is the value that will be used as undefined .- See Also:
-
TOP
public static final int TOPThis represents one side of the border of theRectangle
.- See Also:
-
BOTTOM
public static final int BOTTOMThis represents one side of the border of theRectangle
.- See Also:
-
LEFT
public static final int LEFTThis represents one side of the border of theRectangle
.- See Also:
-
RIGHT
public static final int RIGHTThis represents one side of the border of theRectangle
.- See Also:
-
NO_BORDER
public static final int NO_BORDERThis represents a rectangle without borders.- See Also:
-
BOX
public static final int BOXThis represents a type of border.- See Also:
-
llx
protected float llxthe lower left x-coordinate. -
lly
protected float llythe lower left y-coordinate. -
urx
protected float urxthe upper right x-coordinate. -
ury
protected float urythe upper right y-coordinate. -
border
protected int borderThis represents the status of the 4 sides of the rectangle. -
borderWidth
protected float borderWidthThis is the width of the border around this rectangle. -
color
The color of the border of this rectangle. -
borderColorLeft
The color of the left border of this rectangle. -
borderColorRight
The color of the right border of this rectangle. -
borderColorTop
The color of the top border of this rectangle. -
borderColorBottom
The color of the bottom border of this rectangle. -
borderWidthLeft
protected float borderWidthLeftThe width of the left border of this rectangle. -
borderWidthRight
protected float borderWidthRightThe width of the right border of this rectangle. -
borderWidthTop
protected float borderWidthTopThe width of the top border of this rectangle. -
borderWidthBottom
protected float borderWidthBottomThe width of the bottom border of this rectangle. -
useVariableBorders
protected boolean useVariableBordersWhether variable width borders are used. -
background
This is the color of the background of this rectangle. -
grayFill
protected float grayFillThis is the grayscale value of the background of this rectangle. -
rotation
protected int rotation -
markupAttributes
Contains extra markupAttributes
-
-
Constructor Details
-
Rectangle
public Rectangle(float llx, float lly, float urx, float ury) Constructs aRectangle
-object.- Parameters:
llx
- lower left xlly
- lower left yurx
- upper right xury
- upper right y
-
Rectangle
public Rectangle(float urx, float ury) Constructs aRectangle
-object starting from the origin (0, 0).- Parameters:
urx
- upper right xury
- upper right y
-
Rectangle
Constructs aRectangle
-object.- Parameters:
rect
- anotherRectangle
-
-
Method Details
-
cloneNonPositionParameters
Copies all of the parameters from aRectangle
object except the position.- Parameters:
rect
-Rectangle
to copy from
-
softCloneNonPositionParameters
Copies all of the parameters from aRectangle
object except the position.- Parameters:
rect
-Rectangle
to copy from
-
process
Processes the element by adding it (or the different parts) to anElementListener
. -
type
public int type()Gets the type of the text element. -
getChunks
Gets all the chunks in this element. -
normalize
public void normalize()Switches lowerleft with upperright -
rectangle
Gets a Rectangle that is altered to fit on the page.- Parameters:
top
- the top positionbottom
- the bottom position- Returns:
- a
Rectangle
-
rotate
Swaps the values of urx and ury and of lly and llx in order to rotate the rectangle.- Returns:
- a
Rectangle
-
setLeft
public void setLeft(float value) Sets the lower left x-coordinate.- Parameters:
value
- the new value
-
setRight
public void setRight(float value) Sets the upper right x-coordinate.- Parameters:
value
- the new value
-
setTop
public void setTop(float value) Sets the upper right y-coordinate.- Parameters:
value
- the new value
-
setBottom
public void setBottom(float value) Sets the lower left y-coordinate.- Parameters:
value
- the new value
-
setBorder
public void setBorder(int value) Enables/Disables the border on the specified sides. The border is specified as an integer bitwise combination of the constants:LEFT, RIGHT, TOP, BOTTOM
.- Parameters:
value
- the new value- See Also:
-
enableBorderSide
public void enableBorderSide(int side) Enables the border on the specified side.- Parameters:
side
- the side to enable. One ofLEFT, RIGHT, TOP, BOTTOM
-
disableBorderSide
public void disableBorderSide(int side) Disables the border on the specified side.- Parameters:
side
- the side to disable. One ofLEFT, RIGHT, TOP, BOTTOM
-
setBorderWidth
public void setBorderWidth(float value) Sets the borderwidth of the table.- Parameters:
value
- the new value
-
setBorderColor
Sets the color of the border.- Parameters:
value
- the new value
-
setBorderColorRight
Sets the value of the border color- Parameters:
value
- a color value
-
setBorderColorLeft
Sets the value of the border color- Parameters:
value
- a color value
-
setBorderColorTop
Sets the value of the border color- Parameters:
value
- a color value
-
setBorderColorBottom
Sets the value of the border color- Parameters:
value
- a color value
-
setBackgroundColor
Sets the backgroundcolor of the rectangle.- Parameters:
value
- the new value
-
setGrayFill
public void setGrayFill(float value) Sets the grayscale of the rectangle.- Parameters:
value
- the new value
-
left
public float left()Returns the lower left x-coordinate.- Returns:
- the lower left x-coordinate
-
getLeft
public float getLeft() -
right
public float right()Returns the upper right x-coordinate.- Returns:
- the upper right x-coordinate
-
getRight
public float getRight() -
top
public float top()Returns the upper right y-coordinate.- Returns:
- the upper right y-coordinate
-
getTop
public float getTop() -
bottom
public float bottom()Returns the lower left y-coordinate.- Returns:
- the lower left y-coordinate
-
getBottom
public float getBottom() -
left
public float left(float margin) Returns the lower left x-coordinate, considering a given margin.- Parameters:
margin
- a margin- Returns:
- the lower left x-coordinate
-
right
public float right(float margin) Returns the upper right x-coordinate, considering a given margin.- Parameters:
margin
- a margin- Returns:
- the upper right x-coordinate
-
top
public float top(float margin) Returns the upper right y-coordinate, considering a given margin.- Parameters:
margin
- a margin- Returns:
- the upper right y-coordinate
-
bottom
public float bottom(float margin) Returns the lower left y-coordinate, considering a given margin.- Parameters:
margin
- a margin- Returns:
- the lower left y-coordinate
-
width
public float width()Returns the width of the rectangle.- Returns:
- a width
-
getWidth
public float getWidth() -
height
public float height()Returns the height of the rectangle.- Returns:
- a height
-
getHeight
public float getHeight() -
hasBorders
public boolean hasBorders()Indicates if the table has borders.- Returns:
- a boolean
-
hasBorder
public boolean hasBorder(int type) Indicates if the table has a some type of border.- Parameters:
type
- the type of border- Returns:
- a boolean
-
border
public int border()Returns the exact type of the border.- Returns:
- a value
-
borderWidth
public float borderWidth()Gets the borderwidth.- Returns:
- a value
-
borderColor
Gets the color of the border.- Returns:
- a value
-
backgroundColor
Gets the backgroundcolor.- Returns:
- a value
-
grayFill
public float grayFill()Gets the grayscale.- Returns:
- a value
-
getRotation
public int getRotation()Gets the rotation of the rectangle- Returns:
- a rotation value
-
setMarkupAttribute
Description copied from interface:MarkupAttributes
Sets the specified attribute.- Specified by:
setMarkupAttribute
in interfaceMarkupAttributes
- Parameters:
name
-String
attribute name.value
-String
attribute value.- See Also:
-
setMarkupAttributes
Description copied from interface:MarkupAttributes
Sets the markupAttributes.- Specified by:
setMarkupAttributes
in interfaceMarkupAttributes
- Parameters:
markupAttributes
- aProperties
-object containing markupattributes- See Also:
-
getMarkupAttribute
Description copied from interface:MarkupAttributes
Returns the value of the specified attribute.- Specified by:
getMarkupAttribute
in interfaceMarkupAttributes
- Parameters:
name
-String
attribute name.- Returns:
String
.- See Also:
-
getMarkupAttributeNames
Description copied from interface:MarkupAttributes
Returns aSet
ofString
attribute names for theMarkupAttributes
implementor.- Specified by:
getMarkupAttributeNames
in interfaceMarkupAttributes
- Returns:
Set
.- See Also:
-
getMarkupAttributes
Description copied from interface:MarkupAttributes
Return aProperties
-object containing all the markupAttributes.- Specified by:
getMarkupAttributes
in interfaceMarkupAttributes
- Returns:
Properties
- See Also:
-
getBorderColorLeft
Gets the color of a border.- Returns:
- a color value
-
getBorderColorRight
Gets the color of a border.- Returns:
- a color value
-
getBorderColorTop
Gets the color of a border.- Returns:
- a color value
-
getBorderColorBottom
Gets the color of a border.- Returns:
- a color value
-
getBorderWidthLeft
public float getBorderWidthLeft()Gets the width of a border.- Returns:
- a width
-
setBorderWidthLeft
public void setBorderWidthLeft(float borderWidthLeft) Sets the width of a border- Parameters:
borderWidthLeft
- a width
-
getBorderWidthRight
public float getBorderWidthRight()Gets the width of a border.- Returns:
- a width
-
setBorderWidthRight
public void setBorderWidthRight(float borderWidthRight) Sets the width of a border- Parameters:
borderWidthRight
- a width
-
getBorderWidthTop
public float getBorderWidthTop()Gets the width of a border.- Returns:
- a width
-
setBorderWidthTop
public void setBorderWidthTop(float borderWidthTop) Sets the width of a border- Parameters:
borderWidthTop
- a width
-
getBorderWidthBottom
public float getBorderWidthBottom()Gets the width of a border.- Returns:
- a width
-
setBorderWidthBottom
public void setBorderWidthBottom(float borderWidthBottom) Sets the width of a border- Parameters:
borderWidthBottom
- a width
-
updateBorderBasedOnWidth
private void updateBorderBasedOnWidth(float width, int side) Updates the border flag for a side based on the specified width. A width of 0 will disable the border on that side. Any other width enables it.- Parameters:
width
- width of borderside
- border side constant
-
getVariableBorderWidth
private float getVariableBorderWidth(float variableWidthValue, int side) -
isUseVariableBorders
public boolean isUseVariableBorders()Indicates whether variable width borders are being used. Returns true ifsetBorderWidthLeft, setBorderWidthRight, setBorderWidthTop, or setBorderWidthBottom
has been called.- Returns:
- true if variable width borders are in use
-
setUseVariableBorders
public void setUseVariableBorders(boolean useVariableBorders) Sets a parameter indicating if the rectangle has variable borders- Parameters:
useVariableBorders
- indication if the rectangle has variable borders
-
toString
Description copied from interface:Element
Gets the content of the text element.
-