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.util;
029:
030: import net.sf.jasperreports.charts.JRDataRange;
031: import net.sf.jasperreports.charts.base.JRBaseDataRange;
032: import net.sf.jasperreports.engine.JRConstants;
033: import net.sf.jasperreports.engine.base.JRBaseObjectFactory;
034:
035: import java.awt.Color;
036: import java.io.Serializable;
037:
038: /**
039: * Defines a subsection of a meter chart. This section has its own range,
040: * a label, and can shade a section of the meter face with its own color.
041: * Common usages are to show "critical", "warning" and "good" ranges.
042: *
043: * @author Barry Klawans (barry@users.sourceforge.net)
044: * @version $Id: JRMeterInterval.java 1794 2007-07-30 09:07:50Z teodord $
045: */
046:
047: public class JRMeterInterval implements Serializable {
048: /**
049: * The range of this interval. Must be inside the meter's range.
050: */
051: protected JRDataRange dataRange = null;
052:
053: /**
054: * The label of this interval. Only appears in the meter's legend.
055: */
056: protected String label = null;
057:
058: /**
059: * Color to use to shade in this region on the meter's face.
060: */
061: protected Color backgroundColor = null;
062:
063: /**
064: * Transparency of the interval's color. 1.0 is fully opaque, 0.0 is
065: * fully transparent.
066: */
067: protected double alpha = 1.0;
068:
069: private static final long serialVersionUID = JRConstants.SERIAL_VERSION_UID;
070:
071: /**
072: * Construct an empty interval.
073: */
074: public JRMeterInterval() {
075: }
076:
077: /**
078: * Construct a new interval by copying an existing one.
079: *
080: * @param meterInterval the interval to copy
081: * @param factory factory object to register expressions with
082: */
083: public JRMeterInterval(JRMeterInterval meterInterval,
084: JRBaseObjectFactory factory) {
085: dataRange = new JRBaseDataRange(meterInterval.getDataRange(),
086: factory);
087: label = meterInterval.getLabel();
088: backgroundColor = meterInterval.getBackgroundColor();
089: alpha = meterInterval.getAlpha();
090: }
091:
092: /**
093: * Returns the range this interval is for.
094: *
095: * @return the range of this interval
096: */
097: public JRDataRange getDataRange() {
098: return dataRange;
099: }
100:
101: /**
102: * Sets the range for this interval. The range must be inside the
103: * range of the meter we are going to add the interval to.
104: *
105: * @param dataRange the range of this interval
106: */
107: public void setDataRange(JRDataRange dataRange) {
108: this .dataRange = dataRange;
109: }
110:
111: /**
112: * The text describing this range. This text only appears in the
113: * meter's legend.
114: *
115: * @return the text describing this range
116: */
117: public String getLabel() {
118: return label;
119: }
120:
121: /**
122: * Sets the textual description of this range. This text only appears
123: * in the meter's legend.
124: *
125: * @param label the textual description of this range
126: */
127: public void setLabel(String label) {
128: this .label = label;
129: }
130:
131: /**
132: * Returns the color used to shade this interval.
133: *
134: * @return the color used to shade this interval
135: */
136: public Color getBackgroundColor() {
137: return backgroundColor;
138: }
139:
140: /**
141: * Specifies the color to use to shade this interval.
142: *
143: * @param backgroundColor the color to use to shade this interval
144: */
145: public void setBackgroundColor(Color backgroundColor) {
146: this .backgroundColor = backgroundColor;
147: }
148:
149: /**
150: * Returns the transparency of the interval color, with 0.0 being fully
151: * transparent and 1.0 being fully opaque.
152: *
153: * @return the transparency of the interval color
154: */
155: public double getAlpha() {
156: return alpha;
157: }
158:
159: /**
160: * Sets the transparency of the interval color, with 0.0 being fully
161: * transparent and 1.0 being fully opaque.
162: *
163: * @param alpha the transparency of the interval color
164: */
165: public void setAlpha(double alpha) {
166: this.alpha = alpha;
167: }
168: }
|