KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > jasperreports > charts > design > JRDesignChartAxis


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.design;
29
30 import net.sf.jasperreports.charts.JRChartAxis;
31 import net.sf.jasperreports.charts.base.JRBaseChartAxis;
32 import net.sf.jasperreports.engine.JRConstants;
33 import net.sf.jasperreports.engine.JRElement;
34 import net.sf.jasperreports.engine.design.JRDesignChart;
35
36 /**
37  * {@link JRChartAxis JRChartAxis} implementation to be used for report design.
38  *
39  * @author Barry Klawans (barry@users.sourceforge.net)
40  * @version $Id: JRDesignChartAxis.java 1400 2006-09-21 10:45:46 +0300 (Thu, 21 Sep 2006) lucianc $
41  */

42 public class JRDesignChartAxis extends JRBaseChartAxis
43 {
44     
45     /**
46      * The multiple axis chart that this axis belongs to.
47      */

48     protected JRDesignChart parentChart = null;
49
50     private static final long serialVersionUID = JRConstants.SERIAL_VERSION_UID;
51
52     /**
53      * Construct a new axis that will be added to the specified chart.
54      *
55      * @param parentChart the chart that the axis will be added to
56      */

57     public JRDesignChartAxis(JRDesignChart parentChart)
58     {
59         this.parentChart = parentChart;
60     }
61
62     /**
63      * Sets the position of this axis' value line relative to the multiple
64      * axis chart.
65      *
66      * @param position the position of this axis
67      */

68     public void setPosition(byte position)
69     {
70         this.position = position;
71     }
72     
73     /**
74      * Set the chart that contains the dataset and plot to use for this
75      * axis. The plot is used to figure out how to render the dataset (ie
76      * as a line or bar chart) when adding it to the multiple axis chart.
77      *
78      * @param chart the chart that contains the dataset and plot for this axis
79      */

80     public void setChart(JRDesignChart chart)
81     {
82         // Override the chart elements that we are going to ignore, as they
83
// are supposed to be controlled by the multi chart's settings.
84
chart.setBackcolor(parentChart.getBackcolor());
85         chart.setShowLegend(parentChart.isShowLegend());
86         chart.setTitleExpression(parentChart.getTitleExpression());
87         chart.setTitleFont(parentChart.getTitleFont());
88         chart.setTitlePosition(parentChart.getTitlePosition());
89         chart.setTitleColor(parentChart.getTitleColor());
90         chart.setSubtitleExpression(parentChart.getSubtitleExpression());
91         chart.setSubtitleFont(parentChart.getSubtitleFont());
92         chart.setSubtitleColor(parentChart.getSubtitleColor());
93         chart.setLegendColor(parentChart.getLegendColor());
94         chart.setLegendBackgroundColor(parentChart.getLegendBackgroundColor());
95         chart.setLegendFont(parentChart.getLegendFont());
96         this.chart = chart;
97     }
98
99     /**
100      * Sets the chart that contains the dataset and plot for this axis.
101      * Identical to {@link #setChart} but is called by the XML digester
102      * when parsing the report source.
103      *
104      * @param element
105      */

106     public void addElement(JRElement element)
107     {
108         setChart((JRDesignChart)element);
109     }
110 }
111
Popular Tags