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.JRDataRange;
031: import net.sf.jasperreports.charts.JRThermometerPlot;
032: import net.sf.jasperreports.charts.JRValueDisplay;
033: import net.sf.jasperreports.charts.base.JRBaseDataRange;
034: import net.sf.jasperreports.charts.base.JRBaseValueDisplay;
035: import net.sf.jasperreports.engine.JRChart;
036: import net.sf.jasperreports.engine.JRChartPlot;
037: import net.sf.jasperreports.engine.JRConstants;
038: import net.sf.jasperreports.engine.JRExpressionCollector;
039: import net.sf.jasperreports.engine.base.JRBaseChartPlot;
040: import net.sf.jasperreports.engine.base.JRBaseObjectFactory;
041:
042: import java.awt.Color;
043:
044: /**
045: * An immutable representation of the layout of a thermometer plot.
046: *
047: * @author Barry Klawans (bklawans@users.sourceforge.net)
048: * @version $Id: JRBaseThermometerPlot.java 1793 2007-07-30 09:06:18Z teodord $
049: */
050: public class JRBaseThermometerPlot extends JRBaseChartPlot implements
051: JRThermometerPlot {
052: /**
053: *
054: */
055: private static final long serialVersionUID = JRConstants.SERIAL_VERSION_UID;
056:
057: /**
058: * The range of values that can be displayed by this thermometer. Specifies
059: * the upper and lower bounds of the meter itself.
060: */
061: protected JRDataRange dataRange = null;
062:
063: /**
064: * Formatting information for the textual display of the value, including
065: * font, color and a mask.
066: */
067: protected JRValueDisplay valueDisplay = null;
068:
069: /**
070: * Indicates if the boundaries of each range should be shown.
071: */
072: protected boolean showValueLines = false;
073:
074: /**
075: * Specifies where the textual display of the value should be shown.
076: */
077: protected byte valueLocation = JRThermometerPlot.LOCATION_BULB;
078:
079: /**
080: * The default color to use for the mercury in the thermometer.
081: */
082: protected Color mercuryColor = null;
083:
084: /**
085: * The boundaries of the low range.
086: */
087: protected JRDataRange lowRange = null;
088:
089: /**
090: * The boundaries of the medium range.
091: */
092: protected JRDataRange mediumRange = null;
093:
094: /**
095: * The boundaries of the high range.
096: */
097: protected JRDataRange highRange = null;
098:
099: /**
100: * Constructs a new thermometer plot that is a copy of an existing one.
101: *
102: * @param thermoPlot the plot to copy
103: */
104: public JRBaseThermometerPlot(JRChartPlot thermoPlot, JRChart chart) {
105: super (thermoPlot, chart);
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,
116: JRBaseObjectFactory factory) {
117: super (thermoPlot, factory);
118:
119: dataRange = new JRBaseDataRange(thermoPlot.getDataRange(),
120: factory);
121:
122: valueDisplay = new JRBaseValueDisplay(thermoPlot
123: .getValueDisplay(), factory);
124:
125: showValueLines = thermoPlot.isShowValueLines();
126:
127: valueLocation = thermoPlot.getValueLocation();
128:
129: mercuryColor = thermoPlot.getMercuryColor();
130:
131: if (thermoPlot.getLowRange() != null)
132: lowRange = new JRBaseDataRange(thermoPlot.getLowRange(),
133: factory);
134: if (thermoPlot.getMediumRange() != null)
135: mediumRange = new JRBaseDataRange(thermoPlot
136: .getMediumRange(), factory);
137: if (thermoPlot.getHighRange() != null)
138: highRange = new JRBaseDataRange(thermoPlot.getHighRange(),
139: factory);
140: }
141:
142: /**
143: *
144: */
145: public JRDataRange getDataRange() {
146: return dataRange;
147: }
148:
149: /**
150: *
151: */
152: public JRValueDisplay getValueDisplay() {
153: return valueDisplay;
154: }
155:
156: /**
157: *
158: */
159: public boolean isShowValueLines() {
160: return showValueLines;
161: }
162:
163: /**
164: *
165: */
166: public byte getValueLocation() {
167: return valueLocation;
168: }
169:
170: /**
171: *
172: */
173: public Color getMercuryColor() {
174: return mercuryColor;
175: }
176:
177: /**
178: *
179: */
180: public JRDataRange getLowRange() {
181: return lowRange;
182: }
183:
184: /**
185: *
186: */
187: public JRDataRange getMediumRange() {
188: return mediumRange;
189: }
190:
191: /**
192: *
193: */
194: public JRDataRange getHighRange() {
195: return highRange;
196: }
197:
198: /**
199: * Adds all the expression used by this plot with the specified collector.
200: * All collected expression that are also registered with a factory will
201: * be included with the report is compiled.
202: *
203: * @param collector the expression collector to use
204: */
205: public void collectExpressions(JRExpressionCollector collector) {
206: collector.collect(this);
207: }
208: }
|