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 Colorbackground
This is the color of the background of this rectangle.
protected intborder
This represents the status of the 4 sides of the 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 Colorcolor
The color of the border of this rectangle.
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.
protected PropertiesmarkupAttributes
Contains extra markupAttributes
static intNO_BORDER
This represents a rectangle without borders.
protected introtation
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 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
ColorbackgroundColor()
Gets the backgroundcolor.
intborder()
Returns the exact type of the border.
ColorborderColor()
Gets the color of the border.
floatborderWidth()
Gets the borderwidth.
floatbottom()
Returns the lower left y-coordinate.
floatbottom(float margin)
Returns the lower left y-coordinate, considering a given margin.
voidcloneNonPositionParameters(Rectangle rect)
Copies all of the parameters from a Rectangle object except the position.
voiddisableBorderSide(int side)
Disables the border on the specified side.
voidenableBorderSide(int side)
Enables the border on the specified side.
ColorgetBorderColorBottom()
Gets the color of a border.
ColorgetBorderColorLeft()
Gets the color of a border.
ColorgetBorderColorRight()
Gets the color of a border.
ColorgetBorderColorTop()
Gets the color of a border.
floatgetBorderWidthBottom()
Gets the width of a border.
floatgetBorderWidthLeft()
Gets the width of a border.
floatgetBorderWidthRight()
Gets the width of a border.
floatgetBorderWidthTop()
Gets the width of a border.
ArrayListgetChunks()
Gets all the chunks in this element.
intgetRotation()
Gets the rotation of the rectangle
floatgetVariableBorderWidth(float variableWidthValue, int side)
floatgrayFill()
Gets the grayscale.
booleanhasBorder(int type)
Indicates if the table has a some type of border.
booleanhasBorders()
Indicates if the table has borders.
floatheight()
Returns the height of the rectangle.
booleanisUseVariableBorders()
Indicates whether variable width borders are being used.
floatleft()
Returns the lower left x-coordinate.
floatleft(float margin)
Returns the lower left x-coordinate, considering a given margin.
voidnormalize()
Switches lowerleft with upperright
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.
floatright()
Returns the upper right x-coordinate.
floatright(float margin)
Returns the upper right x-coordinate, considering a given margin.
Rectanglerotate()
Swaps the values of urx and ury and of lly and llx in order to rotate the rectangle.
voidsetBackgroundColor(Color value)
Sets the backgroundcolor of the rectangle.
voidsetBorder(int value)
Enables/Disables the border on the specified sides.
voidsetBorderColor(Color value)
Sets the color of the border.
voidsetBorderColorBottom(Color value)
Sets the value of the border color
voidsetBorderColorLeft(Color value)
Sets the value of the border color
voidsetBorderColorRight(Color value)
Sets the value of the border color
voidsetBorderColorTop(Color value)
Sets the value of the border color
voidsetBorderWidth(float value)
Sets the borderwidth of the table.
voidsetBorderWidthBottom(float borderWidthBottom)
Sets the width of a border
voidsetBorderWidthLeft(float borderWidthLeft)
Sets the width of a border
voidsetBorderWidthRight(float borderWidthRight)
Sets the width of a border
voidsetBorderWidthTop(float borderWidthTop)
Sets the width of a border
voidsetBottom(float value)
Sets the lower left y-coordinate.
voidsetGrayFill(float value)
Sets the grayscale of the rectangle.
voidsetLeft(float value)
Sets the lower left x-coordinate.
voidsetRight(float value)
Sets the upper right x-coordinate.
voidsetTop(float value)
Sets the upper right y-coordinate.
voidsetUseVariableBorders(boolean useVariableBorders)
Sets a parameter indicating if the rectangle has variable borders
voidsoftCloneNonPositionParameters(Rectangle rect)
Copies all of the parameters from a Rectangle object except the position.
floattop()
Returns the upper right y-coordinate.
floattop(float margin)
Returns the upper right y-coordinate, considering a given margin.
StringtoString()
inttype()
Gets the type of the text element.
voidupdateBorderBasedOnWidth(float width, int side)
Updates the border flag for a side based on the specified width.
floatwidth()
Returns the width of the rectangle.

Field Detail

background

protected Color background
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.

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.

color

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

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.

markupAttributes

protected Properties markupAttributes
Contains extra markupAttributes

NO_BORDER

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

rotation

protected int rotation

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

backgroundColor

public Color backgroundColor()
Gets the backgroundcolor.

Returns: a value

border

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

Returns: a value

borderColor

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

Returns: a value

borderWidth

public float borderWidth()
Gets the borderwidth.

Returns: a value

bottom

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

Returns: the lower left 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

cloneNonPositionParameters

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

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

getBorderColorBottom

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

Returns: a color value

getBorderColorLeft

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

Returns: a color value

getBorderColorRight

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

Returns: a color value

getBorderColorTop

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

Returns: a color value

getBorderWidthBottom

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

Returns: a width

getBorderWidthLeft

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

Returns: a width

getBorderWidthRight

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

Returns: a width

getBorderWidthTop

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

Returns: a width

getChunks

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

Returns: an ArrayList

getRotation

public int getRotation()
Gets the rotation of the rectangle

Returns: a rotation value

getVariableBorderWidth

private float getVariableBorderWidth(float variableWidthValue, int side)

grayFill

public float grayFill()
Gets the grayscale.

Returns: a value

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

hasBorders

public boolean hasBorders()
Indicates if the table has borders.

Returns: a boolean

height

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

Returns: a height

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

left

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

Returns: the lower left x-coordinate

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

normalize

public void normalize()
Switches lowerleft with upperright

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

right

public float right()
Returns the upper right x-coordinate.

Returns: the upper right 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

rotate

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

Returns: a Rectangle

setBackgroundColor

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

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

setBorderColor

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

Parameters: value the new value

setBorderColorBottom

public void setBorderColorBottom(Color value)
Sets the value of the border color

Parameters: value a color value

setBorderColorLeft

public void setBorderColorLeft(Color value)
Sets the value of the border color

Parameters: value a color value

setBorderColorRight

public void setBorderColorRight(Color value)
Sets the value of the border color

Parameters: value a color value

setBorderColorTop

public void setBorderColorTop(Color value)
Sets the value of the border color

Parameters: value a color value

setBorderWidth

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

Parameters: value the new value

setBorderWidthBottom

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

Parameters: borderWidthBottom a width

setBorderWidthLeft

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

Parameters: borderWidthLeft a width

setBorderWidthRight

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

Parameters: borderWidthRight a width

setBorderWidthTop

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

Parameters: borderWidthTop a width

setBottom

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

Parameters: value the new value

setGrayFill

public void setGrayFill(float value)
Sets the grayscale of the rectangle.

Parameters: value the new value

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

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 all of the parameters from a Rectangle object except the position.

Parameters: rect Rectangle to copy from

top

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

Returns: the upper right y-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

toString

public String toString()

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

width

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

Returns: a width