1 39 40 package org.krysalis.jcharts.chartData; 41 42 43 import org.krysalis.jcharts.chartData.interfaces.IAxisDataSeries; 44 import org.krysalis.jcharts.chartData.interfaces.IAxisPlotDataSet; 45 import org.krysalis.jcharts.test.HTMLGenerator; 46 import org.krysalis.jcharts.test.HTMLTestable; 47 import org.krysalis.jcharts.types.ChartType; 48 import org.krysalis.jcharts.properties.PropertyException; 49 50 import java.util.Iterator ; 51 import java.util.HashMap ; 52 53 54 58 public abstract class AxisDataSeries implements IAxisDataSeries, HTMLTestable 59 { 60 private String chartTitle; 61 private String xAxisTitle; 62 private String yAxisTitle; 63 protected HashMap dataSets; 64 65 protected int totalNumberOfDataSets; 66 private int sizeOfEachDataSet; 67 68 69 76 public AxisDataSeries( String xAxisTitle, String yAxisTitle, String chartTitle ) 77 { 78 this.xAxisTitle=xAxisTitle; 79 this.yAxisTitle=yAxisTitle; 80 this.chartTitle=chartTitle; 81 dataSets = new HashMap (); 82 } 83 84 85 90 public String getXAxisTitle() 91 { 92 return this.xAxisTitle; 93 } 94 95 96 101 public String getYAxisTitle() 102 { 103 return this.yAxisTitle; 104 } 105 106 107 112 public String getChartTitle() 113 { 114 return this.chartTitle; 115 } 116 117 118 125 public IAxisPlotDataSet getIAxisPlotDataSet( ChartType chartType ) 126 { 127 return (IAxisPlotDataSet) this.dataSets.get( chartType ); 128 } 129 130 131 136 public Iterator getIAxisPlotDataSetIterator() 137 { 138 return this.dataSets.values().iterator(); 139 } 140 141 142 150 public int getTotalNumberOfDataSets() 151 { 152 return this.totalNumberOfDataSets; 153 } 154 155 156 161 public void addIAxisPlotDataSet( IAxisPlotDataSet iAxisPlotDataSet ) 162 { 163 this.dataSets.put( iAxisPlotDataSet.getChartType(), iAxisPlotDataSet ); 164 165 totalNumberOfDataSets+=iAxisPlotDataSet.getNumberOfDataSets(); 167 168 this.sizeOfEachDataSet= iAxisPlotDataSet.getNumberOfDataItems(); 169 } 170 171 172 177 public void validate() throws ChartDataException, PropertyException 178 { 179 IAxisPlotDataSet iAxisPlotDataSet; 180 Iterator iterator= this.getIAxisPlotDataSetIterator(); 181 182 while( iterator.hasNext() ) 183 { 184 iAxisPlotDataSet= (IAxisPlotDataSet) iterator.next(); 185 iAxisPlotDataSet.validate(); 186 187 if( iAxisPlotDataSet.getNumberOfDataItems() != this.sizeOfEachDataSet ) 188 { 189 throw new ChartDataException( "All IAxisPlotDataSet implementations must contain an equal number of elements in a Combo Chart" ); 190 } 191 } 192 } 193 194 195 202 public int getSizeOfEachDataSet() 203 { 204 return sizeOfEachDataSet; 205 } 206 207 208 213 public void toHTML( HTMLGenerator htmlGenerator ) 214 { 215 htmlGenerator.propertiesTableRowStart(); 216 { 217 htmlGenerator.propertiesTableStart( this.getClass().getName() ); 218 htmlGenerator.addTableRow( "chart title", this.chartTitle ); 219 htmlGenerator.addTableRow( "xAxisTitle", this.xAxisTitle ); 220 htmlGenerator.addTableRow( "yAxisTitle", this.yAxisTitle ); 221 htmlGenerator.propertiesTableEnd(); 222 } 223 htmlGenerator.propertiesTableRowEnd(); 224 } 225 226 227 232 public int size() 233 { 234 return this.dataSets.size(); 235 } 236 237 } 238 | Popular Tags |