| 1 39 40 package org.krysalis.jcharts.chartData; 41 42 43 import org.krysalis.jcharts.chartData.interfaces.IDataSet; 44 import org.krysalis.jcharts.properties.ChartTypeProperties; 45 import org.krysalis.jcharts.test.HTMLGenerator; 46 import org.krysalis.jcharts.test.HTMLTestable; 47 48 import java.awt.*; 49 50 51 public class DataSet implements IDataSet, HTMLTestable 52 { 53 private ChartTypeProperties chartTypeProperties; 54 55 protected double[][] data; 56 protected String [] legendLabels; 57 protected Paint[] paints; 58 59 60 68 public DataSet( double[][] data, String [] legendLabels, Paint[] paints, ChartTypeProperties chartTypeProperties ) 69 { 70 this.data = data; 71 this.legendLabels = legendLabels; 72 this.paints = paints; 73 this.chartTypeProperties = chartTypeProperties; 74 } 75 76 77 84 public final String getLegendLabel( int index ) 85 { 86 if( this.legendLabels == null ) 87 { 88 return null; 89 } 90 else 91 { 92 return this.legendLabels[ index ]; 93 } 94 } 95 96 97 103 public int getNumberOfLegendLabels() 104 { 105 if( this.legendLabels == null ) 106 { 107 return 0; 108 } 109 else 110 { 111 return this.legendLabels.length; 112 } 113 } 114 115 116 123 public Paint getPaint( int index ) 124 { 125 return this.paints[ index ]; 126 } 127 128 129 134 public ChartTypeProperties getChartTypeProperties() 135 { 136 return this.chartTypeProperties; 137 } 138 139 140 146 public int getNumberOfDataItems() 147 { 148 return this.data[ 0 ].length; 149 } 150 151 152 157 public void toHTML( HTMLGenerator htmlGenerator ) 158 { 159 htmlGenerator.propertiesTableStart( this.getClass().getName() ); 160 htmlGenerator.addTableRow( "data", HTMLGenerator.arrayToString( this.data ) ); 161 162 if( this.legendLabels != null ) 163 { 164 htmlGenerator.addTableRow( "legendLabels", HTMLGenerator.arrayToString( this.legendLabels ) ); 165 } 166 htmlGenerator.addTableRow( "paints", HTMLGenerator.arrayToString( this.paints ) ); 167 htmlGenerator.propertiesTableEnd(); 168 169 htmlGenerator.chartTableRowStart(); 170 this.chartTypeProperties.toHTML( htmlGenerator ); 171 htmlGenerator.chartTableRowEnd(); 172 } 173 174 } 175 | Popular Tags |