1 28 package net.sf.jasperreports.engine.xml; 29 30 import java.awt.Color ; 31 32 import net.sf.jasperreports.engine.JRBox; 33 34 import org.xml.sax.Attributes ; 35 36 37 41 public class JRBoxFactory extends JRBaseFactory 42 { 43 44 45 48 private static final String ATTRIBUTE_border = "border"; 49 private static final String ATTRIBUTE_borderColor = "borderColor"; 50 private static final String ATTRIBUTE_padding = "padding"; 51 private static final String ATTRIBUTE_topBorder = "topBorder"; 52 private static final String ATTRIBUTE_topBorderColor = "topBorderColor"; 53 private static final String ATTRIBUTE_topPadding = "topPadding"; 54 private static final String ATTRIBUTE_leftBorder = "leftBorder"; 55 private static final String ATTRIBUTE_leftBorderColor = "leftBorderColor"; 56 private static final String ATTRIBUTE_leftPadding = "leftPadding"; 57 private static final String ATTRIBUTE_bottomBorder = "bottomBorder"; 58 private static final String ATTRIBUTE_bottomBorderColor = "bottomBorderColor"; 59 private static final String ATTRIBUTE_bottomPadding = "bottomPadding"; 60 private static final String ATTRIBUTE_rightBorder = "rightBorder"; 61 private static final String ATTRIBUTE_rightBorderColor = "rightBorderColor"; 62 private static final String ATTRIBUTE_rightPadding = "rightPadding"; 63 64 65 68 public Object createObject(Attributes atts) 69 { 70 JRBox box = (JRBox) digester.peek(); 71 setBoxAttributes(atts, box); 72 return box; 73 } 74 75 76 public static void setBoxAttributes(Attributes atts, JRBox box) 77 { 78 Byte border = (Byte )JRXmlConstants.getPenMap().get(atts.getValue(ATTRIBUTE_border)); 79 if (border != null) 80 { 81 box.setBorder(border); 82 } 83 84 Color borderColor = JRXmlConstants.getColor(atts.getValue(ATTRIBUTE_borderColor), null); 85 if (borderColor != null) 86 { 87 box.setBorderColor(borderColor); 88 } 89 90 String padding = atts.getValue(ATTRIBUTE_padding); 91 if (padding != null && padding.length() > 0) 92 { 93 box.setPadding(Integer.parseInt(padding)); 94 } 95 96 border = (Byte )JRXmlConstants.getPenMap().get(atts.getValue(ATTRIBUTE_topBorder)); 97 if (border != null) 98 { 99 box.setTopBorder(border); 100 } 101 102 borderColor = JRXmlConstants.getColor(atts.getValue(ATTRIBUTE_topBorderColor), Color.black); 103 if (borderColor != null) 104 { 105 box.setTopBorderColor(borderColor); 106 } 107 108 padding = atts.getValue(ATTRIBUTE_topPadding); 109 if (padding != null && padding.length() > 0) 110 { 111 box.setTopPadding(Integer.parseInt(padding)); 112 } 113 114 border = (Byte )JRXmlConstants.getPenMap().get(atts.getValue(ATTRIBUTE_leftBorder)); 115 if (border != null) 116 { 117 box.setLeftBorder(border); 118 } 119 120 borderColor = JRXmlConstants.getColor(atts.getValue(ATTRIBUTE_leftBorderColor), Color.black); 121 if (borderColor != null) 122 { 123 box.setLeftBorderColor(borderColor); 124 } 125 126 padding = atts.getValue(ATTRIBUTE_leftPadding); 127 if (padding != null && padding.length() > 0) 128 { 129 box.setLeftPadding(Integer.parseInt(padding)); 130 } 131 132 border = (Byte )JRXmlConstants.getPenMap().get(atts.getValue(ATTRIBUTE_bottomBorder)); 133 if (border != null) 134 { 135 box.setBottomBorder(border); 136 } 137 138 borderColor = JRXmlConstants.getColor(atts.getValue(ATTRIBUTE_bottomBorderColor), Color.black); 139 if (borderColor != null) 140 { 141 box.setBottomBorderColor(borderColor); 142 } 143 144 padding = atts.getValue(ATTRIBUTE_bottomPadding); 145 if (padding != null && padding.length() > 0) 146 { 147 box.setBottomPadding(Integer.parseInt(padding)); 148 } 149 150 border = (Byte )JRXmlConstants.getPenMap().get(atts.getValue(ATTRIBUTE_rightBorder)); 151 if (border != null) 152 { 153 box.setRightBorder(border); 154 } 155 156 borderColor = JRXmlConstants.getColor(atts.getValue(ATTRIBUTE_rightBorderColor), Color.black); 157 if (borderColor != null) 158 { 159 box.setRightBorderColor(borderColor); 160 } 161 162 padding = atts.getValue(ATTRIBUTE_rightPadding); 163 if (padding != null && padding.length() > 0) 164 { 165 box.setRightPadding(Integer.parseInt(padding)); 166 } 167 } 168 169 170 } 171 | Popular Tags |