KickJava   Java API By Example, From Geeks To Geeks.

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


1 /***********************************************************************************************
2  * File Info: $Id: LegendAreaProperties.java,v 1.2 2003/06/01 05:23:05 staringindablu Exp $
3  * Copyright (C) 2002
4  * Author: Nathaniel G. Auvil
5  * Contributor(s): Sandor Dornbush
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
47
48 abstract public class LegendAreaProperties extends AreaProperties implements HTMLTestable
49 {
50     public static final int COLUMNS_AS_MANY_AS_NEEDED = 0;
51
52     //---This will wrap the legend to fit the image size.
53
public static final int COLUMNS_FIT_TO_IMAGE = -1;
54
55     public static final int BOTTOM = 0;
56     public static final int RIGHT = 1;
57    public static final int LEFT = 2;
58     public static final int TOP = 3;
59
60
61     private int numColumns = COLUMNS_AS_MANY_AS_NEEDED;
62
63     //---vertical padding between labels
64
private int rowPadding = 5;
65
66     //---horizontal padding between labels
67
private int columnPadding = 10;
68
69     //---padding between icon and Label
70
private int iconPadding = 5;
71
72     //---distance from edge of chart to Legend
73
private int chartPadding = 5;
74     
75     //---for LineCharts, length of line around point shapes as part of the icon in the legend.
76
//---for example, ---o---. here iconLineStrokeLength is the length of --- on either sides of 'o'
77
private int iconLineStrokeLength = 20;
78
79     //---where Legend should be drawn in relation to the chart.
80
private int placement = BOTTOM;
81
82
83     /*********************************************************************************************
84      * Constructor for those desiring auto-calculation of the Legend width based on the number
85      * of columns. All Labels are on a single row as default number of rows is: COLUMNS_AS_MANY_AS_NEEDED
86      *
87      **********************************************************************************************/

88     public LegendAreaProperties()
89     {
90         super();
91     }
92
93
94     /*********************************************************************************************
95      * Returns where the Legend should be drawn in relation to the Chart.
96      *
97      * @return int
98      **********************************************************************************************/

99     public int getPlacement()
100     {
101         return this.placement;
102     }
103
104
105     /*********************************************************************************************
106      * Sets where the Legend should be drawn in relation to the Chart.
107      *
108      * @param placementConstant
109      **********************************************************************************************/

110     public void setPlacement( int placementConstant )
111     {
112         this.placement = placementConstant;
113     }
114
115
116     /*********************************************************************************************
117      * Returns the padding between chart plot and the Legend.
118      *
119      * @return int
120      **********************************************************************************************/

121     public int getChartPadding()
122     {
123         return this.chartPadding;
124     }
125
126
127     /*********************************************************************************************
128      * Sets the padding between chart plot and the Legend.
129      *
130      * @param chartPadding
131      **********************************************************************************************/

132     public void setChartPadding( int chartPadding )
133     {
134         this.chartPadding = chartPadding;
135     }
136
137
138     /*********************************************************************************************
139      * Returns the padding between label columns.
140      *
141      * @return int
142      **********************************************************************************************/

143     public int getColumnPadding()
144     {
145         return this.columnPadding;
146     }
147
148
149     /*********************************************************************************************
150      * Returns the padding between labels in each row.
151      *
152      * @return int
153      **********************************************************************************************/

154     public int getRowPadding()
155     {
156         return this.rowPadding;
157     }
158
159
160     /*********************************************************************************************
161      * Sets the number of text columns the legend should display.
162      *
163      * @param numColumns
164      **********************************************************************************************/

165     public void setNumColumns( int numColumns )
166     {
167         this.numColumns = numColumns;
168     }
169
170
171     /*********************************************************************************************
172      * Gets the number of text columns the legend should display.
173      *
174      * @return int
175      **********************************************************************************************/

176     public int getNumColumns()
177     {
178         return this.numColumns;
179     }
180
181
182     /*********************************************************************************************
183      * Returns the padding between the icon and the Label
184      *
185      * @return int
186      **********************************************************************************************/

187     public int getIconPadding()
188     {
189         return this.iconPadding;
190     }
191
192
193     /*********************************************************************************************
194      * Sets the padding between labels in each row, in pixels.
195      *
196      * @param rowPadding
197      **********************************************************************************************/

198     public void setRowPadding( int rowPadding )
199     {
200         this.rowPadding = rowPadding;
201     }
202
203
204     /*********************************************************************************************
205      * Sets the padding between label columns, in pixels.
206      *
207      * @param columnPadding
208      **********************************************************************************************/

209     public void setColumnPadding( int columnPadding )
210     {
211         this.columnPadding = columnPadding;
212     }
213
214
215     /*********************************************************************************************
216      * Sets the padding between the icon and the Label, in pixels.
217      *
218      * @param iconPadding
219      **********************************************************************************************/

220     public void setIconPadding( int iconPadding )
221     {
222         this.iconPadding = iconPadding;
223     }
224
225
226     /**
227      * Returns the iconLineStrokeLength.
228      * @return int
229      */

230     public int getIconLineStrokeLength() {
231         return iconLineStrokeLength;
232     }
233
234     /**
235      * Sets the iconLineStrokeLength.
236      * @param iconLineStrokeLength The iconLineStrokeLength to set
237      */

238     public void setIconLineStrokeLength(int iconLineStrokeLength) {
239         this.iconLineStrokeLength = iconLineStrokeLength;
240     }
241
242
243     /*********************************************************************************************
244      * Enables the testing routines to display the contents of this Object.
245      *
246      * @param htmlGenerator
247      **********************************************************************************************/

248     public void toHTML( HTMLGenerator htmlGenerator )
249     {
250         super.toHTML( htmlGenerator );
251         htmlGenerator.addTableRow( "LegendAreaProperties->Num Columns", Integer.toString( this.getNumColumns() ) );
252         htmlGenerator.addTableRow( "LegendAreaProperties->Row Padding", Integer.toString( this.getRowPadding() ) );
253         htmlGenerator.addTableRow( "LegendAreaProperties->Icon Padding", Integer.toString( this.getIconPadding() ) );
254         htmlGenerator.addTableRow( "LegendAreaProperties->Chart Padding", Integer.toString( this.getChartPadding() ) );
255         htmlGenerator.addTableRow( "LegendAreaProperties->Column Padding", Integer.toString( this.getColumnPadding() ) );
256         htmlGenerator.addTableRow( "LegendAreaProperties->Placement", Integer.toString( this.getPlacement() ) );
257     }
258 }
259
Popular Tags