001: /***********************************************************************************************
002: * File Info: $Id: PointChartProperties.java,v 1.1 2003/05/17 17:00:36 nathaniel_auvil Exp $
003: * Copyright (C) 2002
004: * Author: 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.chartData.interfaces.IAxisPlotDataSet;
041: import org.krysalis.jcharts.test.HTMLGenerator;
042:
043: import java.awt.*;
044: import java.awt.geom.Ellipse2D;
045: import java.awt.geom.Rectangle2D;
046:
047: final public class PointChartProperties extends AxisChartTypeProperties {
048: public final static Stroke DEFAULT_POINT_BORDER_STROKE = new BasicStroke(
049: 1.0f);
050:
051: public final static Shape SHAPE_SQUARE = new Rectangle2D.Double(0,
052: 0, 10, 10);
053: public final static Shape SHAPE_TRIANGLE = new Polygon(new int[] {
054: 0, 5, 10 }, new int[] { 10, 0, 10 }, 3);
055: public final static Shape SHAPE_CIRCLE = new Ellipse2D.Double(0, 0,
056: 10, 10);
057: public final static Shape SHAPE_DIAMOND = new Polygon(new int[] {
058: 0, 5, 10, 5 }, new int[] { 5, 0, 5, 10 }, 4);
059:
060: private Shape[] shapes;
061: private boolean[] fillPointFlags;
062: private Paint[] outlinePaints;
063:
064: /***************************************************************************************************
065: * Constructor
066: *
067: * @param shapes the Shapes to use for each DataSet drawn in this chart. There must
068: * be an one to one mapping of Shape objects and DataSets in the chart.
069: * @param fillPointFlags flags indicating whether to fill the point Shapes or to only outline them
070: * using the Paint specified on the DataSet object. If this is set to TRUE, the 'outlinePaint'
071: * attribute can be used to outline the Shape.
072: * @param outlinePaints Sets the outline Paint to use for each Shape in the chart. This Paint is
073: * only used if the 'setFillPointsFlag' is set to TRUE for the Shape.
074: **************************************************************************************************/
075: public PointChartProperties(Shape[] shapes,
076: boolean[] fillPointFlags, Paint[] outlinePaints) {
077: this .shapes = shapes;
078: this .fillPointFlags = fillPointFlags;
079: this .outlinePaints = outlinePaints;
080: }
081:
082: /**********************************************************************************************
083: *
084: *
085: ***********************************************************************************************/
086: public boolean getFillPointsFlag(int index) {
087: return this .fillPointFlags[index];
088: }
089:
090: /**********************************************************************************************
091: *
092: *
093: * @param index
094: * @return Paint
095: ***********************************************************************************************/
096: public Paint getPointOutlinePaints(int index) {
097: return this .outlinePaints[index];
098: }
099:
100: /**********************************************************************************************
101: *
102: * @param index
103: * @return Shape
104: ***********************************************************************************************/
105: public Shape getShape(int index) {
106: return this .shapes[index];
107: }
108:
109: /*********************************************************************************************
110: * Enables the testing routines to display the contents of this Object.
111: *
112: * @param htmlGenerator
113: **********************************************************************************************/
114: public void toHTML(HTMLGenerator htmlGenerator) {
115: htmlGenerator.propertiesTableStart("PointChartProperties");
116: //htmlGenerator.addTableRow( "Zero Degree Offset", Double.toString( this.getZeroDegreeOffset() ) );
117: htmlGenerator.propertiesTableEnd();
118: }
119:
120: /******************************************************************************************
121: * Validates the properties.
122: *
123: * @param iAxisPlotDataSet
124: * @throws PropertyException
125: *****************************************************************************************/
126: public void validate(IAxisPlotDataSet iAxisPlotDataSet)
127: throws PropertyException {
128: if (iAxisPlotDataSet.getNumberOfDataSets() != this .shapes.length) {
129: throw new PropertyException(
130: "<PointChartProperties> There must be a Shape implementation for each data set.");
131: }
132:
133: if (this .shapes.length != fillPointFlags.length) {
134: throw new PropertyException(
135: "<PointChartProperties> There is NOT an one to one mapping between 'fillPointsFlags' and Shapes");
136: }
137:
138: if (this .shapes.length != outlinePaints.length) {
139: throw new PropertyException(
140: "<PointChartProperties> There is NOT an one to one mapping between 'outlinePaints' and Shapes");
141: }
142: }
143:
144: }
|