001: /*
002: * $Id: Element.java 2566 2007-02-02 15:38:59Z blowagie $
003: * $Name$
004: *
005: * Copyright 1999, 2000, 2001, 2002 by Bruno Lowagie.
006: *
007: * The contents of this file are subject to the Mozilla Public License Version 1.1
008: * (the "License"); you may not use this file except in compliance with the License.
009: * You may obtain a copy of the License at http://www.mozilla.org/MPL/
010: *
011: * Software distributed under the License is distributed on an "AS IS" basis,
012: * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
013: * for the specific language governing rights and limitations under the License.
014: *
015: * The Original Code is 'iText, a free JAVA-PDF library'.
016: *
017: * The Initial Developer of the Original Code is Bruno Lowagie. Portions created by
018: * the Initial Developer are Copyright (C) 1999, 2000, 2001, 2002 by Bruno Lowagie.
019: * All Rights Reserved.
020: * Co-Developer of the code is Paulo Soares. Portions created by the Co-Developer
021: * are Copyright (C) 2000, 2001, 2002 by Paulo Soares. All Rights Reserved.
022: *
023: * Contributor(s): all the names of the contributors are added in the source code
024: * where applicable.
025: *
026: * Alternatively, the contents of this file may be used under the terms of the
027: * LGPL license (the "GNU LIBRARY GENERAL PUBLIC LICENSE"), in which case the
028: * provisions of LGPL are applicable instead of those above. If you wish to
029: * allow use of your version of this file only under the terms of the LGPL
030: * License and not to allow others to use your version of this file under
031: * the MPL, indicate your decision by deleting the provisions above and
032: * replace them with the notice and other provisions required by the LGPL.
033: * If you do not delete the provisions above, a recipient may use your version
034: * of this file under either the MPL or the GNU LIBRARY GENERAL PUBLIC LICENSE.
035: *
036: * This library is free software; you can redistribute it and/or modify it
037: * under the terms of the MPL as stated above or under the terms of the GNU
038: * Library General Public License as published by the Free Software Foundation;
039: * either version 2 of the License, or any later version.
040: *
041: * This library is distributed in the hope that it will be useful, but WITHOUT
042: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
043: * FOR A PARTICULAR PURPOSE. See the GNU Library general Public License for more
044: * details.
045: *
046: * If you didn't download this code from the following link, you should check if
047: * you aren't using an obsolete version:
048: * http://www.lowagie.com/iText/
049: */
050:
051: package com.lowagie.text;
052:
053: import java.util.ArrayList;
054:
055: /**
056: * Interface for a text element.
057: * <P>
058: * Remark: I looked at the interface javax.swing.text.Element, but I decided to
059: * write my own text-classes for two reasons:
060: * <OL>
061: * <LI>The javax.swing.text-classes may be very generic, I think they are
062: * overkill: they are to heavy for what they have to do.
063: * <LI>A lot of people using iText (formerly known as rugPdf), still use
064: * JDK1.1.x. I try to keep the Java2 requirements limited to the Collection
065: * classes (I think they're really great). However, if I use the
066: * javax.swing.text classes, it will become very difficult to downgrade rugPdf.
067: * </OL>
068: *
069: * @see Anchor
070: * @see Cell
071: * @see Chapter
072: * @see Chunk
073: * @see Header
074: * @see Image
075: * @see Jpeg
076: * @see List
077: * @see ListItem
078: * @see Meta
079: * @see Paragraph
080: * @see Phrase
081: * @see Rectangle
082: * @see Row
083: * @see Section
084: * @see Table
085: */
086:
087: public interface Element {
088:
089: // static membervariables (meta information)
090:
091: /** This is a possible type of <CODE>Element</CODE>. */
092: public static final int HEADER = 0;
093:
094: /** This is a possible type of <CODE>Element</CODE>. */
095: public static final int TITLE = 1;
096:
097: /** This is a possible type of <CODE>Element</CODE>. */
098: public static final int SUBJECT = 2;
099:
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 getChunks();
316:
317: /**
318: * Gets the content of the text element.
319: *
320: * @return a type
321: */
322:
323: public String toString();
324: }
|