KickJava   Java API By Example, From Geeks To Geeks.

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


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.JRValueDisplay;
31 import net.sf.jasperreports.engine.JRConstants;
32 import net.sf.jasperreports.engine.JRExpressionCollector;
33 import net.sf.jasperreports.engine.JRFont;
34 import net.sf.jasperreports.engine.base.JRBaseObjectFactory;
35
36 import java.awt.Color JavaDoc;
37 import java.io.Serializable JavaDoc;
38
39 /**
40  * An immutable representation of the formatting options for showing the
41  * value of a value dataset. Used by charts that display a single value,
42  * such as a Meter or Thermometer.
43  *
44  * @author Barry Klawans (bklawans@users.sourceforge.net)
45  * @version $Id: JRBaseValueDisplay.java 1386 2006-09-06 00:33:02 +0300 (Wed, 06 Sep 2006) bklawans $
46  */

47 public class JRBaseValueDisplay implements JRValueDisplay, Serializable JavaDoc
48 {
49
50
51     /**
52      *
53      */

54     private static final long serialVersionUID = JRConstants.SERIAL_VERSION_UID;
55
56     /**
57      * The color to use when writing the value.
58      */

59     protected Color JavaDoc color = null;
60     
61     /**
62      * The formatting mask to use when writing the value. Must a pattern
63      * that is accepted by a code>java.text.DecimalFormat</code> object.
64      */

65     protected String JavaDoc mask = null;
66     
67     /**
68      * The font to use when writing the value.
69      */

70     protected JRFont font = null;
71     
72     
73     /**
74      * Constructs a copy of an existing value format specification.
75      *
76      * @param valueDisplay the value formatting object to copy
77      */

78     public JRBaseValueDisplay(JRValueDisplay valueDisplay)
79     {
80         if (valueDisplay != null)
81         {
82             color = valueDisplay.getColor();
83             mask = valueDisplay.getMask();
84             font = valueDisplay.getFont();
85         }
86     }
87     
88     /**
89      * Constructs a copy of an existing value format specification and registers
90      * any expression in the new copy with the specified factory.
91      *
92      * @param valueDisplay the value formatting object to copy
93      * @param factory the factory object to register expressions with
94      */

95     public JRBaseValueDisplay(JRValueDisplay valueDisplay, JRBaseObjectFactory factory)
96     {
97         factory.put(valueDisplay, this);
98         
99         if (valueDisplay != null)
100         {
101             color = valueDisplay.getColor();
102             mask = valueDisplay.getMask();
103             font = valueDisplay.getFont();
104         }
105     }
106         
107         
108     /**
109      *
110      */

111     public Color JavaDoc getColor()
112     {
113         return color;
114     }
115     /**
116      *
117      */

118     public String JavaDoc getMask()
119     {
120         return mask;
121     }
122     /**
123      *
124      */

125     public JRFont getFont()
126     {
127         return font;
128     }
129
130     /**
131      * Adds all the expression used by this plot with the specified collector.
132      * All collected expression that are also registered with a factory will
133      * be included with the report is compiled.
134      *
135      * @param collector the expression collector to use
136      */

137     public void collectExpressions(JRExpressionCollector collector)
138     {
139     }
140
141 }
142
Popular Tags