KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > lowagie > text > Element


1 /*
2  * $Id: Element.java 2566 2007-02-02 15:38:59Z blowagie $
3  * $Name$
4  *
5  * Copyright 1999, 2000, 2001, 2002 by Bruno Lowagie.
6  *
7  * The contents of this file are subject to the Mozilla Public License Version 1.1
8  * (the "License"); you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at http://www.mozilla.org/MPL/
10  *
11  * Software distributed under the License is distributed on an "AS IS" basis,
12  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13  * for the specific language governing rights and limitations under the License.
14  *
15  * The Original Code is 'iText, a free JAVA-PDF library'.
16  *
17  * The Initial Developer of the Original Code is Bruno Lowagie. Portions created by
18  * the Initial Developer are Copyright (C) 1999, 2000, 2001, 2002 by Bruno Lowagie.
19  * All Rights Reserved.
20  * Co-Developer of the code is Paulo Soares. Portions created by the Co-Developer
21  * are Copyright (C) 2000, 2001, 2002 by Paulo Soares. All Rights Reserved.
22  *
23  * Contributor(s): all the names of the contributors are added in the source code
24  * where applicable.
25  *
26  * Alternatively, the contents of this file may be used under the terms of the
27  * LGPL license (the "GNU LIBRARY GENERAL PUBLIC LICENSE"), in which case the
28  * provisions of LGPL are applicable instead of those above. If you wish to
29  * allow use of your version of this file only under the terms of the LGPL
30  * License and not to allow others to use your version of this file under
31  * the MPL, indicate your decision by deleting the provisions above and
32  * replace them with the notice and other provisions required by the LGPL.
33  * If you do not delete the provisions above, a recipient may use your version
34  * of this file under either the MPL or the GNU LIBRARY GENERAL PUBLIC LICENSE.
35  *
36  * This library is free software; you can redistribute it and/or modify it
37  * under the terms of the MPL as stated above or under the terms of the GNU
38  * Library General Public License as published by the Free Software Foundation;
39  * either version 2 of the License, or any later version.
40  *
41  * This library is distributed in the hope that it will be useful, but WITHOUT
42  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
43  * FOR A PARTICULAR PURPOSE. See the GNU Library general Public License for more
44  * details.
45  *
46  * If you didn't download this code from the following link, you should check if
47  * you aren't using an obsolete version:
48  * http://www.lowagie.com/iText/
49  */

50
51 package com.lowagie.text;
52
53 import java.util.ArrayList JavaDoc;
54
55 /**
56  * Interface for a text element.
57  * <P>
58  * Remark: I looked at the interface javax.swing.text.Element, but I decided to
59  * write my own text-classes for two reasons:
60  * <OL>
61  * <LI>The javax.swing.text-classes may be very generic, I think they are
62  * overkill: they are to heavy for what they have to do.
63  * <LI>A lot of people using iText (formerly known as rugPdf), still use
64  * JDK1.1.x. I try to keep the Java2 requirements limited to the Collection
65  * classes (I think they're really great). However, if I use the
66  * javax.swing.text classes, it will become very difficult to downgrade rugPdf.
67  * </OL>
68  *
69  * @see Anchor
70  * @see Cell
71  * @see Chapter
72  * @see Chunk
73  * @see Header
74  * @see Image
75  * @see Jpeg
76  * @see List
77  * @see ListItem
78  * @see Meta
79  * @see Paragraph
80  * @see Phrase
81  * @see Rectangle
82  * @see Row
83  * @see Section
84  * @see Table
85  */

86
87 public interface Element {
88
89     // static membervariables (meta information)
90

91     /** This is a possible type of <CODE>Element</CODE>. */
92     public static final int HEADER = 0;
93
94     /** This is a possible type of <CODE>Element</CODE>. */
95     public static final int TITLE = 1;
96
97     /** This is a possible type of <CODE>Element</CODE>. */
98     public static final int SUBJECT = 2;
99
100     /** This is a possible type of <CODE>Element</CODE>. */
101     public static final int KEYWORDS = 3;
102
103     /** This is a possible type of <CODE>Element </CIDE>. */
104     public static final int AUTHOR = 4;
105
106     /** This is a possible type of <CODE>Element </CIDE>. */
107     public static final int PRODUCER = 5;
108
109     /** This is a possible type of <CODE>Element </CIDE>. */
110     public static final int CREATIONDATE = 6;
111
112     /** This is a possible type of <CODE>Element </CIDE>. */
113     public static final int CREATOR = 7;
114
115     // static membervariables (content)
116

117     /** This is a possible type of <CODE>Element</CODE>. */
118     public static final int CHUNK = 10;
119
120     /** This is a possible type of <CODE>Element</CODE>. */
121     public static final int PHRASE = 11;
122
123     /** This is a possible type of <CODE>Element</CODE>. */
124     public static final int PARAGRAPH = 12;
125
126     /** This is a possible type of <CODE>Element</CODE> */
127     public static final int SECTION = 13;
128
129     /** This is a possible type of <CODE>Element</CODE> */
130     public static final int LIST = 14;
131
132     /** This is a possible type of <CODE>Element</CODE> */
133     public static final int LISTITEM = 15;
134
135     /** This is a possible type of <CODE>Element</CODE> */
136     public static final int CHAPTER = 16;
137
138     /** This is a possible type of <CODE>Element</CODE> */
139     public static final int ANCHOR = 17;
140
141     // static membervariables (tables)
142

143     /** This is a possible type of <CODE>Element</CODE>. */
144     public static final int CELL = 20;
145
146     /** This is a possible type of <CODE>Element</CODE>. */
147     public static final int ROW = 21;
148
149     /** This is a possible type of <CODE>Element</CODE>. */
150     public static final int TABLE = 22;
151
152     /** This is a possible type of <CODE>Element</CODE>. */
153     public static final int PTABLE = 23;
154
155     // static membervariables (annotations)
156

157     /** This is a possible type of <CODE>Element</CODE>. */
158     public static final int ANNOTATION = 29;
159
160     // static membervariables (geometric figures)
161

162     /** This is a possible type of <CODE>Element</CODE>. */
163     public static final int RECTANGLE = 30;
164
165     /** This is a possible type of <CODE>Element</CODE>. */
166     public static final int JPEG = 32;
167
168     /** This is a possible type of <CODE>Element</CODE>. */
169     public static final int IMGRAW = 34;
170
171     /** This is a possible type of <CODE>Element</CODE>. */
172     public static final int IMGTEMPLATE = 35;
173
174     /** This is a possible type of <CODE>Element</CODE>. */
175     public static final int MULTI_COLUMN_TEXT = 40;
176     
177     /** This is a possible type of <CODE>Element</CODE>. */
178     public static final int MARKED = 50;
179
180     // static membervariables (alignment)
181

182     /**
183      * A possible value for paragraph alignment. This specifies that the text is
184      * aligned to the left indent and extra whitespace should be placed on the
185      * right.
186      */

187     public static final int ALIGN_UNDEFINED = -1;
188
189     /**
190      * A possible value for paragraph alignment. This specifies that the text is
191      * aligned to the left indent and extra whitespace should be placed on the
192      * right.
193      */

194     public static final int ALIGN_LEFT = 0;
195
196     /**
197      * A possible value for paragraph alignment. This specifies that the text is
198      * aligned to the center and extra whitespace should be placed equally on
199      * the left and right.
200      */

201     public static final int ALIGN_CENTER = 1;
202
203     /**
204      * A possible value for paragraph alignment. This specifies that the text is
205      * aligned to the right indent and extra whitespace should be placed on the
206      * left.
207      */

208     public static final int ALIGN_RIGHT = 2;
209
210     /**
211      * A possible value for paragraph alignment. This specifies that extra
212      * whitespace should be spread out through the rows of the paragraph with
213      * the text lined up with the left and right indent except on the last line
214      * which should be aligned to the left.
215      */

216     public static final int ALIGN_JUSTIFIED = 3;
217
218     /**
219      * A possible value for vertical alignment.
220      */

221
222     public static final int ALIGN_TOP = 4;
223
224     /**
225      * A possible value for vertical alignment.
226      */

227
228     public static final int ALIGN_MIDDLE = 5;
229
230     /**
231      * A possible value for vertical alignment.
232      */

233
234     public static final int ALIGN_BOTTOM = 6;
235
236     /**
237      * A possible value for vertical alignment.
238      */

239     public static final int ALIGN_BASELINE = 7;
240
241     /**
242      * Does the same as ALIGN_JUSTIFIED but the last line is also spread out.
243      */

244     public static final int ALIGN_JUSTIFIED_ALL = 8;
245
246     // static member variables for CCITT compression
247

248     /**
249      * Pure two-dimensional encoding (Group 4)
250      */

251     public static final int CCITTG4 = 0x100;
252
253     /**
254      * Pure one-dimensional encoding (Group 3, 1-D)
255      */

256     public static final int CCITTG3_1D = 0x101;
257
258     /**
259      * Mixed one- and two-dimensional encoding (Group 3, 2-D)
260      */

261     public static final int CCITTG3_2D = 0x102;
262
263     /**
264      * A flag indicating whether 1-bits are to be interpreted as black pixels
265      * and 0-bits as white pixels,
266      */

267     public static final int CCITT_BLACKIS1 = 1;
268
269     /**
270      * A flag indicating whether the filter expects extra 0-bits before each
271      * encoded line so that the line begins on a byte boundary.
272      */

273     public static final int CCITT_ENCODEDBYTEALIGN = 2;
274
275     /**
276      * A flag indicating whether end-of-line bit patterns are required to be
277      * present in the encoding.
278      */

279     public static final int CCITT_ENDOFLINE = 4;
280
281     /**
282      * A flag indicating whether the filter expects the encoded data to be
283      * terminated by an end-of-block pattern, overriding the Rows parameter. The
284      * use of this flag will set the key /EndOfBlock to false.
285      */

286     public static final int CCITT_ENDOFBLOCK = 8;
287
288     // methods
289

290     /**
291      * Processes the element by adding it (or the different parts) to an <CODE>
292      * ElementListener</CODE>.
293      *
294      * @param listener
295      * an <CODE>ElementListener</CODE>
296      * @return <CODE>true</CODE> if the element was processed successfully
297      */

298
299     public boolean process(ElementListener listener);
300
301     /**
302      * Gets the type of the text element.
303      *
304      * @return a type
305      */

306
307     public int type();
308
309     /**
310      * Gets all the chunks in this element.
311      *
312      * @return an <CODE>ArrayList</CODE>
313      */

314
315     public ArrayList JavaDoc getChunks();
316
317     /**
318      * Gets the content of the text element.
319      *
320      * @return a type
321      */

322
323     public String JavaDoc toString();
324 }
Popular Tags