KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > jasperreports > charts > base > JRBaseMultiAxisPlot


1 /*
2  * ============================================================================
3  * GNU Lesser General Public License
4  * ============================================================================
5  *
6  * JasperReports - Free Java report-generating library.
7  * Copyright (C) 2001-2006 JasperSoft Corporation http://www.jaspersoft.com
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with this library; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
22  *
23  * JasperSoft Corporation
24  * 303 Second Street, Suite 450 North
25  * San Francisco, CA 94107
26  * http://www.jaspersoft.com
27  */

28 package net.sf.jasperreports.charts.base;
29
30 import net.sf.jasperreports.charts.JRChartAxis;
31 import net.sf.jasperreports.charts.JRMultiAxisPlot;
32 import net.sf.jasperreports.engine.JRChartPlot;
33 import net.sf.jasperreports.engine.JRConstants;
34 import net.sf.jasperreports.engine.JRExpressionCollector;
35 import net.sf.jasperreports.engine.base.JRBaseChartPlot;
36 import net.sf.jasperreports.engine.base.JRBaseObjectFactory;
37
38 import java.util.Iterator JavaDoc;
39 import java.util.List JavaDoc;
40
41 /**
42  * An immutable representation of the layout options of a multiple axis chart.
43  *
44  * @author Barry Klawans (bklawans@users.sourceforge.net)
45  * @version $Id: JRBaseMultiAxisPlot.java 1404 2006-09-21 16:51:29 +0300 (Thu, 21 Sep 2006) teodord $
46  */

47 public class JRBaseMultiAxisPlot extends JRBaseChartPlot implements JRMultiAxisPlot
48 {
49
50
51     /**
52      *
53      */

54     private static final long serialVersionUID = JRConstants.SERIAL_VERSION_UID;
55
56     /**
57      * All the axes contained in this plot. Each entry indicates a chart containing
58      * the dataset and layout of that entry and where to draw that chart's range
59      * axis. All entries in the list are of the type
60      * <code>{@link JRChartAxis}</code>
61      */

62     protected List JavaDoc axes = new java.util.ArrayList JavaDoc();
63     
64
65     
66     /**
67      * Constructs a copy of an existing multiple axis chart plot.
68      *
69      * @param multiAxisPlot the plot to copy
70      */

71     public JRBaseMultiAxisPlot(JRChartPlot multiAxisPlot)
72     {
73         super(multiAxisPlot);
74     }
75     
76     /**
77      * Creates a copy of an existing multiple axis chart plot and registers
78      * any expression contained in the plot with the specified factory. Since
79      * the plot contains multiple other charts nested inside of it all of the
80      * expressions used by those charts is also registered with the factory.
81      *
82      * @param multiAxisPlot the plot to copy
83      * @param factory the factory to register expressions with
84      */

85     public JRBaseMultiAxisPlot(JRMultiAxisPlot multiAxisPlot, JRBaseObjectFactory factory)
86     {
87         super(multiAxisPlot, factory);
88
89         List JavaDoc origAxes = multiAxisPlot.getAxes();
90         axes.clear();
91         if (origAxes != null)
92         {
93             Iterator JavaDoc iter = origAxes.iterator();
94             while (iter.hasNext())
95             {
96                 JRChartAxis axis = (JRChartAxis)iter.next();
97                 axes.add(factory.getChartAxis(axis));
98             }
99         }
100     }
101
102         
103         
104     /**
105      *
106      */

107     public List JavaDoc getAxes()
108     {
109         return axes;
110     }
111
112     /**
113      * Adds all the expression used by this plot with the specified collector.
114      * All collected expression that are also registered with a factory will
115      * be included with the report is compiled.
116      *
117      * @param collector the expression collector to use
118      */

119     public void collectExpressions(JRExpressionCollector collector)
120     {
121         Iterator JavaDoc iter = axes.iterator();
122         while (iter.hasNext())
123         {
124             JRChartAxis axis = (JRChartAxis)iter.next();
125             collector.collect(axis.getChart());
126         }
127     }
128 }
129
Popular Tags