1 58 package org.krysalis.barcode.fop0205; 59 60 import java.util.HashMap ; 61 62 import org.apache.fop.fo.DirectPropertyListBuilder; 63 import org.apache.fop.fo.ElementMapping; 64 import org.apache.fop.fo.TreeBuilder; 65 import org.apache.fop.fo.FObj; 66 67 import org.krysalis.barcode.BarcodeConstants; 68 69 public class BarcodeElementMapping implements ElementMapping { 70 71 private static final String [] BARCODE_ELEMENTS = 72 {"intl2of5", "code39", "codabar", "code128", 73 "upc-a", "upc-e", "ean-13", "ean-8", 74 "postnet", 75 "height", "module-width", "wide-factor", "quiet-zone", 76 "checksum", "human-readable", "interchar-gap-width", 77 "tall-bar-height", "short-bar-height", "baseline-alignment" 78 }; 79 80 private static HashMap foObjs = null; 81 82 protected FObj.Maker getBarcodeElementMaker() { 83 return BarcodeElement.maker(); 84 } 85 86 protected FObj.Maker getBarcodeObjMaker(String name) { 87 return BarcodeObj.maker(name); 88 } 89 90 private synchronized void setupBarcodeElements() { 91 if (foObjs == null) { 92 foObjs = new HashMap (); 93 foObjs.put("barcode", getBarcodeElementMaker()); 94 for (int i = 0; i < BARCODE_ELEMENTS.length; i++) { 95 foObjs.put(BARCODE_ELEMENTS[i], getBarcodeObjMaker(BARCODE_ELEMENTS[i])); 96 } 97 } 98 } 99 100 public void addToBuilder(TreeBuilder builder) { 101 setupBarcodeElements(); 102 builder.addMapping(BarcodeConstants.NAMESPACE, foObjs); 103 104 builder.addPropertyListBuilder(BarcodeConstants.NAMESPACE, new DirectPropertyListBuilder()); 105 } 106 } 107 108 | Popular Tags |