001: /*
002: * ============================================================================
003: * GNU Lesser General Public License
004: * ============================================================================
005: *
006: * JasperReports - Free Java report-generating library.
007: * Copyright (C) 2001-2006 JasperSoft Corporation http://www.jaspersoft.com
008: *
009: * This library is free software; you can redistribute it and/or
010: * modify it under the terms of the GNU Lesser General Public
011: * License as published by the Free Software Foundation; either
012: * version 2.1 of the License, or (at your option) any later version.
013: *
014: * This library is distributed in the hope that it will be useful,
015: * but WITHOUT ANY WARRANTY; without even the implied warranty of
016: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
017: * Lesser General Public License for more details.
018: *
019: * You should have received a copy of the GNU Lesser General Public
020: * License along with this library; if not, write to the Free Software
021: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
022: *
023: * JasperSoft Corporation
024: * 303 Second Street, Suite 450 North
025: * San Francisco, CA 94107
026: * http://www.jaspersoft.com
027: */
028: package net.sf.jasperreports.engine.xml;
029:
030: import java.awt.Color;
031:
032: import net.sf.jasperreports.engine.JRChartPlot;
033: import net.sf.jasperreports.engine.base.JRBaseChartPlot;
034:
035: import org.jfree.chart.plot.PlotOrientation;
036: import org.xml.sax.Attributes;
037:
038: /**
039: * @author Ionut Nedelcu (ionutned@users.sourceforge.net)
040: * @version $Id: JRChartPlotFactory.java 1581 2007-02-12 14:19:02Z shertage $
041: */
042: public class JRChartPlotFactory extends JRBaseFactory {
043:
044: /**
045: *
046: */
047: public Object createObject(Attributes atts) {
048: JRChartPlot plot = (JRChartPlot) digester.peek();
049:
050: Color color = JRXmlConstants.getColor(atts
051: .getValue(JRXmlConstants.ATTRIBUTE_backcolor),
052: Color.black);
053: if (color != null) {
054: plot.setBackcolor(color);
055: }
056:
057: String orientation = atts
058: .getValue(JRXmlConstants.ATTRIBUTE_orientation);
059: if (orientation != null && orientation.length() > 0)
060: plot.setOrientation((PlotOrientation) JRXmlConstants
061: .getPlotOrientationMap().get(orientation));
062:
063: String foregroundAlpha = atts
064: .getValue(JRXmlConstants.ATTRIBUTE_foregroundAlpha);
065: if (foregroundAlpha != null && foregroundAlpha.length() > 0)
066: plot.setForegroundAlpha(Float.valueOf(foregroundAlpha)
067: .floatValue());
068:
069: String backgroundAlpha = atts
070: .getValue(JRXmlConstants.ATTRIBUTE_backgroundAlpha);
071: if (backgroundAlpha != null && backgroundAlpha.length() > 0)
072: plot.setBackgroundAlpha(Float.valueOf(backgroundAlpha)
073: .floatValue());
074:
075: String labelRotation = atts
076: .getValue(JRXmlConstants.ATTRIBUTE_labelRotation);
077: if (labelRotation != null && labelRotation.length() > 0)
078: plot.setLabelRotation(Double.valueOf(labelRotation)
079: .doubleValue());
080:
081: return plot;
082: }
083:
084: public static class JRSeriesColorFactory extends JRBaseFactory {
085: public Object createObject(Attributes atts) {
086: int seriesIndex = -1;
087: Color color = null;
088:
089: String seriesNumber = atts
090: .getValue(JRXmlConstants.ATTRIBUTE_seriesOrder);
091: if (seriesNumber != null && seriesNumber.length() > 0)
092: seriesIndex = Integer.valueOf(seriesNumber).intValue();
093:
094: String colorName = atts
095: .getValue(JRXmlConstants.ATTRIBUTE_color);
096: if (colorName != null && colorName.length() > 0)
097: color = JRXmlConstants.getColor(colorName, null);
098:
099: return new JRBaseChartPlot.JRBaseSeriesColor(seriesIndex,
100: color);
101: }
102: }
103: }
|