Package com.aowagie.text.pdf
Class BaseField
- java.lang.Object
-
- com.aowagie.text.pdf.BaseField
-
- Direct Known Subclasses:
PushbuttonField,TextField
abstract class BaseField extends java.lang.ObjectCommon field variables.
-
-
Field Summary
Fields Modifier and Type Field Description protected intalignmentprotected java.awt.ColorbackgroundColorprivate static floatBORDER_WIDTH_THINA thin border with 1 point width.protected java.awt.ColorborderColorprotected intborderStyleprotected floatborderWidthprotected Rectangleboxstatic intCOMBcombo box flag.(package private) static intDO_NOT_SCROLLThe field will not scroll (horizontally for single-line fields, vertically for multiple-line fields) to accommodate more text than will fit within its annotation rectangle.(package private) static intDO_NOT_SPELL_CHECKThe text entered in the field will not be spell-checked.static intEDITIf set the combo box includes an editable text box as well as a drop list; if clear, it includes only a drop list.private static java.util.HashMapfieldKeysprotected java.lang.StringfieldNameHolds value of property fieldName.(package private) static intFILE_SELECTIONThe text entered in the field represents the pathname of a file whose contents are to be submitted as the value of the field.private BaseFontfontprotected floatfontSizestatic intHIDDENThe field is hidden.(package private) static intHIDDEN_BUT_PRINTABLEThe field is hidden but is printable.protected intmaxCharacterLengthHolds value of property maxCharacterLength.(package private) static intMULTILINEThe field may contain multiple lines of text.protected intoptionsHolds value of property options.(package private) static intPASSWORDThe field is intended for entering a secure password that should not be echoed visibly to the screen.(package private) static intREAD_ONLYThe user may not change the value of the field.(package private) static intREQUIREDThe field must have a value at the time it is exported by a submit-form action.protected introtationHolds value of property rotation.protected java.lang.Stringtextprotected java.awt.ColortextColorprotected intvisibilityHolds value of property visibility.(package private) static intVISIBLEThe field is visible.(package private) static intVISIBLE_BUT_DOES_NOT_PRINTThe field is visible but does not print.protected PdfWriterwriter
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private voiddrawBottomFrame(PdfAppearance app)private voiddrawTopFrame(PdfAppearance app)intgetAlignment()Gets the text horizontal alignment.java.awt.ColorgetBackgroundColor()Gets the background color.protected PdfAppearancegetBorderAppearance()java.awt.ColorgetBorderColor()Gets the border color.intgetBorderStyle()Gets the border style.floatgetBorderWidth()Gets the border width in points.RectanglegetBox()Gets the field dimension and position.java.lang.StringgetFieldName()Gets the field name.BaseFontgetFont()Gets the text font.floatgetFontSize()Gets the font size.intgetMaxCharacterLength()Gets the maximum length of the field's text, in characters.intgetOptions()Gets the option flags.protected BaseFontgetRealFont()intgetRotation()Gets the field rotation.java.lang.StringgetText()Gets the text.java.awt.ColorgetTextColor()Gets the text color.intgetVisibility()Gets the field visibility flag.PdfWritergetWriter()Getter for property writer.voidsetAlignment(int alignment)Sets the text horizontal alignment.voidsetBackgroundColor(java.awt.Color backgroundColor)Sets the background color.voidsetBorderColor(java.awt.Color borderColor)Sets the border color.voidsetBorderStyle(int borderStyle)Sets the border style.voidsetBorderWidth(float borderWidth)Sets the border width in points.voidsetBox(Rectangle box)Sets the field dimension and position.voidsetFieldName(java.lang.String fieldName)Sets the field name.voidsetFont(BaseFont font)Sets the text font.voidsetFontSize(float fontSize)Sets the font size.voidsetMaxCharacterLength(int maxCharacterLength)Sets the maximum length of the field's text, in characters.voidsetOptions(int options)Sets the option flags.voidsetRotation(int rotation)Sets the field rotation.voidsetRotationFromPage(Rectangle page)Convenience method to set the field rotation the same as the page rotation.voidsetText(java.lang.String text)Sets the text for text fields.voidsetTextColor(java.awt.Color textColor)Sets the text color.voidsetVisibility(int visibility)Sets the field visibility flag.voidsetWriter(PdfWriter writer)Setter for property writer.private static voidtrimRight(java.lang.StringBuffer buf)
-
-
-
Field Detail
-
BORDER_WIDTH_THIN
private static final float BORDER_WIDTH_THIN
A thin border with 1 point width.- See Also:
- Constant Field Values
-
VISIBLE
static final int VISIBLE
The field is visible.- See Also:
- Constant Field Values
-
HIDDEN
public static final int HIDDEN
The field is hidden.- See Also:
- Constant Field Values
-
VISIBLE_BUT_DOES_NOT_PRINT
static final int VISIBLE_BUT_DOES_NOT_PRINT
The field is visible but does not print.- See Also:
- Constant Field Values
-
HIDDEN_BUT_PRINTABLE
static final int HIDDEN_BUT_PRINTABLE
The field is hidden but is printable.- See Also:
- Constant Field Values
-
READ_ONLY
static final int READ_ONLY
The user may not change the value of the field.- See Also:
- Constant Field Values
-
REQUIRED
static final int REQUIRED
The field must have a value at the time it is exported by a submit-form action.- See Also:
- Constant Field Values
-
MULTILINE
static final int MULTILINE
The field may contain multiple lines of text. This flag is only meaningful with text fields.- See Also:
- Constant Field Values
-
DO_NOT_SCROLL
static final int DO_NOT_SCROLL
The field will not scroll (horizontally for single-line fields, vertically for multiple-line fields) to accommodate more text than will fit within its annotation rectangle. Once the field is full, no further text will be accepted.- See Also:
- Constant Field Values
-
PASSWORD
static final int PASSWORD
The field is intended for entering a secure password that should not be echoed visibly to the screen.- See Also:
- Constant Field Values
-
FILE_SELECTION
static final int FILE_SELECTION
The text entered in the field represents the pathname of a file whose contents are to be submitted as the value of the field.- See Also:
- Constant Field Values
-
DO_NOT_SPELL_CHECK
static final int DO_NOT_SPELL_CHECK
The text entered in the field will not be spell-checked. This flag is meaningful only in text fields and in combo fields with theEDITflag set.- See Also:
- Constant Field Values
-
EDIT
public static final int EDIT
If set the combo box includes an editable text box as well as a drop list; if clear, it includes only a drop list. This flag is only meaningful with combo fields.- See Also:
- Constant Field Values
-
COMB
public static final int COMB
combo box flag.- See Also:
- Constant Field Values
-
borderWidth
protected float borderWidth
-
borderStyle
protected int borderStyle
-
borderColor
protected java.awt.Color borderColor
-
backgroundColor
protected java.awt.Color backgroundColor
-
textColor
protected java.awt.Color textColor
-
font
private BaseFont font
-
fontSize
protected float fontSize
-
alignment
protected int alignment
-
writer
protected PdfWriter writer
-
text
protected java.lang.String text
-
box
protected Rectangle box
-
rotation
protected int rotation
Holds value of property rotation.
-
visibility
protected int visibility
Holds value of property visibility.
-
fieldName
protected java.lang.String fieldName
Holds value of property fieldName.
-
options
protected int options
Holds value of property options.
-
maxCharacterLength
protected int maxCharacterLength
Holds value of property maxCharacterLength.
-
fieldKeys
private static final java.util.HashMap fieldKeys
-
-
Constructor Detail
-
BaseField
public BaseField(PdfWriter writer, Rectangle box, java.lang.String fieldName)
Creates a newTextField.- Parameters:
writer- the documentPdfWriterbox- the field location and dimensionsfieldName- the field name. Ifnullonly the widget keys will be included in the field allowing it to be used as a kid field.
-
-
Method Detail
-
getRealFont
protected BaseFont getRealFont() throws java.io.IOException, DocumentException
- Throws:
java.io.IOExceptionDocumentException
-
getBorderAppearance
protected PdfAppearance getBorderAppearance()
-
trimRight
private static void trimRight(java.lang.StringBuffer buf)
-
drawTopFrame
private void drawTopFrame(PdfAppearance app)
-
drawBottomFrame
private void drawBottomFrame(PdfAppearance app)
-
getBorderWidth
public float getBorderWidth()
Gets the border width in points.- Returns:
- the border width in points
-
setBorderWidth
public void setBorderWidth(float borderWidth)
Sets the border width in points. To eliminate the border set the border color tonull.- Parameters:
borderWidth- the border width in points
-
getBorderStyle
public int getBorderStyle()
Gets the border style.- Returns:
- the border style
-
setBorderStyle
public void setBorderStyle(int borderStyle)
Sets the border style. The styles are found inPdfBorderDictionaryand can beSTYLE_SOLID,STYLE_DASHED,STYLE_BEVELED,STYLE_INSETandSTYLE_UNDERLINE.- Parameters:
borderStyle- the border style
-
getBorderColor
public java.awt.Color getBorderColor()
Gets the border color.- Returns:
- the border color
-
setBorderColor
public void setBorderColor(java.awt.Color borderColor)
Sets the border color. Set tonullto remove the border.- Parameters:
borderColor- the border color
-
getBackgroundColor
public java.awt.Color getBackgroundColor()
Gets the background color.- Returns:
- the background color
-
setBackgroundColor
public void setBackgroundColor(java.awt.Color backgroundColor)
Sets the background color. Set tonullfor transparent background.- Parameters:
backgroundColor- the background color
-
getTextColor
public java.awt.Color getTextColor()
Gets the text color.- Returns:
- the text color
-
setTextColor
public void setTextColor(java.awt.Color textColor)
Sets the text color. Ifnullthe color used will be black.- Parameters:
textColor- the text color
-
getFont
public BaseFont getFont()
Gets the text font.- Returns:
- the text font
-
setFont
public void setFont(BaseFont font)
Sets the text font. Ifnullthen Helvetica will be used.- Parameters:
font- the text font
-
getFontSize
public float getFontSize()
Gets the font size.- Returns:
- the font size
-
setFontSize
public void setFontSize(float fontSize)
Sets the font size. If 0 then auto-sizing will be used but only for text fields.- Parameters:
fontSize- the font size
-
getAlignment
public int getAlignment()
Gets the text horizontal alignment.- Returns:
- the text horizontal alignment
-
setAlignment
public void setAlignment(int alignment)
Sets the text horizontal alignment. It can beElement.ALIGN_LEFT,Element.ALIGN_CENTERandElement.ALIGN_RIGHT.- Parameters:
alignment- the text horizontal alignment
-
getText
public java.lang.String getText()
Gets the text.- Returns:
- the text
-
setText
public void setText(java.lang.String text)
Sets the text for text fields.- Parameters:
text- the text
-
getBox
public Rectangle getBox()
Gets the field dimension and position.- Returns:
- the field dimension and position
-
setBox
public void setBox(Rectangle box)
Sets the field dimension and position.- Parameters:
box- the field dimension and position
-
getRotation
public int getRotation()
Gets the field rotation.- Returns:
- the field rotation
-
setRotation
public void setRotation(int rotation)
Sets the field rotation. This value should be the same as the page rotation where the field will be shown.- Parameters:
rotation- the field rotation
-
setRotationFromPage
public void setRotationFromPage(Rectangle page)
Convenience method to set the field rotation the same as the page rotation.- Parameters:
page- the page
-
getVisibility
public int getVisibility()
Gets the field visibility flag.- Returns:
- the field visibility flag
-
setVisibility
public void setVisibility(int visibility)
Sets the field visibility flag. This flags can be one ofVISIBLE,HIDDEN,VISIBLE_BUT_DOES_NOT_PRINTandHIDDEN_BUT_PRINTABLE.- Parameters:
visibility- field visibility flag
-
getFieldName
public java.lang.String getFieldName()
Gets the field name.- Returns:
- the field name
-
setFieldName
public void setFieldName(java.lang.String fieldName)
Sets the field name.- Parameters:
fieldName- the field name. Ifnullonly the widget keys will be included in the field allowing it to be used as a kid field.
-
getOptions
public int getOptions()
Gets the option flags.- Returns:
- the option flags
-
setOptions
public void setOptions(int options)
Sets the option flags. The option flags can be a combination by oring ofREAD_ONLY,REQUIRED,MULTILINE,DO_NOT_SCROLL,PASSWORD,FILE_SELECTION,DO_NOT_SPELL_CHECKandEDIT.- Parameters:
options- the option flags
-
getMaxCharacterLength
public int getMaxCharacterLength()
Gets the maximum length of the field's text, in characters.- Returns:
- the maximum length of the field's text, in characters.
-
setMaxCharacterLength
public void setMaxCharacterLength(int maxCharacterLength)
Sets the maximum length of the field's text, in characters. It is only meaningful for text fields.- Parameters:
maxCharacterLength- the maximum length of the field's text, in characters
-
getWriter
public PdfWriter getWriter()
Getter for property writer.- Returns:
- Value of property writer.
-
setWriter
public void setWriter(PdfWriter writer)
Setter for property writer.- Parameters:
writer- New value of property writer.
-
-