KickJava   Java API By Example, From Geeks To Geeks.

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


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.JRDataRange;
31 import net.sf.jasperreports.charts.JRThermometerPlot;
32 import net.sf.jasperreports.charts.JRValueDisplay;
33 import net.sf.jasperreports.charts.base.JRBaseDataRange;
34 import net.sf.jasperreports.charts.base.JRBaseValueDisplay;
35 import net.sf.jasperreports.engine.JRChartPlot;
36 import net.sf.jasperreports.engine.JRConstants;
37 import net.sf.jasperreports.engine.JRExpressionCollector;
38 import net.sf.jasperreports.engine.base.JRBaseChartPlot;
39 import net.sf.jasperreports.engine.base.JRBaseObjectFactory;
40
41 import java.awt.Color JavaDoc;
42
43 /**
44  * An immutable representation of the layout of a thermometer plot.
45  *
46  * @author Barry Klawans (bklawans@users.sourceforge.net)
47  * @version $Id: JRBaseThermometerPlot.java 1386 2006-09-06 00:33:02 +0300 (Wed, 06 Sep 2006) bklawans $
48  */

49 public class JRBaseThermometerPlot extends JRBaseChartPlot implements JRThermometerPlot
50 {
51     /**
52      *
53      */

54     private static final long serialVersionUID = JRConstants.SERIAL_VERSION_UID;
55
56     /**
57      * The range of values that can be displayed by this thermometer. Specifies
58      * the upper and lower bounds of the meter itself.
59      */

60     protected JRDataRange dataRange = null;
61     
62     /**
63      * Formatting information for the textual display of the value, including
64      * font, color and a mask.
65      */

66     protected JRValueDisplay valueDisplay = null;
67     
68     /**
69      * Indicates if the boundaries of each range should be shown.
70      */

71     protected boolean showValueLines = false;
72
73     /**
74      * Specifies where the textual display of the value should be shown.
75      */

76     protected byte valueLocation = JRThermometerPlot.LOCATION_BULB;
77     
78     /**
79      * The default color to use for the mercury in the thermometer.
80      */

81     protected Color JavaDoc mercuryColor = null;
82
83     /**
84      * The boundaries of the low range.
85      */

86     protected JRDataRange lowRange = null;
87
88     /**
89      * The boundaries of the medium range.
90      */

91     protected JRDataRange mediumRange = null;
92
93     /**
94      * The boundaries of the high range.
95      */

96     protected JRDataRange highRange = null;
97     
98     /**
99      * Constructs a new thermometer plot that is a copy of an existing one.
100      *
101      * @param thermoPlot the plot to copy
102      */

103     public JRBaseThermometerPlot(JRChartPlot thermoPlot)
104     {
105         super(thermoPlot);
106     }
107     
108     /**
109      * Constructs a new plot that is a copy of an existing one, and registers
110      * all expression used by the plot with the specified factory.
111      *
112      * @param thermoPlot the plot to copy
113      * @param factory the factory to register any expressions with
114      */

115     public JRBaseThermometerPlot(JRThermometerPlot thermoPlot, JRBaseObjectFactory factory)
116     {
117         super(thermoPlot, factory);
118
119         dataRange = new JRBaseDataRange(thermoPlot.getDataRange(), factory);
120         
121         valueDisplay = new JRBaseValueDisplay(thermoPlot.getValueDisplay(), factory);
122         
123         showValueLines = thermoPlot.isShowValueLines();
124         
125         valueLocation = thermoPlot.getValueLocation();
126         
127         mercuryColor = thermoPlot.getMercuryColor();
128         
129         if (thermoPlot.getLowRange() != null)
130             lowRange = new JRBaseDataRange(thermoPlot.getLowRange(), factory);
131         if (thermoPlot.getMediumRange() != null)
132             mediumRange = new JRBaseDataRange(thermoPlot.getMediumRange(), factory);
133         if (thermoPlot.getHighRange() != null)
134             highRange = new JRBaseDataRange(thermoPlot.getHighRange(), factory);
135     }
136
137     /**
138      *
139      */

140     public JRDataRange getDataRange()
141     {
142         return dataRange;
143     }
144     
145     /**
146      *
147      */

148     public JRValueDisplay getValueDisplay()
149     {
150         return valueDisplay;
151     }
152     
153     /**
154      *
155      */

156     public boolean isShowValueLines()
157     {
158         return showValueLines;
159     }
160         
161     /**
162      *
163      */

164     public byte getValueLocation()
165     {
166         return valueLocation;
167     }
168         
169     /**
170      *
171      */

172     public Color JavaDoc getMercuryColor()
173     {
174         return mercuryColor;
175     }
176     
177     /**
178      *
179      */

180     public JRDataRange getLowRange()
181     {
182         return lowRange;
183     }
184         
185     /**
186      *
187      */

188     public JRDataRange getMediumRange()
189     {
190         return mediumRange;
191     }
192         
193     /**
194      *
195      */

196     public JRDataRange getHighRange()
197     {
198         return highRange;
199     }
200     
201     /**
202      * Adds all the expression used by this plot with the specified collector.
203      * All collected expression that are also registered with a factory will
204      * be included with the report is compiled.
205      *
206      * @param collector the expression collector to use
207      */

208     public void collectExpressions(JRExpressionCollector collector)
209     {
210         collector.collect(this);
211     }
212 }
213
Popular Tags