KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > krysalis > jcharts > properties > DataAxisProperties


1 /***********************************************************************************************
2  * File Info: $Id: DataAxisProperties.java,v 1.1 2003/05/17 17:00:34 nathaniel_auvil Exp $
3  * Copyright (C) 2002
4  * Author: John Thomson, Nathaniel G. Auvil
5  * Contributor(s):
6  *
7  * Copyright 2002 (C) Nathaniel G. Auvil. All Rights Reserved.
8  *
9  * Redistribution and use of this software and associated documentation ("Software"), with or
10  * without modification, are permitted provided that the following conditions are met:
11  *
12  * 1. Redistributions of source code must retain copyright statements and notices.
13  * Redistributions must also contain a copy of this document.
14  *
15  * 2. Redistributions in binary form must reproduce the above copyright notice, this list of
16  * conditions and the following disclaimer in the documentation and/or other materials
17  * provided with the distribution.
18  *
19  * 3. The name "jCharts" or "Nathaniel G. Auvil" must not be used to endorse or promote
20  * products derived from this Software without prior written permission of Nathaniel G.
21  * Auvil. For written permission, please contact nathaniel_auvil@users.sourceforge.net
22  *
23  * 4. Products derived from this Software may not be called "jCharts" nor may "jCharts" appear
24  * in their names without prior written permission of Nathaniel G. Auvil. jCharts is a
25  * registered trademark of Nathaniel G. Auvil.
26  *
27  * 5. Due credit should be given to the jCharts Project (http://jcharts.sourceforge.net/).
28  *
29  * THIS SOFTWARE IS PROVIDED BY Nathaniel G. Auvil AND CONTRIBUTORS ``AS IS'' AND ANY
30  * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
31  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
32  * jCharts OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
33  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
34  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
35  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,STRICT LIABILITY, OR TORT
36  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
37  * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
38  ************************************************************************************************/

39
40
41 package org.krysalis.jcharts.properties;
42
43
44 import org.krysalis.jcharts.test.HTMLGenerator;
45 import org.krysalis.jcharts.test.HTMLTestable;
46 import org.krysalis.jcharts.properties.util.ChartStroke;
47 import org.krysalis.jcharts.axisChart.axis.scale.ScaleCalculator;
48
49 import java.lang.reflect.Field JavaDoc;
50
51
52 public final class DataAxisProperties extends LabelAxisProperties implements HTMLTestable
53 {
54     //---round to nearest power of ten. 2==100, -3=.001
55
private int roundToNearest = 0;
56
57     private boolean showZeroLine = true;
58     private ChartStroke zeroLineChartStroke= ChartStroke.DEFAULT_ZERO_LINE;
59
60     //---user defined scale
61
private boolean userDefinedScale = false;
62     private double userDefinedMinimumValue;
63     private double userDefinedIncrement;
64
65     //---number of items visible on the axis
66
private int numItems = 5;
67
68     private boolean useDollarSigns = false;
69     private boolean useCommas = true;
70     private boolean usePercentSigns = false;
71
72
73     //---holds data relevant to values displayed on the axis. may be null
74
private ScaleCalculator scaleCalculator;
75
76
77
78
79     /***********************************************************************************************
80      *
81      ************************************************************************************************/

82     public DataAxisProperties()
83     {
84         super();
85     }
86
87
88     /****************************************************************************************
89      *
90      * @param axisMinimum
91      * @param axisIncrement
92      * @throws PropertyException
93      **************************************************************************************/

94     public void setUserDefinedScale( double axisMinimum, double axisIncrement ) throws PropertyException
95     {
96         if( axisIncrement <= 0 )
97         {
98             throw new PropertyException( "The Axis Increment can not be a negative value or zero." );
99         }
100
101         this.userDefinedScale = true;
102         this.userDefinedMinimumValue = axisMinimum;
103         this.userDefinedIncrement = axisIncrement;
104     }
105
106
107
108     public int getRoundToNearest()
109     {
110         return roundToNearest;
111     }
112
113
114     public void setRoundToNearest( int roundToNearest )
115     {
116         this.roundToNearest = roundToNearest;
117     }
118
119
120     public boolean showZeroLine()
121     {
122         return showZeroLine;
123     }
124
125
126     public void setShowZeroLine( boolean showZeroLine )
127     {
128         this.showZeroLine = showZeroLine;
129     }
130
131
132     public ChartStroke getZeroLineChartStroke()
133     {
134         return this.zeroLineChartStroke;
135     }
136
137
138     public void setZeroLineChartStroke( ChartStroke zeroLine )
139     {
140         this.zeroLineChartStroke = zeroLine;
141     }
142
143
144     public boolean hasUserDefinedScale()
145     {
146         return userDefinedScale;
147     }
148
149
150     public double getUserDefinedMinimumValue()
151     {
152         return this.userDefinedMinimumValue;
153     }
154
155
156     public double getUserDefinedIncrement()
157     {
158         return this.userDefinedIncrement;
159     }
160
161
162     public int getNumItems()
163     {
164         return numItems;
165     }
166
167
168     public void setNumItems( int numItems )
169     {
170         this.numItems = numItems;
171     }
172
173
174     public boolean useDollarSigns()
175     {
176         return useDollarSigns;
177     }
178
179
180     public void setUseDollarSigns( boolean useDollarSigns )
181     {
182         this.useDollarSigns = useDollarSigns;
183     }
184
185
186     public boolean useCommas()
187     {
188         return useCommas;
189     }
190
191
192     public void setUseCommas( boolean useCommas )
193     {
194         this.useCommas = useCommas;
195     }
196
197
198     public boolean usePercentSigns()
199     {
200         return usePercentSigns;
201     }
202
203
204     public void setUsePercentSigns( boolean usePercentSigns )
205     {
206         this.usePercentSigns = usePercentSigns;
207     }
208
209
210     public ScaleCalculator getScaleCalculator()
211     {
212         return scaleCalculator;
213     }
214
215
216     /******************************************************************************************
217      * You do not have to explicitly set a ScaleCalculator implementation as jCharts will
218      * create one, but if you do not like the way Scale ranges are created, you could
219      * create your own implementation of ScaleCalculator and jCharts will use it!
220      *
221      * @param scaleCalculator
222      ******************************************************************************************/

223     public void setScaleCalculator( ScaleCalculator scaleCalculator )
224     {
225         this.scaleCalculator = scaleCalculator;
226     }
227
228
229     /*********************************************************************************************
230      * Enables the testing routines to display the contents of this Object.
231      *
232      * @param htmlGenerator
233      **********************************************************************************************/

234     public void toHTML( HTMLGenerator htmlGenerator )
235     {
236         htmlGenerator.propertiesTableStart( DataAxisProperties.class.getName() );
237         //super.toHTML( htmlGenerator );
238

239         Field JavaDoc[] fields = this.getClass().getDeclaredFields();
240         for( int i = 0; i < fields.length; i++ )
241         {
242             try
243             {
244                 htmlGenerator.addField( fields[ i ].getName(), fields[ i ].get( this ) );
245             }
246             catch( IllegalAccessException JavaDoc illegalAccessException )
247             {
248                 illegalAccessException.printStackTrace();
249             }
250         }
251
252         htmlGenerator.propertiesTableEnd();
253     }
254
255
256 }
257
Popular Tags