1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
|
/* ====================================================================
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.List;
import org.apache.poi.util.Beta;
import org.apache.poi.util.Internal;
import org.apache.poi.xddf.usermodel.XDDFShapeProperties;
import org.openxmlformats.schemas.drawingml.x2006.chart.*;
@Beta
public class XDDFPie3DChartData extends XDDFChartData {
private CTPie3DChart chart;
@Internal
protected XDDFPie3DChartData(XDDFChart parent, CTPie3DChart chart) {
super(parent);
this.chart = chart;
for (CTPieSer series : chart.getSerList()) {
this.series.add(new Series(series, series.getCat(), series.getVal()));
}
}
@Internal
@Override
protected void removeCTSeries(int n) {
chart.removeSer(n);
}
@Override
public void setVaryColors(Boolean varyColors) {
if (varyColors == null) {
if (chart.isSetVaryColors()) {
chart.unsetVaryColors();
}
} else {
if (chart.isSetVaryColors()) {
chart.getVaryColors().setVal(varyColors);
} else {
chart.addNewVaryColors().setVal(varyColors);
}
}
}
@Override
public XDDFChartData.Series addSeries(XDDFDataSource<?> category,
XDDFNumericalDataSource<? extends Number> values) {
final long index = this.parent.incrementSeriesCount();
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;
}
/**
* @since POI 5.2.3
*/
public CTPieSer getCTPieSer() {
return 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 null;
}
}
public void setExplosion(Long explosion) {
if (explosion == null) {
if (series.isSetExplosion()) {
series.unsetExplosion();
}
} else {
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
protected void setIndex(long val) {
series.getIdx().setVal(val);
}
@Override
protected void setOrder(long val) {
series.getOrder().setVal(val);
}
@Override
protected List<CTDPt> getDPtList() {
return series.getDPtList();
}
}
}
|