Package com.lowagie.text
Class Rectangle
java.lang.Object
com.lowagie.text.Rectangle
- All Implemented Interfaces:
Element
- Direct Known Subclasses:
Cell,HeaderFooter,Image,PdfCell,PdfPCell,PdfTable,RectangleReadOnly,SimpleCell,SimpleTable,Table
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 ColorThis is the color of the background of this rectangle.protected intThis represents the status of the 4 sides of the rectangle.protected ColorThe color of the border of this rectangle.protected ColorThe color of the bottom border of this rectangle.protected ColorThe color of the left border of this rectangle.protected ColorThe color of the right border of this rectangle.protected ColorThe color of the top border of this rectangle.protected floatThis is the width of the border around this rectangle.protected floatThe width of the bottom border of this rectangle.protected floatThe width of the left border of this rectangle.protected floatThe width of the right border of this rectangle.protected floatThe width of the top border of this rectangle.static final intThis represents one side of the border of theRectangle.static final intThis represents a type of border.static final intThis represents one side of the border of theRectangle.protected floatthe lower left x-coordinate.protected floatthe lower left y-coordinate.static final intThis represents a rectangle without borders.static final intThis represents one side of the border of theRectangle.protected intThe rotation of the Rectanglestatic final intThis represents one side of the border of theRectangle.static final intThis is the value that will be used as undefined .protected floatthe upper right x-coordinate.protected floatthe upper right y-coordinate.protected booleanWhether 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, HEADER, IMGRAW, IMGTEMPLATE, JBIG2, JPEG, JPEG2000, KEYWORDS, LIST, LISTITEM, MARKED, MULTI_COLUMN_TEXT, PARAGRAPH, PHRASE, PRODUCER, PTABLE, RECTANGLE, ROW, SECTION, SUBJECT, TABLE, TITLE, YMARK -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidCopies each of the parameters, except the position, from aRectangleobjectvoiddisableBorderSide(int side) Disables the border on the specified side.voidenableBorderSide(int side) Enables the border on the specified side.Gets the backgroundcolor.intReturns 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.floatGets the borderwidth.floatGets the width of the bottom border.floatGets the width of the left border.floatGets the width of the right border.floatGets the width of the top border.floatReturns the lower left y-coordinate.floatgetBottom(float margin) Returns the lower left y-coordinate, considering a given margin.Gets all the chunks in this element.floatGets the grayscale.floatReturns 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.intGets the rotation of the rectanglefloatgetTop()Returns the upper right y-coordinate.floatgetTop(float margin) Returns the upper right y-coordinate, considering a given margin.floatgetWidth()Returns the width of the rectangle.booleanhasBorder(int type) Indicates whether the specified type of border is set.booleanIndicates whether some type of border is set.booleanChecks if this element is a content object.booleanChecks if this element is nestable.booleanIndicates whether variable width borders are being used.voidNormalizes the rectangle.booleanprocess(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.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 bordersvoidCopies each of the parameters, except the position, from aRectangleobject if the value is set theretoString()Gets the content of the text element.inttype()Gets the type of the text element.
-
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. -
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
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:ElementChecks if this element is a content object. If not, it's a metadata object. -
isNestable
public boolean isNestable()Description copied from interface:ElementChecks if this element is nestable.- Specified by:
isNestablein interfaceElement- Returns:
- true if this element can be nested inside other elements.
- Since:
- iText 2.0.8
- See Also:
-
setLeft
public void setLeft(float llx) Sets the lower left x-coordinate.- Parameters:
llx- the new value
-
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
-
setRight
public void setRight(float urx) Sets the upper right x-coordinate.- Parameters:
urx- the new value
-
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
-
getWidth
public float getWidth()Returns the width of the rectangle.- Returns:
- the width
-
setTop
public void setTop(float ury) Sets the upper right y-coordinate.- Parameters:
ury- the new 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
-
setBottom
public void setBottom(float lly) Sets the lower left y-coordinate.- Parameters:
lly- the new value
-
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
-
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
-
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
-
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
-
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:
-
isUseVariableBorders
public boolean isUseVariableBorders()Indicates whether variable width borders are being used. Returns true ifsetBorderWidthLeft, setBorderWidthRight, setBorderWidthTop, or setBorderWidthBottomhas 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
-
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 aRectangleobject- Parameters:
rect-Rectangleto copy from
-
softCloneNonPositionParameters
Copies each of the parameters, except the position, from aRectangleobject if the value is set there- Parameters:
rect-Rectangleto copy from
-
toString
Description copied from interface:ElementGets the content of the text element.
-