1 /* 2 * $Id: Element.java 3672 2009-02-01 15:32:09Z blowagie $ 3 * 4 * Copyright 1999, 2000, 2001, 2002 by Bruno Lowagie. 5 * 6 * The contents of this file are subject to the Mozilla Public License Version 1.1 7 * (the "License"); you may not use this file except in compliance with the License. 8 * You may obtain a copy of the License at http://www.mozilla.org/MPL/ 9 * 10 * Software distributed under the License is distributed on an "AS IS" basis, 11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 12 * for the specific language governing rights and limitations under the License. 13 * 14 * The Original Code is 'iText, a free JAVA-PDF library'. 15 * 16 * The Initial Developer of the Original Code is Bruno Lowagie. Portions created by 17 * the Initial Developer are Copyright (C) 1999, 2000, 2001, 2002 by Bruno Lowagie. 18 * All Rights Reserved. 19 * Co-Developer of the code is Paulo Soares. Portions created by the Co-Developer 20 * are Copyright (C) 2000, 2001, 2002 by Paulo Soares. All Rights Reserved. 21 * 22 * Contributor(s): all the names of the contributors are added in the source code 23 * where applicable. 24 * 25 * Alternatively, the contents of this file may be used under the terms of the 26 * LGPL license (the "GNU LIBRARY GENERAL PUBLIC LICENSE"), in which case the 27 * provisions of LGPL are applicable instead of those above. If you wish to 28 * allow use of your version of this file only under the terms of the LGPL 29 * License and not to allow others to use your version of this file under 30 * the MPL, indicate your decision by deleting the provisions above and 31 * replace them with the notice and other provisions required by the LGPL. 32 * If you do not delete the provisions above, a recipient may use your version 33 * of this file under either the MPL or the GNU LIBRARY GENERAL PUBLIC LICENSE. 34 * 35 * This library is free software; you can redistribute it and/or modify it 36 * under the terms of the MPL as stated above or under the terms of the GNU 37 * Library General Public License as published by the Free Software Foundation; 38 * either version 2 of the License, or any later version. 39 * 40 * This library is distributed in the hope that it will be useful, but WITHOUT 41 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 42 * FOR A PARTICULAR PURPOSE. See the GNU Library general Public License for more 43 * details. 44 * 45 * If you didn't download this code from the following link, you should check if 46 * you aren't using an obsolete version: 47 * http://www.lowagie.com/iText/ 48 */ 49 50 package com.lowagie.text; 51 52 import java.util.ArrayList; 53 54 /** 55 * Interface for a text element. 56 * <P> 57 * Remark: I looked at the interface javax.swing.text.Element, but I decided to 58 * write my own text-classes for two reasons: 59 * <OL> 60 * <LI>The javax.swing.text-classes may be very generic, I think they are 61 * overkill: they are to heavy for what they have to do. 62 * <LI>A lot of people using iText (formerly known as rugPdf), still use 63 * JDK1.1.x. I try to keep the Java2 requirements limited to the Collection 64 * classes (I think they're really great). However, if I use the 65 * javax.swing.text classes, it will become very difficult to downgrade rugPdf. 66 * </OL> 67 * 68 * @see Anchor 69 * @see Cell 70 * @see Chapter 71 * @see Chunk 72 * @see Header 73 * @see Image 74 * @see Jpeg 75 * @see List 76 * @see ListItem 77 * @see Meta 78 * @see Paragraph 79 * @see Phrase 80 * @see Rectangle 81 * @see Row 82 * @see Section 83 * @see Table 84 */ 85 86 public interface Element { 87 88 // static membervariables (meta information) 89 90 /** This is a possible type of <CODE>Element</CODE>. */ 91 public static final int HEADER = 0; 92 93 /** This is a possible type of <CODE>Element</CODE>. */ 94 public static final int TITLE = 1; 95 96 /** This is a possible type of <CODE>Element</CODE>. */ 97 public static final int SUBJECT = 2; 98 99 /** This is a possible type of <CODE>Element</CODE>. */ 100 public static final int KEYWORDS = 3; 101 102 /** This is a possible type of <CODE>Element </CIDE>. */ 103 public static final int AUTHOR = 4; 104 105 /** This is a possible type of <CODE>Element </CIDE>. */ 106 public static final int PRODUCER = 5; 107 108 /** This is a possible type of <CODE>Element </CIDE>. */ 109 public static final int CREATIONDATE = 6; 110 111 /** This is a possible type of <CODE>Element </CIDE>. */ 112 public static final int CREATOR = 7; 113 114 // static membervariables (content) 115 116 /** This is a possible type of <CODE>Element</CODE>. */ 117 public static final int CHUNK = 10; 118 119 /** This is a possible type of <CODE>Element</CODE>. */ 120 public static final int PHRASE = 11; 121 122 /** This is a possible type of <CODE>Element</CODE>. */ 123 public static final int PARAGRAPH = 12; 124 125 /** This is a possible type of <CODE>Element</CODE> */ 126 public static final int SECTION = 13; 127 128 /** This is a possible type of <CODE>Element</CODE> */ 129 public static final int LIST = 14; 130 131 /** This is a possible type of <CODE>Element</CODE> */ 132 public static final int LISTITEM = 15; 133 134 /** This is a possible type of <CODE>Element</CODE> */ 135 public static final int CHAPTER = 16; 136 137 /** This is a possible type of <CODE>Element</CODE> */ 138 public static final int ANCHOR = 17; 139 140 // static membervariables (tables) 141 142 /** This is a possible type of <CODE>Element</CODE>. */ 143 public static final int CELL = 20; 144 145 /** This is a possible type of <CODE>Element</CODE>. */ 146 public static final int ROW = 21; 147 148 /** This is a possible type of <CODE>Element</CODE>. */ 149 public static final int TABLE = 22; 150 151 /** This is a possible type of <CODE>Element</CODE>. */ 152 public static final int PTABLE = 23; 153 154 // static membervariables (annotations) 155 156 /** This is a possible type of <CODE>Element</CODE>. */ 157 public static final int ANNOTATION = 29; 158 159 // static membervariables (geometric figures) 160 161 /** This is a possible type of <CODE>Element</CODE>. */ 162 public static final int RECTANGLE = 30; 163 164 /** This is a possible type of <CODE>Element</CODE>. */ 165 public static final int JPEG = 32; 166 167 /** This is a possible type of <CODE>Element</CODE>. */ 168 public static final int JPEG2000 = 33; 169 170 /** This is a possible type of <CODE>Element</CODE>. */ 171 public static final int IMGRAW = 34; 172 173 /** This is a possible type of <CODE>Element</CODE>. */ 174 public static final int IMGTEMPLATE = 35; 175 176 /** 177 * This is a possible type of <CODE>Element</CODE>. 178 * @since 2.1.5 179 */ 180 public static final int JBIG2 = 36; 181 182 /** This is a possible type of <CODE>Element</CODE>. */ 183 public static final int MULTI_COLUMN_TEXT = 40; 184 185 /** This is a possible type of <CODE>Element</CODE>. */ 186 public static final int MARKED = 50; 187 188 /** This is a possible type of <CODE>Element</CODE>. 189 * @since 2.1.2 190 */ 191 public static final int YMARK = 55; 192 193 // static membervariables (alignment) 194 195 /** 196 * A possible value for paragraph alignment. This specifies that the text is 197 * aligned to the left indent and extra whitespace should be placed on the 198 * right. 199 */ 200 public static final int ALIGN_UNDEFINED = -1; 201 202 /** 203 * A possible value for paragraph alignment. This specifies that the text is 204 * aligned to the left indent and extra whitespace should be placed on the 205 * right. 206 */ 207 public static final int ALIGN_LEFT = 0; 208 209 /** 210 * A possible value for paragraph alignment. This specifies that the text is 211 * aligned to the center and extra whitespace should be placed equally on 212 * the left and right. 213 */ 214 public static final int ALIGN_CENTER = 1; 215 216 /** 217 * A possible value for paragraph alignment. This specifies that the text is 218 * aligned to the right indent and extra whitespace should be placed on the 219 * left. 220 */ 221 public static final int ALIGN_RIGHT = 2; 222 223 /** 224 * A possible value for paragraph alignment. This specifies that extra 225 * whitespace should be spread out through the rows of the paragraph with 226 * the text lined up with the left and right indent except on the last line 227 * which should be aligned to the left. 228 */ 229 public static final int ALIGN_JUSTIFIED = 3; 230 231 /** 232 * A possible value for vertical alignment. 233 */ 234 235 public static final int ALIGN_TOP = 4; 236 237 /** 238 * A possible value for vertical alignment. 239 */ 240 241 public static final int ALIGN_MIDDLE = 5; 242 243 /** 244 * A possible value for vertical alignment. 245 */ 246 247 public static final int ALIGN_BOTTOM = 6; 248 249 /** 250 * A possible value for vertical alignment. 251 */ 252 public static final int ALIGN_BASELINE = 7; 253 254 /** 255 * Does the same as ALIGN_JUSTIFIED but the last line is also spread out. 256 */ 257 public static final int ALIGN_JUSTIFIED_ALL = 8; 258 259 // static member variables for CCITT compression 260 261 /** 262 * Pure two-dimensional encoding (Group 4) 263 */ 264 public static final int CCITTG4 = 0x100; 265 266 /** 267 * Pure one-dimensional encoding (Group 3, 1-D) 268 */ 269 public static final int CCITTG3_1D = 0x101; 270 271 /** 272 * Mixed one- and two-dimensional encoding (Group 3, 2-D) 273 */ 274 public static final int CCITTG3_2D = 0x102; 275 276 /** 277 * A flag indicating whether 1-bits are to be interpreted as black pixels 278 * and 0-bits as white pixels, 279 */ 280 public static final int CCITT_BLACKIS1 = 1; 281 282 /** 283 * A flag indicating whether the filter expects extra 0-bits before each 284 * encoded line so that the line begins on a byte boundary. 285 */ 286 public static final int CCITT_ENCODEDBYTEALIGN = 2; 287 288 /** 289 * A flag indicating whether end-of-line bit patterns are required to be 290 * present in the encoding. 291 */ 292 public static final int CCITT_ENDOFLINE = 4; 293 294 /** 295 * A flag indicating whether the filter expects the encoded data to be 296 * terminated by an end-of-block pattern, overriding the Rows parameter. The 297 * use of this flag will set the key /EndOfBlock to false. 298 */ 299 public static final int CCITT_ENDOFBLOCK = 8; 300 301 // methods 302 303 /** 304 * Processes the element by adding it (or the different parts) to an <CODE> 305 * ElementListener</CODE>. 306 * 307 * @param listener 308 * an <CODE>ElementListener</CODE> 309 * @return <CODE>true</CODE> if the element was processed successfully 310 */ 311 312 public boolean process(ElementListener listener); 313 314 /** 315 * Gets the type of the text element. 316 * 317 * @return a type 318 */ 319 320 public int type(); 321 322 /** 323 * Checks if this element is a content object. 324 * If not, it's a metadata object. 325 * @since iText 2.0.8 326 * @return true if this is a 'content' element; false if this is a 'metadata' element 327 */ 328 329 public boolean isContent(); 330 331 /** 332 * Checks if this element is nestable. 333 * @since iText 2.0.8 334 * @return true if this element can be nested inside other elements. 335 */ 336 337 public boolean isNestable(); 338 339 /** 340 * Gets all the chunks in this element. 341 * 342 * @return an <CODE>ArrayList</CODE> 343 */ 344 345 public ArrayList getChunks(); 346 347 /** 348 * Gets the content of the text element. 349 * 350 * @return a type 351 */ 352 353 public String toString(); 354 }