View | Details | Raw Unified | Return to bug 49242
Collapse All | Expand All

(-)src/scratchpad/src/org/apache/poi/hssf/usermodel/HSSFChart.java (-1 / +61 lines)
Lines 38-43 Link Here
38
import org.apache.poi.hssf.record.formula.Area3DPtg;
38
import org.apache.poi.hssf.record.formula.Area3DPtg;
39
import org.apache.poi.hssf.record.formula.Ptg;
39
import org.apache.poi.hssf.record.formula.Ptg;
40
40
41
import org.apache.poi.hssf.record.chart.LinkedDataRecord;
41
/**
42
/**
42
 * Has methods for construction of a chart object.
43
 * Has methods for construction of a chart object.
43
 *
44
 *
Lines 139-145 Link Here
139
	public static HSSFChart[] getSheetCharts(HSSFSheet sheet) {
140
	public static HSSFChart[] getSheetCharts(HSSFSheet sheet) {
140
		List charts = new ArrayList();
141
		List charts = new ArrayList();
141
		HSSFChart lastChart = null;
142
		HSSFChart lastChart = null;
142
143
		HSSFSeries lastSeries = null;
143
		// Find records of interest
144
		// Find records of interest
144
		List records = sheet.getSheet().getRecords();
145
		List records = sheet.getSheet().getRecords();
145
		for(Iterator it = records.iterator(); it.hasNext();) {
146
		for(Iterator it = records.iterator(); it.hasNext();) {
Lines 155-160 Link Here
155
			if(r instanceof SeriesRecord) {
156
			if(r instanceof SeriesRecord) {
156
				HSSFSeries series = lastChart.new HSSFSeries( (SeriesRecord)r );
157
				HSSFSeries series = lastChart.new HSSFSeries( (SeriesRecord)r );
157
				lastChart.series.add(series);
158
				lastChart.series.add(series);
159
				lastSeries = series;
158
			}
160
			}
159
			if(r instanceof ChartTitleFormatRecord) {
161
			if(r instanceof ChartTitleFormatRecord) {
160
				lastChart.chartTitleFormat =
162
				lastChart.chartTitleFormat =
Lines 173-178 Link Here
173
					lastChart.chartTitleText = str;
175
					lastChart.chartTitleText = str;
174
				}
176
				}
175
			}
177
			}
178
			if(r instanceof LinkedDataRecord) {
179
				LinkedDataRecord data = (LinkedDataRecord)r;
180
				lastSeries.insertData( data );
181
			}
176
		}
182
		}
177
183
178
		return (HSSFChart[])
184
		return (HSSFChart[])
Lines 867-877 Link Here
867
	public class HSSFSeries {
873
	public class HSSFSeries {
868
		private SeriesRecord series;
874
		private SeriesRecord series;
869
		private SeriesTextRecord seriesTitleText;
875
		private SeriesTextRecord seriesTitleText;
876
		private LinkedDataRecord dataName;
877
		private LinkedDataRecord dataValues;
878
		private LinkedDataRecord dataCategoryLabels;
879
		private LinkedDataRecord dataSecondaryCategoryLabels;
880
		private int dataReaded = 0;
870
881
871
		/* package */ HSSFSeries(SeriesRecord series) {
882
		/* package */ HSSFSeries(SeriesRecord series) {
872
			this.series = series;
883
			this.series = series;
873
		}
884
		}
874
885
886
		public void insertData(LinkedDataRecord data){
887
			switch(dataReaded){
888
				case 0: dataName = data;
889
				break;
890
				case 1: dataValues = data;
891
				break;
892
				case 2: dataCategoryLabels = data;
893
				break;
894
				case 3: dataSecondaryCategoryLabels = data;
895
				break;
896
			}
897
			dataReaded++;
898
		}
899
		
875
		public short getNumValues() {
900
		public short getNumValues() {
876
			return series.getNumValues();
901
			return series.getNumValues();
877
		}
902
		}
Lines 905-909 Link Here
905
				throw new IllegalStateException("No series title found to change");
930
				throw new IllegalStateException("No series title found to change");
906
			}
931
			}
907
		}
932
		}
933
934
		/**
935
		 * @return record with data names
936
		 */
937
		public LinkedDataRecord getDataName(){
938
			return dataName;
939
		}
940
		
941
		/**
942
		 * @return record with data values
943
		 */
944
		public LinkedDataRecord getDataValues(){
945
			return dataValues;
946
		}
947
		
948
		/**
949
		 * @return record with data category labels
950
		 */
951
		public LinkedDataRecord getDataCategoryLabels(){
952
			return dataCategoryLabels;
953
		}
954
		
955
		/**
956
		 * @return record with data secondary category labels
957
		 */
958
		public LinkedDataRecord getDataSecondaryCategoryLabels() {
959
			return dataSecondaryCategoryLabels;
960
		}
961
		
962
		/**
963
		 * @return record with series
964
		 */
965
		public SeriesRecord getSeries() {
966
			return series;
967
		}
908
	}
968
	}
909
}
969
}

Return to bug 49242