001/*
002 * $Id: Element.java 4879 2011-05-23 23:27:02Z redlab_b $
003 *
004 * This file is part of the iText (R) project.
005 * Copyright (c) 1998-2011 1T3XT BVBA
006 * Authors: Bruno Lowagie, Paulo Soares, et al.
007 *
008 * This program is free software; you can redistribute it and/or modify
009 * it under the terms of the GNU Affero General Public License version 3
010 * as published by the Free Software Foundation with the addition of the
011 * following permission added to Section 15 as permitted in Section 7(a):
012 * FOR ANY PART OF THE COVERED WORK IN WHICH THE COPYRIGHT IS OWNED BY 1T3XT,
013 * 1T3XT DISCLAIMS THE WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
014 *
015 * This program is distributed in the hope that it will be useful, but
016 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
017 * or FITNESS FOR A PARTICULAR PURPOSE.
018 * See the GNU Affero General Public License for more details.
019 * You should have received a copy of the GNU Affero General Public License
020 * along with this program; if not, see http://www.gnu.org/licenses or write to
021 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
022 * Boston, MA, 02110-1301 USA, or download the license from the following URL:
023 * http://itextpdf.com/terms-of-use/
024 *
025 * The interactive user interfaces in modified source and object code versions
026 * of this program must display Appropriate Legal Notices, as required under
027 * Section 5 of the GNU Affero General Public License.
028 *
029 * In accordance with Section 7(b) of the GNU Affero General Public License,
030 * a covered work must retain the producer line in every PDF that is created
031 * or manipulated using iText.
032 *
033 * You can be released from the requirements of the license by purchasing
034 * a commercial license. Buying such a license is mandatory as soon as you
035 * develop commercial activities involving the iText software without
036 * disclosing the source code of your own applications.
037 * These activities include: offering paid services to customers as an ASP,
038 * serving PDFs on the fly in a web application, shipping iText with a closed
039 * source product.
040 *
041 * For more information, please contact iText Software Corp. at this
042 * address: sales@itextpdf.com
043 */
044package com.itextpdf.text;
045
046import java.util.List;
047
048/**
049 * Interface for a text element.
050 * <P>
051 * Remark: I looked at the interface javax.swing.text.Element, but I decided to
052 * write my own text-classes for two reasons:
053 * <OL>
054 * <LI>The javax.swing.text-classes may be very generic, I think they are
055 * overkill: they are to heavy for what they have to do.
056 * <LI>A lot of people using iText (formerly known as rugPdf), still use
057 * JDK1.1.x. I try to keep the Java2 requirements limited to the Collection
058 * classes (I think they're really great). However, if I use the
059 * javax.swing.text classes, it will become very difficult to downgrade rugPdf.
060 * </OL>
061 *
062 * @see Anchor
063 * @see Chapter
064 * @see Chunk
065 * @see Header
066 * @see Image
067 * @see Jpeg
068 * @see List
069 * @see ListItem
070 * @see Meta
071 * @see Paragraph
072 * @see Phrase
073 * @see Rectangle
074 * @see Section
075 */
076
077public interface Element {
078
079        // static membervariables (meta information)
080
081        /** This is a possible type of <CODE>Element</CODE>. */
082        public static final int HEADER = 0;
083
084        /** This is a possible type of <CODE>Element</CODE>. */
085        public static final int TITLE = 1;
086
087        /** This is a possible type of <CODE>Element</CODE>. */
088        public static final int SUBJECT = 2;
089
090        /** This is a possible type of <CODE>Element</CODE>. */
091        public static final int KEYWORDS = 3;
092
093        /** This is a possible type of <CODE>Element </CIDE>. */
094        public static final int AUTHOR = 4;
095
096        /** This is a possible type of <CODE>Element </CIDE>. */
097        public static final int PRODUCER = 5;
098
099        /** This is a possible type of <CODE>Element </CIDE>. */
100        public static final int CREATIONDATE = 6;
101
102        /** This is a possible type of <CODE>Element </CIDE>. */
103        public static final int CREATOR = 7;
104
105        // static membervariables (content)
106
107        /** This is a possible type of <CODE>Element</CODE>. */
108        public static final int CHUNK = 10;
109
110        /** This is a possible type of <CODE>Element</CODE>. */
111        public static final int PHRASE = 11;
112
113        /** This is a possible type of <CODE>Element</CODE>. */
114        public static final int PARAGRAPH = 12;
115
116        /** This is a possible type of <CODE>Element</CODE> */
117        public static final int SECTION = 13;
118
119        /** This is a possible type of <CODE>Element</CODE> */
120        public static final int LIST = 14;
121
122        /** This is a possible type of <CODE>Element</CODE> */
123        public static final int LISTITEM = 15;
124
125        /** This is a possible type of <CODE>Element</CODE> */
126        public static final int CHAPTER = 16;
127
128        /** This is a possible type of <CODE>Element</CODE> */
129        public static final int ANCHOR = 17;
130
131        // static membervariables (tables)
132
133        /** This is a possible type of <CODE>Element</CODE>. */
134        public static final int PTABLE = 23;
135
136        // static membervariables (annotations)
137
138        /** This is a possible type of <CODE>Element</CODE>. */
139        public static final int ANNOTATION = 29;
140
141        // static membervariables (geometric figures)
142
143        /** This is a possible type of <CODE>Element</CODE>. */
144        public static final int RECTANGLE = 30;
145
146        /** This is a possible type of <CODE>Element</CODE>. */
147        public static final int JPEG = 32;
148
149        /** This is a possible type of <CODE>Element</CODE>. */
150        public static final int JPEG2000 = 33;
151
152        /** This is a possible type of <CODE>Element</CODE>. */
153        public static final int IMGRAW = 34;
154
155        /** This is a possible type of <CODE>Element</CODE>. */
156        public static final int IMGTEMPLATE = 35;
157
158        /**
159         * This is a possible type of <CODE>Element</CODE>.
160         * @since       2.1.5
161         */
162        public static final int JBIG2 = 36;
163
164        /** This is a possible type of <CODE>Element</CODE>. */
165        public static final int MULTI_COLUMN_TEXT = 40;
166
167        /** This is a possible type of <CODE>Element</CODE>. */
168        public static final int MARKED = 50;
169
170        /** This is a possible type of <CODE>Element</CODE>.
171         * @since 2.1.2
172         */
173        public static final int YMARK = 55;
174
175        /**
176         * This is an element thats not an element.
177         * @see WritableDirectElement
178         */
179        public static final int WRITABLE_DIRECT = 666;
180
181        // static membervariables (alignment)
182
183        /**
184         * A possible value for paragraph alignment. This specifies that the text is
185         * aligned to the left indent and extra whitespace should be placed on the
186         * right.
187         */
188        public static final int ALIGN_UNDEFINED = -1;
189
190        /**
191         * A possible value for paragraph alignment. This specifies that the text is
192         * aligned to the left indent and extra whitespace should be placed on the
193         * right.
194         */
195        public static final int ALIGN_LEFT = 0;
196
197        /**
198         * A possible value for paragraph alignment. This specifies that the text is
199         * aligned to the center and extra whitespace should be placed equally on
200         * the left and right.
201         */
202        public static final int ALIGN_CENTER = 1;
203
204        /**
205         * A possible value for paragraph alignment. This specifies that the text is
206         * aligned to the right indent and extra whitespace should be placed on the
207         * left.
208         */
209        public static final int ALIGN_RIGHT = 2;
210
211        /**
212         * A possible value for paragraph alignment. This specifies that extra
213         * whitespace should be spread out through the rows of the paragraph with
214         * the text lined up with the left and right indent except on the last line
215         * which should be aligned to the left.
216         */
217        public static final int ALIGN_JUSTIFIED = 3;
218
219        /**
220         * A possible value for vertical alignment.
221         */
222
223        public static final int ALIGN_TOP = 4;
224
225        /**
226         * A possible value for vertical alignment.
227         */
228
229        public static final int ALIGN_MIDDLE = 5;
230
231        /**
232         * A possible value for vertical alignment.
233         */
234
235        public static final int ALIGN_BOTTOM = 6;
236
237        /**
238         * A possible value for vertical alignment.
239         */
240        public static final int ALIGN_BASELINE = 7;
241
242        /**
243         * Does the same as ALIGN_JUSTIFIED but the last line is also spread out.
244         */
245        public static final int ALIGN_JUSTIFIED_ALL = 8;
246
247        // static member variables for CCITT compression
248
249        /**
250         * Pure two-dimensional encoding (Group 4)
251         */
252        public static final int CCITTG4 = 0x100;
253
254        /**
255         * Pure one-dimensional encoding (Group 3, 1-D)
256         */
257        public static final int CCITTG3_1D = 0x101;
258
259        /**
260         * Mixed one- and two-dimensional encoding (Group 3, 2-D)
261         */
262        public static final int CCITTG3_2D = 0x102;
263
264        /**
265         * A flag indicating whether 1-bits are to be interpreted as black pixels
266         * and 0-bits as white pixels,
267         */
268        public static final int CCITT_BLACKIS1 = 1;
269
270        /**
271         * A flag indicating whether the filter expects extra 0-bits before each
272         * encoded line so that the line begins on a byte boundary.
273         */
274        public static final int CCITT_ENCODEDBYTEALIGN = 2;
275
276        /**
277         * A flag indicating whether end-of-line bit patterns are required to be
278         * present in the encoding.
279         */
280        public static final int CCITT_ENDOFLINE = 4;
281
282        /**
283         * A flag indicating whether the filter expects the encoded data to be
284         * terminated by an end-of-block pattern, overriding the Rows parameter. The
285         * use of this flag will set the key /EndOfBlock to false.
286         */
287        public static final int CCITT_ENDOFBLOCK = 8;
288
289        // methods
290
291        /**
292         * Processes the element by adding it (or the different parts) to an <CODE>
293         * ElementListener</CODE>.
294         *
295         * @param listener
296         *            an <CODE>ElementListener</CODE>
297         * @return <CODE>true</CODE> if the element was processed successfully
298         */
299
300        public boolean process(ElementListener listener);
301
302        /**
303         * Gets the type of the text element.
304         *
305         * @return a type
306         */
307
308        public int type();
309
310        /**
311         * Checks if this element is a content object.
312         * If not, it's a metadata object.
313         * @since       iText 2.0.8
314         * @return      true if this is a 'content' element; false if this is a 'metadata' element
315         */
316
317        public boolean isContent();
318
319        /**
320         * Checks if this element is nestable.
321         * @since       iText 2.0.8
322         * @return      true if this element can be nested inside other elements.
323         */
324
325        public boolean isNestable();
326
327        /**
328         * Gets all the chunks in this element.
329         *
330         * @return an <CODE>ArrayList</CODE>
331         */
332
333        public List<Chunk> getChunks();
334
335        /**
336         * Gets the content of the text element.
337         *
338         * @return a type
339         */
340
341        public String toString();
342}