1 28 package net.sf.jasperreports.charts.xml; 29 30 import net.sf.jasperreports.charts.design.JRDesignThermometerPlot; 31 import net.sf.jasperreports.engine.JRChart; 32 import net.sf.jasperreports.engine.JRException; 33 import net.sf.jasperreports.engine.xml.JRBaseFactory; 34 import net.sf.jasperreports.engine.xml.JRXmlConstants; 35 36 import org.xml.sax.Attributes ; 37 38 39 43 public class JRThermometerPlotFactory extends JRBaseFactory 44 { 45 public static final String ATTRIBUTE_showValueLines = "isShowValueLines"; 46 public static final String ATTRIBUTE_valueLocation = "valueLocation"; 47 public static final String ATTRIBUTE_mercuryColor = "mercuryColor"; 48 49 52 public Object createObject(Attributes atts) throws JRException 53 { 54 JRChart chart = (JRChart)digester.peek(); 55 JRDesignThermometerPlot thermometerPlot = (JRDesignThermometerPlot)chart.getPlot(); 56 57 String showValueLines = atts.getValue(ATTRIBUTE_showValueLines); 58 if (showValueLines != null && showValueLines.length() > 0) 59 { 60 thermometerPlot.setShowValueLines(Boolean.valueOf(showValueLines).booleanValue()); 61 } 62 63 String location = atts.getValue(ATTRIBUTE_valueLocation); 64 Byte loc = (Byte )JRXmlConstants.getThermometerValueLocationMap().get(location); 65 if (loc == null) 66 { 67 throw new JRException("Invalid thermometer value location: " + location); 68 } 69 else 70 { 71 thermometerPlot.setValueLocation(loc.byteValue()); 72 } 73 74 String mercuryColor = atts.getValue(ATTRIBUTE_mercuryColor); 75 if (mercuryColor != null && mercuryColor.length() > 0) 76 { 77 thermometerPlot.setMercuryColor(JRXmlConstants.getColor(mercuryColor, null)); 78 } 79 80 return thermometerPlot; 81 } 82 } 83 | Popular Tags |