1 28 package net.sf.jasperreports.engine.xml; 29 30 import java.awt.Color ; 31 32 import org.xml.sax.Attributes ; 33 import net.sf.jasperreports.engine.design.JRDesignConditionalStyle; 34 35 39 public class JRConditionalStyleFillerFactory extends JRBaseFactory 40 { 41 private static final String ATTRIBUTE_mode = "mode"; 42 private static final String ATTRIBUTE_forecolor = "forecolor"; 43 private static final String ATTRIBUTE_backcolor = "backcolor"; 44 45 private static final String ATTRIBUTE_pen = "pen"; 46 private static final String ATTRIBUTE_fill = "fill"; 47 48 private static final String ATTRIBUTE_radius = "radius"; 49 50 private static final String ATTRIBUTE_scaleImage = "scaleImage"; 51 private static final String ATTRIBUTE_hAlign = "hAlign"; 53 private static final String ATTRIBUTE_vAlign = "vAlign"; 54 55 private static final String ATTRIBUTE_border = "border"; 56 private static final String ATTRIBUTE_borderColor = "borderColor"; 57 private static final String ATTRIBUTE_padding = "padding"; 58 private static final String ATTRIBUTE_topBorder = "topBorder"; 59 private static final String ATTRIBUTE_topBorderColor = "topBorderColor"; 60 private static final String ATTRIBUTE_topPadding = "topPadding"; 61 private static final String ATTRIBUTE_leftBorder = "leftBorder"; 62 private static final String ATTRIBUTE_leftBorderColor = "leftBorderColor"; 63 private static final String ATTRIBUTE_leftPadding = "leftPadding"; 64 private static final String ATTRIBUTE_bottomBorder = "bottomBorder"; 65 private static final String ATTRIBUTE_bottomBorderColor = "bottomBorderColor"; 66 private static final String ATTRIBUTE_bottomPadding = "bottomPadding"; 67 private static final String ATTRIBUTE_rightBorder = "rightBorder"; 68 private static final String ATTRIBUTE_rightBorderColor = "rightBorderColor"; 69 private static final String ATTRIBUTE_rightPadding = "rightPadding"; 70 71 private static final String ATTRIBUTE_rotation = "rotation"; 72 private static final String ATTRIBUTE_lineSpacing = "lineSpacing"; 73 private static final String ATTRIBUTE_isStyledText = "isStyledText"; 74 private static final String ATTRIBUTE_pattern = "pattern"; 75 private static final String ATTRIBUTE_isBlankWhenNull = "isBlankWhenNull"; 76 77 private static final String ATTRIBUTE_fontName = "fontName"; 78 private static final String ATTRIBUTE_isBold = "isBold"; 79 private static final String ATTRIBUTE_isItalic = "isItalic"; 80 private static final String ATTRIBUTE_isUnderline = "isUnderline"; 81 private static final String ATTRIBUTE_isStrikeThrough = "isStrikeThrough"; 82 private static final String ATTRIBUTE_fontSize = "fontSize"; 83 private static final String ATTRIBUTE_pdfFontName = "pdfFontName"; 84 private static final String ATTRIBUTE_pdfEncoding = "pdfEncoding"; 85 private static final String ATTRIBUTE_isPdfEmbedded = "isPdfEmbedded"; 86 87 88 91 public Object createObject(Attributes atts) 92 { 93 JRDesignConditionalStyle style = (JRDesignConditionalStyle) digester.peek(); 94 95 96 Byte mode = (Byte )JRXmlConstants.getModeMap().get(atts.getValue(ATTRIBUTE_mode)); 98 if (mode != null) 99 { 100 style.setMode(mode); 101 } 102 103 String forecolor = atts.getValue(ATTRIBUTE_forecolor); 104 style.setForecolor(JRXmlConstants.getColor(forecolor, null)); 105 106 String backcolor = atts.getValue(ATTRIBUTE_backcolor); 107 style.setBackcolor(JRXmlConstants.getColor(backcolor, null)); 108 109 110 111 Byte pen = (Byte )JRXmlConstants.getPenMap().get(atts.getValue(ATTRIBUTE_pen)); 113 style.setPen(pen); 114 115 Byte fill = (Byte )JRXmlConstants.getFillMap().get(atts.getValue(ATTRIBUTE_fill)); 116 style.setFill(fill); 117 118 119 120 String radius = atts.getValue(ATTRIBUTE_radius); 122 if (radius != null && radius.length() > 0) 123 { 124 style.setRadius(Integer.parseInt(radius)); 125 } 126 127 128 129 Byte scaleImage = (Byte )JRXmlConstants.getScaleImageMap().get(atts.getValue(ATTRIBUTE_scaleImage)); 131 if (scaleImage != null) 132 { 133 style.setScaleImage(scaleImage); 134 } 135 136 Byte horizontalAlignment = (Byte )JRXmlConstants.getHorizontalAlignMap().get(atts.getValue(ATTRIBUTE_hAlign)); 137 if (horizontalAlignment != null) 138 { 139 style.setHorizontalAlignment(horizontalAlignment); 140 } 141 142 Byte verticalAlignment = (Byte )JRXmlConstants.getVerticalAlignMap().get(atts.getValue(ATTRIBUTE_vAlign)); 143 if (verticalAlignment != null) 144 { 145 style.setVerticalAlignment(verticalAlignment); 146 } 147 148 149 Byte border = (Byte )JRXmlConstants.getPenMap().get(atts.getValue(ATTRIBUTE_border)); 151 if (border != null) 152 { 153 style.setBorder(border); 154 } 155 156 Color borderColor = JRXmlConstants.getColor(atts.getValue(ATTRIBUTE_borderColor), null); 157 if (borderColor != null) 158 { 159 style.setBorderColor(borderColor); 160 } 161 162 String padding = atts.getValue(ATTRIBUTE_padding); 163 if (padding != null && padding.length() > 0) 164 { 165 style.setPadding(Integer.parseInt(padding)); 166 } 167 168 border = (Byte )JRXmlConstants.getPenMap().get(atts.getValue(ATTRIBUTE_topBorder)); 169 if (border != null) 170 { 171 style.setTopBorder(border); 172 } 173 174 borderColor = JRXmlConstants.getColor(atts.getValue(ATTRIBUTE_topBorderColor), Color.black); 175 if (borderColor != null) 176 { 177 style.setTopBorderColor(borderColor); 178 } 179 180 padding = atts.getValue(ATTRIBUTE_topPadding); 181 if (padding != null && padding.length() > 0) 182 { 183 style.setTopPadding(Integer.parseInt(padding)); 184 } 185 186 border = (Byte )JRXmlConstants.getPenMap().get(atts.getValue(ATTRIBUTE_leftBorder)); 187 if (border != null) 188 { 189 style.setLeftBorder(border); 190 } 191 192 borderColor = JRXmlConstants.getColor(atts.getValue(ATTRIBUTE_leftBorderColor), Color.black); 193 if (borderColor != null) 194 { 195 style.setLeftBorderColor(borderColor); 196 } 197 198 padding = atts.getValue(ATTRIBUTE_leftPadding); 199 if (padding != null && padding.length() > 0) 200 { 201 style.setLeftPadding(Integer.parseInt(padding)); 202 } 203 204 border = (Byte )JRXmlConstants.getPenMap().get(atts.getValue(ATTRIBUTE_bottomBorder)); 205 if (border != null) 206 { 207 style.setBottomBorder(border); 208 } 209 210 borderColor = JRXmlConstants.getColor(atts.getValue(ATTRIBUTE_bottomBorderColor), Color.black); 211 if (borderColor != null) 212 { 213 style.setBottomBorderColor(borderColor); 214 } 215 216 padding = atts.getValue(ATTRIBUTE_bottomPadding); 217 if (padding != null && padding.length() > 0) 218 { 219 style.setBottomPadding(Integer.parseInt(padding)); 220 } 221 222 border = (Byte )JRXmlConstants.getPenMap().get(atts.getValue(ATTRIBUTE_rightBorder)); 223 if (border != null) 224 { 225 style.setRightBorder(border); 226 } 227 228 borderColor = JRXmlConstants.getColor(atts.getValue(ATTRIBUTE_rightBorderColor), Color.black); 229 if (borderColor != null) 230 { 231 style.setRightBorderColor(borderColor); 232 } 233 234 padding = atts.getValue(ATTRIBUTE_rightPadding); 235 if (padding != null && padding.length() > 0) 236 { 237 style.setRightPadding(Integer.parseInt(padding)); 238 } 239 240 241 242 Byte rotation = (Byte )JRXmlConstants.getRotationMap().get(atts.getValue(ATTRIBUTE_rotation)); 243 if (rotation != null) 244 { 245 style.setRotation(rotation); 246 } 247 248 Byte lineSpacing = (Byte )JRXmlConstants.getLineSpacingMap().get(atts.getValue(ATTRIBUTE_lineSpacing)); 249 if (lineSpacing != null) 250 { 251 style.setLineSpacing(lineSpacing); 252 } 253 254 String isStyledText = atts.getValue(ATTRIBUTE_isStyledText); 255 if (isStyledText != null && isStyledText.length() > 0) 256 { 257 style.setStyledText(Boolean.valueOf(isStyledText)); 258 } 259 260 style.setPattern(atts.getValue(ATTRIBUTE_pattern)); 261 262 String isBlankWhenNull = atts.getValue(ATTRIBUTE_isBlankWhenNull); 263 if (isBlankWhenNull != null && isBlankWhenNull.length() > 0) 264 { 265 style.setBlankWhenNull(Boolean.valueOf(isBlankWhenNull)); 266 } 267 268 if (atts.getValue(ATTRIBUTE_fontName) != null) 269 style.setFontName(atts.getValue(ATTRIBUTE_fontName)); 270 271 if (atts.getValue(ATTRIBUTE_isBold) != null) 272 style.setBold(Boolean.valueOf(atts.getValue(ATTRIBUTE_isBold))); 273 274 if (atts.getValue(ATTRIBUTE_isItalic) != null) 275 style.setItalic(Boolean.valueOf(atts.getValue(ATTRIBUTE_isItalic))); 276 277 if (atts.getValue(ATTRIBUTE_isUnderline) != null) 278 style.setUnderline(Boolean.valueOf(atts.getValue(ATTRIBUTE_isUnderline))); 279 280 if (atts.getValue(ATTRIBUTE_isStrikeThrough) != null) 281 style.setStrikeThrough(Boolean.valueOf(atts.getValue(ATTRIBUTE_isStrikeThrough))); 282 283 if (atts.getValue(ATTRIBUTE_fontSize) != null) 284 style.setFontSize(Integer.valueOf(atts.getValue(ATTRIBUTE_fontSize))); 285 286 if (atts.getValue(ATTRIBUTE_pdfFontName) != null) 287 style.setPdfFontName(atts.getValue(ATTRIBUTE_pdfFontName)); 288 289 if (atts.getValue(ATTRIBUTE_pdfEncoding) != null) 290 style.setPdfEncoding(atts.getValue(ATTRIBUTE_pdfEncoding)); 291 292 if (atts.getValue(ATTRIBUTE_isPdfEmbedded) != null) 293 style.setPdfEmbedded(Boolean.valueOf(atts.getValue(ATTRIBUTE_isPdfEmbedded))); 294 295 return style; 296 } 297 } 298 | Popular Tags |