aboutsummaryrefslogtreecommitdiffstats
path: root/src/ooxml/testcases/org/apache
diff options
context:
space:
mode:
authorYegor Kozlov <yegor@apache.org>2011-09-10 19:00:47 +0000
committerYegor Kozlov <yegor@apache.org>2011-09-10 19:00:47 +0000
commite4b2a66d0915c6487a95d87a3e082847d8557107 (patch)
tree22e22cea138d9bdee9de0531a01fa5fb170e1671 /src/ooxml/testcases/org/apache
parent57c369a5416c1ee967590258e3c37969ad609e36 (diff)
downloadpoi-e4b2a66d0915c6487a95d87a3e082847d8557107.tar.gz
poi-e4b2a66d0915c6487a95d87a3e082847d8557107.zip
more progress with xssf chart api, see Bug 51196
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1167579 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/ooxml/testcases/org/apache')
-rw-r--r--src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFChartSheet.java2
-rw-r--r--src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java2
-rw-r--r--src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFNumberCache.java64
-rw-r--r--src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFScatterChartData.java43
4 files changed, 24 insertions, 87 deletions
diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFChartSheet.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFChartSheet.java
index a5de464e5f..3ca9263940 100644
--- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFChartSheet.java
+++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFChartSheet.java
@@ -40,7 +40,7 @@ public final class TestXSSFChartSheet extends TestCase {
XSSFChartSheet sheet = (XSSFChartSheet)wb.getSheetAt(2);
for(Row row : sheet) {
- fail("Row iterator for chart sheets should return zero rows");
+ fail("Row iterator for charts sheets should return zero rows");
}
//access to a arbitrary row
assertEquals(null, sheet.getRow(1));
diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java
index 526ab9224a..e0cfcc0336 100644
--- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java
+++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java
@@ -332,7 +332,7 @@ public final class TestXSSFWorkbook extends BaseTestWorkbook {
}
/**
- * Problems with XSSFWorkbook.removeSheetAt when workbook contains chart
+ * Problems with XSSFWorkbook.removeSheetAt when workbook contains charts
*/
public void testBug47813() {
XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("47813.xlsx");
diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFNumberCache.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFNumberCache.java
deleted file mode 100644
index 94621de825..0000000000
--- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFNumberCache.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/* ====================================================================
- 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.xssf.usermodel.charts;
-
-import org.apache.poi.ss.usermodel.*;
-import org.apache.poi.ss.util.CellRangeAddress;
-import org.apache.poi.ss.util.DataMarker;
-import org.apache.poi.ss.util.SheetBuilder;
-import org.apache.poi.ss.usermodel.charts.*;
-import org.apache.poi.xssf.usermodel.XSSFWorkbook;
-
-
-import junit.framework.TestCase;
-
-public class TestXSSFNumberCache extends TestCase {
- private static Object[][] plotData = {
- {0, 1, 2, 3, 4},
- {0, "=B1*2", "=C1*2", "=D1*2", "=E1*4"}
- };
-
- public void testFormulaCache() {
- 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();
-
- DataMarker xMarker = new DataMarker(sheet, CellRangeAddress.valueOf("A1:E1"));
- DataMarker yMarker = new DataMarker(sheet, CellRangeAddress.valueOf("A2:E2"));
- ScatterChartSerie serie = scatterChartData.addSerie(xMarker, yMarker);
-
- chart.plot(scatterChartData, bottomAxis, leftAxis);
-
- XSSFScatterChartData.Serie xssfScatterSerie =
- (XSSFScatterChartData.Serie) serie;
- XSSFNumberCache yCache = xssfScatterSerie.getLastCalculatedYCache();
-
- assertEquals(5, yCache.getPointCount());
- assertEquals(4.0, yCache.getValueAt(3), 0.00001);
- assertEquals(16.0, yCache.getValueAt(5), 0.00001);
- }
-
-
-} \ No newline at end of file
diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFScatterChartData.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFScatterChartData.java
index 4a3b9c0f43..87f8ea7b12 100644
--- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFScatterChartData.java
+++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFScatterChartData.java
@@ -21,42 +21,43 @@ import junit.framework.TestCase;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.util.CellRangeAddress;
-import org.apache.poi.ss.util.DataMarker;
import org.apache.poi.ss.util.SheetBuilder;
import org.apache.poi.ss.usermodel.charts.*;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
/**
* Tests for XSSFScatterChartData.
+ *
* @author Roman Kashitsyn
*/
-public final class TestXSSFScatterChartData extends TestCase {
+public final class TestXSSFScatterChartData extends TestCase {
- private static Object[][] plotData = new Object[][] {
- {1, 2, 3, 4, 5, 6, 7, 8, 9, 10},
- {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
+ private static final Object[][] plotData = {
+ {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J"},
+ { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
};
-
+
public void testOneSeriePlot() throws Exception {
- 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);
+ 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);
+ ChartAxis bottomAxis = chart.getChartAxisFactory().createValueAxis(AxisPosition.BOTTOM);
+ ChartAxis leftAxis = chart.getChartAxisFactory().createValueAxis(AxisPosition.LEFT);
- ScatterChartData scatterChartData =
- chart.getChartDataFactory().createScatterChartData();
+ ScatterChartData scatterChartData =
+ chart.getChartDataFactory().createScatterChartData();
- DataMarker xMarker = new DataMarker(sheet, CellRangeAddress.valueOf("A1:A10"));
- DataMarker yMarker = new DataMarker(sheet, CellRangeAddress.valueOf("B1:B10"));
- ScatterChartSerie serie = scatterChartData.addSerie(xMarker, yMarker);
+ ChartDataSource<String> xs = DataSources.fromStringCellRange(sheet, CellRangeAddress.valueOf("A1:J1"));
+ ChartDataSource<Number> ys = DataSources.fromNumericCellRange(sheet, CellRangeAddress.valueOf("A2:J2"));
+ ScatterChartSerie serie = scatterChartData.addSerie(xs, ys);
- assertEquals(1, scatterChartData.getSeries().size());
+ assertNotNull(serie);
+ assertEquals(1, scatterChartData.getSeries().size());
+ assertTrue(scatterChartData.getSeries().contains(serie));
- chart.plot(scatterChartData, bottomAxis, leftAxis);
+ chart.plot(scatterChartData, bottomAxis, leftAxis);
}
-
}