KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > faceless > pdf > FormElement


1 // $Id: FormElement.java,v 1.2 2003/10/06 12:40:06 mike Exp $
2

3 package org.faceless.pdf;
4
5 import java.util.*;
6 import java.awt.Color JavaDoc;
7
8 /**
9  * The <code>FormElement</code> class is the baseclass for all
10  * elements which may be added to a {@link Form}.
11  *
12  * @since 1.1.13
13  */

14 public abstract class FormElement extends PeeredObject
15 {
16     /**
17      * A style to use for <code>Checkbox</code> and <code>RadioButton</code>
18      * elements which sets its appearance to a check mark (a tick). This is
19      * the default for {@link FormCheckbox} elements.
20      * @since 1.1.23
21      */

22     public static final int STYLE_CHECK=0x2714;
23
24     /**
25      * A style to use for <code>Checkbox</code> and <code>RadioButton</code>
26      * elements which sets its appearance to a filled circle. This is the
27      * default for {@link FormRadioButton} elements.
28      * @since 1.1.23
29      */

30     public static final int STYLE_CIRCLE=0x25CF;
31
32     /**
33      * A style to use for <code>Checkbox</code> and <code>RadioButton</code>
34      * elements which sets its appearance to a cross or "X"
35      * @since 1.1.23
36      */

37     public static final int STYLE_CROSS=0x2718;
38
39     /**
40      * A style to use for <code>Checkbox</code> and <code>RadioButton</code>
41      * elements which sets its appearance to a filled square
42      * @since 1.1.23
43      */

44     public static final int STYLE_SQUARE=0x25A0;
45
46     /**
47      * A style to use for <code>Checkbox</code> and <code>RadioButton</code>
48      * elements which sets its appearance to a filled diamond
49      * @since 1.1.23
50      */

51     public static final int STYLE_DIAMOND=0x25C6;
52
53     /**
54      * A style to use for <code>Checkbox</code> and <code>RadioButton</code>
55      * elements which sets its appearance to a filled five-pointed star
56      * @since 1.1.23
57      */

58     public static final int STYLE_STAR=0x2605;
59
60
61     final org.faceless.pdf2.FormElement element;
62
63     Object JavaDoc getPeer()
64     {
65         return element;
66     }
67
68     FormElement(org.faceless.pdf2.FormElement element)
69     {
70         this.element=element;
71     }
72
73     /**
74      * Get the list of annotations (visible appearances) associated with this Form element.
75      * Signatures may have no annotations at all, radio buttons usually have
76      * several, and most other fields will usually (but not always) have a
77      * single annotation.
78      * @return the list of annotations associated with the form element
79      * @since 1.1.23
80      */

81     public PDFAnnotation[] getAnnotations()
82     {
83     List l = element.getAnnotations();
84     PDFAnnotation[] z = new PDFAnnotation[l.size()];
85     for (int i=0;i<z.length;i++) {
86         z[i]=(PDFAnnotation)PeeredObject.getPeer(l.get(i));
87     }
88     return z;
89     }
90
91     /**
92      * Set whether the field is read-only or not.
93      * @param readonly whether the field is read-only or not
94      * @since 1.1.23
95      */

96     public void setReadOnly(boolean readonly)
97     {
98     element.setReadOnly(readonly);
99     }
100
101     /**
102      * Get whether the field is read-only or not.
103      * @return true if the field is read-only
104      * @since 1.1.23
105      */

106     public boolean isReadOnly()
107     {
108     return element.isReadOnly();
109     }
110
111     /**
112      * Set whether the field is required before the form is submitted.
113      * For some fields like pushbuttons, this method has no effect.
114      * @param required whether the field is a required field or not
115      * @since 1.1.23
116      */

117     public void setRequired(boolean required)
118     {
119     element.setRequired(required);
120     }
121
122     /**
123      * Get whether the field is required before the form is submitted.
124      * For some fields like pushbuttons, this method always returns false.
125      * @return true if the field is required on form submission
126      * @since 1.1.23
127      */

128     public boolean isRequired()
129     {
130     return element.isRequired();
131     }
132
133     /**
134      * Set whether the field is submitted or not. The default for
135      * every element in the form is true.
136      * @param submit whether the element is submitted or not.
137      * @since 1.1.23
138      */

139     public void setSubmitted(boolean submit)
140     {
141     element.setSubmitted(submit);
142     }
143
144     /**
145      * Get whether the field is submitted or not.
146      * @return true if the field is submitted, false otherwise
147      * @since 1.1.23
148      */

149     public boolean isSubmitted()
150     {
151     return element.isSubmitted();
152     }
153 }
154
Popular Tags