001: /***********************************************************************************************
002: * Copyright 2002 (C) Nathaniel G. Auvil. All Rights Reserved.
003: *
004: * Redistribution and use of this software and associated documentation ("Software"), with or
005: * without modification, are permitted provided that the following conditions are met:
006: *
007: * 1. Redistributions of source code must retain copyright statements and notices.
008: * Redistributions must also contain a copy of this document.
009: *
010: * 2. Redistributions in binary form must reproduce the above copyright notice, this list of
011: * conditions and the following disclaimer in the documentation and/or other materials
012: * provided with the distribution.
013: *
014: * 3. The name "jCharts" or "Nathaniel G. Auvil" must not be used to endorse or promote
015: * products derived from this Software without prior written permission of Nathaniel G.
016: * Auvil. For written permission, please contact nathaniel_auvil@users.sourceforge.net
017: *
018: * 4. Products derived from this Software may not be called "jCharts" nor may "jCharts" appear
019: * in their names without prior written permission of Nathaniel G. Auvil. jCharts is a
020: * registered trademark of Nathaniel G. Auvil.
021: *
022: * 5. Due credit should be given to the jCharts Project (http://jcharts.sourceforge.net/).
023: *
024: * THIS SOFTWARE IS PROVIDED BY Nathaniel G. Auvil AND CONTRIBUTORS ``AS IS'' AND ANY
025: * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
026: * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
027: * jCharts OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
028: * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
029: * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
030: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,STRICT LIABILITY, OR TORT
031: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
032: * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
033: ************************************************************************************************/package org.krysalis.jcharts.properties;
034:
035: import org.krysalis.jcharts.Chart;
036: import org.krysalis.jcharts.properties.util.ChartFont;
037: import org.krysalis.jcharts.properties.util.ChartStroke;
038: import org.krysalis.jcharts.test.HTMLGenerator;
039: import org.krysalis.jcharts.test.HTMLTestable;
040: import org.krysalis.jcharts.types.PieLabelType;
041:
042: /*************************************************************************************
043: *
044: * @author Nathaniel Auvil
045: * @version $Id: PieChart2DProperties.java,v 1.4 2004/05/31 16:31:07 nathaniel_auvil Exp $
046: ************************************************************************************/
047: public class PieChart2DProperties extends ChartTypeProperties implements
048: HTMLTestable {
049: /*
050: public static final Paint DEFAULT_BORDER_PAINT = Color.black;
051: public static final Stroke DEFAULT_BORDER_STROKE = new BasicStroke( 1.5f, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_ROUND );
052:
053: private Paint borderPaint = DEFAULT_BORDER_PAINT;
054: private Stroke borderStroke = DEFAULT_BORDER_STROKE;
055: */
056:
057: private ChartStroke borderChartStroke = ChartStroke.DEFAULT_PIE_OUTLINE;
058:
059: //---draw a twenty degrees by default.
060: private float zeroDegreeOffset = 20.0f;
061:
062: private PieLabelType pieLabelType = PieLabelType.NO_LABELS;
063: private boolean isCurrency = false;
064: private boolean showGrouping = false;
065: private int roundingPowerOfTen = 0;
066: private ChartFont valueLabelFont = ChartFont.DEFAULT_PIE_VALUE;
067: private float tickLength = 5;
068:
069: /*********************************************************************************************
070: *
071: **********************************************************************************************/
072: public PieChart2DProperties() {
073: super ();
074: }
075:
076: /*********************************************************************************************
077: * The offset from zero degrees which the first slice of pie is drawn. Charts look better to
078: * my eye when they do not start at zero degrees, but beauty is in the eye of the beholder.
079: *
080: * @param zeroDegreeOffset
081: **********************************************************************************************/
082: public void setZeroDegreeOffset(float zeroDegreeOffset) {
083: this .zeroDegreeOffset = zeroDegreeOffset;
084: }
085:
086: /*********************************************************************************************
087: *
088: * @return double
089: **********************************************************************************************/
090: public float getZeroDegreeOffset() {
091: return this .zeroDegreeOffset;
092: }
093:
094: public ChartStroke getBorderChartStroke() {
095: return borderChartStroke;
096: }
097:
098: public void setBorderChartStroke(ChartStroke borderChartStroke) {
099: this .borderChartStroke = borderChartStroke;
100: }
101:
102: /*****************************************************************************
103: *
104: *****************************************************************************/
105: public PieLabelType getPieLabelType() {
106: return pieLabelType;
107: }
108:
109: /****************************************************************************
110: * Sets the type of label to draw on the PieChart. The default value is:
111: * PieLabelType.NO_LABELS so no labels will be drawn on chart.
112: *
113: * @param pieLabelType
114: ***************************************************************************/
115: public void setPieLabelType(PieLabelType pieLabelType) {
116: this .pieLabelType = pieLabelType;
117: }
118:
119: public ChartFont getValueLabelFont() {
120: return valueLabelFont;
121: }
122:
123: /*****************************************************************************
124: * Sets the ChartFont used to draw the chart value labels.
125: *
126: * @param valueLabelFont
127: *****************************************************************************/
128: public void setValueLabelFont(ChartFont valueLabelFont) {
129: this .valueLabelFont = valueLabelFont;
130: }
131:
132: public void setCurrency(boolean currency) {
133: isCurrency = currency;
134: }
135:
136: public void setShowGrouping(boolean showGrouping) {
137: this .showGrouping = showGrouping;
138: }
139:
140: public void setRoundingPowerOfTen(int roundingPowerOfTen) {
141: this .roundingPowerOfTen = roundingPowerOfTen;
142: }
143:
144: public void setTickLength(float tickLength) {
145: this .tickLength = tickLength;
146: }
147:
148: public float getTickLength() {
149: return tickLength;
150: }
151:
152: public boolean showValueLabelCurrency() {
153: return isCurrency;
154: }
155:
156: public boolean showValueLabelGrouping() {
157: return showGrouping;
158: }
159:
160: public int getValueLabelRoundingPowerOfTen() {
161: return roundingPowerOfTen;
162: }
163:
164: /*********************************************************************************************
165: * Enables the testing routines to display the contents of this Object.
166: *
167: * @param htmlGenerator
168: **********************************************************************************************/
169: public void toHTML(HTMLGenerator htmlGenerator) {
170: htmlGenerator.propertiesTableStart("PieChart2DProperties");
171: htmlGenerator.addTableRow("Zero Degree Offset", Double
172: .toString(this .getZeroDegreeOffset()));
173: htmlGenerator.addTableRow("Border Chart Stroke", this
174: .getBorderChartStroke());
175: htmlGenerator.addTableRow("Label Type", this .pieLabelType);
176: htmlGenerator.propertiesTableEnd();
177: }
178:
179: /******************************************************************************************
180: * Validates the properties.
181: *
182: * @param chart
183: * @throws PropertyException
184: *****************************************************************************************/
185: public void validate(Chart chart) throws PropertyException {
186: //TODO
187: }
188:
189: }
|