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.base;
029:
030: import net.sf.jasperreports.charts.JRChartAxis;
031: import net.sf.jasperreports.charts.JRMultiAxisPlot;
032: import net.sf.jasperreports.engine.JRChart;
033: import net.sf.jasperreports.engine.JRChartPlot;
034: import net.sf.jasperreports.engine.JRConstants;
035: import net.sf.jasperreports.engine.JRExpressionCollector;
036: import net.sf.jasperreports.engine.base.JRBaseChartPlot;
037: import net.sf.jasperreports.engine.base.JRBaseObjectFactory;
038:
039: import java.util.Iterator;
040: import java.util.List;
041:
042: /**
043: * An immutable representation of the layout options of a multiple axis chart.
044: *
045: * @author Barry Klawans (bklawans@users.sourceforge.net)
046: * @version $Id: JRBaseMultiAxisPlot.java 1793 2007-07-30 09:06:18Z teodord $
047: */
048: public class JRBaseMultiAxisPlot extends JRBaseChartPlot implements
049: JRMultiAxisPlot {
050:
051: /**
052: *
053: */
054: private static final long serialVersionUID = JRConstants.SERIAL_VERSION_UID;
055:
056: /**
057: * All the axes contained in this plot. Each entry indicates a chart containing
058: * the dataset and layout of that entry and where to draw that chart's range
059: * axis. All entries in the list are of the type
060: * <code>{@link JRChartAxis}</code>
061: */
062: protected List axes = new java.util.ArrayList();
063:
064: /**
065: * Constructs a copy of an existing multiple axis chart plot.
066: *
067: * @param multiAxisPlot the plot to copy
068: */
069: public JRBaseMultiAxisPlot(JRChartPlot multiAxisPlot, JRChart chart) {
070: super (multiAxisPlot, chart);
071: }
072:
073: /**
074: * Creates a copy of an existing multiple axis chart plot and registers
075: * any expression contained in the plot with the specified factory. Since
076: * the plot contains multiple other charts nested inside of it all of the
077: * expressions used by those charts is also registered with the factory.
078: *
079: * @param multiAxisPlot the plot to copy
080: * @param factory the factory to register expressions with
081: */
082: public JRBaseMultiAxisPlot(JRMultiAxisPlot multiAxisPlot,
083: JRBaseObjectFactory factory) {
084: super (multiAxisPlot, factory);
085:
086: List origAxes = multiAxisPlot.getAxes();
087: axes.clear();
088: if (origAxes != null) {
089: Iterator iter = origAxes.iterator();
090: while (iter.hasNext()) {
091: JRChartAxis axis = (JRChartAxis) iter.next();
092: axes.add(factory.getChartAxis(axis));
093: }
094: }
095: }
096:
097: /**
098: *
099: */
100: public List getAxes() {
101: return axes;
102: }
103:
104: /**
105: * Adds all the expression used by this plot with the specified collector.
106: * All collected expression that are also registered with a factory will
107: * be included with the report is compiled.
108: *
109: * @param collector the expression collector to use
110: */
111: public void collectExpressions(JRExpressionCollector collector) {
112: Iterator iter = axes.iterator();
113: while (iter.hasNext()) {
114: JRChartAxis axis = (JRChartAxis) iter.next();
115: collector.collect(axis.getChart());
116: }
117: }
118: }
|