com.lowagie.text

Class Rectangle

public class Rectangle extends Object implements Element

A Rectangle is the representation of a geometric figure. Rectangles support constant width borders using Rectangleand Rectangle. They also support borders that vary in width/color on each side using methods like Rectangleor setBorderColorLeft.

See Also: Element Table Cell HeaderFooter

Field Summary
protected ColorbackgroundColor
This is the color of the background of this rectangle.
protected intborder
This represents the status of the 4 sides of the rectangle.
protected ColorborderColor
The color of the border of this rectangle.
protected ColorborderColorBottom
The color of the bottom border of this rectangle.
protected ColorborderColorLeft
The color of the left border of this rectangle.
protected ColorborderColorRight
The color of the right border of this rectangle.
protected ColorborderColorTop
The color of the top border of this rectangle.
protected floatborderWidth
This is the width of the border around this rectangle.
protected floatborderWidthBottom
The width of the bottom border of this rectangle.
protected floatborderWidthLeft
The width of the left border of this rectangle.
protected floatborderWidthRight
The width of the right border of this rectangle.
protected floatborderWidthTop
The width of the top border of this rectangle.
static intBOTTOM
This represents one side of the border of the Rectangle.
static intBOX
This represents a type of border.
protected floatllx
the lower left x-coordinate.
protected floatlly
the lower left y-coordinate.
static intLEFT
This represents one side of the border of the Rectangle.
static intNO_BORDER
This represents a rectangle without borders.
protected introtation
The rotation of the Rectangle
static intRIGHT
This represents one side of the border of the Rectangle.
static intTOP
This represents one side of the border of the Rectangle.
protected floaturx
the upper right x-coordinate.
protected floatury
the upper right y-coordinate.
protected booleanuseVariableBorders
Whether variable width/color borders are used.
static intUNDEFINED
This is the value that will be used as undefined .
Constructor Summary
Rectangle(float llx, float lly, float urx, float ury)
Constructs a Rectangle -object.
Rectangle(float urx, float ury)
Constructs a Rectangle -object starting from the origin (0, 0).
Rectangle(Rectangle rect)
Constructs a Rectangle -object.
Method Summary
voidcloneNonPositionParameters(Rectangle rect)
Copies each of the parameters, except the position, from a Rectangle object
voiddisableBorderSide(int side)
Disables the border on the specified side.
voidenableBorderSide(int side)
Enables the border on the specified side.
ColorgetBackgroundColor()
Gets the backgroundcolor.
intgetBorder()
Returns the exact type of the border.
ColorgetBorderColor()
Gets the color of the border.
ColorgetBorderColorBottom()
Gets the color of the bottom border.
ColorgetBorderColorLeft()
Gets the color of the left border.
ColorgetBorderColorRight()
Gets the color of the right border.
ColorgetBorderColorTop()
Gets the color of the top border.
floatgetBorderWidth()
Gets the borderwidth.
floatgetBorderWidthBottom()
Gets the width of the bottom border.
floatgetBorderWidthLeft()
Gets the width of the left border.
floatgetBorderWidthRight()
Gets the width of the right border.
floatgetBorderWidthTop()
Gets the width of the top border.
floatgetBottom()
Returns the lower left y-coordinate.
floatgetBottom(float margin)
Returns the lower left y-coordinate, considering a given margin.
ArrayListgetChunks()
Gets all the chunks in this element.
floatgetGrayFill()
Gets the grayscale.
floatgetHeight()
Returns the height of the rectangle.
floatgetLeft()
Returns the lower left x-coordinate.
floatgetLeft(float margin)
Returns the lower left x-coordinate, considering a given margin.
floatgetRight()
Returns the upper right x-coordinate.
floatgetRight(float margin)
Returns the upper right x-coordinate, considering a given margin.
intgetRotation()
Gets the rotation of the rectangle
floatgetTop()
Returns the upper right y-coordinate.
floatgetTop(float margin)
Returns the upper right y-coordinate, considering a given margin.
floatgetVariableBorderWidth(float variableWidthValue, int side)
Helper function returning the border width of a specific side.
floatgetWidth()
Returns the width of the rectangle.
booleanhasBorder(int type)
Indicates whether the specified type of border is set.
booleanhasBorders()
Indicates whether some type of border is set.
booleanisContent()
booleanisNestable()
booleanisUseVariableBorders()
Indicates whether variable width borders are being used.
voidnormalize()
Normalizes the rectangle.
booleanprocess(ElementListener listener)
Processes the element by adding it (or the different parts) to an ElementListener.
Rectanglerectangle(float top, float bottom)
Gets a Rectangle that is altered to fit on the page.
Rectanglerotate()
Rotates the rectangle.
voidsetBackgroundColor(Color backgroundColor)
Sets the backgroundcolor of the rectangle.
voidsetBorder(int border)
Enables/Disables the border on the specified sides.
voidsetBorderColor(Color borderColor)
Sets the color of the border.
voidsetBorderColorBottom(Color borderColorBottom)
Sets the color of the bottom border.
voidsetBorderColorLeft(Color borderColorLeft)
Sets the color of the left border.
voidsetBorderColorRight(Color borderColorRight)
Sets the color of the right border.
voidsetBorderColorTop(Color borderColorTop)
Sets the color of the top border.
voidsetBorderWidth(float borderWidth)
Sets the borderwidth of the table.
voidsetBorderWidthBottom(float borderWidthBottom)
Sets the width of the bottom border.
voidsetBorderWidthLeft(float borderWidthLeft)
Sets the width of the left border.
voidsetBorderWidthRight(float borderWidthRight)
Sets the width of the right border.
voidsetBorderWidthTop(float borderWidthTop)
Sets the width of the top border.
voidsetBottom(float lly)
Sets the lower left y-coordinate.
voidsetGrayFill(float value)
Sets the the background color to a grayscale value.
voidsetLeft(float llx)
Sets the lower left x-coordinate.
voidsetRight(float urx)
Sets the upper right x-coordinate.
voidsetTop(float ury)
Sets the upper right y-coordinate.
voidsetUseVariableBorders(boolean useVariableBorders)
Sets a parameter indicating if the rectangle has variable borders
voidsoftCloneNonPositionParameters(Rectangle rect)
Copies each of the parameters, except the position, from a Rectangle object if the value is set there
StringtoString()
inttype()
Gets the type of the text element.
voidupdateBorderBasedOnWidth(float width, int side)
Helper function updating the border flag for a side based on the specified width.

Field Detail

backgroundColor

protected Color backgroundColor
This is the color of the background of this rectangle.

border

protected int border
This represents the status of the 4 sides of the rectangle.

borderColor

protected Color borderColor
The color of the border of this rectangle.

borderColorBottom

protected Color borderColorBottom
The color of the bottom border of this rectangle.

borderColorLeft

protected Color borderColorLeft
The color of the left border of this rectangle.

borderColorRight

protected Color borderColorRight
The color of the right border of this rectangle.

borderColorTop

protected Color borderColorTop
The color of the top border of this rectangle.

borderWidth

protected float borderWidth
This is the width of the border around this rectangle.

borderWidthBottom

protected float borderWidthBottom
The width of the bottom border of this rectangle.

borderWidthLeft

protected float borderWidthLeft
The width of the left border of this rectangle.

borderWidthRight

protected float borderWidthRight
The width of the right border of this rectangle.

borderWidthTop

protected float borderWidthTop
The width of the top border of this rectangle.

BOTTOM

public static final int BOTTOM
This represents one side of the border of the Rectangle.

BOX

public static final int BOX
This represents a type of border.

llx

protected float llx
the lower left x-coordinate.

lly

protected float lly
the lower left y-coordinate.

LEFT

public static final int LEFT
This represents one side of the border of the Rectangle.

NO_BORDER

public static final int NO_BORDER
This represents a rectangle without borders.

rotation

protected int rotation
The rotation of the Rectangle

RIGHT

public static final int RIGHT
This represents one side of the border of the Rectangle.

TOP

public static final int TOP
This represents one side of the border of the Rectangle.

urx

protected float urx
the upper right x-coordinate.

ury

protected float ury
the upper right y-coordinate.

useVariableBorders

protected boolean useVariableBorders
Whether variable width/color borders are used.

UNDEFINED

public static final int UNDEFINED
This is the value that will be used as undefined .

Constructor Detail

Rectangle

public Rectangle(float llx, float lly, float urx, float ury)
Constructs a Rectangle -object.

Parameters: llx lower left x lly lower left y urx upper right x ury upper right y

Rectangle

public Rectangle(float urx, float ury)
Constructs a Rectangle -object starting from the origin (0, 0).

Parameters: urx upper right x ury upper right y

Rectangle

public Rectangle(Rectangle rect)
Constructs a Rectangle -object.

Parameters: rect another Rectangle

Method Detail

cloneNonPositionParameters

public void cloneNonPositionParameters(Rectangle rect)
Copies each of the parameters, except the position, from a Rectangle object

Parameters: rect Rectangle to copy from

disableBorderSide

public void disableBorderSide(int side)
Disables the border on the specified side.

Parameters: side the side to disable. One of LEFT, RIGHT, TOP, BOTTOM

enableBorderSide

public void enableBorderSide(int side)
Enables the border on the specified side.

Parameters: side the side to enable. One of LEFT, RIGHT, TOP, BOTTOM

getBackgroundColor

public Color getBackgroundColor()
Gets the backgroundcolor.

Returns: a Color

getBorder

public int getBorder()
Returns the exact type of the border.

Returns: a value

getBorderColor

public Color getBorderColor()
Gets the color of the border.

Returns: a Color

getBorderColorBottom

public Color getBorderColorBottom()
Gets the color of the bottom border.

Returns: a Color

getBorderColorLeft

public Color getBorderColorLeft()
Gets the color of the left border.

Returns: a Color

getBorderColorRight

public Color getBorderColorRight()
Gets the color of the right border.

Returns: a Color

getBorderColorTop

public Color getBorderColorTop()
Gets the color of the top border.

Returns: a Color

getBorderWidth

public float getBorderWidth()
Gets the borderwidth.

Returns: a value

getBorderWidthBottom

public float getBorderWidthBottom()
Gets the width of the bottom border.

Returns: a width

getBorderWidthLeft

public float getBorderWidthLeft()
Gets the width of the left border.

Returns: a width

getBorderWidthRight

public float getBorderWidthRight()
Gets the width of the right border.

Returns: a width

getBorderWidthTop

public float getBorderWidthTop()
Gets the width of the top border.

Returns: a width

getBottom

public float getBottom()
Returns the lower left y-coordinate.

Returns: the lower left y-coordinate

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

getChunks

public ArrayList getChunks()
Gets all the chunks in this element.

Returns: an ArrayList

getGrayFill

public float getGrayFill()
Gets the grayscale.

Returns: the grayscale color of the background or 0 if the background has no grayscale color.

getHeight

public float getHeight()
Returns the height of the rectangle.

Returns: the height

getLeft

public float getLeft()
Returns the lower left x-coordinate.

Returns: the lower left x-coordinate

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

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

getRotation

public int getRotation()
Gets the rotation of the rectangle

Returns: a rotation value

getTop

public float getTop()
Returns the upper right y-coordinate.

Returns: the upper right y-coordinate

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

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

getWidth

public float getWidth()
Returns the width of the rectangle.

Returns: the width

hasBorder

public boolean hasBorder(int type)
Indicates whether the specified type of border is set.

Parameters: type the type of border

Returns: a boolean

hasBorders

public boolean hasBorders()
Indicates whether some type of border is set.

Returns: a boolean

isContent

public boolean isContent()

Since: iText 2.0.8

See Also: isContent

isNestable

public boolean isNestable()

Since: iText 2.0.8

See Also: isNestable

isUseVariableBorders

public boolean isUseVariableBorders()
Indicates whether variable width borders are being used. Returns true if setBorderWidthLeft, setBorderWidthRight, setBorderWidthTop, or setBorderWidthBottom has been called.

Returns: true if variable width borders are in use

normalize

public void normalize()
Normalizes the rectangle. Switches lower left with upper right if necessary.

process

public boolean process(ElementListener listener)
Processes the element by adding it (or the different parts) to an ElementListener.

Parameters: listener an ElementListener

Returns: true if the element was processed successfully

rectangle

public Rectangle rectangle(float top, float bottom)
Gets a Rectangle that is altered to fit on the page.

Parameters: top the top position bottom the bottom position

Returns: a Rectangle

rotate

public Rectangle rotate()
Rotates the rectangle. Swaps the values of llx and lly and of urx and ury.

Returns: the rotated Rectangle

setBackgroundColor

public void setBackgroundColor(Color backgroundColor)
Sets the backgroundcolor of the rectangle.

Parameters: backgroundColor a Color

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: Rectangle Rectangle

setBorderColor

public void setBorderColor(Color borderColor)
Sets the color of the border.

Parameters: borderColor a Color

setBorderColorBottom

public void setBorderColorBottom(Color borderColorBottom)
Sets the color of the bottom border.

Parameters: borderColorBottom a Color

setBorderColorLeft

public void setBorderColorLeft(Color borderColorLeft)
Sets the color of the left border.

Parameters: borderColorLeft a Color

setBorderColorRight

public void setBorderColorRight(Color borderColorRight)
Sets the color of the right border.

Parameters: borderColorRight a Color

setBorderColorTop

public void setBorderColorTop(Color borderColorTop)
Sets the color of the top border.

Parameters: borderColorTop a Color

setBorderWidth

public void setBorderWidth(float borderWidth)
Sets the borderwidth of the table.

Parameters: borderWidth the new value

setBorderWidthBottom

public void setBorderWidthBottom(float borderWidthBottom)
Sets the width of the bottom border.

Parameters: borderWidthBottom a width

setBorderWidthLeft

public void setBorderWidthLeft(float borderWidthLeft)
Sets the width of the left border.

Parameters: borderWidthLeft a width

setBorderWidthRight

public void setBorderWidthRight(float borderWidthRight)
Sets the width of the right border.

Parameters: borderWidthRight a width

setBorderWidthTop

public void setBorderWidthTop(float borderWidthTop)
Sets the width of the top border.

Parameters: borderWidthTop a width

setBottom

public void setBottom(float lly)
Sets the lower left y-coordinate.

Parameters: lly the new value

setGrayFill

public void setGrayFill(float value)
Sets the the background color to a grayscale value.

Parameters: value the new grayscale value

setLeft

public void setLeft(float llx)
Sets the lower left x-coordinate.

Parameters: llx the new value

setRight

public void setRight(float urx)
Sets the upper right x-coordinate.

Parameters: urx the new value

setTop

public void setTop(float ury)
Sets the upper right y-coordinate.

Parameters: ury the new value

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

softCloneNonPositionParameters

public void softCloneNonPositionParameters(Rectangle rect)
Copies each of the parameters, except the position, from a Rectangle object if the value is set there

Parameters: rect Rectangle to copy from

toString

public String toString()

Returns: a String representation of the rectangle

See Also: java.lang.Object#toString()

type

public int type()
Gets the type of the text element.

Returns: a type

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 border side border side constant