KickJava   Java API By Example, From Geeks To Geeks.

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


1 /***********************************************************************************************
2  * File Info: $Id: ChartProperties.java,v 1.2 2003/05/18 18:06:04 nathaniel_auvil Exp $
3  * Copyright (C) 2002
4  * Author: 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 package org.krysalis.jcharts.properties;
41
42
43 import org.krysalis.jcharts.properties.util.ChartFont;
44 import org.krysalis.jcharts.test.HTMLGenerator;
45 import org.krysalis.jcharts.test.HTMLTestable;
46
47 import java.lang.reflect.Field JavaDoc;
48
49
50 public class ChartProperties extends AreaProperties implements HTMLTestable
51 {
52     public ChartFont titleChartFont = ChartFont.DEFAULT_CHART_TITLE;
53
54     //---number of pixels between the chart title and the plotted chart
55
private float titlePadding = 5f;
56
57     //---flag allows you to toggle validations to spare extra CPU cycles after development is over.
58
private boolean validate = true;
59
60     private boolean useAntiAliasing= true;
61
62
63     /******************************************************************************************
64      *
65      * @return ChartFont
66      ******************************************************************************************/

67     public ChartFont getTitleFont()
68     {
69         return this.titleChartFont;
70     }
71
72
73     public void setTitleFont( ChartFont titleFont )
74     {
75         this.titleChartFont = titleFont;
76     }
77
78
79     /******************************************************************************************
80      * Returns the number of pixels between the Chart Title and the axis plot area
81      *
82      * @return float
83      ******************************************************************************************/

84     public float getTitlePadding()
85     {
86         return this.titlePadding;
87     }
88
89
90     public void setTitlePadding( float pixels )
91     {
92         this.titlePadding = pixels;
93     }
94
95
96     /******************************************************************************************
97      *
98      * @return boolean
99      * @since 0.7.0
100      ******************************************************************************************/

101     public boolean validate()
102     {
103         return validate;
104     }
105
106
107     /******************************************************************************************
108      * Toggles the validation of data and properties for the charts. This should be false for
109      * production systems as it will run slightly faster. Anything for speed, right? ;)
110      *
111      * @param validate
112      * @since 0.7.0
113      ******************************************************************************************/

114     public void setValidate( boolean validate )
115     {
116         this.validate = validate;
117     }
118
119
120     /*****************************************************************************************
121      *
122      * @return boolean
123      * @since 1.0.0
124      ****************************************************************************************/

125     public boolean useAntiAliasing()
126     {
127         return useAntiAliasing;
128     }
129
130
131     /*****************************************************************************************
132      * Sets flag on whether the charts will render with Anti-Aliasing enabled. If you are
133      * embeding a chart image in a PDF file, you should set this to 'false' to get a
134      * 'cleaner' image.
135      *
136      * @param useAntiAliasing
137      * @since 1.0.0
138      ****************************************************************************************/

139     public void setUseAntiAliasing( boolean useAntiAliasing )
140     {
141         this.useAntiAliasing = useAntiAliasing;
142     }
143
144
145     /*********************************************************************************************
146      * Enables the testing routines to display the contents of this Object.
147      *
148      * @param htmlGenerator
149      **********************************************************************************************/

150     public void toHTML( HTMLGenerator htmlGenerator )
151     {
152         htmlGenerator.propertiesTableStart( this.getClass().getName() );
153         super.toHTML( htmlGenerator );
154
155         Field JavaDoc[] fields = this.getClass().getDeclaredFields();
156         for( int i = 0; i < fields.length; i++ )
157         {
158             try
159             {
160                 htmlGenerator.addField( fields[ i ].getName(), fields[ i ].get( this ) );
161             }
162             catch( IllegalAccessException JavaDoc illegalAccessException )
163             {
164                 illegalAccessException.printStackTrace();
165             }
166         }
167
168         htmlGenerator.propertiesTableEnd();
169
170
171 /*
172
173         super.toHTML( htmlGenerator );
174         htmlGenerator.addTableRow( "ChartProperties-Title Padding", Float.toString( this.getTitlePadding() ) );
175         htmlGenerator.addTableRow( "ChartProperties-Title Font", this.getTitleFont() );
176         htmlGenerator.addTableRow( "ChartProperties-Title Paint", this.getTitlePaint() );
177         htmlGenerator.addTableRow( "ChartProperties-Title Paint", this.getTitlePaint() );
178 */

179     }
180
181 }
182
Popular Tags