lineCategories.crossAxis(rightValues);
// the bar chart
- XDDFBarChartData bar = (XDDFBarChartData) chart.createData(ChartTypes.BAR, lineCategories, rightValues);
+ XDDFBarChartData bar = (XDDFBarChartData) chart.createData(ChartTypes.BAR, barCategories, leftValues);
XDDFBarChartData.Series series1 = (XDDFBarChartData.Series) bar.addSeries(xs, ys1);
series1.setTitle("Bars", new CellReference("Sheet1!$B$1"));
bar.setVaryColors(true);
bar.setBarDirection(BarDirection.COL);
chart.plot(bar);
- // the line chart
+ // the line chart on secondary axis
XDDFLineChartData lines = (XDDFLineChartData) chart.createData(ChartTypes.LINE, lineCategories,
rightValues);
+
+ //uncomment below line if only primary axis required and comment above line
+ // the line chart on primary axis
+ /*XDDFLineChartData lines = (XDDFLineChartData) chart.createData(ChartTypes.LINE, lineCategories,
+ leftValues);*/
+
+
XDDFLineChartData.Series series2 = (XDDFLineChartData.Series) lines.addSeries(xs, ys2);
+ series2.updateIdXVal(1);
+ series2.updateOrderVal(1);
series2.setTitle("Lines", new CellReference("Sheet1!$C$1"));
lines.setVaryColors(true);
chart.plot(lines);
package org.apache.poi.xddf.usermodel.chart;
public enum ChartTypes {
+ AREA,
+ AREA3D,
BAR,
+ BAR3D,
LINE,
+ LINE3D,
PIE,
+ PIE3D,
RADAR,
- SCATTER
+ SCATTER,
+ SURFACE,
+ SURFACE3D
}
--- /dev/null
+/* ====================================================================
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+
+package org.apache.poi.xddf.usermodel.chart;
+
+import java.util.Map;
+
+import org.apache.poi.util.Beta;
+import org.apache.poi.xddf.usermodel.XDDFShapeProperties;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTArea3DChart;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTAreaSer;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTAxDataSource;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTNumDataSource;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTSerTx;
+
+@Beta
+public class XDDFArea3DChartData extends XDDFChartData {
+ private CTArea3DChart chart;
+
+ public XDDFArea3DChartData(CTArea3DChart chart, Map<Long, XDDFChartAxis> categories,
+ Map<Long, XDDFValueAxis> values) {
+ this.chart = chart;
+ for (CTAreaSer series : chart.getSerList()) {
+ this.series.add(new Series(series, series.getCat(), series.getVal()));
+ }
+ defineAxes(categories, values);
+ }
+
+ private void defineAxes(Map<Long, XDDFChartAxis> categories, Map<Long, XDDFValueAxis> values) {
+ if (chart.sizeOfAxIdArray() == 0) {
+ for (Long id : categories.keySet()) {
+ chart.addNewAxId().setVal(id);
+ }
+ for (Long id : values.keySet()) {
+ chart.addNewAxId().setVal(id);
+ }
+ }
+ defineAxes(chart.getAxIdArray(), categories, values);
+ }
+
+ @Override
+ public void setVaryColors(boolean varyColors) {
+ if (chart.isSetVaryColors()) {
+ chart.getVaryColors().setVal(varyColors);
+ } else {
+ chart.addNewVaryColors().setVal(varyColors);
+ }
+ }
+
+ public Grouping getGrouping() {
+ return Grouping.valueOf(chart.getGrouping().getVal());
+ }
+
+ public void setGrouping(Grouping grouping) {
+ if (chart.getGrouping() != null) {
+ chart.getGrouping().setVal(grouping.underlying);
+ } else {
+ chart.addNewGrouping().setVal(grouping.underlying);
+ }
+ }
+
+ @Override
+ public XDDFChartData.Series addSeries(XDDFDataSource<?> category,
+ XDDFNumericalDataSource<? extends Number> values) {
+ final int index = this.series.size();
+ final CTAreaSer ctSer = this.chart.addNewSer();
+ ctSer.addNewCat();
+ ctSer.addNewVal();
+ ctSer.addNewIdx().setVal(index);
+ ctSer.addNewOrder().setVal(index);
+ final Series added = new Series(ctSer, category, values);
+ this.series.add(added);
+ return added;
+ }
+
+ public class Series extends XDDFChartData.Series {
+ private CTAreaSer series;
+
+ protected Series(CTAreaSer series, XDDFDataSource<?> category,
+ XDDFNumericalDataSource<? extends Number> values) {
+ super(category, values);
+ this.series = series;
+ }
+
+ protected Series(CTAreaSer series, CTAxDataSource category, CTNumDataSource values) {
+ super(XDDFDataSourcesFactory.fromDataSource(category), XDDFDataSourcesFactory.fromDataSource(values));
+ this.series = series;
+ }
+
+ @Override
+ protected CTSerTx getSeriesText() {
+ if (series.isSetTx()) {
+ return series.getTx();
+ } else {
+ return series.addNewTx();
+ }
+ }
+
+ @Override
+ public void setShowLeaderLines(boolean showLeaderLines) {
+ if (!series.isSetDLbls()) {
+ series.addNewDLbls();
+ }
+ if (series.getDLbls().isSetShowLeaderLines()) {
+ series.getDLbls().getShowLeaderLines().setVal(showLeaderLines);
+ } else {
+ series.getDLbls().addNewShowLeaderLines().setVal(showLeaderLines);
+ }
+ }
+
+ @Override
+ public XDDFShapeProperties getShapeProperties() {
+ if (series.isSetSpPr()) {
+ return new XDDFShapeProperties(series.getSpPr());
+ } else {
+ return null;
+ }
+ }
+
+ @Override
+ public void setShapeProperties(XDDFShapeProperties properties) {
+ if (properties == null) {
+ if (series.isSetSpPr()) {
+ series.unsetSpPr();
+ }
+ } else {
+ if (series.isSetSpPr()) {
+ series.setSpPr(properties.getXmlObject());
+ } else {
+ series.addNewSpPr().set(properties.getXmlObject());
+ }
+ }
+ }
+
+ @Override
+ protected CTAxDataSource getAxDS() {
+ return series.getCat();
+ }
+
+ @Override
+ protected CTNumDataSource getNumDS() {
+ return series.getVal();
+ }
+
+ @Override
+ public void updateIdXVal(long val) {
+ series.getIdx().setVal(val);
+ }
+
+ @Override
+ public void updateOrderVal(long val) {
+ series.getOrder().setVal(val);
+ }
+ }
+}
--- /dev/null
+/* ====================================================================
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+
+package org.apache.poi.xddf.usermodel.chart;
+
+import java.util.Map;
+
+import org.apache.poi.util.Beta;
+import org.apache.poi.xddf.usermodel.XDDFShapeProperties;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTAreaChart;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTAreaSer;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTAxDataSource;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTLineChart;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTLineSer;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTMarker;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTNumDataSource;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTSerTx;
+
+@Beta
+public class XDDFAreaChartData extends XDDFChartData {
+ private CTAreaChart chart;
+
+ public XDDFAreaChartData(CTAreaChart chart, Map<Long, XDDFChartAxis> categories,
+ Map<Long, XDDFValueAxis> values) {
+ this.chart = chart;
+ for (CTAreaSer series : chart.getSerList()) {
+ this.series.add(new Series(series, series.getCat(), series.getVal()));
+ }
+ defineAxes(categories, values);
+ }
+
+ private void defineAxes(Map<Long, XDDFChartAxis> categories, Map<Long, XDDFValueAxis> values) {
+ if (chart.sizeOfAxIdArray() == 0) {
+ for (Long id : categories.keySet()) {
+ chart.addNewAxId().setVal(id);
+ }
+ for (Long id : values.keySet()) {
+ chart.addNewAxId().setVal(id);
+ }
+ }
+ defineAxes(chart.getAxIdArray(), categories, values);
+ }
+
+ @Override
+ public void setVaryColors(boolean varyColors) {
+ if (chart.isSetVaryColors()) {
+ chart.getVaryColors().setVal(varyColors);
+ } else {
+ chart.addNewVaryColors().setVal(varyColors);
+ }
+ }
+
+ public Grouping getGrouping() {
+ return Grouping.valueOf(chart.getGrouping().getVal());
+ }
+
+ public void setGrouping(Grouping grouping) {
+ if (chart.getGrouping() != null) {
+ chart.getGrouping().setVal(grouping.underlying);
+ } else {
+ chart.addNewGrouping().setVal(grouping.underlying);
+ }
+ }
+
+ @Override
+ public XDDFChartData.Series addSeries(XDDFDataSource<?> category,
+ XDDFNumericalDataSource<? extends Number> values) {
+ final int index = this.series.size();
+ final CTAreaSer ctSer = this.chart.addNewSer();
+ ctSer.addNewCat();
+ ctSer.addNewVal();
+ ctSer.addNewIdx().setVal(index);
+ ctSer.addNewOrder().setVal(index);
+ final Series added = new Series(ctSer, category, values);
+ this.series.add(added);
+ return added;
+ }
+
+ public class Series extends XDDFChartData.Series {
+ private CTAreaSer series;
+
+ protected Series(CTAreaSer series, XDDFDataSource<?> category,
+ XDDFNumericalDataSource<? extends Number> values) {
+ super(category, values);
+ this.series = series;
+ }
+
+ protected Series(CTAreaSer series, CTAxDataSource category, CTNumDataSource values) {
+ super(XDDFDataSourcesFactory.fromDataSource(category), XDDFDataSourcesFactory.fromDataSource(values));
+ this.series = series;
+ }
+
+ @Override
+ protected CTSerTx getSeriesText() {
+ if (series.isSetTx()) {
+ return series.getTx();
+ } else {
+ return series.addNewTx();
+ }
+ }
+
+ @Override
+ public void setShowLeaderLines(boolean showLeaderLines) {
+ if (!series.isSetDLbls()) {
+ series.addNewDLbls();
+ }
+ if (series.getDLbls().isSetShowLeaderLines()) {
+ series.getDLbls().getShowLeaderLines().setVal(showLeaderLines);
+ } else {
+ series.getDLbls().addNewShowLeaderLines().setVal(showLeaderLines);
+ }
+ }
+
+ @Override
+ public XDDFShapeProperties getShapeProperties() {
+ if (series.isSetSpPr()) {
+ return new XDDFShapeProperties(series.getSpPr());
+ } else {
+ return null;
+ }
+ }
+
+ @Override
+ public void setShapeProperties(XDDFShapeProperties properties) {
+ if (properties == null) {
+ if (series.isSetSpPr()) {
+ series.unsetSpPr();
+ }
+ } else {
+ if (series.isSetSpPr()) {
+ series.setSpPr(properties.getXmlObject());
+ } else {
+ series.addNewSpPr().set(properties.getXmlObject());
+ }
+ }
+ }
+
+ @Override
+ protected CTAxDataSource getAxDS() {
+ return series.getCat();
+ }
+
+ @Override
+ protected CTNumDataSource getNumDS() {
+ return series.getVal();
+ }
+
+ @Override
+ public void updateIdXVal(long val) {
+ series.getIdx().setVal(val);
+ }
+
+ @Override
+ public void updateOrderVal(long val) {
+ series.getOrder().setVal(val);
+ }
+ }
+}
--- /dev/null
+/* ====================================================================
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+
+package org.apache.poi.xddf.usermodel.chart;
+
+import java.util.Map;
+
+import org.apache.poi.util.Beta;
+import org.apache.poi.xddf.usermodel.XDDFShapeProperties;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTAxDataSource;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTBar3DChart;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTBarSer;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTNumDataSource;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTSerTx;
+
+@Beta
+public class XDDFBar3DChartData extends XDDFChartData {
+ private CTBar3DChart chart;
+
+ public XDDFBar3DChartData(CTBar3DChart chart, Map<Long, XDDFChartAxis> categories,
+ Map<Long, XDDFValueAxis> values) {
+ this.chart = chart;
+ if (chart.getBarDir() == null) {
+ chart.addNewBarDir().setVal(BarDirection.BAR.underlying);
+ }
+ for (CTBarSer series : chart.getSerList()) {
+ this.series.add(new Series(series, series.getCat(), series.getVal()));
+ }
+ defineAxes(categories, values);
+ }
+
+ private void defineAxes(Map<Long, XDDFChartAxis> categories, Map<Long, XDDFValueAxis> values) {
+ if (chart.sizeOfAxIdArray() == 0) {
+ for (Long id : categories.keySet()) {
+ chart.addNewAxId().setVal(id);
+ }
+ for (Long id : values.keySet()) {
+ chart.addNewAxId().setVal(id);
+ }
+ }
+ defineAxes(chart.getAxIdArray(), categories, values);
+ }
+
+ @Override
+ public void setVaryColors(boolean varyColors) {
+ if (chart.isSetVaryColors()) {
+ chart.getVaryColors().setVal(varyColors);
+ } else {
+ chart.addNewVaryColors().setVal(varyColors);
+ }
+ }
+
+ public BarDirection getBarDirection() {
+ return BarDirection.valueOf(chart.getBarDir().getVal());
+ }
+
+ public void setBarDirection(BarDirection direction) {
+ chart.getBarDir().setVal(direction.underlying);
+ }
+
+ public BarGrouping getBarGrouping() {
+ if (chart.isSetGrouping()) {
+ return BarGrouping.valueOf(chart.getGrouping().getVal());
+ } else {
+ return BarGrouping.STANDARD;
+ }
+ }
+
+ public void setBarGrouping(BarGrouping grouping) {
+ if (chart.isSetGrouping()) {
+ chart.getGrouping().setVal(grouping.underlying);
+ } else {
+ chart.addNewGrouping().setVal(grouping.underlying);
+ }
+ }
+
+ public int getGapWidth() {
+ if (chart.isSetGapWidth()) {
+ return chart.getGapWidth().getVal();
+ } else {
+ return 0;
+ }
+ }
+
+ public void setGapWidth(int width) {
+ if (chart.isSetGapWidth()) {
+ chart.getGapWidth().setVal(width);
+ } else {
+ chart.addNewGapWidth().setVal(width);
+ }
+ }
+
+ @Override
+ public XDDFChartData.Series addSeries(XDDFDataSource<?> category,
+ XDDFNumericalDataSource<? extends Number> values) {
+ final int index = this.series.size();
+ final CTBarSer ctSer = this.chart.addNewSer();
+ ctSer.addNewTx();
+ ctSer.addNewCat();
+ ctSer.addNewVal();
+ ctSer.addNewIdx().setVal(index);
+ ctSer.addNewOrder().setVal(index);
+ final Series added = new Series(ctSer, category, values);
+ this.series.add(added);
+ return added;
+ }
+
+ public class Series extends XDDFChartData.Series {
+ private CTBarSer series;
+
+ protected Series(CTBarSer series, XDDFDataSource<?> category,
+ XDDFNumericalDataSource<? extends Number> values) {
+ super(category, values);
+ this.series = series;
+ }
+
+ protected Series(CTBarSer series, CTAxDataSource category, CTNumDataSource values) {
+ super(XDDFDataSourcesFactory.fromDataSource(category), XDDFDataSourcesFactory.fromDataSource(values));
+ this.series = series;
+ }
+
+ @Override
+ protected CTSerTx getSeriesText() {
+ if (series.isSetTx()) {
+ return series.getTx();
+ } else {
+ return series.addNewTx();
+ }
+ }
+
+ @Override
+ public void setShowLeaderLines(boolean showLeaderLines) {
+ if (!series.isSetDLbls()) {
+ series.addNewDLbls();
+ }
+ if (series.getDLbls().isSetShowLeaderLines()) {
+ series.getDLbls().getShowLeaderLines().setVal(showLeaderLines);
+ } else {
+ series.getDLbls().addNewShowLeaderLines().setVal(showLeaderLines);
+ }
+ }
+
+ @Override
+ public XDDFShapeProperties getShapeProperties() {
+ if (series.isSetSpPr()) {
+ return new XDDFShapeProperties(series.getSpPr());
+ } else {
+ return null;
+ }
+ }
+
+ @Override
+ public void setShapeProperties(XDDFShapeProperties properties) {
+ if (properties == null) {
+ if (series.isSetSpPr()) {
+ series.unsetSpPr();
+ }
+ } else {
+ if (series.isSetSpPr()) {
+ series.setSpPr(properties.getXmlObject());
+ } else {
+ series.addNewSpPr().set(properties.getXmlObject());
+ }
+ }
+ }
+
+ @Override
+ protected CTAxDataSource getAxDS() {
+ return series.getCat();
+ }
+
+ @Override
+ protected CTNumDataSource getNumDS() {
+ return series.getVal();
+ }
+
+ @Override
+ public void updateIdXVal(long val) {
+ series.getIdx().setVal(val);
+ }
+
+ @Override
+ public void updateOrderVal(long val) {
+ series.getOrder().setVal(val);
+ }
+ }
+}
protected CTNumDataSource getNumDS() {
return series.getVal();
}
+
+ @Override
+ public void updateIdXVal(long val) {
+ series.getIdx().setVal(val);
+ }
+
+ @Override
+ public void updateOrderVal(long val) {
+ series.getOrder().setVal(val);
+ }
}
}
import org.openxmlformats.schemas.drawingml.x2006.chart.CTSurface;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTTitle;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTValAx;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTView3D;
import org.openxmlformats.schemas.drawingml.x2006.chart.ChartSpaceDocument;
import org.openxmlformats.schemas.drawingml.x2006.main.CTShapeProperties;
import org.openxmlformats.schemas.drawingml.x2006.main.CTTextCharacterProperties;
}
}
+ /**
+ * Get or Add chart 3D view into chart
+ *
+ * @return this method will add 3D view
+ */
+ public XDDFView3D getOrAddView3D() {
+ CTView3D view3D;
+ if (chart.isSetView3D()) {
+ view3D = chart.getView3D();
+ } else {
+ view3D = chart.addNewView3D();
+ }
+ return new XDDFView3D(view3D);
+ }
+
/**
* Get the chart title body if there is one, i.e. title is set and is not a
* formula.
return valueAxis;
}
+ /**
+ * this method will return series axis with specified position
+ *
+ * @param pos axis position Left, Right, Top, Bottom
+ * @return series axis with specified position
+ */
+ public XDDFSeriesAxis createSeriesAxis(AxisPosition pos) {
+ XDDFSeriesAxis seriesAxis = new XDDFSeriesAxis(chart.getPlotArea(), pos);
+ if (axes.size() == 1) {
+ XDDFChartAxis axis = axes.get(0);
+ axis.crossAxis(seriesAxis);
+ seriesAxis.crossAxis(axis);
+ }
+ axes.add(seriesAxis);
+ return seriesAxis;
+ }
+
public XDDFCategoryAxis createCategoryAxis(AxisPosition pos) {
XDDFCategoryAxis categoryAxis = new XDDFCategoryAxis(chart.getPlotArea(), pos);
if (axes.size() == 1) {
return dateAxis;
}
+ /**
+ * this method will return specified chart data with category and series values
+ *
+ * @param type chart type
+ * @param category category values of chart
+ * @param values series values of chart
+ * @return specified chart data.
+ */
public XDDFChartData createData(ChartTypes type, XDDFChartAxis category, XDDFValueAxis values) {
- Map<Long, XDDFChartAxis> categories = Collections.singletonMap(category.getId(), category);
- Map<Long, XDDFValueAxis> mapValues = Collections.singletonMap(values.getId(), values);
+ Map<Long, XDDFChartAxis> categories = null;
+ Map<Long, XDDFValueAxis> mapValues = null;
+
+ if(ChartTypes.PIE != type && ChartTypes.PIE3D != type)
+ {
+ categories = Collections.singletonMap(category.getId(), category);
+ mapValues = Collections.singletonMap(values.getId(), values);
+ }
+
final CTPlotArea plotArea = getCTPlotArea();
switch (type) {
+ case AREA:
+ return new XDDFAreaChartData(plotArea.addNewAreaChart(), categories, mapValues);
+ case AREA3D:
+ return new XDDFArea3DChartData(plotArea.addNewArea3DChart(), categories, mapValues);
case BAR:
return new XDDFBarChartData(plotArea.addNewBarChart(), categories, mapValues);
+ case BAR3D:
+ return new XDDFBar3DChartData(plotArea.addNewBar3DChart(), categories, mapValues);
case LINE:
return new XDDFLineChartData(plotArea.addNewLineChart(), categories, mapValues);
+ case LINE3D:
+ return new XDDFLine3DChartData(plotArea.addNewLine3DChart(), categories, mapValues);
case PIE:
return new XDDFPieChartData(plotArea.addNewPieChart());
+ case PIE3D:
+ return new XDDFPie3DChartData(plotArea.addNewPie3DChart());
case RADAR:
return new XDDFRadarChartData(plotArea.addNewRadarChart(), categories, mapValues);
case SCATTER:
return new XDDFScatterChartData(plotArea.addNewScatterChart(), categories, mapValues);
+ case SURFACE:
+ return new XDDFSurfaceChartData(plotArea.addNewSurfaceChart(), categories, mapValues);
+ case SURFACE3D:
+ return new XDDFSurface3DChartData(plotArea.addNewSurface3DChart(), categories, mapValues);
default:
return null;
}
protected abstract CTNumDataSource getNumDS();
+ /**
+ * This method will update series id value
+ *
+ * @param val
+ */
+ public abstract void updateIdXVal(long val);
+
+ /**
+ * this method will update series order value
+ *
+ * @param val
+ */
+ public abstract void updateOrderVal(long val);
+
protected Series(XDDFDataSource<?> category, XDDFNumericalDataSource<? extends Number> values) {
replaceData(category, values);
}
--- /dev/null
+/* ====================================================================
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+
+package org.apache.poi.xddf.usermodel.chart;
+
+import java.util.Map;
+
+import org.apache.poi.util.Beta;
+import org.apache.poi.xddf.usermodel.XDDFShapeProperties;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTAxDataSource;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTLine3DChart;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTLineSer;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTMarker;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTNumDataSource;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTSerTx;
+
+@Beta
+public class XDDFLine3DChartData extends XDDFChartData {
+ private CTLine3DChart chart;
+
+ public XDDFLine3DChartData(CTLine3DChart chart, Map<Long, XDDFChartAxis> categories,
+ Map<Long, XDDFValueAxis> values) {
+ this.chart = chart;
+ for (CTLineSer series : chart.getSerList()) {
+ this.series.add(new Series(series, series.getCat(), series.getVal()));
+ }
+ defineAxes(categories, values);
+ }
+
+ private void defineAxes(Map<Long, XDDFChartAxis> categories, Map<Long, XDDFValueAxis> values) {
+ if (chart.sizeOfAxIdArray() == 0) {
+ for (Long id : categories.keySet()) {
+ chart.addNewAxId().setVal(id);
+ }
+ for (Long id : values.keySet()) {
+ chart.addNewAxId().setVal(id);
+ }
+ }
+ defineAxes(chart.getAxIdArray(), categories, values);
+ }
+
+ @Override
+ public void setVaryColors(boolean varyColors) {
+ if (chart.isSetVaryColors()) {
+ chart.getVaryColors().setVal(varyColors);
+ } else {
+ chart.addNewVaryColors().setVal(varyColors);
+ }
+ }
+
+ public Grouping getGrouping() {
+ return Grouping.valueOf(chart.getGrouping().getVal());
+ }
+
+ public void setGrouping(Grouping grouping) {
+ if (chart.getGrouping() != null) {
+ chart.getGrouping().setVal(grouping.underlying);
+ } else {
+ chart.addNewGrouping().setVal(grouping.underlying);
+ }
+ }
+
+ @Override
+ public XDDFChartData.Series addSeries(XDDFDataSource<?> category,
+ XDDFNumericalDataSource<? extends Number> values) {
+ final int index = this.series.size();
+ final CTLineSer ctSer = this.chart.addNewSer();
+ ctSer.addNewCat();
+ ctSer.addNewVal();
+ ctSer.addNewIdx().setVal(index);
+ ctSer.addNewOrder().setVal(index);
+ final Series added = new Series(ctSer, category, values);
+ this.series.add(added);
+ return added;
+ }
+
+ public class Series extends XDDFChartData.Series {
+ private CTLineSer series;
+
+ protected Series(CTLineSer series, XDDFDataSource<?> category,
+ XDDFNumericalDataSource<? extends Number> values) {
+ super(category, values);
+ this.series = series;
+ }
+
+ protected Series(CTLineSer series, CTAxDataSource category, CTNumDataSource values) {
+ super(XDDFDataSourcesFactory.fromDataSource(category), XDDFDataSourcesFactory.fromDataSource(values));
+ this.series = series;
+ }
+
+ @Override
+ protected CTSerTx getSeriesText() {
+ if (series.isSetTx()) {
+ return series.getTx();
+ } else {
+ return series.addNewTx();
+ }
+ }
+
+ @Override
+ public void setShowLeaderLines(boolean showLeaderLines) {
+ if (!series.isSetDLbls()) {
+ series.addNewDLbls();
+ }
+ if (series.getDLbls().isSetShowLeaderLines()) {
+ series.getDLbls().getShowLeaderLines().setVal(showLeaderLines);
+ } else {
+ series.getDLbls().addNewShowLeaderLines().setVal(showLeaderLines);
+ }
+ }
+
+ @Override
+ public XDDFShapeProperties getShapeProperties() {
+ if (series.isSetSpPr()) {
+ return new XDDFShapeProperties(series.getSpPr());
+ } else {
+ return null;
+ }
+ }
+
+ @Override
+ public void setShapeProperties(XDDFShapeProperties properties) {
+ if (properties == null) {
+ if (series.isSetSpPr()) {
+ series.unsetSpPr();
+ }
+ } else {
+ if (series.isSetSpPr()) {
+ series.setSpPr(properties.getXmlObject());
+ } else {
+ series.addNewSpPr().set(properties.getXmlObject());
+ }
+ }
+ }
+
+
+ public Boolean getSmooth() {
+ if (series.isSetSmooth()) {
+ return series.getSmooth().getVal();
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * @param smooth
+ * whether or not to smooth lines, if <code>null</code> then reverts to default.
+ *
+ */
+ public void setSmooth(Boolean smooth) {
+ if (smooth == null) {
+ if (series.isSetSmooth()) {
+ series.unsetSmooth();
+ }
+ } else {
+ if (series.isSetSmooth()) {
+ series.getSmooth().setVal(smooth);
+ } else {
+ series.addNewSmooth().setVal(smooth);
+ }
+ }
+ }
+
+ /**
+ * @param size
+ * <dl><dt>Minimum inclusive:</dt><dd>2</dd><dt>Maximum inclusive:</dt><dd>72</dd></dl>
+ */
+ public void setMarkerSize(short size) {
+ if (size < 2 || 72 < size) {
+ throw new IllegalArgumentException("Minimum inclusive: 2; Maximum inclusive: 72");
+ }
+ CTMarker marker = getMarker();
+ if (marker.isSetSize()) {
+ marker.getSize().setVal(size);
+ } else {
+ marker.addNewSize().setVal(size);
+ }
+ }
+
+ public void setMarkerStyle(MarkerStyle style) {
+ CTMarker marker = getMarker();
+ if (marker.isSetSymbol()) {
+ marker.getSymbol().setVal(style.underlying);
+ } else {
+ marker.addNewSymbol().setVal(style.underlying);
+ }
+ }
+
+ private CTMarker getMarker() {
+ if (series.isSetMarker()) {
+ return series.getMarker();
+ } else {
+ return series.addNewMarker();
+ }
+ }
+
+ @Override
+ protected CTAxDataSource getAxDS() {
+ return series.getCat();
+ }
+
+ @Override
+ protected CTNumDataSource getNumDS() {
+ return series.getVal();
+ }
+
+ @Override
+ public void updateIdXVal(long val) {
+ series.getIdx().setVal(val);
+ }
+
+ @Override
+ public void updateOrderVal(long val) {
+ series.getOrder().setVal(val);
+ }
+ }
+}
return Grouping.valueOf(chart.getGrouping().getVal());
}
- public void setGrouping(Grouping grouping) {
- chart.getGrouping().setVal(grouping.underlying);
- }
+ public void setGrouping(Grouping grouping) {
+ if (chart.getGrouping() != null) {
+ chart.getGrouping().setVal(grouping.underlying);
+ } else {
+ chart.addNewGrouping().setVal(grouping.underlying);
+ }
+ }
@Override
public XDDFChartData.Series addSeries(XDDFDataSource<?> category,
protected CTNumDataSource getNumDS() {
return series.getVal();
}
+
+ @Override
+ public void updateIdXVal(long val) {
+ series.getIdx().setVal(val);
+ }
+
+ @Override
+ public void updateOrderVal(long val) {
+ series.getOrder().setVal(val);
+ }
}
}
--- /dev/null
+/* ====================================================================
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+
+package org.apache.poi.xddf.usermodel.chart;
+
+import org.apache.poi.util.Beta;
+import org.apache.poi.xddf.usermodel.XDDFShapeProperties;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTAxDataSource;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTNumDataSource;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTPie3DChart;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTPieSer;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTSerTx;
+
+@Beta
+public class XDDFPie3DChartData extends XDDFChartData {
+ private CTPie3DChart chart;
+
+ public XDDFPie3DChartData(CTPie3DChart chart) {
+ this.chart = chart;
+ for (CTPieSer series : chart.getSerList()) {
+ this.series.add(new Series(series, series.getCat(), series.getVal()));
+ }
+ }
+
+ @Override
+ public void setVaryColors(boolean varyColors) {
+ if (chart.isSetVaryColors()) {
+ chart.getVaryColors().setVal(varyColors);
+ } else {
+ chart.addNewVaryColors().setVal(varyColors);
+ }
+ }
+
+ @Override
+ public XDDFChartData.Series addSeries(XDDFDataSource<?> category,
+ XDDFNumericalDataSource<? extends Number> values) {
+ final int index = this.series.size();
+ final CTPieSer ctSer = this.chart.addNewSer();
+ ctSer.addNewCat();
+ ctSer.addNewVal();
+ ctSer.addNewIdx().setVal(index);
+ ctSer.addNewOrder().setVal(index);
+ final Series added = new Series(ctSer, category, values);
+ this.series.add(added);
+ return added;
+ }
+
+ public class Series extends XDDFChartData.Series {
+ private CTPieSer series;
+
+ protected Series(CTPieSer series, XDDFDataSource<?> category,
+ XDDFNumericalDataSource<? extends Number> values) {
+ super(category, values);
+ this.series = series;
+ }
+
+ protected Series(CTPieSer series, CTAxDataSource category, CTNumDataSource values) {
+ super(XDDFDataSourcesFactory.fromDataSource(category), XDDFDataSourcesFactory.fromDataSource(values));
+ this.series = series;
+ }
+
+ @Override
+ protected CTSerTx getSeriesText() {
+ if (series.isSetTx()) {
+ return series.getTx();
+ } else {
+ return series.addNewTx();
+ }
+ }
+
+ @Override
+ public void setShowLeaderLines(boolean showLeaderLines) {
+ if (!series.isSetDLbls()) {
+ series.addNewDLbls();
+ }
+ if (series.getDLbls().isSetShowLeaderLines()) {
+ series.getDLbls().getShowLeaderLines().setVal(showLeaderLines);
+ } else {
+ series.getDLbls().addNewShowLeaderLines().setVal(showLeaderLines);
+ }
+ }
+
+ @Override
+ public XDDFShapeProperties getShapeProperties() {
+ if (series.isSetSpPr()) {
+ return new XDDFShapeProperties(series.getSpPr());
+ } else {
+ return null;
+ }
+ }
+
+ @Override
+ public void setShapeProperties(XDDFShapeProperties properties) {
+ if (properties == null) {
+ if (series.isSetSpPr()) {
+ series.unsetSpPr();
+ }
+ } else {
+ if (series.isSetSpPr()) {
+ series.setSpPr(properties.getXmlObject());
+ } else {
+ series.addNewSpPr().set(properties.getXmlObject());
+ }
+ }
+ }
+
+ public long getExplosion() {
+ if (series.isSetExplosion()) {
+ return series.getExplosion().getVal();
+ } else {
+ return 0;
+ }
+ }
+
+ public void setExplosion(long explosion) {
+ if (series.isSetExplosion()) {
+ series.getExplosion().setVal(explosion);
+ } else {
+ series.addNewExplosion().setVal(explosion);
+ }
+ }
+
+ @Override
+ protected CTAxDataSource getAxDS() {
+ return series.getCat();
+ }
+
+ @Override
+ protected CTNumDataSource getNumDS() {
+ return series.getVal();
+ }
+
+ @Override
+ public void updateIdXVal(long val) {
+ series.getIdx().setVal(val);
+ }
+
+ @Override
+ public void updateOrderVal(long val) {
+ series.getOrder().setVal(val);
+ }
+ }
+}
protected CTNumDataSource getNumDS() {
return series.getVal();
}
+
+ @Override
+ public void updateIdXVal(long val) {
+ series.getIdx().setVal(val);
+ }
+
+ @Override
+ public void updateOrderVal(long val) {
+ series.getOrder().setVal(val);
+ }
}
}
protected CTNumDataSource getNumDS() {
return series.getVal();
}
+
+ @Override
+ public void updateIdXVal(long val) {
+ series.getIdx().setVal(val);
+ }
+
+ @Override
+ public void updateOrderVal(long val) {
+ series.getOrder().setVal(val);
+ }
}
}
protected CTNumDataSource getNumDS() {
return series.getYVal();
}
+
+ @Override
+ public void updateIdXVal(long val) {
+ series.getIdx().setVal(val);
+ }
+
+ @Override
+ public void updateOrderVal(long val) {
+ series.getOrder().setVal(val);
+ }
}
}
--- /dev/null
+/* ====================================================================
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+
+package org.apache.poi.xddf.usermodel.chart;
+
+import java.util.Map;
+
+import org.apache.poi.util.Beta;
+import org.apache.poi.xddf.usermodel.XDDFShapeProperties;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTAxDataSource;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTBoolean;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTNumDataSource;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTSerTx;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTSurface3DChart;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTSurfaceSer;
+
+@Beta
+public class XDDFSurface3DChartData extends XDDFChartData {
+ private CTSurface3DChart chart;
+
+ public XDDFSurface3DChartData(CTSurface3DChart chart, Map<Long, XDDFChartAxis> categories,
+ Map<Long, XDDFValueAxis> values) {
+ this.chart = chart;
+ for (CTSurfaceSer series : chart.getSerList()) {
+ this.series.add(new Series(series, series.getCat(), series.getVal()));
+ }
+ defineAxes(categories, values);
+ }
+
+ private void defineAxes(Map<Long, XDDFChartAxis> categories, Map<Long, XDDFValueAxis> values) {
+ if (chart.sizeOfAxIdArray() == 0) {
+ for (Long id : categories.keySet()) {
+ chart.addNewAxId().setVal(id);
+ }
+ for (Long id : values.keySet()) {
+ chart.addNewAxId().setVal(id);
+ }
+ }
+ defineAxes(chart.getAxIdArray(), categories, values);
+ }
+
+ public void setSeriesAxisId(XDDFSeriesAxis seriesAxis) {
+ chart.addNewAxId().setVal(seriesAxis.getId());
+ }
+
+ public CTBoolean getWireframe() {
+ if (chart.isSetWireframe()) {
+ return chart.getWireframe();
+ } else {
+ return chart.addNewWireframe();
+ }
+ }
+
+ public void setWireframe(boolean val) {
+ if (chart.isSetWireframe()) {
+ chart.getWireframe().setVal(val);
+ } else {
+ chart.addNewWireframe().setVal(val);
+ }
+ }
+
+ /**
+ * Surface chart is not supporting vary color property
+ */
+ @Override
+ public void setVaryColors(boolean varyColors) {
+
+ }
+
+ @Override
+ public XDDFChartData.Series addSeries(XDDFDataSource<?> category,
+ XDDFNumericalDataSource<? extends Number> values) {
+ final int index = this.series.size();
+ final CTSurfaceSer ctSer = this.chart.addNewSer();
+ ctSer.addNewCat();
+ ctSer.addNewVal();
+ ctSer.addNewIdx().setVal(index);
+ ctSer.addNewOrder().setVal(index);
+ final Series added = new Series(ctSer, category, values);
+ this.series.add(added);
+ return added;
+ }
+
+ public class Series extends XDDFChartData.Series {
+ private CTSurfaceSer series;
+
+ protected Series(CTSurfaceSer series, XDDFDataSource<?> category,
+ XDDFNumericalDataSource<? extends Number> values) {
+ super(category, values);
+ this.series = series;
+ }
+
+ protected Series(CTSurfaceSer series, CTAxDataSource category, CTNumDataSource values) {
+ super(XDDFDataSourcesFactory.fromDataSource(category), XDDFDataSourcesFactory.fromDataSource(values));
+ this.series = series;
+ }
+
+ @Override
+ protected CTSerTx getSeriesText() {
+ if (series.isSetTx()) {
+ return series.getTx();
+ } else {
+ return series.addNewTx();
+ }
+ }
+
+ /**
+ * Surface chart is not supporting vary show leader lines property
+ */
+ @Override
+ public void setShowLeaderLines(boolean showLeaderLines) {
+
+ }
+
+ @Override
+ public XDDFShapeProperties getShapeProperties() {
+ if (series.isSetSpPr()) {
+ return new XDDFShapeProperties(series.getSpPr());
+ } else {
+ return null;
+ }
+ }
+
+ @Override
+ public void setShapeProperties(XDDFShapeProperties properties) {
+ if (properties == null) {
+ if (series.isSetSpPr()) {
+ series.unsetSpPr();
+ }
+ } else {
+ if (series.isSetSpPr()) {
+ series.setSpPr(properties.getXmlObject());
+ } else {
+ series.addNewSpPr().set(properties.getXmlObject());
+ }
+ }
+ }
+
+ @Override
+ protected CTAxDataSource getAxDS() {
+ return series.getCat();
+ }
+
+ @Override
+ protected CTNumDataSource getNumDS() {
+ return series.getVal();
+ }
+
+ @Override
+ public void updateIdXVal(long val) {
+ series.getIdx().setVal(val);
+ }
+
+ @Override
+ public void updateOrderVal(long val) {
+ series.getOrder().setVal(val);
+ }
+ }
+}
--- /dev/null
+/* ====================================================================
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+
+package org.apache.poi.xddf.usermodel.chart;
+
+import java.util.Map;
+
+import org.apache.poi.util.Beta;
+import org.apache.poi.xddf.usermodel.XDDFShapeProperties;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTAxDataSource;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTBoolean;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTNumDataSource;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTSerTx;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTSurfaceChart;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTSurfaceSer;
+
+@Beta
+public class XDDFSurfaceChartData extends XDDFChartData {
+ private CTSurfaceChart chart;
+
+ public XDDFSurfaceChartData(CTSurfaceChart chart, Map<Long, XDDFChartAxis> categories,
+ Map<Long, XDDFValueAxis> values) {
+ this.chart = chart;
+ for (CTSurfaceSer series : chart.getSerList()) {
+ this.series.add(new Series(series, series.getCat(), series.getVal()));
+ }
+ defineAxes(categories, values);
+ }
+ private void defineAxes(Map<Long, XDDFChartAxis> categories, Map<Long, XDDFValueAxis> values) {
+ if (chart.sizeOfAxIdArray() == 0) {
+ for (Long id : categories.keySet()) {
+ chart.addNewAxId().setVal(id);
+ }
+ for (Long id : values.keySet()) {
+ chart.addNewAxId().setVal(id);
+ }
+ }
+ defineAxes(chart.getAxIdArray(), categories, values);
+ }
+
+ public void setSeriesAxisId(XDDFSeriesAxis seriesAxis) {
+ chart.addNewAxId().setVal(seriesAxis.getId());
+ }
+
+ public CTBoolean getWireframe() {
+ if (chart.isSetWireframe()) {
+ return chart.getWireframe();
+ } else {
+ return chart.addNewWireframe();
+ }
+ }
+
+ public void setWireframe(boolean val) {
+ if (chart.isSetWireframe()) {
+ chart.getWireframe().setVal(val);
+ } else {
+ chart.addNewWireframe().setVal(val);
+ }
+ }
+
+ /**
+ * Surface chart is not supporting vary color property
+ */
+ @Override
+ public void setVaryColors(boolean varyColors) {
+
+ }
+
+ @Override
+ public XDDFChartData.Series addSeries(XDDFDataSource<?> category,
+ XDDFNumericalDataSource<? extends Number> values) {
+ final int index = this.series.size();
+ final CTSurfaceSer ctSer = this.chart.addNewSer();
+ ctSer.addNewCat();
+ ctSer.addNewVal();
+ ctSer.addNewIdx().setVal(index);
+ ctSer.addNewOrder().setVal(index);
+ final Series added = new Series(ctSer, category, values);
+ this.series.add(added);
+ return added;
+ }
+
+ public class Series extends XDDFChartData.Series {
+ private CTSurfaceSer series;
+
+ protected Series(CTSurfaceSer series, XDDFDataSource<?> category,
+ XDDFNumericalDataSource<? extends Number> values) {
+ super(category, values);
+ this.series = series;
+ }
+
+ protected Series(CTSurfaceSer series, CTAxDataSource category, CTNumDataSource values) {
+ super(XDDFDataSourcesFactory.fromDataSource(category), XDDFDataSourcesFactory.fromDataSource(values));
+ this.series = series;
+ }
+
+ @Override
+ protected CTSerTx getSeriesText() {
+ if (series.isSetTx()) {
+ return series.getTx();
+ } else {
+ return series.addNewTx();
+ }
+ }
+
+ /**
+ * Surface chart is not supporting vary show leader lines property
+ */
+ @Override
+ public void setShowLeaderLines(boolean showLeaderLines) {
+
+ }
+
+ @Override
+ public XDDFShapeProperties getShapeProperties() {
+ if (series.isSetSpPr()) {
+ return new XDDFShapeProperties(series.getSpPr());
+ } else {
+ return null;
+ }
+ }
+
+ @Override
+ public void setShapeProperties(XDDFShapeProperties properties) {
+ if (properties == null) {
+ if (series.isSetSpPr()) {
+ series.unsetSpPr();
+ }
+ } else {
+ if (series.isSetSpPr()) {
+ series.setSpPr(properties.getXmlObject());
+ } else {
+ series.addNewSpPr().set(properties.getXmlObject());
+ }
+ }
+ }
+
+ @Override
+ protected CTAxDataSource getAxDS() {
+ return series.getCat();
+ }
+
+ @Override
+ protected CTNumDataSource getNumDS() {
+ return series.getVal();
+ }
+
+ @Override
+ public void updateIdXVal(long val) {
+ series.getIdx().setVal(val);
+ }
+
+ @Override
+ public void updateOrderVal(long val) {
+ series.getOrder().setVal(val);
+ }
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * ====================================================================
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ====================================================================
+ */
+
+package org.apache.poi.xddf.usermodel.chart;
+
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTView3D;
+
+
+public class XDDFView3D {
+ private final CTView3D view3D;
+
+ public XDDFView3D(CTView3D view3D) {
+ this.view3D = view3D;
+ }
+
+ public int getXRotationAngle() {
+ return view3D.getRotX().getVal();
+ }
+
+ public void setXRotationAngle(int val) {
+ if (view3D.isSetRotY()) {
+ view3D.getRotY().setVal(val);
+ } else {
+ view3D.addNewRotY().setVal(val);
+ }
+ }
+
+ public int getYRotationAngle() {
+ return view3D.getRotY().getVal();
+ }
+
+ public void setYRotationAngle(int val) {
+ if (view3D.isSetRotY()) {
+ view3D.getRotY().setVal(val);
+ } else {
+ view3D.addNewRotY().setVal(val);
+ }
+ }
+
+ public boolean getRightAngleAxes() {
+ return view3D.getRAngAx().getVal();
+ }
+
+ public void setRightAngleAxes(boolean val) {
+ if (view3D.isSetRAngAx()) {
+ view3D.getRAngAx().setVal(val);
+ } else {
+ view3D.addNewRAngAx().setVal(val);
+ }
+ }
+
+ public short getPerspectiveAngle() {
+ return view3D.getPerspective().getVal();
+ }
+
+ public void setPerspectiveAngle(short val) {
+ if (view3D.isSetPerspective()) {
+ view3D.getPerspective().setVal(val);
+ } else {
+ view3D.addNewPerspective().setVal(val);
+ }
+ }
+
+ public int getDepthPercentVal() {
+ return view3D.getDepthPercent().getVal();
+ }
+
+ public void setDepthPercent(int val) {
+ if (view3D.isSetDepthPercent()) {
+ view3D.getDepthPercent().setVal(val);
+ } else {
+ view3D.addNewDepthPercent().setVal(val);
+ }
+ }
+
+ public int getHeightPercent() {
+ return view3D.getHPercent().getVal();
+ }
+
+ public void setHeightPercent(int val) {
+ if (view3D.isSetHPercent()) {
+ view3D.getHPercent().setVal(val);
+ } else {
+ view3D.addNewHPercent().setVal(val);
+ }
+ }
+}