1 49 package com.lowagie.text.pdf; 50 51 import java.awt.Color ; 52 53 import com.lowagie.text.ExceptionConverter; 54 import com.lowagie.text.Image; 55 import com.lowagie.text.Rectangle; 56 61 public abstract class Barcode { 62 63 public static final int EAN13 = 1; 64 65 public static final int EAN8 = 2; 66 67 public static final int UPCA = 3; 68 69 public static final int UPCE = 4; 70 71 public static final int SUPP2 = 5; 72 73 public static final int SUPP5 = 6; 74 75 public static final int POSTNET = 7; 76 77 public static final int PLANET = 8; 78 79 public static final int CODE128 = 9; 80 81 public static final int CODE128_UCC = 10; 82 83 public static final int CODE128_RAW = 11; 84 85 public static final int CODABAR = 12; 86 87 89 protected float x; 90 91 94 protected float n; 95 96 98 protected BaseFont font; 99 100 103 protected float size; 104 105 108 protected float baseline; 109 110 112 protected float barHeight; 113 114 117 protected int textAlignment; 118 119 121 protected boolean generateChecksum; 122 123 125 protected boolean checksumText; 126 127 130 protected boolean startStopText; 131 132 134 protected boolean extended; 135 136 138 protected String code = ""; 139 140 142 protected boolean guardBars; 143 144 146 protected int codeType; 147 148 149 protected float inkSpreading = 0; 150 151 154 public float getX() { 155 return x; 156 } 157 158 161 public void setX(float x) { 162 this.x = x; 163 } 164 165 168 public float getN() { 169 return n; 170 } 171 172 175 public void setN(float n) { 176 this.n = n; 177 } 178 179 182 public BaseFont getFont() { 183 return font; 184 } 185 186 189 public void setFont(BaseFont font) { 190 this.font = font; 191 } 192 193 196 public float getSize() { 197 return size; 198 } 199 200 203 public void setSize(float size) { 204 this.size = size; 205 } 206 207 212 public float getBaseline() { 213 return baseline; 214 } 215 216 221 public void setBaseline(float baseline) { 222 this.baseline = baseline; 223 } 224 225 228 public float getBarHeight() { 229 return barHeight; 230 } 231 232 235 public void setBarHeight(float barHeight) { 236 this.barHeight = barHeight; 237 } 238 239 243 public int getTextAlignment() { 244 return textAlignment; 245 } 246 247 251 public void setTextAlignment(int textAlignment) { 252 this.textAlignment = textAlignment; 253 } 254 255 258 public boolean isGenerateChecksum() { 259 return generateChecksum; 260 } 261 262 265 public void setGenerateChecksum(boolean generateChecksum) { 266 this.generateChecksum = generateChecksum; 267 } 268 269 272 public boolean isChecksumText() { 273 return checksumText; 274 } 275 276 279 public void setChecksumText(boolean checksumText) { 280 this.checksumText = checksumText; 281 } 282 283 287 public boolean isStartStopText() { 288 return startStopText; 289 } 290 291 295 public void setStartStopText(boolean startStopText) { 296 this.startStopText = startStopText; 297 } 298 299 302 public boolean isExtended() { 303 return extended; 304 } 305 306 309 public void setExtended(boolean extended) { 310 this.extended = extended; 311 } 312 313 316 public String getCode() { 317 return code; 318 } 319 320 323 public void setCode(String code) { 324 this.code = code; 325 } 326 327 330 public boolean isGuardBars() { 331 return guardBars; 332 } 333 334 337 public void setGuardBars(boolean guardBars) { 338 this.guardBars = guardBars; 339 } 340 341 344 public int getCodeType() { 345 return codeType; 346 } 347 348 351 public void setCodeType(int codeType) { 352 this.codeType = codeType; 353 } 354 355 359 public abstract Rectangle getBarcodeSize(); 360 361 397 public abstract Rectangle placeBarcode(PdfContentByte cb, Color barColor, Color textColor); 398 399 407 public PdfTemplate createTemplateWithBarcode(PdfContentByte cb, Color barColor, Color textColor) { 408 PdfTemplate tp = cb.createTemplate(0, 0); 409 Rectangle rect = placeBarcode(tp, barColor, textColor); 410 tp.setBoundingBox(rect); 411 return tp; 412 } 413 414 422 public Image createImageWithBarcode(PdfContentByte cb, Color barColor, Color textColor) { 423 try { 424 return Image.getInstance(createTemplateWithBarcode(cb, barColor, textColor)); 425 } 426 catch (Exception e) { 427 throw new ExceptionConverter(e); 428 } 429 } 430 431 437 public abstract java.awt.Image createAwtImage(Color foreground, Color background); 438 439 443 public float getInkSpreading() { 444 return this.inkSpreading; 445 } 446 447 453 public void setInkSpreading(float inkSpreading) { 454 this.inkSpreading = inkSpreading; 455 } 456 457 460 protected String altText; 461 462 466 public String getAltText() { 467 return this.altText; 468 } 469 470 475 public void setAltText(String altText) { 476 this.altText = altText; 477 } 478 479 } 480 | Popular Tags |