Package net.atthegate.server.service.pdf
Class TextBox
java.lang.Object
net.atthegate.server.service.pdf.TextBox
- All Implemented Interfaces:
Drawable
A box containing line-wrapped text.
Defaults:
x = 0f
y = 0f
width = 300f
height = 0f
alignment = Align.LEFT
valign = Align.TOP
spacing = 3f
margin = 1f
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreates a text box and sets the font.Creates a text box and sets the font.Creates a text box and sets the font and the text.Creates a text box and sets the font and the text. -
Method Summary
Modifier and TypeMethodDescriptionfloat[]
Draws this text box on the specified page.float[]
Draws this text box on the specified page.int
Returns the background color.boolean
getBorder
(int border) Returns the text box border.int
Returns the brush color.getFont()
Returns the font used by this text box.float
Returns the text box height.float
Returns the border line width.float
Returns the text box margin.int
Returns the pen color as 0xRRGGBB integer.float
Returns the spacing between lines of text.boolean
Returns the strikeout flag.getText()
Returns the text box text.int
Returns the text alignment.boolean
Whether the text will be underlined.int
float
getWidth()
Returns the text box width.float
getX()
Gets the x coordinate where this text box will be drawn on the page.float
getY()
Gets the y coordinate where this text box will be drawn on the page.void
setBgColor
(double[] color) Sets the background to the specified color.void
setBgColor
(int color) Sets the background to the specified color.void
setBgColor
(int[] color) Sets the background to the specified color.void
setBorder
(int border, boolean visible) Sets the TextBox border object.void
setBrushColor
(double[] color) Sets the brush color.void
setBrushColor
(int color) Sets the brush color.void
setBrushColor
(int[] color) Sets the brush color.void
setFallbackFont
(Font font) void
setFgColor
(double[] color) Sets the foreground pen and brush colors to the specified color.void
setFgColor
(int color) Sets the pen and brush colors to the specified color.void
setFgColor
(int[] color) Sets the pen and brush colors to the specified color.void
Sets the font for this text box.void
setHeight
(double height) Sets the height of this text box.void
setHeight
(float height) Sets the height of this text box.void
setLineWidth
(double lineWidth) Sets the border line width.void
setLineWidth
(float lineWidth) Sets the border line width.void
setLocation
(float x, float y) Sets the location where this text box will be drawn on the page.void
setMargin
(double margin) Sets the margin of this text box.void
setMargin
(float margin) Sets the margin of this text box.void
Sets all borders to be invisible.void
setPenColor
(double[] color) Sets the pen color.void
setPenColor
(int color) Sets the pen color.void
setPenColor
(int[] color) Sets the pen color.void
setPosition
(double x, double y) Sets the position where this text box will be drawn on the page.void
setPosition
(float x, float y) Sets the position where this text box will be drawn on the page.void
setSpacing
(double spacing) Sets the spacing between lines of text.void
setSpacing
(float spacing) Sets the spacing between lines of text.void
setStrikeout
(boolean strikeout) Sets the srikeout flag.void
Sets the text box text.void
setTextAlignment
(int alignment) Sets the cell text alignment.void
setTextColors
(Map<String, Integer> colors) void
setUnderline
(boolean underline) Sets the underline variable.void
setVerticalAlignment
(int alignment) Sets the vertical alignment of the text in this TextBox.void
setWidth
(double width) Sets the width of this text box.void
setWidth
(float width) Sets the width of this text box.
-
Field Details
-
font
-
text
-
x
protected float x -
y
protected float y -
width
protected float width -
height
protected float height -
spacing
protected float spacing -
margin
protected float margin
-
-
Constructor Details
-
TextBox
Creates a text box and sets the font.- Parameters:
font
- the font.
-
TextBox
Creates a text box and sets the font.- Parameters:
font
- the font.text
- the text.
-
TextBox
Creates a text box and sets the font and the text.- Parameters:
font
- the font.text
- the text.width
- the width.height
- the height.
-
TextBox
Creates a text box and sets the font and the text.- Parameters:
font
- the font.text
- the text.width
- the width.height
- the height.
-
-
Method Details
-
setFont
Sets the font for this text box.- Parameters:
font
- the font.
-
getFont
Returns the font used by this text box.- Returns:
- the font.
-
setText
Sets the text box text.- Parameters:
text
- the text box text.
-
getText
Returns the text box text.- Returns:
- the text box text.
-
setPosition
public void setPosition(double x, double y) Sets the position where this text box will be drawn on the page.- Parameters:
x
- the x coordinate of the top left corner of the text box.y
- the y coordinate of the top left corner of the text box.
-
setPosition
public void setPosition(float x, float y) Sets the position where this text box will be drawn on the page.- Parameters:
x
- the x coordinate of the top left corner of the text box.y
- the y coordinate of the top left corner of the text box.
-
setLocation
public void setLocation(float x, float y) Sets the location where this text box will be drawn on the page.- Parameters:
x
- the x coordinate of the top left corner of the text box.y
- the y coordinate of the top left corner of the text box.
-
getX
public float getX()Gets the x coordinate where this text box will be drawn on the page.- Returns:
- the x coordinate of the top left corner of the text box.
-
getY
public float getY()Gets the y coordinate where this text box will be drawn on the page.- Returns:
- the y coordinate of the top left corner of the text box.
-
setWidth
public void setWidth(double width) Sets the width of this text box.- Parameters:
width
- the specified width.
-
setWidth
public void setWidth(float width) Sets the width of this text box.- Parameters:
width
- the specified width.
-
getWidth
public float getWidth()Returns the text box width.- Returns:
- the text box width.
-
setHeight
public void setHeight(double height) Sets the height of this text box.- Parameters:
height
- the specified height.
-
setHeight
public void setHeight(float height) Sets the height of this text box.- Parameters:
height
- the specified height.
-
getHeight
public float getHeight()Returns the text box height.- Returns:
- the text box height.
-
setMargin
public void setMargin(double margin) Sets the margin of this text box.- Parameters:
margin
- the margin between the text and the box
-
setMargin
public void setMargin(float margin) Sets the margin of this text box.- Parameters:
margin
- the margin between the text and the box
-
getMargin
public float getMargin()Returns the text box margin.- Returns:
- the margin between the text and the box
-
setLineWidth
public void setLineWidth(double lineWidth) Sets the border line width.- Parameters:
lineWidth
- double
-
setLineWidth
public void setLineWidth(float lineWidth) Sets the border line width.- Parameters:
lineWidth
- float
-
getLineWidth
public float getLineWidth()Returns the border line width.- Returns:
- float the line width.
-
setSpacing
public void setSpacing(double spacing) Sets the spacing between lines of text.- Parameters:
spacing
- the spacing
-
setSpacing
public void setSpacing(float spacing) Sets the spacing between lines of text.- Parameters:
spacing
-
-
getSpacing
public float getSpacing()Returns the spacing between lines of text.- Returns:
- float the spacing.
-
setBgColor
public void setBgColor(int color) Sets the background to the specified color.- Parameters:
color
- the color specified as 0xRRGGBB integer.
-
setBgColor
public void setBgColor(int[] color) Sets the background to the specified color.- Parameters:
color
- the color specified as array of integer values from 0x00 to 0xFF.
-
setBgColor
public void setBgColor(double[] color) Sets the background to the specified color.- Parameters:
color
- the color specified as array of double values from 0.0 to 1.0.
-
getBgColor
public int getBgColor()Returns the background color.- Returns:
- int the color as 0xRRGGBB integer.
-
setFgColor
public void setFgColor(int color) Sets the pen and brush colors to the specified color.- Parameters:
color
- the color specified as 0xRRGGBB integer.
-
setFgColor
public void setFgColor(int[] color) Sets the pen and brush colors to the specified color.- Parameters:
color
- the color specified as 0xRRGGBB integer.
-
setFgColor
public void setFgColor(double[] color) Sets the foreground pen and brush colors to the specified color.- Parameters:
color
- the color specified as an array of double values from 0.0 to 1.0.
-
setPenColor
public void setPenColor(int color) Sets the pen color.- Parameters:
color
- the color specified as 0xRRGGBB integer.
-
setPenColor
public void setPenColor(int[] color) Sets the pen color.- Parameters:
color
- the color specified as an array of int values from 0x00 to 0xFF.
-
setPenColor
public void setPenColor(double[] color) Sets the pen color.- Parameters:
color
- the color specified as an array of double values from 0.0 to 1.0.
-
getPenColor
public int getPenColor()Returns the pen color as 0xRRGGBB integer.- Returns:
- int the pen color.
-
setBrushColor
public void setBrushColor(int color) Sets the brush color.- Parameters:
color
- the color specified as 0xRRGGBB integer.
-
setBrushColor
public void setBrushColor(int[] color) Sets the brush color.- Parameters:
color
- the color specified as an array of int values from 0x00 to 0xFF.
-
setBrushColor
public void setBrushColor(double[] color) Sets the brush color.- Parameters:
color
- the color specified as an array of double values from 0.0 to 1.0.
-
getBrushColor
public int getBrushColor()Returns the brush color.- Returns:
- int the brush color specified as 0xRRGGBB integer.
-
setBorder
public void setBorder(int border, boolean visible) Sets the TextBox border object.- Parameters:
border
- the border object.
-
getBorder
public boolean getBorder(int border) Returns the text box border.- Returns:
- boolean the text border object.
-
setNoBorders
public void setNoBorders()Sets all borders to be invisible. This cell will have no borders when drawn on the page. -
setTextAlignment
public void setTextAlignment(int alignment) Sets the cell text alignment.- Parameters:
alignment
- the alignment code. Supported values: Align.LEFT, Align.RIGHT and Align.CENTER.
-
getTextAlignment
public int getTextAlignment()Returns the text alignment.- Returns:
- alignment the alignment code. Supported values: Align.LEFT, Align.RIGHT and Align.CENTER.
-
setUnderline
public void setUnderline(boolean underline) Sets the underline variable. If the value of the underline variable is 'true' - the text is underlined.- Parameters:
underline
- the underline flag.
-
getUnderline
public boolean getUnderline()Whether the text will be underlined.- Returns:
- whether the text will be underlined
-
setStrikeout
public void setStrikeout(boolean strikeout) Sets the srikeout flag. In the flag is true - draw strikeout line through the text.- Parameters:
strikeout
- the strikeout flag.
-
getStrikeout
public boolean getStrikeout()Returns the strikeout flag.- Returns:
- boolean the strikeout flag.
-
setFallbackFont
-
getFallbackFont
-
setVerticalAlignment
public void setVerticalAlignment(int alignment) Sets the vertical alignment of the text in this TextBox.- Parameters:
alignment
- - valid values areAlign.TOP, Align.BOTTOM and Align.CENTER
-
getVerticalAlignment
public int getVerticalAlignment() -
setTextColors
-
getTextColors
-
drawOn
Draws this text box on the specified page. -
drawOn
Draws this text box on the specified page.- Parameters:
page
- the Page where the TextBox is to be drawn.draw
- flag specifying if this component should actually be drawn on the page.- Returns:
- x and y coordinates of the bottom right corner of this component.
- Throws:
Exception
-