public class Rectangle extends Object implements Element
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(BaseColor)
.
Element
Modifier and Type | Field and Description |
---|---|
protected BaseColor |
backgroundColor
This is the color of the background of this rectangle.
|
protected int |
border
This represents the status of the 4 sides of the rectangle.
|
protected BaseColor |
borderColor
The color of the border of this rectangle.
|
protected BaseColor |
borderColorBottom
The color of the bottom border of this rectangle.
|
protected BaseColor |
borderColorLeft
The color of the left border of this rectangle.
|
protected BaseColor |
borderColorRight
The color of the right border of this rectangle.
|
protected BaseColor |
borderColorTop
The color of the top border of this rectangle.
|
protected float |
borderWidth
This is the width of the border around this rectangle.
|
protected float |
borderWidthBottom
The width of the bottom border of this rectangle.
|
protected float |
borderWidthLeft
The width of the left border of this rectangle.
|
protected float |
borderWidthRight
The width of the right border of this rectangle.
|
protected float |
borderWidthTop
The width of the top border of this rectangle.
|
static int |
BOTTOM
This represents one side of the border of the Rectangle .
|
static int |
BOX
This represents a type of border.
|
static int |
LEFT
This represents one side of the border of the Rectangle .
|
protected float |
llx
the lower left x-coordinate.
|
protected float |
lly
the lower left y-coordinate.
|
static int |
NO_BORDER
This represents a rectangle without borders.
|
static int |
RIGHT
This represents one side of the border of the Rectangle .
|
protected int |
rotation
The rotation of the Rectangle
|
static int |
TOP
This represents one side of the border of the Rectangle .
|
static int |
UNDEFINED
This is the value that will be used as undefined .
|
protected float |
urx
the upper right x-coordinate.
|
protected float |
ury
the upper right y-coordinate.
|
protected boolean |
useVariableBorders
Whether variable width/color borders are used.
|
ALIGN_BASELINE, ALIGN_BOTTOM, ALIGN_CENTER, ALIGN_JUSTIFIED, ALIGN_JUSTIFIED_ALL, ALIGN_LEFT, ALIGN_MIDDLE, ALIGN_RIGHT, ALIGN_TOP, ALIGN_UNDEFINED, ANCHOR, ANNOTATION, AUTHOR, BODY, CCITT_BLACKIS1, CCITT_ENCODEDBYTEALIGN, CCITT_ENDOFBLOCK, CCITT_ENDOFLINE, CCITTG3_1D, CCITTG3_2D, CCITTG4, CHAPTER, CHUNK, CREATIONDATE, CREATOR, DIV, HEADER, IMGRAW, IMGTEMPLATE, JBIG2, JPEG, JPEG2000, KEYWORDS, LANGUAGE, LIST, LISTITEM, MARKED, PARAGRAPH, PHRASE, PRODUCER, PTABLE, RECTANGLE, SECTION, SUBJECT, TITLE, WRITABLE_DIRECT, YMARK
Constructor and Description |
---|
Rectangle(float urx, float ury)
Constructs a Rectangle -object starting from the origin (0, 0).
|
Rectangle(float llx, float lly, float urx, float ury)
Constructs a Rectangle -object.
|
Rectangle(float llx, float lly, float urx, float ury, int rotation)
Constructs a Rectangle -object.
|
Rectangle(float urx, float ury, int rotation)
Constructs a Rectangle -object starting from the origin (0, 0) and with a specific rotation (valid values are 0, 90, 180, 270).
|
Rectangle(Rectangle rect)
Constructs a Rectangle -object.
|
Rectangle(Rectangle rect)
Constructs a Rectangle -object based on a com.itextpdf.awt.geom.Rectangle object
|
Modifier and Type | Method and Description |
---|---|
void |
cloneNonPositionParameters(Rectangle rect)
Copies each of the parameters, except the position, from a Rectangle object
|
void |
disableBorderSide(int side)
Disables the border on the specified side.
|
void |
enableBorderSide(int side)
Enables the border on the specified side.
|
boolean |
equals(Object obj) |
BaseColor |
getBackgroundColor()
Gets the backgroundcolor.
|
int |
getBorder()
Returns the exact type of the border.
|
BaseColor |
getBorderColor()
Gets the color of the border.
|
BaseColor |
getBorderColorBottom()
Gets the color of the bottom border.
|
BaseColor |
getBorderColorLeft()
Gets the color of the left border.
|
BaseColor |
getBorderColorRight()
Gets the color of the right border.
|
BaseColor |
getBorderColorTop()
Gets the color of the top border.
|
float |
getBorderWidth()
Gets the borderwidth.
|
float |
getBorderWidthBottom()
Gets the width of the bottom border.
|
float |
getBorderWidthLeft()
Gets the width of the left border.
|
float |
getBorderWidthRight()
Gets the width of the right border.
|
float |
getBorderWidthTop()
Gets the width of the top border.
|
float |
getBottom()
Returns the lower left y-coordinate.
|
float |
getBottom(float margin)
Returns the lower left y-coordinate, considering a given margin.
|
List<Chunk> |
getChunks()
Gets all the chunks in this element.
|
float |
getGrayFill()
Gets the grayscale.
|
float |
getHeight()
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 |
getRight()
Returns the upper right x-coordinate.
|
float |
getRight(float margin)
Returns the upper right x-coordinate, considering a given margin.
|
int |
getRotation()
Gets the rotation of the rectangle
|
float |
getTop()
Returns the upper right y-coordinate.
|
float |
getTop(float margin)
Returns the upper right y-coordinate, considering a given margin.
|
float |
getWidth()
Returns the width of the rectangle.
|
boolean |
hasBorder(int type)
Indicates whether the specified type of border is set.
|
boolean |
hasBorders()
Indicates whether some type of border is set.
|
boolean |
isContent()
Checks if this element is a content object.
|
boolean |
isNestable()
Checks if this element is nestable.
|
boolean |
isUseVariableBorders()
Indicates whether variable width borders are being used.
|
void |
normalize()
Normalizes the rectangle.
|
boolean |
process(ElementListener listener)
Processes the element by adding it (or the different parts) to an ElementListener .
|
Rectangle |
rectangle(float top, float bottom)
Gets a Rectangle that is altered to fit on the page.
|
Rectangle |
rotate()
Rotates the rectangle.
|
void |
setBackgroundColor(BaseColor backgroundColor)
Sets the backgroundcolor of the rectangle.
|
void |
setBorder(int border)
Enables/Disables the border on the specified sides.
|
void |
setBorderColor(BaseColor borderColor)
Sets the color of the border.
|
void |
setBorderColorBottom(BaseColor borderColorBottom)
Sets the color of the bottom border.
|
void |
setBorderColorLeft(BaseColor borderColorLeft)
Sets the color of the left border.
|
void |
setBorderColorRight(BaseColor borderColorRight)
Sets the color of the right border.
|
void |
setBorderColorTop(BaseColor 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 |
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 borders
|
void |
softCloneNonPositionParameters(Rectangle rect)
Copies each of the parameters, except the position, from a Rectangle object if the value is set there
|
String |
toString()
Gets the content of the text element.
|
int |
type()
Gets the type of the text element.
|
public static final int UNDEFINED
public static final int TOP
Rectangle
.
public static final int BOTTOM
Rectangle
.
public static final int LEFT
Rectangle
.
public static final int RIGHT
Rectangle
.
public static final int NO_BORDER
public static final int BOX
protected float llx
protected float lly
protected float urx
protected float ury
protected int rotation
protected BaseColor backgroundColor
protected int border
protected boolean useVariableBorders
protected float borderWidth
protected float borderWidthLeft
protected float borderWidthRight
protected float borderWidthTop
protected float borderWidthBottom
protected BaseColor borderColor
protected BaseColor borderColorLeft
protected BaseColor borderColorRight
protected BaseColor borderColorTop
protected BaseColor borderColorBottom
public Rectangle(float llx, float lly, float urx, float ury)
Rectangle
-object.
llx
- lower left x
lly
- lower left y
urx
- upper right x
ury
- upper right y
public Rectangle(float llx, float lly, float urx, float ury, int rotation)
Rectangle
-object.
llx
- lower left x
lly
- lower left y
urx
- upper right x
ury
- upper right y
rotation
- the rotation (0, 90, 180, or 270)
public Rectangle(float urx, float ury)
Rectangle
-object starting from the origin (0, 0).
urx
- upper right x
ury
- upper right y
public Rectangle(float urx, float ury, int rotation)
Rectangle
-object starting from the origin (0, 0) and with a specific rotation (valid values are 0, 90, 180, 270).
urx
- upper right x
ury
- upper right y
rotation
- the rotation of the rectangle
public Rectangle(Rectangle rect)
Rectangle
-object.
rect
- another Rectangle
public Rectangle(Rectangle rect)
Rectangle
-object based on a com.itextpdf.awt.geom.Rectangle
object
rect
- com.itextpdf.awt.geom.Rectangle
public boolean process(ElementListener listener)
ElementListener
.
public int type()
public boolean isContent()
Element
isContent
in interface Element
Element.isContent()
public boolean isNestable()
Element
isNestable
in interface Element
Element.isNestable()
public void setLeft(float llx)
llx
- the new value
public float getLeft()
public float getLeft(float margin)
margin
- a margin
public void setRight(float urx)
urx
- the new value
public float getRight()
public float getRight(float margin)
margin
- a margin
public float getWidth()
public void setTop(float ury)
ury
- the new value
public float getTop()
public float getTop(float margin)
margin
- a margin
public void setBottom(float lly)
lly
- the new value
public float getBottom()
public float getBottom(float margin)
margin
- a margin
public float getHeight()
public void normalize()
public int getRotation()
public void setRotation(int rotation)
rotation
- the new rotation value
public Rectangle rotate()
Rectangle
public BaseColor getBackgroundColor()
BaseColor
public void setBackgroundColor(BaseColor backgroundColor)
backgroundColor
- a BaseColor
public float getGrayFill()
public void setGrayFill(float value)
value
- the new grayscale value
public int getBorder()
public boolean hasBorders()
public boolean hasBorder(int type)
type
- the type of border
public void setBorder(int border)
LEFT, RIGHT, TOP, BOTTOM
.
border
- the new value
enableBorderSide(int)
, disableBorderSide(int)
public boolean isUseVariableBorders()
setBorderWidthLeft, setBorderWidthRight, setBorderWidthTop, or setBorderWidthBottom
has been called.
public void setUseVariableBorders(boolean useVariableBorders)
useVariableBorders
- indication if the rectangle has variable borders
public void enableBorderSide(int side)
side
- the side to enable. One of LEFT, RIGHT, TOP, BOTTOM
public void disableBorderSide(int side)
side
- the side to disable. One of LEFT, RIGHT, TOP, BOTTOM
public float getBorderWidth()
public void setBorderWidth(float borderWidth)
borderWidth
- the new value
public float getBorderWidthLeft()
public void setBorderWidthLeft(float borderWidthLeft)
borderWidthLeft
- a width
public float getBorderWidthRight()
public void setBorderWidthRight(float borderWidthRight)
borderWidthRight
- a width
public float getBorderWidthTop()
public void setBorderWidthTop(float borderWidthTop)
borderWidthTop
- a width
public float getBorderWidthBottom()
public void setBorderWidthBottom(float borderWidthBottom)
borderWidthBottom
- a width
public BaseColor getBorderColor()
BaseColor
public void setBorderColor(BaseColor borderColor)
borderColor
- a BaseColor
public BaseColor getBorderColorLeft()
BaseColor
public void setBorderColorLeft(BaseColor borderColorLeft)
borderColorLeft
- a BaseColor
public BaseColor getBorderColorRight()
BaseColor
public void setBorderColorRight(BaseColor borderColorRight)
borderColorRight
- a BaseColor
public BaseColor getBorderColorTop()
BaseColor
public void setBorderColorTop(BaseColor borderColorTop)
borderColorTop
- a BaseColor
public BaseColor getBorderColorBottom()
BaseColor
public void setBorderColorBottom(BaseColor borderColorBottom)
borderColorBottom
- a BaseColor
public Rectangle rectangle(float top, float bottom)
top
- the top position
bottom
- the bottom position
Rectangle
public void cloneNonPositionParameters(Rectangle rect)
Rectangle
object
rect
- Rectangle
to copy from
public void softCloneNonPositionParameters(Rectangle rect)
Rectangle
object if the value is set there
rect
- Rectangle
to copy from
public String toString()
Element
toString
in interface Element
toString
in class Object
Object.toString()
Copyright © 1998–2017. All rights reserved.