remove some deprecated classes

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1879269 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
PJ Fanning 2020-06-27 13:25:40 +00:00
parent a126dae032
commit fdd73de259
7 changed files with 18 additions and 653 deletions

View File

@ -124,7 +124,7 @@ public final class FormulaRecord extends CellRecord {
* @deprecated POI 5.0.0, will be removed in 6.0, use getCachedResultTypeEnum until switch to enum is fully done
*/
@Deprecated
@Removal(version = "6.0.0")
@Removal(version = "6.0.0XSSFScatterChartData.java")
public int getCachedResultType() {
if (specialCachedValue == null) {
return CellType.NUMERIC.getCode();

View File

@ -17,52 +17,32 @@
package org.apache.poi.xssf.usermodel;
import static org.apache.poi.ooxml.POIXMLTypeLoader.DEFAULT_XML_OPTIONS;
import org.apache.poi.ooxml.POIXMLFactory;
import org.apache.poi.ooxml.POIXMLRelation;
import org.apache.poi.openxml4j.opc.PackagePart;
import org.apache.poi.util.Removal;
import org.apache.poi.xddf.usermodel.chart.XDDFChart;
import org.apache.poi.xssf.usermodel.charts.XSSFChartAxis;
import org.apache.xmlbeans.XmlException;
import org.apache.xmlbeans.XmlObject;
import org.apache.xmlbeans.XmlOptions;
import org.openxmlformats.schemas.drawingml.x2006.chart.*;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.w3c.dom.Text;
import javax.xml.namespace.QName;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
import javax.xml.namespace.QName;
import org.apache.poi.ooxml.POIXMLFactory;
import org.apache.poi.ooxml.POIXMLRelation;
import org.apache.poi.openxml4j.opc.PackagePart;
import org.apache.poi.ss.usermodel.Chart;
import org.apache.poi.ss.usermodel.charts.ChartAxis;
import org.apache.poi.ss.usermodel.charts.ChartAxisFactory;
import org.apache.poi.ss.usermodel.charts.ChartData;
import org.apache.poi.util.Removal;
import org.apache.poi.xddf.usermodel.chart.XDDFChart;
import org.apache.poi.xssf.usermodel.charts.XSSFCategoryAxis;
import org.apache.poi.xssf.usermodel.charts.XSSFChartAxis;
import org.apache.poi.xssf.usermodel.charts.XSSFChartDataFactory;
import org.apache.poi.xssf.usermodel.charts.XSSFChartLegend;
import org.apache.poi.xssf.usermodel.charts.XSSFDateAxis;
import org.apache.poi.xssf.usermodel.charts.XSSFManualLayout;
import org.apache.poi.xssf.usermodel.charts.XSSFValueAxis;
import org.apache.xmlbeans.XmlException;
import org.apache.xmlbeans.XmlObject;
import org.apache.xmlbeans.XmlOptions;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTCatAx;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTChartSpace;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTDateAx;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTPageMargins;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTPlotArea;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTPrintSettings;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTStrRef;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTTitle;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTTx;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTValAx;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.w3c.dom.Text;
import static org.apache.poi.ooxml.POIXMLTypeLoader.DEFAULT_XML_OPTIONS;
/**
* Represents a SpreadsheetML Chart
*/
public final class XSSFChart extends XDDFChart implements Chart, ChartAxisFactory {
public final class XSSFChart extends XDDFChart {
/**
* Parent graphic frame.
@ -170,92 +150,6 @@ public final class XSSFChart extends XDDFChart implements Chart, ChartAxisFactor
this.frame = frame;
}
@Override
@Deprecated
@Removal(version = "4.2")
public XSSFChartDataFactory getChartDataFactory() {
return XSSFChartDataFactory.getInstance();
}
@Override
@Deprecated
@Removal(version = "4.2")
public XSSFChart getChartAxisFactory() {
return this;
}
@Override
@Deprecated
@Removal(version = "4.2")
public void plot(ChartData data, ChartAxis... chartAxis) {
data.fillChart(this, chartAxis);
}
@Override
@Deprecated
@Removal(version = "4.2")
public XSSFValueAxis createValueAxis(org.apache.poi.ss.usermodel.charts.AxisPosition pos) {
long id = axis.size() + 1L;
XSSFValueAxis valueAxis = new XSSFValueAxis(this, id, pos);
if (axis.size() == 1) {
ChartAxis ax = axis.get(0);
ax.crossAxis(valueAxis);
valueAxis.crossAxis(ax);
}
axis.add(valueAxis);
return valueAxis;
}
@Override
@Deprecated
@Removal(version = "4.2")
public XSSFCategoryAxis createCategoryAxis(org.apache.poi.ss.usermodel.charts.AxisPosition pos) {
long id = axis.size() + 1L;
XSSFCategoryAxis categoryAxis = new XSSFCategoryAxis(this, id, pos);
if (axis.size() == 1) {
ChartAxis ax = axis.get(0);
ax.crossAxis(categoryAxis);
categoryAxis.crossAxis(ax);
}
axis.add(categoryAxis);
return categoryAxis;
}
@Override
@Deprecated
@Removal(version = "4.2")
public XSSFDateAxis createDateAxis(org.apache.poi.ss.usermodel.charts.AxisPosition pos) {
long id = axis.size() + 1L;
XSSFDateAxis dateAxis = new XSSFDateAxis(this, id, pos);
if (axis.size() == 1) {
ChartAxis ax = axis.get(0);
ax.crossAxis(dateAxis);
dateAxis.crossAxis(ax);
}
axis.add(dateAxis);
return dateAxis;
}
/**
* @deprecated use {@link #getAxes()} instead
*/
@Override
@Deprecated
@Removal(version = "4.2")
public List<? extends XSSFChartAxis> getAxis() {
if (axis.isEmpty() && hasAxis()) {
parseAxis();
}
return axis;
}
@Override
@Deprecated
@Removal(version = "4.2")
public XSSFManualLayout getManualLayout() {
return new XSSFManualLayout(this);
}
/**
* Returns the title static text, or null if none is set. Note that a title
* formula may be set instead. Empty text result is for backward
@ -348,54 +242,4 @@ public final class XSSFChart extends XDDFChart implements Chart, ChartAxisFactor
strRef.setF(formula);
}
@Override
@Deprecated
@Removal(version = "4.2")
public XSSFChartLegend getOrCreateLegend() {
return new XSSFChartLegend(this);
}
@Deprecated
@Removal(version = "4.2")
private boolean hasAxis() {
CTPlotArea ctPlotArea = chart.getPlotArea();
int totalAxisCount = ctPlotArea.sizeOfValAxArray() + ctPlotArea.sizeOfCatAxArray() + ctPlotArea
.sizeOfDateAxArray() + ctPlotArea.sizeOfSerAxArray();
return totalAxisCount > 0;
}
@Deprecated
@Removal(version = "4.2")
private void parseAxis() {
// TODO: add other axis types
parseCategoryAxis();
parseDateAxis();
parseValueAxis();
}
@Deprecated
@Removal(version = "4.2")
private void parseCategoryAxis() {
for (CTCatAx catAx : chart.getPlotArea().getCatAxArray()) {
axis.add(new XSSFCategoryAxis(this, catAx));
}
}
@Deprecated
@Removal(version = "4.2")
private void parseDateAxis() {
for (CTDateAx dateAx : chart.getPlotArea().getDateAxArray()) {
axis.add(new XSSFDateAxis(this, dateAx));
}
}
@Deprecated
@Removal(version = "4.2")
private void parseValueAxis() {
for (CTValAx valAx : chart.getPlotArea().getValAxArray()) {
axis.add(new XSSFValueAxis(this, valAx));
}
}
}

View File

@ -1,62 +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.charts.ChartDataFactory;
import org.apache.poi.util.Removal;
/**
* @deprecated
*/
@Deprecated
@Removal(version="4.2")
public class XSSFChartDataFactory implements ChartDataFactory {
private static XSSFChartDataFactory instance;
private XSSFChartDataFactory() {
super();
}
/**
* @return new scatter charts data instance
*/
@Override
public XSSFScatterChartData createScatterChartData() {
return new XSSFScatterChartData();
}
/**
* @return new line charts data instance
*/
@Override
public XSSFLineChartData createLineChartData() {
return new XSSFLineChartData();
}
/**
* @return factory instance
*/
public static XSSFChartDataFactory getInstance() {
if (instance == null) {
instance = new XSSFChartDataFactory();
}
return instance;
}
}

View File

@ -1,137 +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.charts.ChartLegend;
import org.apache.poi.ss.usermodel.charts.LegendPosition;
import org.apache.poi.util.Internal;
import org.apache.poi.util.Removal;
import org.apache.poi.xddf.usermodel.chart.XDDFChartLegend;
import org.apache.poi.xssf.usermodel.XSSFChart;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTChart;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTLegend;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTLegendPos;
import org.openxmlformats.schemas.drawingml.x2006.chart.STLegendPos;
/**
* Represents a SpreadsheetML chart legend
* @deprecated use {@link XDDFChartLegend} instead
*/
@Deprecated
@Removal(version="4.2")
public final class XSSFChartLegend implements ChartLegend {
/**
* Underlaying CTLagend bean
*/
private CTLegend legend;
/**
* Create a new SpreadsheetML chart legend
*/
public XSSFChartLegend(XSSFChart chart) {
CTChart ctChart = chart.getCTChart();
this.legend = (ctChart.isSetLegend()) ?
ctChart.getLegend() :
ctChart.addNewLegend();
setDefaults();
}
/**
* Set sensible default styling.
*/
private void setDefaults() {
if (!legend.isSetOverlay()) {
legend.addNewOverlay();
}
legend.getOverlay().setVal(false);
}
/**
* Return the underlying CTLegend bean.
*
* @return the underlying CTLegend bean
*/
@Internal
public CTLegend getCTLegend(){
return legend;
}
@Override
public void setPosition(LegendPosition position) {
if (!legend.isSetLegendPos()) {
legend.addNewLegendPos();
}
legend.getLegendPos().setVal(fromLegendPosition(position));
}
/*
* According to ECMA-376 default position is RIGHT.
*/
@Override
public LegendPosition getPosition() {
if (legend.isSetLegendPos()) {
return toLegendPosition(legend.getLegendPos());
} else {
return LegendPosition.RIGHT;
}
}
@Override
public XSSFManualLayout getManualLayout() {
if (!legend.isSetLayout()) {
legend.addNewLayout();
}
return new XSSFManualLayout(legend.getLayout());
}
@Override
public boolean isOverlay() {
return legend.getOverlay().getVal();
}
@Override
public void setOverlay(boolean value) {
legend.getOverlay().setVal(value);
}
private STLegendPos.Enum fromLegendPosition(LegendPosition position) {
switch (position) {
case BOTTOM: return STLegendPos.B;
case LEFT: return STLegendPos.L;
case RIGHT: return STLegendPos.R;
case TOP: return STLegendPos.T;
case TOP_RIGHT: return STLegendPos.TR;
default:
throw new IllegalArgumentException();
}
}
private LegendPosition toLegendPosition(CTLegendPos ctLegendPos) {
switch (ctLegendPos.getVal().intValue()) {
case STLegendPos.INT_B: return LegendPosition.BOTTOM;
case STLegendPos.INT_L: return LegendPosition.LEFT;
case STLegendPos.INT_R: return LegendPosition.RIGHT;
case STLegendPos.INT_T: return LegendPosition.TOP;
case STLegendPos.INT_TR: return LegendPosition.TOP_RIGHT;
default:
throw new IllegalArgumentException();
}
}
}

View File

@ -1,131 +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 java.util.ArrayList;
import java.util.List;
import org.apache.poi.ss.usermodel.Chart;
import org.apache.poi.ss.usermodel.charts.ChartAxis;
import org.apache.poi.ss.usermodel.charts.ChartDataSource;
import org.apache.poi.ss.usermodel.charts.LineChartData;
import org.apache.poi.ss.usermodel.charts.LineChartSeries;
import org.apache.poi.util.Removal;
import org.apache.poi.xddf.usermodel.chart.XDDFLineChartData;
import org.apache.poi.xssf.usermodel.XSSFChart;
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.CTNumDataSource;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTPlotArea;
import org.openxmlformats.schemas.drawingml.x2006.chart.STMarkerStyle;
/**
* Holds data for a XSSF Line Chart
*
* @deprecated use {@link XDDFLineChartData} instead
*/
@Deprecated
@Removal(version="4.2")
public class XSSFLineChartData implements LineChartData {
/**
* List of all data series.
*/
private final List<Series> series = new ArrayList<>();
static class Series extends AbstractXSSFChartSeries implements LineChartSeries {
private int id;
private int order;
private ChartDataSource<?> categories;
private ChartDataSource<? extends Number> values;
protected Series(int id, int order,
ChartDataSource<?> categories,
ChartDataSource<? extends Number> values) {
this.id = id;
this.order = order;
this.categories = categories;
this.values = values;
}
@Override
public ChartDataSource<?> getCategoryAxisData() {
return categories;
}
@Override
public ChartDataSource<? extends Number> getValues() {
return values;
}
protected void addToChart(CTLineChart ctLineChart) {
CTLineSer ctLineSer = ctLineChart.addNewSer();
ctLineSer.addNewIdx().setVal(id);
ctLineSer.addNewOrder().setVal(order);
// No marker symbol on the chart line.
ctLineSer.addNewMarker().addNewSymbol().setVal(STMarkerStyle.NONE);
CTAxDataSource catDS = ctLineSer.addNewCat();
XSSFChartUtil.buildAxDataSource(catDS, categories);
CTNumDataSource valueDS = ctLineSer.addNewVal();
XSSFChartUtil.buildNumDataSource(valueDS, values);
if (isTitleSet()) {
ctLineSer.setTx(getCTSerTx());
}
}
}
@Override
public LineChartSeries addSeries(ChartDataSource<?> categoryAxisData, ChartDataSource<? extends Number> values) {
if (!values.isNumeric()) {
throw new IllegalArgumentException("Value data source must be numeric.");
}
int numOfSeries = series.size();
Series newSeries = new Series(numOfSeries, numOfSeries, categoryAxisData, values);
series.add(newSeries);
return newSeries;
}
@Override
public List<? extends LineChartSeries> getSeries() {
return series;
}
@Override
public void fillChart(Chart chart, ChartAxis... axis) {
if (!(chart instanceof XSSFChart)) {
throw new IllegalArgumentException("Chart must be instance of XSSFChart");
}
XSSFChart xssfChart = (XSSFChart) chart;
CTPlotArea plotArea = xssfChart.getCTChart().getPlotArea();
CTLineChart lineChart = plotArea.addNewLineChart();
lineChart.addNewVaryColors().setVal(false);
for (Series s : series) {
s.addToChart(lineChart);
}
for (ChartAxis ax : axis) {
lineChart.addNewAxId().setVal(ax.getId());
}
}
}

View File

@ -1,149 +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 java.util.ArrayList;
import java.util.List;
import org.apache.poi.ss.usermodel.Chart;
import org.apache.poi.ss.usermodel.charts.ChartAxis;
import org.apache.poi.ss.usermodel.charts.ChartDataSource;
import org.apache.poi.ss.usermodel.charts.ScatterChartData;
import org.apache.poi.ss.usermodel.charts.ScatterChartSeries;
import org.apache.poi.util.Removal;
import org.apache.poi.xddf.usermodel.chart.XDDFScatterChartData;
import org.apache.poi.xssf.usermodel.XSSFChart;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTAxDataSource;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTNumDataSource;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTPlotArea;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTScatterChart;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTScatterSer;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTScatterStyle;
import org.openxmlformats.schemas.drawingml.x2006.chart.STScatterStyle;
/**
* Represents DrawingML scatter charts.
*
* @deprecated use {@link XDDFScatterChartData} instead
*/
@Deprecated
@Removal(version="4.2")
public class XSSFScatterChartData implements ScatterChartData {
/**
* List of all data series.
*/
private final List<Series> series = new ArrayList<>();
/**
* Package private ScatterChartSerie implementation.
*/
static class Series extends AbstractXSSFChartSeries implements ScatterChartSeries {
private int id;
private int order;
private ChartDataSource<?> xs;
private ChartDataSource<? extends Number> ys;
protected Series(int id, int order,
ChartDataSource<?> xs,
ChartDataSource<? extends Number> ys) {
super();
this.id = id;
this.order = order;
this.xs = xs;
this.ys = ys;
}
/**
* Returns data source used for X axis values.
* @return data source used for X axis values
*/
@Override
public ChartDataSource<?> getXValues() {
return xs;
}
/**
* Returns data source used for Y axis values.
* @return data source used for Y axis values
*/
@Override
public ChartDataSource<? extends Number> getYValues() {
return ys;
}
protected void addToChart(CTScatterChart ctScatterChart) {
CTScatterSer scatterSer = ctScatterChart.addNewSer();
scatterSer.addNewIdx().setVal(this.id);
scatterSer.addNewOrder().setVal(this.order);
CTAxDataSource xVal = scatterSer.addNewXVal();
XSSFChartUtil.buildAxDataSource(xVal, xs);
CTNumDataSource yVal = scatterSer.addNewYVal();
XSSFChartUtil.buildNumDataSource(yVal, ys);
if (isTitleSet()) {
scatterSer.setTx(getCTSerTx());
}
}
}
@Override
public ScatterChartSeries addSerie(ChartDataSource<?> xs,
ChartDataSource<? extends Number> ys) {
if (!ys.isNumeric()) {
throw new IllegalArgumentException("Y axis data source must be numeric.");
}
int numOfSeries = series.size();
Series newSerie = new Series(numOfSeries, numOfSeries, xs, ys);
series.add(newSerie);
return newSerie;
}
@Override
public void fillChart(Chart chart, ChartAxis... axis) {
if (!(chart instanceof XSSFChart)) {
throw new IllegalArgumentException("Chart must be instance of XSSFChart");
}
XSSFChart xssfChart = (XSSFChart) chart;
CTPlotArea plotArea = xssfChart.getCTChart().getPlotArea();
CTScatterChart scatterChart = plotArea.addNewScatterChart();
addStyle(scatterChart);
for (Series s : series) {
s.addToChart(scatterChart);
}
for (ChartAxis ax : axis) {
scatterChart.addNewAxId().setVal(ax.getId());
}
}
@Override
public List<? extends Series> getSeries() {
return series;
}
private void addStyle(CTScatterChart ctScatterChart) {
CTScatterStyle scatterStyle = ctScatterChart.addNewScatterStyle();
scatterStyle.setVal(STScatterStyle.LINE_MARKER);
}
}

View File

@ -35,7 +35,7 @@ import org.junit.Test;
/**
* Tests ChartLegend
*/
public final class TestXSSFChartLegend {
public final class TestXDDFChartLegend {
@Test
public void testLegendPositionAccessMethods() throws IOException {
XSSFWorkbook wb = new XSSFWorkbook();