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.charts.design;
029:
030: import net.sf.jasperreports.charts.JRChartAxis;
031: import net.sf.jasperreports.charts.base.JRBaseChartAxis;
032: import net.sf.jasperreports.engine.JRConstants;
033: import net.sf.jasperreports.engine.JRElement;
034: import net.sf.jasperreports.engine.design.JRDesignChart;
035:
036: /**
037: * {@link JRChartAxis JRChartAxis} implementation to be used for report design.
038: *
039: * @author Barry Klawans (barry@users.sourceforge.net)
040: * @version $Id: JRDesignChartAxis.java 1794 2007-07-30 09:07:50Z teodord $
041: */
042: public class JRDesignChartAxis extends JRBaseChartAxis {
043:
044: /**
045: * The multiple axis chart that this axis belongs to.
046: */
047: protected JRDesignChart parentChart = null;
048:
049: private static final long serialVersionUID = JRConstants.SERIAL_VERSION_UID;
050:
051: /**
052: * Construct a new axis that will be added to the specified chart.
053: *
054: * @param parentChart the chart that the axis will be added to
055: */
056: public JRDesignChartAxis(JRDesignChart parentChart) {
057: this .parentChart = parentChart;
058: }
059:
060: /**
061: * Sets the position of this axis' value line relative to the multiple
062: * axis chart.
063: *
064: * @param position the position of this axis
065: */
066: public void setPosition(byte position) {
067: this .position = position;
068: }
069:
070: /**
071: * Set the chart that contains the dataset and plot to use for this
072: * axis. The plot is used to figure out how to render the dataset (ie
073: * as a line or bar chart) when adding it to the multiple axis chart.
074: *
075: * @param chart the chart that contains the dataset and plot for this axis
076: */
077: public void setChart(JRDesignChart chart) {
078: // Override the chart elements that we are going to ignore, as they
079: // are supposed to be controlled by the multi chart's settings.
080: chart.setBackcolor(parentChart.getBackcolor());
081: chart.setShowLegend(parentChart.isShowLegend());
082: chart.setTitleExpression(parentChart.getTitleExpression());
083: chart.setTitleFont(parentChart.getTitleFont());
084: chart.setTitlePosition(parentChart.getTitlePosition());
085: chart.setTitleColor(parentChart.getTitleColor());
086: chart
087: .setSubtitleExpression(parentChart
088: .getSubtitleExpression());
089: chart.setSubtitleFont(parentChart.getSubtitleFont());
090: chart.setSubtitleColor(parentChart.getSubtitleColor());
091: chart.setLegendColor(parentChart.getLegendColor());
092: chart.setLegendBackgroundColor(parentChart
093: .getLegendBackgroundColor());
094: chart.setLegendFont(parentChart.getLegendFont());
095: this .chart = chart;
096: }
097:
098: /**
099: * Sets the chart that contains the dataset and plot for this axis.
100: * Identical to {@link #setChart} but is called by the XML digester
101: * when parsing the report source.
102: *
103: * @param element
104: */
105: public void addElement(JRElement element) {
106: setChart((JRDesignChart) element);
107: }
108: }
|