KickJava   Java API By Example, From Geeks To Geeks.

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


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.test.HTMLGenerator;
39 import org.krysalis.jcharts.test.HTMLTestable;
40 import org.krysalis.jcharts.properties.util.ChartStroke;
41 import org.krysalis.jcharts.properties.util.ChartFont;
42
43 import java.awt.*;
44
45
46 /*************************************************************************************
47  *
48  * @author Nathaniel Auvil, Sandor Dornbush
49  * @version $Id: LegendProperties.java,v 1.3 2003/07/05 13:23:50 nathaniel_auvil Exp $
50  ************************************************************************************/

51 public class LegendProperties extends LegendAreaProperties implements HTMLTestable
52 {
53     public static final Font DEFAULT_FONT = new Font( "Serif", Font.PLAIN, 12 );
54     public static final Paint DEFAULT_FONT_PAINT = Color.black;
55     public static final Stroke DEFAULT_ICON_BORDER_STROKE = new BasicStroke( 1.0f );
56     public static final Paint DEFAULT_ICON_BORDER_PAINT = Color.black;
57
58     private ChartFont font = ChartFont.DEFAULT_LEGEND;
59
60     private Paint iconBorderPaint = DEFAULT_ICON_BORDER_PAINT;
61     private Stroke iconBorderStroke = DEFAULT_ICON_BORDER_STROKE;
62     private Dimension size = null;
63
64
65     /*********************************************************************************************
66      *
67      **********************************************************************************************/

68     public LegendProperties()
69     {
70         super();
71
72         //---Legend background should be transparent by default.
73
super.setBackgroundPaint( null );
74
75         super.setBorderStroke( ChartStroke.DEFAULT_LEGEND_OUTLINE );
76     }
77
78
79     /*********************************************************************************************
80      * Sets the Font used by the Legend.
81      *
82      * @param legendFont
83      **********************************************************************************************/

84     public void setChartFont( ChartFont legendFont )
85     {
86         this.font = legendFont;
87     }
88
89
90     /*********************************************************************************************
91      * Returns the Font used by the Legend.
92      *
93      * @return ChartFont
94      **********************************************************************************************/

95     public ChartFont getChartFont()
96     {
97         return this.font;
98     }
99
100
101     /*********************************************************************************************
102      * Sets the Icon border color used by the Legend. If NULL is passed, there will be no border.
103      *
104      * @param iconBorderPaint
105      **********************************************************************************************/

106     public void setIconBorderPaint( Paint iconBorderPaint )
107     {
108         this.iconBorderPaint = iconBorderPaint;
109     }
110
111
112     /*********************************************************************************************
113      * Returns the Icon border Color used by the Legend.
114      *
115      * @return Paint
116      **********************************************************************************************/

117     public Paint getIconBorderPaint()
118     {
119         return this.iconBorderPaint;
120     }
121
122
123     /*********************************************************************************************
124      * Sets the icon border Stroke. If NULL is passed, there will be no border.
125      *
126      * @param stroke
127      **********************************************************************************************/

128     public void setIconBorderStroke( Stroke stroke )
129     {
130         this.iconBorderStroke = stroke;
131     }
132
133
134     /*********************************************************************************************
135      * Returns the icon border Stroke
136      *
137      * @return Stroke
138      **********************************************************************************************/

139     public Stroke getIconBorderStroke()
140     {
141         return this.iconBorderStroke;
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( "LegendProperties" );
153         super.toHTML( htmlGenerator );
154         htmlGenerator.addTableRow( "Icon Border Paint", this.getIconBorderPaint() );
155         htmlGenerator.addTableRow( "Icon Border Stroke", this.getIconBorderStroke() );
156         htmlGenerator.addTableRow( "Chart Font", this.getChartFont() );
157         htmlGenerator.propertiesTableEnd();
158     }
159
160
161     /** Getter for property size.
162      * @return Value of property size.
163      *
164      */

165     public java.awt.Dimension JavaDoc getSize()
166     {
167         return this.size;
168     }
169
170
171     /** Setter for property size.
172      * @param size New value of property size.
173      *
174      */

175     public void setSize( java.awt.Dimension JavaDoc size )
176     {
177         this.size = size;
178     }
179
180 }
181
Popular Tags