aboutsummaryrefslogtreecommitdiffstats
path: root/src/examples
diff options
context:
space:
mode:
authorAlain Béarez <abearez@apache.org>2019-12-07 23:10:32 +0000
committerAlain Béarez <abearez@apache.org>2019-12-07 23:10:32 +0000
commit4703c18b83d2796c8d7f67bd15c75b74b555fb45 (patch)
treec57fd6983b47c43df0f730463d8f8ba396ba24d7 /src/examples
parentde2467e9aeb3727d3182479f1cf6d7664e757f08 (diff)
downloadpoi-4703c18b83d2796c8d7f67bd15c75b74b555fb45.tar.gz
poi-4703c18b83d2796c8d7f67bd15c75b74b555fb45.zip
Miscellaneous fixes for chart functionalities
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1871010 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/examples')
-rw-r--r--src/examples/src/org/apache/poi/xslf/usermodel/ChartFromScratch.java17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/examples/src/org/apache/poi/xslf/usermodel/ChartFromScratch.java b/src/examples/src/org/apache/poi/xslf/usermodel/ChartFromScratch.java
index 1e923b9aab..637b485bda 100644
--- a/src/examples/src/org/apache/poi/xslf/usermodel/ChartFromScratch.java
+++ b/src/examples/src/org/apache/poi/xslf/usermodel/ChartFromScratch.java
@@ -87,11 +87,9 @@ public class ChartFromScratch {
Double[] values2 = listSpeakers.toArray(new Double[0]);
try (XMLSlideShow ppt = new XMLSlideShow()) {
- XSLFSlide slide = ppt.createSlide();
- XSLFChart chart = ppt.createChart();
- Rectangle2D rect2D = new java.awt.Rectangle(fromCM(1.5), fromCM(4), fromCM(22), fromCM(14));
- slide.addChart(chart, rect2D);
- setBarData(chart, chartTitle, series, categories, values1, values2);
+ createSlideWithChart(ppt, chartTitle, series, categories, values1, values2);
+ createSlideWithChart(ppt, chartTitle, series, categories, values1, values2);
+ createSlideWithChart(ppt, chartTitle, series, categories, values1, values2);
// save the result
try (OutputStream out = new FileOutputStream("chart-from-scratch.pptx")) {
ppt.write(out);
@@ -101,6 +99,15 @@ public class ChartFromScratch {
System.out.println("Done");
}
+ private static void createSlideWithChart(XMLSlideShow ppt, String chartTitle, String[] series, String[] categories,
+ Double[] values1, Double[] values2) {
+ XSLFSlide slide = ppt.createSlide();
+ XSLFChart chart = ppt.createChart();
+ Rectangle2D rect2D = new java.awt.Rectangle(fromCM(1.5), fromCM(4), fromCM(22), fromCM(14));
+ slide.addChart(chart, rect2D);
+ setBarData(chart, chartTitle, series, categories, values1, values2);
+ }
+
private static int fromCM(double cm) {
return (int) (Math.rint(cm * Units.EMU_PER_CENTIMETER));
}