use of org.apache.poi.hssf.record.chart.ValueRangeRecord in project poi by apache.
the class HSSFChart method createValueRangeRecord.
private ValueRangeRecord createValueRangeRecord() {
ValueRangeRecord r = new ValueRangeRecord();
r.setMinimumAxisValue(0.0);
r.setMaximumAxisValue(0.0);
r.setMajorIncrement(0);
r.setMinorIncrement(0);
r.setCategoryAxisCross(0);
r.setAutomaticMinimum(true);
r.setAutomaticMaximum(true);
r.setAutomaticMajor(true);
r.setAutomaticMinor(true);
r.setAutomaticCategoryCrossing(true);
r.setLogarithmicScale(false);
r.setValuesInReverse(false);
r.setCrossCategoryAxisAtMaximum(false);
// what's this do??
r.setReserved(true);
return r;
}
use of org.apache.poi.hssf.record.chart.ValueRangeRecord in project poi by apache.
the class HSSFChart method getSheetCharts.
/**
* Returns all the charts for the given sheet.
*
* NOTE: You won't be able to do very much with
* these charts yet, as this is very limited support
*/
public static HSSFChart[] getSheetCharts(HSSFSheet sheet) {
List<HSSFChart> charts = new ArrayList<HSSFChart>();
HSSFChart lastChart = null;
HSSFSeries lastSeries = null;
// Find records of interest
List<RecordBase> records = sheet.getSheet().getRecords();
for (RecordBase r : records) {
if (r instanceof ChartRecord) {
lastSeries = null;
lastChart = new HSSFChart(sheet, (ChartRecord) r);
charts.add(lastChart);
} else if (r instanceof LinkedDataRecord) {
LinkedDataRecord linkedDataRecord = (LinkedDataRecord) r;
if (lastSeries != null) {
lastSeries.insertData(linkedDataRecord);
}
}
if (lastChart == null) {
continue;
}
if (r instanceof LegendRecord) {
lastChart.legendRecord = (LegendRecord) r;
} else if (r instanceof SeriesRecord) {
HSSFSeries series = new HSSFSeries((SeriesRecord) r);
lastChart.series.add(series);
lastSeries = series;
} else if (r instanceof ChartTitleFormatRecord) {
lastChart.chartTitleFormat = (ChartTitleFormatRecord) r;
} else if (r instanceof SeriesTextRecord) {
// Applies to a series, unless we've seen a legend already
SeriesTextRecord str = (SeriesTextRecord) r;
if (lastChart.legendRecord == null && lastChart.series.size() > 0) {
HSSFSeries series = lastChart.series.get(lastChart.series.size() - 1);
series.seriesTitleText = str;
} else {
lastChart.chartTitleText = str;
}
} else if (r instanceof ValueRangeRecord) {
lastChart.valueRanges.add((ValueRangeRecord) r);
} else if (r instanceof Record) {
Record record = (Record) r;
for (HSSFChartType type : HSSFChartType.values()) {
if (type == HSSFChartType.Unknown) {
continue;
}
if (record.getSid() == type.getSid()) {
lastChart.type = type;
break;
}
}
}
}
return charts.toArray(new HSSFChart[charts.size()]);
}
use of org.apache.poi.hssf.record.chart.ValueRangeRecord in project poi by apache.
the class HSSFChart method setValueRange.
/**
* Set value range (basic Axis Options)
* @param axisIndex 0 - primary axis, 1 - secondary axis
* @param minimum minimum value; Double.NaN - automatic; null - no change
* @param maximum maximum value; Double.NaN - automatic; null - no change
* @param majorUnit major unit value; Double.NaN - automatic; null - no change
* @param minorUnit minor unit value; Double.NaN - automatic; null - no change
*/
public void setValueRange(int axisIndex, Double minimum, Double maximum, Double majorUnit, Double minorUnit) {
ValueRangeRecord valueRange = valueRanges.get(axisIndex);
if (valueRange == null)
return;
if (minimum != null) {
valueRange.setAutomaticMinimum(minimum.isNaN());
valueRange.setMinimumAxisValue(minimum);
}
if (maximum != null) {
valueRange.setAutomaticMaximum(maximum.isNaN());
valueRange.setMaximumAxisValue(maximum);
}
if (majorUnit != null) {
valueRange.setAutomaticMajor(majorUnit.isNaN());
valueRange.setMajorIncrement(majorUnit);
}
if (minorUnit != null) {
valueRange.setAutomaticMinor(minorUnit.isNaN());
valueRange.setMinorIncrement(minorUnit);
}
}
Aggregations