1 28 package net.sf.jasperreports.engine.xml; 29 30 import net.sf.jasperreports.engine.JasperPrint; 31 import net.sf.jasperreports.engine.base.JRBasePrintImage; 32 33 import org.xml.sax.Attributes ; 34 35 36 40 public class JRPrintImageFactory extends JRBaseFactory 41 { 42 43 44 47 private static final String ATTRIBUTE_scaleImage = "scaleImage"; 48 private static final String ATTRIBUTE_hAlign = "hAlign"; 49 private static final String ATTRIBUTE_vAlign = "vAlign"; 50 private static final String ATTRIBUTE_isLazy = "isLazy"; 51 private static final String ATTRIBUTE_onErrorType = "onErrorType"; 52 private static final String ATTRIBUTE_hyperlinkType = "hyperlinkType"; 53 private static final String ATTRIBUTE_hyperlinkTarget = "hyperlinkTarget"; 54 private static final String ATTRIBUTE_anchorName = "anchorName"; 55 private static final String ATTRIBUTE_hyperlinkReference = "hyperlinkReference"; 56 private static final String ATTRIBUTE_hyperlinkAnchor = "hyperlinkAnchor"; 57 private static final String ATTRIBUTE_hyperlinkPage = "hyperlinkPage"; 58 public static final String ATTRIBUTE_hyperlinkTooltip = "hyperlinkTooltip"; 59 private static final String ATTRIBUTE_bookmarkLevel = "bookmarkLevel"; 60 61 62 65 public Object createObject(Attributes atts) 66 { 67 JasperPrint jasperPrint = (JasperPrint)digester.peek(digester.getCount() - 2); 68 69 JRBasePrintImage image = new JRBasePrintImage(jasperPrint.getDefaultStyleProvider()); 70 71 Byte scaleImage = (Byte )JRXmlConstants.getScaleImageMap().get(atts.getValue(ATTRIBUTE_scaleImage)); 72 if (scaleImage != null) 73 { 74 image.setScaleImage(scaleImage); 75 } 76 77 Byte horizontalAlignment = (Byte )JRXmlConstants.getHorizontalAlignMap().get(atts.getValue(ATTRIBUTE_hAlign)); 78 if (horizontalAlignment != null) 79 { 80 image.setHorizontalAlignment(horizontalAlignment); 81 } 82 83 Byte verticalAlignment = (Byte )JRXmlConstants.getVerticalAlignMap().get(atts.getValue(ATTRIBUTE_vAlign)); 84 if (verticalAlignment != null) 85 { 86 image.setVerticalAlignment(verticalAlignment); 87 } 88 89 String isLazy = atts.getValue(ATTRIBUTE_isLazy); 90 if (isLazy != null && isLazy.length() > 0) 91 { 92 image.setLazy(Boolean.valueOf(isLazy).booleanValue()); 93 } 94 95 Byte onErrorType = (Byte )JRXmlConstants.getOnErrorTypeMap().get(atts.getValue(ATTRIBUTE_onErrorType)); 96 if (onErrorType != null) 97 { 98 image.setOnErrorType(onErrorType.byteValue()); 99 } 100 101 String hyperlinkType = atts.getValue(ATTRIBUTE_hyperlinkType); 102 if (hyperlinkType != null) 103 { 104 image.setLinkType(hyperlinkType); 105 } 106 107 Byte hyperlinkTarget = (Byte )JRXmlConstants.getHyperlinkTargetMap().get(atts.getValue(ATTRIBUTE_hyperlinkTarget)); 108 if (hyperlinkTarget != null) 109 { 110 image.setHyperlinkTarget(hyperlinkTarget.byteValue()); 111 } 112 113 image.setAnchorName(atts.getValue(ATTRIBUTE_anchorName)); 114 image.setHyperlinkReference(atts.getValue(ATTRIBUTE_hyperlinkReference)); 115 image.setHyperlinkAnchor(atts.getValue(ATTRIBUTE_hyperlinkAnchor)); 116 117 String hyperlinkPage = atts.getValue(ATTRIBUTE_hyperlinkPage); 118 if (hyperlinkPage != null) 119 { 120 image.setHyperlinkPage(new Integer (hyperlinkPage)); 121 } 122 123 image.setHyperlinkTooltip(atts.getValue(ATTRIBUTE_hyperlinkTooltip)); 124 125 String bookmarkLevelAttr = atts.getValue(ATTRIBUTE_bookmarkLevel); 126 if (bookmarkLevelAttr != null) 127 { 128 image.setBookmarkLevel(Integer.parseInt(bookmarkLevelAttr)); 129 } 130 131 return image; 132 } 133 134 135 } 136 | Popular Tags |