1 47 package com.lowagie.text.pdf; 48 import java.awt.Color ; 49 50 import com.lowagie.text.Rectangle; 51 52 64 public class BarcodeEANSUPP extends Barcode{ 65 66 68 protected Barcode ean; 69 71 protected Barcode supp; 72 73 77 public BarcodeEANSUPP(Barcode ean, Barcode supp) { 78 n = 8; this.ean = ean; 80 this.supp = supp; 81 } 82 83 87 public Rectangle getBarcodeSize() { 88 Rectangle rect = ean.getBarcodeSize(); 89 rect.setRight(rect.getWidth() + supp.getBarcodeSize().getWidth() + n); 90 return rect; 91 } 92 93 129 public Rectangle placeBarcode(PdfContentByte cb, Color barColor, Color textColor) { 130 if (supp.getFont() != null) 131 supp.setBarHeight(ean.getBarHeight() + supp.getBaseline() - supp.getFont().getFontDescriptor(BaseFont.CAPHEIGHT, supp.getSize())); 132 else 133 supp.setBarHeight(ean.getBarHeight()); 134 Rectangle eanR = ean.getBarcodeSize(); 135 cb.saveState(); 136 ean.placeBarcode(cb, barColor, textColor); 137 cb.restoreState(); 138 cb.saveState(); 139 cb.concatCTM(1, 0, 0, 1, eanR.getWidth() + n, eanR.getHeight() - ean.getBarHeight()); 140 supp.placeBarcode(cb, barColor, textColor); 141 cb.restoreState(); 142 return getBarcodeSize(); 143 } 144 145 151 public java.awt.Image createAwtImage(Color foreground, Color background) { 152 throw new UnsupportedOperationException ("The two barcodes must be composed externally."); 153 } 154 } 155 | Popular Tags |