Package com.lowagie.text
Class Rectangle
java.lang.Object
com.lowagie.text.Rectangle
- All Implemented Interfaces:
Element
- Direct Known Subclasses:
HeaderFooter
,Image
,PdfCell
,PdfPCell
,PdfTable
,RectangleReadOnly
,SimpleCell
,SimpleTable
,TableRectangle
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 border of this 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.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.static final int
This represents a rectangle without borders.protected float
the offset relative to a certain top.static final int
This represents one side of the border of theRectangle
.protected int
The rotation of the Rectanglestatic 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/color borders are used.Fields inherited from interface 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, FOOTNOTE, HEADER, IMGRAW, IMGTEMPLATE, JBIG2, JPEG, JPEG2000, KEYWORDS, LIST, LISTITEM, MARKED, MODIFICATIONDATE, MULTI_COLUMN_TEXT, PARAGRAPH, PHRASE, PRODUCER, PTABLE, RECTANGLE, ROW, SECTION, SUBJECT, TABLE, TITLE, YMARK
-
Constructor Summary
ConstructorsConstructorDescriptionRectangle
(float urx, float ury) Constructs aRectangle
-object starting from the origin (0, 0).Rectangle
(float llx, float lly, float urx, float ury) Constructs aRectangle
-object.Rectangle
(float llx, float lly, float urx, float ury, int rotation) Constructs aRectangle
-object.Rectangle
(float urx, float ury, int rotation) Constructs aRectangle
-object starting from the origin (0, 0).Constructs aRectangle
-object. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Copies each of the parameters, except the position, from aRectangle
objectvoid
disableBorderSide
(int side) Disables the border on the specified side.void
enableBorderSide
(int side) Enables the border on the specified side.Gets the backgroundcolor.int
Returns the exact type of the border.Gets the color of the border.Gets the color of the bottom border.Gets the color of the left border.Gets the color of the right border.Gets the color of the top border.float
Gets the borderwidth.float
Gets the width of the bottom border.float
Gets the width of the left border.float
Gets the width of the right border.float
Gets the width of the top border.float
Returns the lower left y-coordinate.float
getBottom
(float margin) Returns the lower left y-coordinate, considering a given margin.Gets all the chunks in this element.float
Gets the grayscale.float
Returns the height of the rectangle.float
getLeft()
Returns the lower left x-coordinate.float
getLeft
(float margin) Returns the lower left x-coordinate, considering a given margin.float
Gets offset relative to top.float
getRight()
Returns the upper right x-coordinate.float
getRight
(float margin) Returns the upper right x-coordinate, considering a given margin.int
Gets the rotation of the rectanglefloat
getTop()
Returns the upper right y-coordinate.float
getTop
(float margin) Returns the upper right y-coordinate, considering a given margin.private float
getVariableBorderWidth
(float variableWidthValue, int side) Helper function returning the border width of a specific side.float
getWidth()
Returns the width of the rectangle.boolean
hasBorder
(int type) Indicates whether the specified type of border is set.boolean
Indicates whether some type of border is set.boolean
Checks if this element is a content object.boolean
Checks if this element is nestable.boolean
Indicates whether variable width borders are being used.void
Normalizes the rectangle.boolean
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.rotate()
Rotates the rectangle.void
setBackgroundColor
(Color backgroundColor) Sets the backgroundcolor of the rectangle.void
setBorder
(int border) Enables/Disables the border on the specified sides.void
setBorderColor
(Color borderColor) Sets the color of the border.void
setBorderColorBottom
(Color borderColorBottom) Sets the color of the bottom border.void
setBorderColorLeft
(Color borderColorLeft) Sets the color of the left border.void
setBorderColorRight
(Color borderColorRight) Sets the color of the right border.void
setBorderColorTop
(Color borderColorTop) Sets the color of the top border.void
setBorderWidth
(float borderWidth) Sets the borderwidth of the table.void
setBorderWidthBottom
(float borderWidthBottom) Sets the width of the bottom border.void
setBorderWidthLeft
(float borderWidthLeft) Sets the width of the left border.void
setBorderWidthRight
(float borderWidthRight) Sets the width of the right border.void
setBorderWidthTop
(float borderWidthTop) Sets the width of the top border.void
setBottom
(float lly) Sets the lower left y-coordinate.void
setGrayFill
(float value) Sets the the background color to a grayscale value.void
setLeft
(float llx) Sets the lower left x-coordinate.void
setRelativeTop
(float offsetToTop) Sets offset relative to top.void
setRight
(float urx) Sets the upper right x-coordinate.void
setRotation
(int rotation) Sets the rotation of the rectangle.void
setTop
(float ury) Sets the upper right y-coordinate.void
setUseVariableBorders
(boolean useVariableBorders) Sets a parameter indicating if the rectangle has variable bordersvoid
Copies each of the parameters, except the position, from aRectangle
object if the value is set theretoString()
Gets the content of the text element.int
type()
Gets the type of the text element.private void
updateBorderBasedOnWidth
(float width, int side) Helper function updating the border flag for a side based on the specified width.
-
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. -
offsetToTop
protected float offsetToTopthe offset relative to a certain top. -
rotation
protected int rotationThe rotation of the Rectangle -
backgroundColor
This is the color of the background of this rectangle. -
border
protected int borderThis represents the status of the 4 sides of the rectangle. -
useVariableBorders
protected boolean useVariableBordersWhether variable width/color borders are used. -
borderWidth
protected float borderWidthThis is the width of the border around 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. -
borderColor
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.
-
-
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
public Rectangle(float llx, float lly, float urx, float ury, int rotation) Constructs aRectangle
-object.- Parameters:
llx
- lower left xlly
- lower left yurx
- upper right xury
- upper right yrotation
- 0, 90, 180, or 270 grades
-
Rectangle
public Rectangle(float urx, float ury, int rotation) Constructs aRectangle
-object starting from the origin (0, 0).- Parameters:
urx
- upper right xury
- upper right yrotation
- 0, 90, 180, or 270 grades
-
Rectangle
Constructs aRectangle
-object.- Parameters:
rect
- anotherRectangle
-
-
Method Details
-
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. -
isContent
public boolean isContent()Description copied from interface:Element
Checks if this element is a content object. If not, it's a metadata object. -
isNestable
public boolean isNestable()Description copied from interface:Element
Checks if this element is nestable.- Specified by:
isNestable
in interfaceElement
- Returns:
- true if this element can be nested inside other elements.
- Since:
- iText 2.0.8
- See Also:
-
getLeft
public float getLeft()Returns the lower left x-coordinate.- Returns:
- the lower left x-coordinate
-
setLeft
public void setLeft(float llx) Sets the lower left x-coordinate.- Parameters:
llx
- the new value
-
getLeft
public float getLeft(float margin) Returns the lower left x-coordinate, considering a given margin.- Parameters:
margin
- a margin- Returns:
- the lower left x-coordinate
-
getRight
public float getRight()Returns the upper right x-coordinate.- Returns:
- the upper right x-coordinate
-
setRight
public void setRight(float urx) Sets the upper right x-coordinate.- Parameters:
urx
- the new value
-
getRight
public float getRight(float margin) Returns the upper right x-coordinate, considering a given margin.- Parameters:
margin
- a margin- Returns:
- the upper right x-coordinate
-
getWidth
public float getWidth()Returns the width of the rectangle.- Returns:
- the width
-
getTop
public float getTop()Returns the upper right y-coordinate.- Returns:
- the upper right y-coordinate
-
setTop
public void setTop(float ury) Sets the upper right y-coordinate.- Parameters:
ury
- the new value
-
getTop
public float getTop(float margin) Returns the upper right y-coordinate, considering a given margin.- Parameters:
margin
- a margin- Returns:
- the upper right y-coordinate
-
getRelativeTop
public float getRelativeTop()Gets offset relative to top.- Returns:
- offset relative to top
-
setRelativeTop
public void setRelativeTop(float offsetToTop) Sets offset relative to top.- Parameters:
offsetToTop
- the new offset
-
getBottom
public float getBottom()Returns the lower left y-coordinate.- Returns:
- the lower left y-coordinate
-
setBottom
public void setBottom(float lly) Sets the lower left y-coordinate.- Parameters:
lly
- the new value
-
getBottom
public float getBottom(float margin) Returns the lower left y-coordinate, considering a given margin.- Parameters:
margin
- a margin- Returns:
- the lower left y-coordinate
-
getHeight
public float getHeight()Returns the height of the rectangle.- Returns:
- the height
-
normalize
public void normalize()Normalizes the rectangle. Switches lower left with upper right if necessary. -
getRotation
public int getRotation()Gets the rotation of the rectangle- Returns:
- a rotation value
-
setRotation
public void setRotation(int rotation) Sets the rotation of the rectangle. Valid values are 0, 90, 180, and 270.- Parameters:
rotation
- the new rotation value- Since:
- iText 5.0.6
-
rotate
Rotates the rectangle. Swaps the values of llx and lly and of urx and ury.- Returns:
- the rotated
Rectangle
-
getBackgroundColor
Gets the backgroundcolor.- Returns:
- a
Color
-
setBackgroundColor
Sets the backgroundcolor of the rectangle.- Parameters:
backgroundColor
- aColor
-
getGrayFill
public float getGrayFill()Gets the grayscale.- Returns:
- the grayscale color of the background or 0 if the background has no grayscale color.
-
setGrayFill
public void setGrayFill(float value) Sets the the background color to a grayscale value.- Parameters:
value
- the new grayscale value
-
getBorder
public int getBorder()Returns the exact type of the border.- Returns:
- a value
-
setBorder
public void setBorder(int border) 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:
border
- the new value- See Also:
-
hasBorders
public boolean hasBorders()Indicates whether some type of border is set.- Returns:
- a boolean
-
hasBorder
public boolean hasBorder(int type) Indicates whether the specified type of border is set.- Parameters:
type
- the type of border- Returns:
- a boolean
-
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
-
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
-
getBorderWidth
public float getBorderWidth()Gets the borderwidth.- Returns:
- a value
-
setBorderWidth
public void setBorderWidth(float borderWidth) Sets the borderwidth of the table.- Parameters:
borderWidth
- the new value
-
getVariableBorderWidth
private float getVariableBorderWidth(float variableWidthValue, int side) Helper function returning the border width of a specific side.- Parameters:
variableWidthValue
- a variable width (could be undefined)side
- the border you want to check- Returns:
- the variableWidthValue if not undefined, otherwise the borderWidth
-
updateBorderBasedOnWidth
private void updateBorderBasedOnWidth(float width, int side) Helper function updating 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
-
getBorderWidthLeft
public float getBorderWidthLeft()Gets the width of the left border.- Returns:
- a width
-
setBorderWidthLeft
public void setBorderWidthLeft(float borderWidthLeft) Sets the width of the left border.- Parameters:
borderWidthLeft
- a width
-
getBorderWidthRight
public float getBorderWidthRight()Gets the width of the right border.- Returns:
- a width
-
setBorderWidthRight
public void setBorderWidthRight(float borderWidthRight) Sets the width of the right border.- Parameters:
borderWidthRight
- a width
-
getBorderWidthTop
public float getBorderWidthTop()Gets the width of the top border.- Returns:
- a width
-
setBorderWidthTop
public void setBorderWidthTop(float borderWidthTop) Sets the width of the top border.- Parameters:
borderWidthTop
- a width
-
getBorderWidthBottom
public float getBorderWidthBottom()Gets the width of the bottom border.- Returns:
- a width
-
setBorderWidthBottom
public void setBorderWidthBottom(float borderWidthBottom) Sets the width of the bottom border.- Parameters:
borderWidthBottom
- a width
-
getBorderColor
Gets the color of the border.- Returns:
- a
Color
-
setBorderColor
Sets the color of the border.- Parameters:
borderColor
- aColor
-
getBorderColorLeft
Gets the color of the left border.- Returns:
- a
Color
-
setBorderColorLeft
Sets the color of the left border.- Parameters:
borderColorLeft
- aColor
-
getBorderColorRight
Gets the color of the right border.- Returns:
- a
Color
-
setBorderColorRight
Sets the color of the right border.- Parameters:
borderColorRight
- aColor
-
getBorderColorTop
Gets the color of the top border.- Returns:
- a
Color
-
setBorderColorTop
Sets the color of the top border.- Parameters:
borderColorTop
- aColor
-
getBorderColorBottom
Gets the color of the bottom border.- Returns:
- a
Color
-
setBorderColorBottom
Sets the color of the bottom border.- Parameters:
borderColorBottom
- aColor
-
rectangle
Gets a Rectangle that is altered to fit on the page.- Parameters:
top
- the top positionbottom
- the bottom position- Returns:
- a
Rectangle
-
cloneNonPositionParameters
Copies each of the parameters, except the position, from aRectangle
object- Parameters:
rect
-Rectangle
to copy from
-
softCloneNonPositionParameters
Copies each of the parameters, except the position, from aRectangle
object if the value is set there- Parameters:
rect
-Rectangle
to copy from
-
toString
Description copied from interface:Element
Gets the content of the text element.
-