You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ab...@apache.org on 2017/11/26 14:03:03 UTC
svn commit: r1816383 [5/5] - in /poi/trunk: ./
src/examples/src/org/apache/poi/xslf/usermodel/
src/examples/src/org/apache/poi/xssf/usermodel/examples/
src/java/org/apache/poi/hssf/usermodel/
src/java/org/apache/poi/ss/usermodel/ src/java/org/apache/po...
Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFChartAxis.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFChartAxis.java?rev=1816383&r1=1816382&r2=1816383&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFChartAxis.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFChartAxis.java Sun Nov 26 14:03:01 2017
@@ -19,18 +19,22 @@ package org.apache.poi.xssf.usermodel.ch
import java.util.List;
-import junit.framework.TestCase;
-
-import org.apache.poi.ss.usermodel.Sheet;
-import org.apache.poi.ss.usermodel.Workbook;
-import org.apache.poi.ss.usermodel.charts.*;
+import org.apache.poi.xddf.usermodel.chart.AxisPosition;
+import org.apache.poi.xddf.usermodel.chart.AxisTickMark;
+import org.apache.poi.xddf.usermodel.chart.XDDFChartAxis;
import org.apache.poi.xssf.XSSFTestDataSamples;
-import org.apache.poi.xssf.usermodel.*;
+import org.apache.poi.xssf.usermodel.XSSFChart;
+import org.apache.poi.xssf.usermodel.XSSFClientAnchor;
+import org.apache.poi.xssf.usermodel.XSSFDrawing;
+import org.apache.poi.xssf.usermodel.XSSFSheet;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+
+import junit.framework.TestCase;
public final class TestXSSFChartAxis extends TestCase {
private static final double EPSILON = 1E-7;
- private final XSSFChartAxis axis;
+ private final XDDFChartAxis axis;
public TestXSSFChartAxis() {
super();
@@ -39,9 +43,9 @@ public final class TestXSSFChartAxis ext
XSSFDrawing drawing = sheet.createDrawingPatriarch();
XSSFClientAnchor anchor = drawing.createAnchor(0, 0, 0, 0, 1, 1, 10, 30);
XSSFChart chart = drawing.createChart(anchor);
- axis = chart.getChartAxisFactory().createValueAxis(AxisPosition.BOTTOM);
+ axis = chart.createValueAxis(AxisPosition.BOTTOM);
}
-
+
public void testLogBaseIllegalArgument() throws Exception {
IllegalArgumentException iae = null;
try {
@@ -119,13 +123,12 @@ public final class TestXSSFChartAxis ext
public void testGetChartAxisBug57362() {
//Load existing excel with some chart on it having primary and secondary axis.
- final Workbook workbook = XSSFTestDataSamples.openSampleWorkbook("57362.xlsx");
- final Sheet sh = workbook.getSheetAt(0);
- final XSSFSheet xsh = (XSSFSheet) sh;
- final XSSFDrawing drawing = xsh.createDrawingPatriarch();
+ final XSSFWorkbook workbook = XSSFTestDataSamples.openSampleWorkbook("57362.xlsx");
+ final XSSFSheet sh = workbook.getSheetAt(0);
+ final XSSFDrawing drawing = sh.createDrawingPatriarch();
final XSSFChart chart = drawing.getCharts().get(0);
- final List<? extends XSSFChartAxis> axisList = chart.getAxis();
+ final List<? extends XDDFChartAxis> axisList = chart.getAxes();
assertEquals(4, axisList.size());
assertNotNull(axisList.get(0));
Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFChartLegend.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFChartLegend.java?rev=1816383&r1=1816382&r2=1816383&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFChartLegend.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFChartLegend.java Sun Nov 26 14:03:01 2017
@@ -23,13 +23,12 @@ import static org.junit.Assert.assertTru
import java.io.IOException;
-import org.apache.poi.ss.usermodel.Chart;
-import org.apache.poi.ss.usermodel.ClientAnchor;
-import org.apache.poi.ss.usermodel.Drawing;
-import org.apache.poi.ss.usermodel.Sheet;
-import org.apache.poi.ss.usermodel.Workbook;
-import org.apache.poi.ss.usermodel.charts.ChartLegend;
-import org.apache.poi.ss.usermodel.charts.LegendPosition;
+import org.apache.poi.xddf.usermodel.chart.LegendPosition;
+import org.apache.poi.xddf.usermodel.chart.XDDFChartLegend;
+import org.apache.poi.xssf.usermodel.XSSFChart;
+import org.apache.poi.xssf.usermodel.XSSFClientAnchor;
+import org.apache.poi.xssf.usermodel.XSSFDrawing;
+import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.junit.Test;
@@ -39,28 +38,28 @@ import org.junit.Test;
public final class TestXSSFChartLegend {
@Test
public void testLegendPositionAccessMethods() throws IOException {
- Workbook wb = new XSSFWorkbook();
- Sheet sheet = wb.createSheet();
- Drawing<?> drawing = sheet.createDrawingPatriarch();
- ClientAnchor anchor = drawing.createAnchor(0, 0, 0, 0, 1, 1, 10, 30);
- Chart chart = drawing.createChart(anchor);
- ChartLegend legend = chart.getOrCreateLegend();
+ XSSFWorkbook wb = new XSSFWorkbook();
+ XSSFSheet sheet = wb.createSheet();
+ XSSFDrawing drawing = sheet.createDrawingPatriarch();
+ XSSFClientAnchor anchor = drawing.createAnchor(0, 0, 0, 0, 1, 1, 10, 30);
+ XSSFChart chart = drawing.createChart(anchor);
+ XDDFChartLegend legend = chart.getOrAddLegend();
legend.setPosition(LegendPosition.TOP_RIGHT);
assertEquals(LegendPosition.TOP_RIGHT, legend.getPosition());
-
+
wb.close();
}
@Test
public void test_setOverlay_defaultChartLegend_expectOverlayInitialValueSetToFalse() throws IOException {
// Arrange
- Workbook wb = new XSSFWorkbook();
- Sheet sheet = wb.createSheet();
- Drawing<?> drawing = sheet.createDrawingPatriarch();
- ClientAnchor anchor = drawing.createAnchor(0, 0, 0, 0, 1, 1, 10, 30);
- Chart chart = drawing.createChart(anchor);
- ChartLegend legend = chart.getOrCreateLegend();
+ XSSFWorkbook wb = new XSSFWorkbook();
+ XSSFSheet sheet = wb.createSheet();
+ XSSFDrawing drawing = sheet.createDrawingPatriarch();
+ XSSFClientAnchor anchor = drawing.createAnchor(0, 0, 0, 0, 1, 1, 10, 30);
+ XSSFChart chart = drawing.createChart(anchor);
+ XDDFChartLegend legend = chart.getOrAddLegend();
// Act
@@ -73,12 +72,12 @@ public final class TestXSSFChartLegend {
@Test
public void test_setOverlay_chartLegendSetToTrue_expectOverlayInitialValueSetToTrue() throws IOException {
// Arrange
- Workbook wb = new XSSFWorkbook();
- Sheet sheet = wb.createSheet();
- Drawing<?> drawing = sheet.createDrawingPatriarch();
- ClientAnchor anchor = drawing.createAnchor(0, 0, 0, 0, 1, 1, 10, 30);
- Chart chart = drawing.createChart(anchor);
- ChartLegend legend = chart.getOrCreateLegend();
+ XSSFWorkbook wb = new XSSFWorkbook();
+ XSSFSheet sheet = wb.createSheet();
+ XSSFDrawing drawing = sheet.createDrawingPatriarch();
+ XSSFClientAnchor anchor = drawing.createAnchor(0, 0, 0, 0, 1, 1, 10, 30);
+ XSSFChart chart = drawing.createChart(anchor);
+ XDDFChartLegend legend = chart.getOrAddLegend();
// Act
legend.setOverlay(true);
Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFChartTitle.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFChartTitle.java?rev=1816383&r1=1816382&r2=1816383&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFChartTitle.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFChartTitle.java Sun Nov 26 14:03:01 2017
@@ -26,24 +26,22 @@ import java.io.IOException;
import java.util.List;
import org.apache.poi.ss.usermodel.Cell;
-import org.apache.poi.ss.usermodel.Chart;
-import org.apache.poi.ss.usermodel.ClientAnchor;
-import org.apache.poi.ss.usermodel.Drawing;
import org.apache.poi.ss.usermodel.Row;
-import org.apache.poi.ss.usermodel.Sheet;
-import org.apache.poi.ss.usermodel.Workbook;
-import org.apache.poi.ss.usermodel.charts.AxisCrosses;
-import org.apache.poi.ss.usermodel.charts.AxisPosition;
-import org.apache.poi.ss.usermodel.charts.ChartAxis;
-import org.apache.poi.ss.usermodel.charts.ChartDataSource;
-import org.apache.poi.ss.usermodel.charts.ChartLegend;
-import org.apache.poi.ss.usermodel.charts.DataSources;
-import org.apache.poi.ss.usermodel.charts.LegendPosition;
-import org.apache.poi.ss.usermodel.charts.LineChartData;
-import org.apache.poi.ss.usermodel.charts.ValueAxis;
import org.apache.poi.ss.util.CellRangeAddress;
+import org.apache.poi.xddf.usermodel.chart.AxisCrosses;
+import org.apache.poi.xddf.usermodel.chart.AxisPosition;
+import org.apache.poi.xddf.usermodel.chart.ChartTypes;
+import org.apache.poi.xddf.usermodel.chart.LegendPosition;
+import org.apache.poi.xddf.usermodel.chart.XDDFChartAxis;
+import org.apache.poi.xddf.usermodel.chart.XDDFChartData;
+import org.apache.poi.xddf.usermodel.chart.XDDFChartLegend;
+import org.apache.poi.xddf.usermodel.chart.XDDFDataSource;
+import org.apache.poi.xddf.usermodel.chart.XDDFDataSourcesFactory;
+import org.apache.poi.xddf.usermodel.chart.XDDFNumericalDataSource;
+import org.apache.poi.xddf.usermodel.chart.XDDFValueAxis;
import org.apache.poi.xssf.XSSFTestDataSamples;
import org.apache.poi.xssf.usermodel.XSSFChart;
+import org.apache.poi.xssf.usermodel.XSSFClientAnchor;
import org.apache.poi.xssf.usermodel.XSSFDrawing;
import org.apache.poi.xssf.usermodel.XSSFRichTextString;
import org.apache.poi.xssf.usermodel.XSSFSheet;
@@ -54,9 +52,9 @@ import org.junit.Test;
* Test get/set chart title.
*/
public class TestXSSFChartTitle {
- private Workbook createWorkbookWithChart() {
- Workbook wb = new XSSFWorkbook();
- Sheet sheet = wb.createSheet("linechart");
+ private XSSFWorkbook createWorkbookWithChart() {
+ XSSFWorkbook wb = new XSSFWorkbook();
+ XSSFSheet sheet = wb.createSheet("linechart");
final int NUM_OF_ROWS = 3;
final int NUM_OF_COLUMNS = 10;
@@ -71,28 +69,26 @@ public class TestXSSFChartTitle {
}
}
- Drawing<?> drawing = sheet.createDrawingPatriarch();
- ClientAnchor anchor = drawing.createAnchor(0, 0, 0, 0, 0, 5, 10, 15);
+ XSSFDrawing drawing = sheet.createDrawingPatriarch();
+ XSSFClientAnchor anchor = drawing.createAnchor(0, 0, 0, 0, 0, 5, 10, 15);
- Chart chart = drawing.createChart(anchor);
- ChartLegend legend = chart.getOrCreateLegend();
+ XSSFChart chart = drawing.createChart(anchor);
+ XDDFChartLegend legend = chart.getOrAddLegend();
legend.setPosition(LegendPosition.TOP_RIGHT);
- LineChartData data = chart.getChartDataFactory().createLineChartData();
-
// Use a category axis for the bottom axis.
- ChartAxis bottomAxis = chart.getChartAxisFactory().createCategoryAxis(AxisPosition.BOTTOM);
- ValueAxis leftAxis = chart.getChartAxisFactory().createValueAxis(AxisPosition.LEFT);
+ XDDFChartAxis bottomAxis = chart.createCategoryAxis(AxisPosition.BOTTOM);
+ XDDFValueAxis leftAxis = chart.createValueAxis(AxisPosition.LEFT);
leftAxis.setCrosses(AxisCrosses.AUTO_ZERO);
- ChartDataSource<Number> xs = DataSources.fromNumericCellRange(sheet, new CellRangeAddress(0, 0, 0, NUM_OF_COLUMNS - 1));
- ChartDataSource<Number> ys1 = DataSources.fromNumericCellRange(sheet, new CellRangeAddress(1, 1, 0, NUM_OF_COLUMNS - 1));
- ChartDataSource<Number> ys2 = DataSources.fromNumericCellRange(sheet, new CellRangeAddress(2, 2, 0, NUM_OF_COLUMNS - 1));
+ XDDFDataSource<Double> xs = XDDFDataSourcesFactory.fromNumericCellRange(sheet, new CellRangeAddress(0, 0, 0, NUM_OF_COLUMNS - 1));
+ XDDFNumericalDataSource<Double> ys1 = XDDFDataSourcesFactory.fromNumericCellRange(sheet, new CellRangeAddress(1, 1, 0, NUM_OF_COLUMNS - 1));
+ XDDFNumericalDataSource<Double> ys2 = XDDFDataSourcesFactory.fromNumericCellRange(sheet, new CellRangeAddress(2, 2, 0, NUM_OF_COLUMNS - 1));
+ XDDFChartData data = chart.createData(ChartTypes.LINE, bottomAxis, leftAxis);
data.addSeries(xs, ys1);
data.addSeries(xs, ys2);
-
- chart.plot(data, bottomAxis, leftAxis);
+ chart.plot(data);
return wb;
}
@@ -100,16 +96,14 @@ public class TestXSSFChartTitle {
/**
* Gets the first chart from the named sheet in the workbook.
*/
- private XSSFChart getChartFromWorkbook(Workbook wb, String sheetName) {
- Sheet sheet = wb.getSheet(sheetName);
- if (sheet instanceof XSSFSheet) {
- XSSFSheet xsheet = (XSSFSheet) sheet;
- XSSFDrawing drawing = xsheet.getDrawingPatriarch();
- if (drawing != null) {
- List<XSSFChart> charts = drawing.getCharts();
- if (charts != null && charts.size() > 0) {
- return charts.get(0);
- }
+ private XSSFChart getChartFromWorkbook(XSSFWorkbook wb, String sheetName) {
+ XSSFSheet sheet = wb.getSheet(sheetName);
+ XSSFSheet xsheet = sheet;
+ XSSFDrawing drawing = xsheet.getDrawingPatriarch();
+ if (drawing != null) {
+ List<XSSFChart> charts = drawing.getCharts();
+ if (charts != null && charts.size() > 0) {
+ return charts.get(0);
}
}
return null;
@@ -117,7 +111,7 @@ public class TestXSSFChartTitle {
@Test
public void testNewChart() throws IOException {
- Workbook wb = createWorkbookWithChart();
+ XSSFWorkbook wb = createWorkbookWithChart();
XSSFChart chart = getChartFromWorkbook(wb, "linechart");
assertNotNull(chart);
assertNull(chart.getTitleText());
@@ -126,7 +120,7 @@ public class TestXSSFChartTitle {
XSSFRichTextString queryTitle = chart.getTitleText();
assertNotNull(queryTitle);
assertEquals(myTitle, queryTitle.toString());
-
+
final String myTitleFormula = "1 & \" and \" & 2";
chart.setTitleFormula(myTitleFormula);
// setting formula should unset text, but since there is a formula, returns an empty string
@@ -139,7 +133,7 @@ public class TestXSSFChartTitle {
@Test
public void testExistingChartWithTitle() throws IOException {
- Workbook wb = XSSFTestDataSamples.openSampleWorkbook("chartTitle_withTitle.xlsx");
+ XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("chartTitle_withTitle.xlsx");
XSSFChart chart = getChartFromWorkbook(wb, "Sheet1");
assertNotNull(chart);
XSSFRichTextString originalTitle = chart.getTitleText();
@@ -155,7 +149,7 @@ public class TestXSSFChartTitle {
@Test
public void testExistingChartNoTitle() throws IOException {
- Workbook wb = XSSFTestDataSamples.openSampleWorkbook("chartTitle_noTitle.xlsx");
+ XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("chartTitle_noTitle.xlsx");
XSSFChart chart = getChartFromWorkbook(wb, "Sheet1");
assertNotNull(chart);
assertNull(chart.getTitleText());
@@ -169,7 +163,7 @@ public class TestXSSFChartTitle {
@Test
public void testExistingChartWithFormulaTitle() throws IOException {
- Workbook wb = XSSFTestDataSamples.openSampleWorkbook("chartTitle_withTitleFormula.xlsx");
+ XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("chartTitle_withTitleFormula.xlsx");
XSSFChart chart = getChartFromWorkbook(wb, "Sheet1");
assertNotNull(chart);
XSSFRichTextString originalTitle = chart.getTitleText();
Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFDateAxis.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFDateAxis.java?rev=1816383&r1=1816382&r2=1816383&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFDateAxis.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFDateAxis.java Sun Nov 26 14:03:01 2017
@@ -17,24 +17,32 @@
package org.apache.poi.xssf.usermodel.charts;
-import junit.framework.TestCase;
+import org.apache.poi.xddf.usermodel.chart.AxisCrosses;
+import org.apache.poi.xddf.usermodel.chart.AxisPosition;
+import org.apache.poi.xddf.usermodel.chart.XDDFDateAxis;
+import org.apache.poi.xssf.usermodel.XSSFChart;
+import org.apache.poi.xssf.usermodel.XSSFClientAnchor;
+import org.apache.poi.xssf.usermodel.XSSFDrawing;
+import org.apache.poi.xssf.usermodel.XSSFSheet;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
-import org.apache.poi.ss.usermodel.charts.*;
-import org.apache.poi.xssf.usermodel.*;
+import junit.framework.TestCase;
public final class TestXSSFDateAxis extends TestCase {
-
+
public void testAccessMethods() throws Exception {
XSSFWorkbook wb = new XSSFWorkbook();
XSSFSheet sheet = wb.createSheet();
XSSFDrawing drawing = sheet.createDrawingPatriarch();
XSSFClientAnchor anchor = drawing.createAnchor(0, 0, 0, 0, 1, 1, 10, 30);
XSSFChart chart = drawing.createChart(anchor);
- XSSFDateAxis axis = chart.getChartAxisFactory().createDateAxis(AxisPosition.BOTTOM);
+ XDDFDateAxis axis = chart.createDateAxis(AxisPosition.BOTTOM);
axis.setCrosses(AxisCrosses.AUTO_ZERO);
assertEquals(axis.getCrosses(), AxisCrosses.AUTO_ZERO);
- assertEquals(chart.getAxis().size(), 1);
+ assertEquals(chart.getAxes().size(), 1);
+
+ wb.close();
}
}
Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFLineChartData.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFLineChartData.java?rev=1816383&r1=1816382&r2=1816383&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFLineChartData.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFLineChartData.java Sun Nov 26 14:03:01 2017
@@ -22,19 +22,20 @@ import static org.junit.Assert.assertTru
import java.io.IOException;
-import org.apache.poi.ss.usermodel.Chart;
-import org.apache.poi.ss.usermodel.ClientAnchor;
-import org.apache.poi.ss.usermodel.Drawing;
-import org.apache.poi.ss.usermodel.Sheet;
-import org.apache.poi.ss.usermodel.Workbook;
-import org.apache.poi.ss.usermodel.charts.AxisPosition;
-import org.apache.poi.ss.usermodel.charts.ChartAxis;
-import org.apache.poi.ss.usermodel.charts.ChartDataSource;
-import org.apache.poi.ss.usermodel.charts.DataSources;
-import org.apache.poi.ss.usermodel.charts.LineChartData;
-import org.apache.poi.ss.usermodel.charts.LineChartSeries;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.ss.util.SheetBuilder;
+import org.apache.poi.xddf.usermodel.chart.AxisPosition;
+import org.apache.poi.xddf.usermodel.chart.ChartTypes;
+import org.apache.poi.xddf.usermodel.chart.XDDFCategoryAxis;
+import org.apache.poi.xddf.usermodel.chart.XDDFChartData;
+import org.apache.poi.xddf.usermodel.chart.XDDFDataSource;
+import org.apache.poi.xddf.usermodel.chart.XDDFDataSourcesFactory;
+import org.apache.poi.xddf.usermodel.chart.XDDFNumericalDataSource;
+import org.apache.poi.xddf.usermodel.chart.XDDFValueAxis;
+import org.apache.poi.xssf.usermodel.XSSFChart;
+import org.apache.poi.xssf.usermodel.XSSFClientAnchor;
+import org.apache.poi.xssf.usermodel.XSSFDrawing;
+import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.junit.Test;
@@ -50,27 +51,26 @@ public class TestXSSFLineChartData {
@Test
public void testOneSeriePlot() throws IOException {
- Workbook wb = new XSSFWorkbook();
- Sheet sheet = new SheetBuilder(wb, plotData).build();
- Drawing<?> drawing = sheet.createDrawingPatriarch();
- ClientAnchor anchor = drawing.createAnchor(0, 0, 0, 0, 1, 1, 10, 30);
- Chart chart = drawing.createChart(anchor);
-
- ChartAxis bottomAxis = chart.getChartAxisFactory().createCategoryAxis(AxisPosition.BOTTOM);
- ChartAxis leftAxis = chart.getChartAxisFactory().createValueAxis(AxisPosition.LEFT);
-
- LineChartData lineChartData =
- chart.getChartDataFactory().createLineChartData();
-
- ChartDataSource<String> xs = DataSources.fromStringCellRange(sheet, CellRangeAddress.valueOf("A1:J1"));
- ChartDataSource<Number> ys = DataSources.fromNumericCellRange(sheet, CellRangeAddress.valueOf("A2:J2"));
- LineChartSeries series = lineChartData.addSeries(xs, ys);
+ XSSFWorkbook wb = new XSSFWorkbook();
+ XSSFSheet sheet = (XSSFSheet) new SheetBuilder(wb, plotData).build();
+ XSSFDrawing drawing = sheet.createDrawingPatriarch();
+ XSSFClientAnchor anchor = drawing.createAnchor(0, 0, 0, 0, 1, 1, 10, 30);
+ XSSFChart chart = drawing.createChart(anchor);
+
+ XDDFCategoryAxis bottomAxis = chart.createCategoryAxis(AxisPosition.BOTTOM);
+ XDDFValueAxis leftAxis = chart.createValueAxis(AxisPosition.LEFT);
+
+ XDDFDataSource<String> xs = XDDFDataSourcesFactory.fromStringCellRange(sheet, CellRangeAddress.valueOf("A1:J1"));
+ XDDFNumericalDataSource<Double> ys = XDDFDataSourcesFactory.fromNumericCellRange(sheet, CellRangeAddress.valueOf("A2:J2"));
+
+ XDDFChartData lineChartData = chart.createData(ChartTypes.LINE, bottomAxis, leftAxis);
+ XDDFChartData.Series series = lineChartData.addSeries(xs, ys);
assertNotNull(series);
assertEquals(1, lineChartData.getSeries().size());
assertTrue(lineChartData.getSeries().contains(series));
- chart.plot(lineChartData, bottomAxis, leftAxis);
+ chart.plot(lineChartData);
wb.close();
}
}
Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFManualLayout.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFManualLayout.java?rev=1816383&r1=1816382&r2=1816383&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFManualLayout.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFManualLayout.java Sun Nov 26 14:03:01 2017
@@ -22,15 +22,14 @@ import static org.junit.Assert.assertTru
import java.io.IOException;
-import org.apache.poi.ss.usermodel.Chart;
-import org.apache.poi.ss.usermodel.ClientAnchor;
-import org.apache.poi.ss.usermodel.Drawing;
-import org.apache.poi.ss.usermodel.Sheet;
-import org.apache.poi.ss.usermodel.Workbook;
-import org.apache.poi.ss.usermodel.charts.ChartLegend;
-import org.apache.poi.ss.usermodel.charts.LayoutMode;
-import org.apache.poi.ss.usermodel.charts.LayoutTarget;
-import org.apache.poi.ss.usermodel.charts.ManualLayout;
+import org.apache.poi.xddf.usermodel.chart.LayoutMode;
+import org.apache.poi.xddf.usermodel.chart.LayoutTarget;
+import org.apache.poi.xddf.usermodel.chart.XDDFChartLegend;
+import org.apache.poi.xddf.usermodel.chart.XDDFManualLayout;
+import org.apache.poi.xssf.usermodel.XSSFChart;
+import org.apache.poi.xssf.usermodel.XSSFClientAnchor;
+import org.apache.poi.xssf.usermodel.XSSFDrawing;
+import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.junit.After;
import org.junit.Before;
@@ -38,25 +37,25 @@ import org.junit.Test;
public final class TestXSSFManualLayout {
- private Workbook wb;
- private ManualLayout layout;
-
+ private XSSFWorkbook wb;
+ private XDDFManualLayout layout;
+
@Before
public void createEmptyLayout() {
wb = new XSSFWorkbook();
- Sheet sheet = wb.createSheet();
- Drawing<?> drawing = sheet.createDrawingPatriarch();
- ClientAnchor anchor = drawing.createAnchor(0, 0, 0, 0, 1, 1, 10, 30);
- Chart chart = drawing.createChart(anchor);
- ChartLegend legend = chart.getOrCreateLegend();
- layout = legend.getManualLayout();
+ XSSFSheet sheet = wb.createSheet();
+ XSSFDrawing drawing = sheet.createDrawingPatriarch();
+ XSSFClientAnchor anchor = drawing.createAnchor(0, 0, 0, 0, 1, 1, 10, 30);
+ XSSFChart chart = drawing.createChart(anchor);
+ XDDFChartLegend legend = chart.getOrAddLegend();
+ layout = legend.getOrAddManualLayout();
}
@After
public void closeWB() throws IOException {
wb.close();
}
-
+
/*
* Accessor methods are not trivial. They use lazy underlying bean
* initialization so there can be some errors (NPE, for example).
Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFScatterChartData.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFScatterChartData.java?rev=1816383&r1=1816382&r2=1816383&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFScatterChartData.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFScatterChartData.java Sun Nov 26 14:03:01 2017
@@ -23,19 +23,21 @@ import static org.junit.Assert.assertTru
import java.io.IOException;
-import org.apache.poi.ss.usermodel.Chart;
-import org.apache.poi.ss.usermodel.ClientAnchor;
-import org.apache.poi.ss.usermodel.Drawing;
-import org.apache.poi.ss.usermodel.Sheet;
-import org.apache.poi.ss.usermodel.Workbook;
-import org.apache.poi.ss.usermodel.charts.AxisPosition;
-import org.apache.poi.ss.usermodel.charts.ChartAxis;
-import org.apache.poi.ss.usermodel.charts.ChartDataSource;
-import org.apache.poi.ss.usermodel.charts.DataSources;
-import org.apache.poi.ss.usermodel.charts.ScatterChartData;
-import org.apache.poi.ss.usermodel.charts.ScatterChartSeries;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.ss.util.SheetBuilder;
+import org.apache.poi.xddf.usermodel.chart.AxisPosition;
+import org.apache.poi.xddf.usermodel.chart.ChartTypes;
+import org.apache.poi.xddf.usermodel.chart.ScatterStyle;
+import org.apache.poi.xddf.usermodel.chart.XDDFChartData;
+import org.apache.poi.xddf.usermodel.chart.XDDFDataSource;
+import org.apache.poi.xddf.usermodel.chart.XDDFDataSourcesFactory;
+import org.apache.poi.xddf.usermodel.chart.XDDFNumericalDataSource;
+import org.apache.poi.xddf.usermodel.chart.XDDFScatterChartData;
+import org.apache.poi.xddf.usermodel.chart.XDDFValueAxis;
+import org.apache.poi.xssf.usermodel.XSSFChart;
+import org.apache.poi.xssf.usermodel.XSSFClientAnchor;
+import org.apache.poi.xssf.usermodel.XSSFDrawing;
+import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.junit.Test;
@@ -51,27 +53,27 @@ public final class TestXSSFScatterChartD
@Test
public void testOneSeriePlot() throws IOException {
- Workbook wb = new XSSFWorkbook();
- Sheet sheet = new SheetBuilder(wb, plotData).build();
- Drawing<?> drawing = sheet.createDrawingPatriarch();
- ClientAnchor anchor = drawing.createAnchor(0, 0, 0, 0, 1, 1, 10, 30);
- Chart chart = drawing.createChart(anchor);
-
- ChartAxis bottomAxis = chart.getChartAxisFactory().createValueAxis(AxisPosition.BOTTOM);
- ChartAxis leftAxis = chart.getChartAxisFactory().createValueAxis(AxisPosition.LEFT);
-
- ScatterChartData scatterChartData =
- chart.getChartDataFactory().createScatterChartData();
-
- ChartDataSource<String> xs = DataSources.fromStringCellRange(sheet, CellRangeAddress.valueOf("A1:J1"));
- ChartDataSource<Number> ys = DataSources.fromNumericCellRange(sheet, CellRangeAddress.valueOf("A2:J2"));
- ScatterChartSeries series = scatterChartData.addSerie(xs, ys);
+ XSSFWorkbook wb = new XSSFWorkbook();
+ XSSFSheet sheet = (XSSFSheet) new SheetBuilder(wb, plotData).build();
+ XSSFDrawing drawing = sheet.createDrawingPatriarch();
+ XSSFClientAnchor anchor = drawing.createAnchor(0, 0, 0, 0, 1, 1, 10, 30);
+ XSSFChart chart = drawing.createChart(anchor);
+
+ XDDFValueAxis bottomAxis = chart.createValueAxis(AxisPosition.BOTTOM);
+ XDDFValueAxis leftAxis = chart.createValueAxis(AxisPosition.LEFT);
+ XDDFDataSource<String> xs = XDDFDataSourcesFactory.fromStringCellRange(sheet, CellRangeAddress.valueOf("A1:J1"));
+ XDDFNumericalDataSource<Double> ys = XDDFDataSourcesFactory.fromNumericCellRange(sheet, CellRangeAddress.valueOf("A2:J2"));
+
+ XDDFScatterChartData scatterChartData = (XDDFScatterChartData) chart.createData(ChartTypes.SCATTER, bottomAxis, leftAxis);
+ XDDFChartData.Series series = scatterChartData.addSeries(xs, ys);
+
+ assertEquals(ScatterStyle.LINE_MARKER, scatterChartData.getStyle());
assertNotNull(series);
assertEquals(1, scatterChartData.getSeries().size());
assertTrue(scatterChartData.getSeries().contains(series));
- chart.plot(scatterChartData, bottomAxis, leftAxis);
+ chart.plot(scatterChartData);
wb.close();
}
}
Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFValueAxis.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFValueAxis.java?rev=1816383&r1=1816382&r2=1816383&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFValueAxis.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFValueAxis.java Sun Nov 26 14:03:01 2017
@@ -17,20 +17,27 @@
package org.apache.poi.xssf.usermodel.charts;
-import junit.framework.TestCase;
+import org.apache.poi.xddf.usermodel.chart.AxisCrossBetween;
+import org.apache.poi.xddf.usermodel.chart.AxisCrosses;
+import org.apache.poi.xddf.usermodel.chart.AxisPosition;
+import org.apache.poi.xddf.usermodel.chart.XDDFValueAxis;
+import org.apache.poi.xssf.usermodel.XSSFChart;
+import org.apache.poi.xssf.usermodel.XSSFClientAnchor;
+import org.apache.poi.xssf.usermodel.XSSFDrawing;
+import org.apache.poi.xssf.usermodel.XSSFSheet;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
-import org.apache.poi.ss.usermodel.charts.*;
-import org.apache.poi.xssf.usermodel.*;
+import junit.framework.TestCase;
public final class TestXSSFValueAxis extends TestCase {
-
+
public void testAccessMethods() throws Exception {
XSSFWorkbook wb = new XSSFWorkbook();
XSSFSheet sheet = wb.createSheet();
XSSFDrawing drawing = sheet.createDrawingPatriarch();
XSSFClientAnchor anchor = drawing.createAnchor(0, 0, 0, 0, 1, 1, 10, 30);
XSSFChart chart = drawing.createChart(anchor);
- XSSFValueAxis axis = chart.getChartAxisFactory().createValueAxis(AxisPosition.BOTTOM);
+ XDDFValueAxis axis = chart.createValueAxis(AxisPosition.BOTTOM);
axis.setCrossBetween(AxisCrossBetween.MIDPOINT_CATEGORY);
assertEquals(axis.getCrossBetween(), AxisCrossBetween.MIDPOINT_CATEGORY);
@@ -38,6 +45,8 @@ public final class TestXSSFValueAxis ext
axis.setCrosses(AxisCrosses.AUTO_ZERO);
assertEquals(axis.getCrosses(), AxisCrosses.AUTO_ZERO);
- assertEquals(chart.getAxis().size(), 1);
+ assertEquals(chart.getAxes().size(), 1);
+
+ wb.close();
}
}
Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFChart.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFChart.java?rev=1816383&r1=1816382&r2=1816383&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFChart.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFChart.java Sun Nov 26 14:03:01 2017
@@ -20,6 +20,8 @@ package org.apache.poi.xwpf.usermodel;
import java.io.IOException;
import java.util.List;
+import org.apache.poi.xddf.usermodel.chart.XDDFBarChartData;
+import org.apache.poi.xddf.usermodel.chart.XDDFChartData;
import org.apache.poi.xwpf.XWPFTestDataSamples;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTChart;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTTitle;
@@ -33,7 +35,7 @@ import junit.framework.TestCase;
public class TestXWPFChart extends TestCase {
/**
- * test method to check charts are null
+ * test method to check charts are not null
*/
public void testRead() throws IOException
{
@@ -41,10 +43,18 @@ public class TestXWPFChart extends TestC
List<XWPFChart> charts = sampleDoc.getCharts();
assertNotNull(charts);
assertEquals(2, charts.size());
- assertNotNull(charts.get(0));
- assertNotNull(charts.get(1));
+ checkData(charts.get(0));
+ checkData(charts.get(1));
}
-
+
+ private void checkData(XWPFChart chart) {
+ assertNotNull(chart);
+ assertEquals(1, chart.getChartSeries().size());
+ XDDFChartData data = chart.getChartSeries().get(0);
+ assertEquals(XDDFBarChartData.class, data.getClass());
+ assertEquals(3, data.getSeries().size());
+ }
+
/**
* test method to add chart title and check whether it's set
*/
Added: poi/trunk/test-data/slideshow/bar-chart.pptx
URL: http://svn.apache.org/viewvc/poi/trunk/test-data/slideshow/bar-chart.pptx?rev=1816383&view=auto
==============================================================================
Binary files poi/trunk/test-data/slideshow/bar-chart.pptx (added) and poi/trunk/test-data/slideshow/bar-chart.pptx Sun Nov 26 14:03:01 2017 differ
Added: poi/trunk/test-data/slideshow/line-chart.pptx
URL: http://svn.apache.org/viewvc/poi/trunk/test-data/slideshow/line-chart.pptx?rev=1816383&view=auto
==============================================================================
Binary files poi/trunk/test-data/slideshow/line-chart.pptx (added) and poi/trunk/test-data/slideshow/line-chart.pptx Sun Nov 26 14:03:01 2017 differ
Added: poi/trunk/test-data/slideshow/radar-chart.pptx
URL: http://svn.apache.org/viewvc/poi/trunk/test-data/slideshow/radar-chart.pptx?rev=1816383&view=auto
==============================================================================
Binary files poi/trunk/test-data/slideshow/radar-chart.pptx (added) and poi/trunk/test-data/slideshow/radar-chart.pptx Sun Nov 26 14:03:01 2017 differ
Added: poi/trunk/test-data/slideshow/scatter-chart.pptx
URL: http://svn.apache.org/viewvc/poi/trunk/test-data/slideshow/scatter-chart.pptx?rev=1816383&view=auto
==============================================================================
Binary files poi/trunk/test-data/slideshow/scatter-chart.pptx (added) and poi/trunk/test-data/slideshow/scatter-chart.pptx Sun Nov 26 14:03:01 2017 differ
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org