001: /***********************************************************************************************
002: * File Info: $Id: DataAxisProperties.java,v 1.1 2003/05/17 17:00:34 nathaniel_auvil Exp $
003: * Copyright (C) 2002
004: * Author: John Thomson, Nathaniel G. Auvil
005: * Contributor(s):
006: *
007: * Copyright 2002 (C) Nathaniel G. Auvil. All Rights Reserved.
008: *
009: * Redistribution and use of this software and associated documentation ("Software"), with or
010: * without modification, are permitted provided that the following conditions are met:
011: *
012: * 1. Redistributions of source code must retain copyright statements and notices.
013: * Redistributions must also contain a copy of this document.
014: *
015: * 2. Redistributions in binary form must reproduce the above copyright notice, this list of
016: * conditions and the following disclaimer in the documentation and/or other materials
017: * provided with the distribution.
018: *
019: * 3. The name "jCharts" or "Nathaniel G. Auvil" must not be used to endorse or promote
020: * products derived from this Software without prior written permission of Nathaniel G.
021: * Auvil. For written permission, please contact nathaniel_auvil@users.sourceforge.net
022: *
023: * 4. Products derived from this Software may not be called "jCharts" nor may "jCharts" appear
024: * in their names without prior written permission of Nathaniel G. Auvil. jCharts is a
025: * registered trademark of Nathaniel G. Auvil.
026: *
027: * 5. Due credit should be given to the jCharts Project (http://jcharts.sourceforge.net/).
028: *
029: * THIS SOFTWARE IS PROVIDED BY Nathaniel G. Auvil AND CONTRIBUTORS ``AS IS'' AND ANY
030: * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
031: * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
032: * jCharts OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
033: * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
034: * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
035: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,STRICT LIABILITY, OR TORT
036: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
037: * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
038: ************************************************************************************************/package org.krysalis.jcharts.properties;
039:
040: import org.krysalis.jcharts.test.HTMLGenerator;
041: import org.krysalis.jcharts.test.HTMLTestable;
042: import org.krysalis.jcharts.properties.util.ChartStroke;
043: import org.krysalis.jcharts.axisChart.axis.scale.ScaleCalculator;
044:
045: import java.lang.reflect.Field;
046:
047: public final class DataAxisProperties extends LabelAxisProperties
048: implements HTMLTestable {
049: //---round to nearest power of ten. 2==100, -3=.001
050: private int roundToNearest = 0;
051:
052: private boolean showZeroLine = true;
053: private ChartStroke zeroLineChartStroke = ChartStroke.DEFAULT_ZERO_LINE;
054:
055: //---user defined scale
056: private boolean userDefinedScale = false;
057: private double userDefinedMinimumValue;
058: private double userDefinedIncrement;
059:
060: //---number of items visible on the axis
061: private int numItems = 5;
062:
063: private boolean useDollarSigns = false;
064: private boolean useCommas = true;
065: private boolean usePercentSigns = false;
066:
067: //---holds data relevant to values displayed on the axis. may be null
068: private ScaleCalculator scaleCalculator;
069:
070: /***********************************************************************************************
071: *
072: ************************************************************************************************/
073: public DataAxisProperties() {
074: super ();
075: }
076:
077: /****************************************************************************************
078: *
079: * @param axisMinimum
080: * @param axisIncrement
081: * @throws PropertyException
082: **************************************************************************************/
083: public void setUserDefinedScale(double axisMinimum,
084: double axisIncrement) throws PropertyException {
085: if (axisIncrement <= 0) {
086: throw new PropertyException(
087: "The Axis Increment can not be a negative value or zero.");
088: }
089:
090: this .userDefinedScale = true;
091: this .userDefinedMinimumValue = axisMinimum;
092: this .userDefinedIncrement = axisIncrement;
093: }
094:
095: public int getRoundToNearest() {
096: return roundToNearest;
097: }
098:
099: public void setRoundToNearest(int roundToNearest) {
100: this .roundToNearest = roundToNearest;
101: }
102:
103: public boolean showZeroLine() {
104: return showZeroLine;
105: }
106:
107: public void setShowZeroLine(boolean showZeroLine) {
108: this .showZeroLine = showZeroLine;
109: }
110:
111: public ChartStroke getZeroLineChartStroke() {
112: return this .zeroLineChartStroke;
113: }
114:
115: public void setZeroLineChartStroke(ChartStroke zeroLine) {
116: this .zeroLineChartStroke = zeroLine;
117: }
118:
119: public boolean hasUserDefinedScale() {
120: return userDefinedScale;
121: }
122:
123: public double getUserDefinedMinimumValue() {
124: return this .userDefinedMinimumValue;
125: }
126:
127: public double getUserDefinedIncrement() {
128: return this .userDefinedIncrement;
129: }
130:
131: public int getNumItems() {
132: return numItems;
133: }
134:
135: public void setNumItems(int numItems) {
136: this .numItems = numItems;
137: }
138:
139: public boolean useDollarSigns() {
140: return useDollarSigns;
141: }
142:
143: public void setUseDollarSigns(boolean useDollarSigns) {
144: this .useDollarSigns = useDollarSigns;
145: }
146:
147: public boolean useCommas() {
148: return useCommas;
149: }
150:
151: public void setUseCommas(boolean useCommas) {
152: this .useCommas = useCommas;
153: }
154:
155: public boolean usePercentSigns() {
156: return usePercentSigns;
157: }
158:
159: public void setUsePercentSigns(boolean usePercentSigns) {
160: this .usePercentSigns = usePercentSigns;
161: }
162:
163: public ScaleCalculator getScaleCalculator() {
164: return scaleCalculator;
165: }
166:
167: /******************************************************************************************
168: * You do not have to explicitly set a ScaleCalculator implementation as jCharts will
169: * create one, but if you do not like the way Scale ranges are created, you could
170: * create your own implementation of ScaleCalculator and jCharts will use it!
171: *
172: * @param scaleCalculator
173: ******************************************************************************************/
174: public void setScaleCalculator(ScaleCalculator scaleCalculator) {
175: this .scaleCalculator = scaleCalculator;
176: }
177:
178: /*********************************************************************************************
179: * Enables the testing routines to display the contents of this Object.
180: *
181: * @param htmlGenerator
182: **********************************************************************************************/
183: public void toHTML(HTMLGenerator htmlGenerator) {
184: htmlGenerator.propertiesTableStart(DataAxisProperties.class
185: .getName());
186: //super.toHTML( htmlGenerator );
187:
188: Field[] fields = this .getClass().getDeclaredFields();
189: for (int i = 0; i < fields.length; i++) {
190: try {
191: htmlGenerator.addField(fields[i].getName(), fields[i]
192: .get(this ));
193: } catch (IllegalAccessException illegalAccessException) {
194: illegalAccessException.printStackTrace();
195: }
196: }
197:
198: htmlGenerator.propertiesTableEnd();
199: }
200:
201: }
|