KickJava   Java API By Example, From Geeks To Geeks.

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


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

34
35 package org.krysalis.jcharts.properties;
36
37
38 import org.krysalis.jcharts.Chart;
39 import org.krysalis.jcharts.properties.util.ChartFont;
40 import org.krysalis.jcharts.properties.util.ChartStroke;
41 import org.krysalis.jcharts.test.HTMLGenerator;
42 import org.krysalis.jcharts.test.HTMLTestable;
43 import org.krysalis.jcharts.types.PieLabelType;
44
45
46 /*************************************************************************************
47  *
48  * @author Nathaniel Auvil
49  * @version $Id: PieChart2DProperties.java,v 1.4 2004/05/31 16:31:07 nathaniel_auvil Exp $
50  ************************************************************************************/

51 public class PieChart2DProperties extends ChartTypeProperties implements HTMLTestable
52 {
53 /*
54     public static final Paint DEFAULT_BORDER_PAINT = Color.black;
55     public static final Stroke DEFAULT_BORDER_STROKE = new BasicStroke( 1.5f, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_ROUND );
56
57     private Paint borderPaint = DEFAULT_BORDER_PAINT;
58     private Stroke borderStroke = DEFAULT_BORDER_STROKE;
59 */

60
61     private ChartStroke borderChartStroke= ChartStroke.DEFAULT_PIE_OUTLINE;
62
63
64     //---draw a twenty degrees by default.
65
private float zeroDegreeOffset = 20.0f;
66
67     private PieLabelType pieLabelType = PieLabelType.NO_LABELS;
68     private boolean isCurrency = false;
69     private boolean showGrouping = false;
70     private int roundingPowerOfTen = 0;
71     private ChartFont valueLabelFont = ChartFont.DEFAULT_PIE_VALUE;
72     private float tickLength = 5;
73
74
75     /*********************************************************************************************
76      *
77      **********************************************************************************************/

78     public PieChart2DProperties()
79     {
80         super();
81     }
82
83
84     /*********************************************************************************************
85      * The offset from zero degrees which the first slice of pie is drawn. Charts look better to
86      * my eye when they do not start at zero degrees, but beauty is in the eye of the beholder.
87      *
88      * @param zeroDegreeOffset
89      **********************************************************************************************/

90     public void setZeroDegreeOffset( float zeroDegreeOffset )
91     {
92         this.zeroDegreeOffset = zeroDegreeOffset;
93     }
94
95
96     /*********************************************************************************************
97      *
98      * @return double
99      **********************************************************************************************/

100     public float getZeroDegreeOffset()
101     {
102         return this.zeroDegreeOffset;
103     }
104
105
106     public ChartStroke getBorderChartStroke()
107     {
108         return borderChartStroke;
109     }
110
111
112     public void setBorderChartStroke( ChartStroke borderChartStroke )
113     {
114         this.borderChartStroke = borderChartStroke;
115     }
116
117
118     /*****************************************************************************
119      *
120      *****************************************************************************/

121     public PieLabelType getPieLabelType()
122     {
123         return pieLabelType;
124     }
125
126
127     /****************************************************************************
128      * Sets the type of label to draw on the PieChart. The default value is:
129      * PieLabelType.NO_LABELS so no labels will be drawn on chart.
130      *
131      * @param pieLabelType
132      ***************************************************************************/

133     public void setPieLabelType( PieLabelType pieLabelType )
134     {
135         this.pieLabelType = pieLabelType;
136     }
137
138
139     public ChartFont getValueLabelFont()
140     {
141         return valueLabelFont;
142     }
143
144
145     /*****************************************************************************
146      * Sets the ChartFont used to draw the chart value labels.
147      *
148      * @param valueLabelFont
149      *****************************************************************************/

150     public void setValueLabelFont( ChartFont valueLabelFont )
151     {
152         this.valueLabelFont = valueLabelFont;
153     }
154
155
156     public void setCurrency( boolean currency )
157     {
158         isCurrency = currency;
159     }
160
161
162     public void setShowGrouping( boolean showGrouping )
163     {
164         this.showGrouping = showGrouping;
165     }
166
167
168     public void setRoundingPowerOfTen( int roundingPowerOfTen )
169     {
170         this.roundingPowerOfTen = roundingPowerOfTen;
171     }
172
173
174     public void setTickLength( float tickLength )
175     {
176         this.tickLength = tickLength;
177     }
178
179
180     public float getTickLength()
181     {
182         return tickLength;
183     }
184
185
186     public boolean showValueLabelCurrency()
187     {
188         return isCurrency;
189     }
190
191
192     public boolean showValueLabelGrouping()
193     {
194         return showGrouping;
195     }
196
197
198     public int getValueLabelRoundingPowerOfTen()
199     {
200         return roundingPowerOfTen;
201     }
202
203
204     /*********************************************************************************************
205      * Enables the testing routines to display the contents of this Object.
206      *
207      * @param htmlGenerator
208      **********************************************************************************************/

209     public void toHTML( HTMLGenerator htmlGenerator )
210     {
211         htmlGenerator.propertiesTableStart( "PieChart2DProperties" );
212         htmlGenerator.addTableRow( "Zero Degree Offset", Double.toString( this.getZeroDegreeOffset() ) );
213         htmlGenerator.addTableRow( "Border Chart Stroke", this.getBorderChartStroke() );
214         htmlGenerator.addTableRow( "Label Type", this.pieLabelType );
215         htmlGenerator.propertiesTableEnd();
216     }
217
218
219     /******************************************************************************************
220      * Validates the properties.
221      *
222      * @param chart
223      * @throws PropertyException
224      *****************************************************************************************/

225     public void validate( Chart chart ) throws PropertyException
226     {
227 //TODO
228
}
229
230 }
231
Popular Tags