Class Rectangle
- java.lang.Object
-
- com.gitlab.pdftk_java.com.lowagie.text.Rectangle
-
- All Implemented Interfaces:
Element,MarkupAttributes
public class Rectangle extends Object implements Element, MarkupAttributes
ARectangleis the representation of a geometric figure. Rectangles support constant width borders usingsetBorderWidth(float)andsetBorder(int). They also support borders that vary in width/color on each side using methods likesetBorderWidthLeft(float)orsetBorderColorLeft(java.awt.Color).- See Also:
Element,Table,Cell,HeaderFooter
-
-
Field Summary
Fields Modifier and Type Field Description protected ColorbackgroundThis is the color of the background of this rectangle.protected intborderThis represents the status of the 4 sides of the rectangle.protected ColorborderColorBottomThe color of the bottom border of this rectangle.protected ColorborderColorLeftThe color of the left border of this rectangle.protected ColorborderColorRightThe color of the right border of this rectangle.protected ColorborderColorTopThe color of the top border of this rectangle.protected floatborderWidthThis is the width of the border around this rectangle.protected floatborderWidthBottomThe width of the bottom border of this rectangle.protected floatborderWidthLeftThe width of the left border of this rectangle.protected floatborderWidthRightThe width of the right border of this rectangle.protected floatborderWidthTopThe width of the top border of this rectangle.static intBOTTOMThis represents one side of the border of theRectangle.static intBOXThis represents a type of border.protected ColorcolorThe color of the border of this rectangle.protected floatgrayFillThis is the grayscale value of the background of this rectangle.static intLEFTThis represents one side of the border of theRectangle.protected floatllxthe lower left x-coordinate.protected floatllythe lower left y-coordinate.protected PropertiesmarkupAttributesContains extra markupAttributesstatic intNO_BORDERThis represents a rectangle without borders.static intRIGHTThis represents one side of the border of theRectangle.protected introtationstatic intTOPThis represents one side of the border of theRectangle.static intUNDEFINEDThis is the value that will be used as undefined .protected floaturxthe upper right x-coordinate.protected floaturythe upper right y-coordinate.protected booleanuseVariableBordersWhether variable width borders are used.-
Fields inherited from interface com.gitlab.pdftk_java.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, GRAPHIC, HEADER, IMGRAW, IMGTEMPLATE, JPEG, KEYWORDS, LIST, LISTITEM, MULTI_COLUMN_TEXT, PARAGRAPH, PHRASE, PRODUCER, PTABLE, RECTANGLE, ROW, SECTION, SUBJECT, TABLE, TITLE
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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 aRectangleobject 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.floatgetBottom()ArrayListgetChunks()Gets all the chunks in this element.floatgetHeight()floatgetLeft()StringgetMarkupAttribute(String name)Returns the value of the specified attribute.SetgetMarkupAttributeNames()Returns aSetofStringattribute names for theMarkupAttributesimplementor.PropertiesgetMarkupAttributes()Return aProperties-object containing all the markupAttributes.floatgetRight()intgetRotation()Gets the rotation of the rectanglefloatgetTop()floatgetWidth()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 upperrightbooleanprocess(ElementListener listener)Processes the element by adding it (or the different parts) to anElementListener.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 colorvoidsetBorderColorLeft(Color value)Sets the value of the border colorvoidsetBorderColorRight(Color value)Sets the value of the border colorvoidsetBorderColorTop(Color value)Sets the value of the border colorvoidsetBorderWidth(float value)Sets the borderwidth of the table.voidsetBorderWidthBottom(float borderWidthBottom)Sets the width of a bordervoidsetBorderWidthLeft(float borderWidthLeft)Sets the width of a bordervoidsetBorderWidthRight(float borderWidthRight)Sets the width of a bordervoidsetBorderWidthTop(float borderWidthTop)Sets the width of a bordervoidsetBottom(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.voidsetMarkupAttribute(String name, String value)Sets the specified attribute.voidsetMarkupAttributes(Properties markupAttributes)Sets the markupAttributes.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 bordersvoidsoftCloneNonPositionParameters(Rectangle rect)Copies all of the parameters from aRectangleobject except the position.floattop()Returns the upper right y-coordinate.floattop(float margin)Returns the upper right y-coordinate, considering a given margin.StringtoString()Gets the content of the text element.inttype()Gets the type of the text element.floatwidth()Returns the width of the rectangle.
-
-
-
Field Detail
-
UNDEFINED
public static final int UNDEFINED
This is the value that will be used as undefined .- See Also:
- Constant Field Values
-
TOP
public static final int TOP
This represents one side of the border of theRectangle.- See Also:
- Constant Field Values
-
BOTTOM
public static final int BOTTOM
This represents one side of the border of theRectangle.- See Also:
- Constant Field Values
-
LEFT
public static final int LEFT
This represents one side of the border of theRectangle.- See Also:
- Constant Field Values
-
RIGHT
public static final int RIGHT
This represents one side of the border of theRectangle.- See Also:
- Constant Field Values
-
NO_BORDER
public static final int NO_BORDER
This represents a rectangle without borders.- See Also:
- Constant Field Values
-
BOX
public static final int BOX
This represents a type of border.- See Also:
- Constant Field Values
-
llx
protected float llx
the lower left x-coordinate.
-
lly
protected float lly
the lower left y-coordinate.
-
urx
protected float urx
the upper right x-coordinate.
-
ury
protected float ury
the upper right y-coordinate.
-
border
protected int border
This represents the status of the 4 sides of the rectangle.
-
borderWidth
protected float borderWidth
This is the width of the border around this rectangle.
-
color
protected Color color
The color of the 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.
-
borderColorBottom
protected Color borderColorBottom
The color 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.
-
borderWidthBottom
protected float borderWidthBottom
The width of the bottom border of this rectangle.
-
useVariableBorders
protected boolean useVariableBorders
Whether variable width borders are used.
-
background
protected Color background
This is the color of the background of this rectangle.
-
grayFill
protected float grayFill
This is the grayscale value of the background of this rectangle.
-
rotation
protected int rotation
-
markupAttributes
protected Properties markupAttributes
Contains extra markupAttributes
-
-
Constructor Detail
-
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(Rectangle rect)
Constructs aRectangle-object.- Parameters:
rect- anotherRectangle
-
-
Method Detail
-
cloneNonPositionParameters
public void cloneNonPositionParameters(Rectangle rect)
Copies all of the parameters from aRectangleobject except the position.- Parameters:
rect-Rectangleto copy from
-
softCloneNonPositionParameters
public void softCloneNonPositionParameters(Rectangle rect)
Copies all of the parameters from aRectangleobject except the position.- Parameters:
rect-Rectangleto copy from
-
process
public boolean process(ElementListener listener)
Processes the element by adding it (or the different parts) to anElementListener.
-
type
public int type()
Gets the type of the text element.
-
getChunks
public ArrayList getChunks()
Gets all the chunks in this element.
-
normalize
public void normalize()
Switches lowerleft with upperright
-
rectangle
public Rectangle rectangle(float top, float bottom)
Gets a Rectangle that is altered to fit on the page.- Parameters:
top- the top positionbottom- the bottom position- Returns:
- a
Rectangle
-
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
-
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
-
setBottom
public void setBottom(float value)
Sets the lower left y-coordinate.- 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:
enableBorderSide(int),disableBorderSide(int)
-
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
-
setBorderWidth
public void setBorderWidth(float value)
Sets the borderwidth of the table.- Parameters:
value- the new value
-
setBorderColor
public void setBorderColor(Color value)
Sets the color of the border.- Parameters:
value- the new value
-
setBorderColorRight
public void setBorderColorRight(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
-
setBorderColorTop
public void setBorderColorTop(Color value)
Sets the value of the border color- Parameters:
value- a color value
-
setBorderColorBottom
public void setBorderColorBottom(Color value)
Sets the value of the border color- Parameters:
value- a color value
-
setBackgroundColor
public void setBackgroundColor(Color value)
Sets the backgroundcolor of the rectangle.- Parameters:
value- the new value
-
setGrayFill
public void setGrayFill(float value)
Sets the grayscale of the rectangle.- Parameters:
value- the new value
-
left
public float left()
Returns the lower left x-coordinate.- Returns:
- the lower left x-coordinate
-
getLeft
public float getLeft()
-
right
public float right()
Returns the upper right x-coordinate.- Returns:
- the upper right x-coordinate
-
getRight
public float getRight()
-
top
public float top()
Returns the upper right y-coordinate.- Returns:
- the upper right y-coordinate
-
getTop
public float getTop()
-
bottom
public float bottom()
Returns the lower left y-coordinate.- Returns:
- the lower left y-coordinate
-
getBottom
public float getBottom()
-
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
-
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
-
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
-
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
-
width
public float width()
Returns the width of the rectangle.- Returns:
- a width
-
getWidth
public float getWidth()
-
height
public float height()
Returns the height of the rectangle.- Returns:
- a height
-
getHeight
public float getHeight()
-
hasBorders
public boolean hasBorders()
Indicates if the table has borders.- Returns:
- a boolean
-
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
-
border
public int border()
Returns the exact type of the border.- Returns:
- a value
-
borderWidth
public float borderWidth()
Gets the borderwidth.- Returns:
- a value
-
borderColor
public Color borderColor()
Gets the color of the border.- Returns:
- a value
-
backgroundColor
public Color backgroundColor()
Gets the backgroundcolor.- Returns:
- a value
-
grayFill
public float grayFill()
Gets the grayscale.- Returns:
- a value
-
getRotation
public int getRotation()
Gets the rotation of the rectangle- Returns:
- a rotation value
-
setMarkupAttribute
public void setMarkupAttribute(String name, String value)
Description copied from interface:MarkupAttributesSets the specified attribute.- Specified by:
setMarkupAttributein interfaceMarkupAttributes- Parameters:
name-Stringattribute name.value-Stringattribute value.- See Also:
MarkupAttributes.setMarkupAttribute(java.lang.String, java.lang.String)
-
setMarkupAttributes
public void setMarkupAttributes(Properties markupAttributes)
Description copied from interface:MarkupAttributesSets the markupAttributes.- Specified by:
setMarkupAttributesin interfaceMarkupAttributes- Parameters:
markupAttributes- aProperties-object containing markupattributes- See Also:
MarkupAttributes.setMarkupAttributes(java.util.Properties)
-
getMarkupAttribute
public String getMarkupAttribute(String name)
Description copied from interface:MarkupAttributesReturns the value of the specified attribute.- Specified by:
getMarkupAttributein interfaceMarkupAttributes- Parameters:
name-Stringattribute name.- Returns:
String.- See Also:
MarkupAttributes.getMarkupAttribute(java.lang.String)
-
getMarkupAttributeNames
public Set getMarkupAttributeNames()
Description copied from interface:MarkupAttributesReturns aSetofStringattribute names for theMarkupAttributesimplementor.- Specified by:
getMarkupAttributeNamesin interfaceMarkupAttributes- Returns:
Set.- See Also:
MarkupAttributes.getMarkupAttributeNames()
-
getMarkupAttributes
public Properties getMarkupAttributes()
Description copied from interface:MarkupAttributesReturn aProperties-object containing all the markupAttributes.- Specified by:
getMarkupAttributesin interfaceMarkupAttributes- Returns:
Properties- See Also:
MarkupAttributes.getMarkupAttributes()
-
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
-
getBorderColorBottom
public Color getBorderColorBottom()
Gets the color of a border.- Returns:
- a color value
-
getBorderWidthLeft
public float getBorderWidthLeft()
Gets the width of a border.- Returns:
- a width
-
setBorderWidthLeft
public void setBorderWidthLeft(float borderWidthLeft)
Sets the width of a border- Parameters:
borderWidthLeft- a width
-
getBorderWidthRight
public float getBorderWidthRight()
Gets the width of a border.- Returns:
- a width
-
setBorderWidthRight
public void setBorderWidthRight(float borderWidthRight)
Sets the width of a border- Parameters:
borderWidthRight- a width
-
getBorderWidthTop
public float getBorderWidthTop()
Gets the width of a border.- Returns:
- a width
-
setBorderWidthTop
public void setBorderWidthTop(float borderWidthTop)
Sets the width of a border- Parameters:
borderWidthTop- a width
-
getBorderWidthBottom
public float getBorderWidthBottom()
Gets the width of a border.- Returns:
- a width
-
setBorderWidthBottom
public void setBorderWidthBottom(float borderWidthBottom)
Sets the width of a border- Parameters:
borderWidthBottom- a width
-
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
-
-