1 39 40 package org.krysalis.jcharts.properties; 41 42 43 import org.krysalis.jcharts.chartData.interfaces.IAxisPlotDataSet; 44 import org.krysalis.jcharts.test.HTMLGenerator; 45 46 import java.awt.*; 47 import java.awt.geom.Ellipse2D ; 48 import java.awt.geom.Rectangle2D ; 49 50 51 final public class PointChartProperties extends AxisChartTypeProperties 52 { 53 public final static Stroke DEFAULT_POINT_BORDER_STROKE = new BasicStroke( 1.0f ); 54 55 public final static Shape SHAPE_SQUARE = new Rectangle2D.Double ( 0, 0, 10, 10 ); 56 public final static Shape SHAPE_TRIANGLE = new Polygon( new int[]{0, 5, 10}, new int[]{10, 0, 10}, 3 ); 57 public final static Shape SHAPE_CIRCLE = new Ellipse2D.Double ( 0, 0, 10, 10 ); 58 public final static Shape SHAPE_DIAMOND = new Polygon( new int[]{0, 5, 10, 5}, new int[]{5, 0, 5, 10}, 4 ); 59 60 61 private Shape[] shapes; 62 private boolean[] fillPointFlags; 63 private Paint[] outlinePaints; 64 65 66 77 public PointChartProperties( Shape[] shapes, boolean[] fillPointFlags, Paint[] outlinePaints ) 78 { 79 this.shapes = shapes; 80 this.fillPointFlags = fillPointFlags; 81 this.outlinePaints = outlinePaints; 82 } 83 84 85 89 public boolean getFillPointsFlag( int index ) 90 { 91 return this.fillPointFlags[ index ]; 92 } 93 94 95 101 public Paint getPointOutlinePaints( int index ) 102 { 103 return this.outlinePaints[ index ]; 104 } 105 106 107 112 public Shape getShape( int index ) 113 { 114 return this.shapes[ index ]; 115 } 116 117 118 123 public void toHTML( HTMLGenerator htmlGenerator ) 124 { 125 htmlGenerator.propertiesTableStart( "PointChartProperties" ); 126 htmlGenerator.propertiesTableEnd(); 128 } 129 130 131 137 public void validate( IAxisPlotDataSet iAxisPlotDataSet ) throws PropertyException 138 { 139 if( iAxisPlotDataSet.getNumberOfDataSets() != this.shapes.length ) 140 { 141 throw new PropertyException( "<PointChartProperties> There must be a Shape implementation for each data set." ); 142 } 143 144 if( this.shapes.length != fillPointFlags.length ) 145 { 146 throw new PropertyException( "<PointChartProperties> There is NOT an one to one mapping between 'fillPointsFlags' and Shapes" ); 147 } 148 149 150 if( this.shapes.length != outlinePaints.length ) 151 { 152 throw new PropertyException( "<PointChartProperties> There is NOT an one to one mapping between 'outlinePaints' and Shapes" ); 153 } 154 } 155 156 } 157 | Popular Tags |