|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.faceless.pdf2.PDFAnnotation
org.faceless.pdf2.WidgetAnnotation
public class WidgetAnnotation
The WidgetAnnotation
class represents the type of annotation
used to represent the visual contents of a FormElement
on the page.
Method Summary | |
---|---|
void |
flatten()
Stamp the visible appearance of this annotation permanently onto its page, and remove the annotation from the page. |
PDFAction |
getAction(Event event)
Return the action that occurs when the specified event happens to this annotation. |
PDFStyle |
getBackgroundStyle()
Get the background style for this annotation. |
PDFCanvas |
getButtonImage()
For a FormButton annotation, return the image that is drawn on the
button, or null if the field is not a button or no image is
specified. |
FormElement |
getField()
Return the FormElement that this annotation represents on the page. |
PDFStyle |
getTextStyle()
Get the text style for this widget. |
String |
getTextValue()
Deprecated. since 2.11 just call getValue() instead. |
String |
getValue()
Get the value of this Widget annotation - the value of the box for RadioButton and Checkbox annotations, the text on the Button for Button annotations, or null otherwise. |
boolean |
isOverflowing()
Return true if the Widget is not big enough to hold the value of the field without overflowing (based on the layout algorithm, rather then the visual appearance of the text). |
boolean |
isSelected()
For Radiobuttons and Checkboxes, this method returns true if this specific Widget is selected. |
void |
setAction(Event event,
PDFAction action)
Set an action to occur when the specified event happens to this annotation. |
void |
setBackgroundStyle(PDFStyle style)
Set the background style for this annotation. |
void |
setButtonImage(PDFCanvas image,
char scale,
boolean anamorphic,
double x,
double y)
For FormButton annotations, set the image to display on the button. |
void |
setButtonImage(PDFImage image)
For FormButton annotations, set the image to display on the button. |
void |
setSelected(boolean selected)
For Radiobuttons and Checkboxes, this method can be called to set the specified Widget to true. |
void |
setTextStyle(PDFStyle style)
Set the text style for this annotation. |
void |
setTextValue(String value)
Deprecated. since 2.11 just call #setValue |
void |
setValue(String value)
Set the value of this annotation for for PushButton, RadioButton and Checkbox annotations. |
String |
toString()
|
Methods inherited from class org.faceless.pdf2.PDFAnnotation |
---|
addPropertyChangeListener, addReview, getAuthor, getColor, getContents, getCreationDate, getInReplyTo, getMetaData, getModifyDate, getOpacity, getPage, getPopup, getRectangle, getReplies, getReviews, getSubject, getType, getUniqueID, hasAppearanceState, isContentLocked, isPositionLocked, isPrintable, isReadOnly, isVisible, removePropertyChangeListener, setAuthor, setColor, setContents, setCreationDate, setInReplyTo, setLocked, setMetaData, setModifyDate, setOpacity, setPage, setPrintable, setReadOnly, setRectangle, setSubject, setUniqueID, setVisible |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Method Detail |
---|
public FormElement getField()
FormElement
that this annotation represents on the page.
public String getValue()
Get the value of this Widget annotation - the value of the box for RadioButton and
Checkbox annotations, the text on the Button for Button annotations, or
null
otherwise.
For example, a RadioButton used to select a type of credit card may have three
annotations with the values "Visa", "MasterCard" and "Amex". For fields other
than Push Buttons, RadioButtons and Checkboxes this method will return
null
- in this case the value of the field can be read by calling
the FormElement.getValue()
method instead.
setValue(java.lang.String)
,
FormRadioButton.setValue(java.lang.String)
,
FormCheckbox.setValue(java.lang.String)
public String getTextValue()
Since 2.11 just returns the value of getValue()
, so just call that
method instead.
From 2.6.3 to 2.10.6, this method returned the value from the "Opt" array of the parent field corresponding to this field. Earlier versions of the PDF specification described this as a way of storing a "key" and "export value" for the field, but in practice this is not how it's used, and when an export value is present the key is simply the numeric index of the field. Release 2.10.6 removed the issues this caused, and widgets are now always referred to by their export value.
public void setValue(String value)
getValue()
method for a discussion of annotation values.
getValue()
,
FormRadioButton.setValue(java.lang.String)
,
FormCheckbox.setValue(java.lang.String)
public void setSelected(boolean selected)
getField().setValue(getValue())
- this method
is only required when a field has multiple items with the same value. For any other type of
field this method throws an IllegalStateException
public boolean isSelected()
getField().getValue().equals(getValue())
,
but see the setSelected(boolean)
method for more detail. For other fields this method always
returns false.
public void setTextValue(String value)
setValue()
. See getTextValue()
for a description of this change.
public PDFStyle getBackgroundStyle()
FormStyle
,
and, if appropriate, a RadioButton
or Checkbox
style.
public PDFStyle getTextStyle()
public void setBackgroundStyle(PDFStyle style)
Fill Color
,
Line Color
, FormStyle
,
Radio Button style
or
Check Box style
attributes set.
A value of null
means the default style for the form will be used.
public void setTextStyle(PDFStyle style)
Font
and fill color
set, although
the font size may be 0 to specified "Auto" sized text. It may also
have a text alignment
specified, which is used
for FormButton
and FormText
annotations.
A value of null
means the default style for the form will be used.
public void setButtonImage(PDFImage image)
FormButton
annotations, set the image to display on the button.
Draws the image to a PDFCanvas
and then calls
setButtonImage(image, 'A', false, 0.5, 0.5)
image
- the image to display on the button
IllegalStateException
- if this method is called on an annotation for anything
other than a FormButton
public void setButtonImage(PDFCanvas image, char scale, boolean anamorphic, double x, double y)
FormButton
annotations, set the image to display on the button.
Where the image is positioned in relation to the text depends on the value
of the text-alignment in the style specified by setTextStyle(org.faceless.pdf2.PDFStyle)
and the
other parameters to this method.
Setting image
to null
removes any current image from
the button annotation.
Calling this method on an annotation for any type of field other than a Button
will result in an IllegalStateException
being thrown
image
- the image to display on the button, or null
for no imagescale
- one of 'A' to always scale the image (the default), 'B' to only
scale the image down to fit the annotation, 'S' to only scale the image up to fit
the annotation or 'N' to never scale the imageanamorphic
- true to ignore the aspect ratio of the image when scaling itx
- where to horizontally position the image in the space allowed to it - 0 for left, 0.5 to center it and 1 to place it to the righty
- where to vertically position the image in the space allowed to it - 0 for top, 0.5 to center it and 1 to place it to the bottompublic PDFCanvas getButtonImage()
FormButton
annotation, return the image that is drawn on the
button, or null
if the field is not a button or no image is
specified.
PDFImage
)public void setAction(Event event, PDFAction action)
Set an action to occur when the specified event happens to
this annotation. These event actions are only used for annotations
created by form elements - those returned from FormElement.getAnnotations()
.
The event can be one of
Event.MOUSEOVER
, Event.MOUSEOUT
,
Event.MOUSEDOWN
, Event.MOUSEUP
,
Event.FOCUS
, Event.BLUR
, Event.CHANGE
,
Event.KEYPRESS
or Event.FORMAT
.
event
- the event the action applies toaction
- the action you wish to occur, or null
to remove the actionFormElement.setAction(org.faceless.pdf2.Event, org.faceless.pdf2.PDFAction)
public PDFAction getAction(Event event)
FormElement.getAnnotations()
method.
event
- the event you want the action for - one of the events listed in setAction(org.faceless.pdf2.Event, org.faceless.pdf2.PDFAction)
null
if no action is specifiedFormElement
public void flatten()
PDFAnnotation
Stamp the visible appearance of this annotation permanently onto its page, and remove the annotation from the page. The annotation object should be discarded afterwards.
Note that this method removes this PDFAnnotation from the page list (and
if this annotation is a Widget, from the FormElement.getAnnotations()
FormElement Annotations list} as well),
which could result in a ConcurrentModificationException
if you
were iterating
over the page's annotations. To flatten
all the annotations on a page we'd recommend something like this:
List l = page.getAnnotations(); while (l.size() > 0) { ((PDFAnnotation)l.get(l.size() - 1)).flatten(); }
flatten
in class PDFAnnotation
FormElement.flatten()
,
Form.flatten()
public boolean isOverflowing()
FormText
fields,
and for some types of field (eg. those formatted by JavaScript or XFA rules)
it cannot reliably be determined - in this case this method returns false.
public String toString()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |