KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > jasperreports > charts > util > JRMeterInterval


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.util;
29
30 import net.sf.jasperreports.charts.JRDataRange;
31 import net.sf.jasperreports.charts.base.JRBaseDataRange;
32 import net.sf.jasperreports.engine.JRConstants;
33 import net.sf.jasperreports.engine.base.JRBaseObjectFactory;
34
35 import java.awt.Color JavaDoc;
36 import java.io.Serializable JavaDoc;
37
38 /**
39  * Defines a subsection of a meter chart. This section has its own range,
40  * a label, and can shade a section of the meter face with its own color.
41  * Common usages are to show "critical", "warning" and "good" ranges.
42  *
43  * @author Barry Klawans (barry@users.sourceforge.net)
44  * @version $Id: JRMeterInterval.java 1388 2006-09-06 00:34:28 +0300 (Wed, 06 Sep 2006) bklawans $
45  */

46
47
48 public class JRMeterInterval implements Serializable JavaDoc
49 {
50     /**
51      * The range of this interval. Must be inside the meter's range.
52      */

53     protected JRDataRange dataRange = null;
54     
55     /**
56      * The label of this interval. Only appears in the meter's legend.
57      */

58     protected String JavaDoc label = null;
59     
60     /**
61      * Color to use to shade in this region on the meter's face.
62      */

63     protected Color JavaDoc backgroundColor = null;
64     
65     /**
66      * Transparency of the interval's color. 1.0 is fully opaque, 0.0 is
67      * fully transparent.
68      */

69     protected double alpha = 1.0;
70
71     private static final long serialVersionUID = JRConstants.SERIAL_VERSION_UID;
72
73     /**
74      * Construct an empty interval.
75      */

76     public JRMeterInterval()
77     {
78     }
79
80     /**
81      * Construct a new interval by copying an existing one.
82      *
83      * @param meterInterval the interval to copy
84      * @param factory factory object to register expressions with
85      */

86     public JRMeterInterval(JRMeterInterval meterInterval, JRBaseObjectFactory factory)
87     {
88         dataRange = new JRBaseDataRange(meterInterval.getDataRange(), factory);
89         label = meterInterval.getLabel();
90         backgroundColor = meterInterval.getBackgroundColor();
91         alpha = meterInterval.getAlpha();
92     }
93
94     /**
95      * Returns the range this interval is for.
96      *
97      * @return the range of this interval
98      */

99     public JRDataRange getDataRange()
100     {
101         return dataRange;
102     }
103
104     /**
105      * Sets the range for this interval. The range must be inside the
106      * range of the meter we are going to add the interval to.
107      *
108      * @param dataRange the range of this interval
109      */

110     public void setDataRange(JRDataRange dataRange)
111     {
112         this.dataRange = dataRange;
113     }
114
115     /**
116      * The text describing this range. This text only appears in the
117      * meter's legend.
118      *
119      * @return the text describing this range
120      */

121     public String JavaDoc getLabel()
122     {
123         return label;
124     }
125
126     /**
127      * Sets the textual description of this range. This text only appears
128      * in the meter's legend.
129      *
130      * @param label the textual description of this range
131      */

132     public void setLabel(String JavaDoc label)
133     {
134         this.label = label;
135     }
136
137     /**
138      * Returns the color used to shade this interval.
139      *
140      * @return the color used to shade this interval
141      */

142     public Color JavaDoc getBackgroundColor()
143     {
144         return backgroundColor;
145     }
146
147     /**
148      * Specifies the color to use to shade this interval.
149      *
150      * @param backgroundColor the color to use to shade this interval
151      */

152     public void setBackgroundColor(Color JavaDoc backgroundColor)
153     {
154         this.backgroundColor = backgroundColor;
155     }
156
157     /**
158      * Returns the transparency of the interval color, with 0.0 being fully
159      * transparent and 1.0 being fully opaque.
160      *
161      * @return the transparency of the interval color
162      */

163     public double getAlpha()
164     {
165         return alpha;
166     }
167     
168     /**
169      * Sets the transparency of the interval color, with 0.0 being fully
170      * transparent and 1.0 being fully opaque.
171      *
172      * @param alpha the transparency of the interval color
173      */

174     public void setAlpha(double alpha)
175     {
176         this.alpha = alpha;
177     }
178 }
179
Popular Tags