瀏覽代碼

remove some deprecated classes

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1879276 13f79535-47bb-0310-9956-ffa450edef68
tags/before_ooxml_3rd_edition
PJ Fanning 3 年之前
父節點
當前提交
883d6bb987
共有 28 個文件被更改,包括 2 次插入1612 次删除
  1. 1
    13
      src/java/org/apache/poi/ss/usermodel/CellValue.java
  2. 0
    70
      src/java/org/apache/poi/ss/usermodel/Chart.java
  3. 0
    40
      src/java/org/apache/poi/ss/usermodel/charts/AxisCrossBetween.java
  4. 0
    44
      src/java/org/apache/poi/ss/usermodel/charts/AxisCrosses.java
  5. 0
    40
      src/java/org/apache/poi/ss/usermodel/charts/AxisOrientation.java
  6. 0
    34
      src/java/org/apache/poi/ss/usermodel/charts/AxisPosition.java
  7. 0
    34
      src/java/org/apache/poi/ss/usermodel/charts/AxisTickMark.java
  8. 0
    163
      src/java/org/apache/poi/ss/usermodel/charts/ChartAxis.java
  9. 0
    49
      src/java/org/apache/poi/ss/usermodel/charts/ChartAxisFactory.java
  10. 0
    39
      src/java/org/apache/poi/ss/usermodel/charts/ChartData.java
  11. 0
    41
      src/java/org/apache/poi/ss/usermodel/charts/ChartDataFactory.java
  12. 0
    73
      src/java/org/apache/poi/ss/usermodel/charts/ChartDataSource.java
  13. 0
    55
      src/java/org/apache/poi/ss/usermodel/charts/ChartLegend.java
  14. 0
    59
      src/java/org/apache/poi/ss/usermodel/charts/ChartSeries.java
  15. 0
    163
      src/java/org/apache/poi/ss/usermodel/charts/DataSources.java
  16. 0
    39
      src/java/org/apache/poi/ss/usermodel/charts/LayoutMode.java
  17. 0
    43
      src/java/org/apache/poi/ss/usermodel/charts/LayoutTarget.java
  18. 0
    35
      src/java/org/apache/poi/ss/usermodel/charts/LegendPosition.java
  19. 0
    44
      src/java/org/apache/poi/ss/usermodel/charts/LineChartData.java
  20. 0
    41
      src/java/org/apache/poi/ss/usermodel/charts/LineChartSeries.java
  21. 0
    154
      src/java/org/apache/poi/ss/usermodel/charts/ManualLayout.java
  22. 0
    37
      src/java/org/apache/poi/ss/usermodel/charts/ManuallyPositionable.java
  23. 0
    43
      src/java/org/apache/poi/ss/usermodel/charts/ScatterChartData.java
  24. 0
    41
      src/java/org/apache/poi/ss/usermodel/charts/ScatterChartSeries.java
  25. 0
    32
      src/java/org/apache/poi/ss/usermodel/charts/TitleType.java
  26. 0
    38
      src/java/org/apache/poi/ss/usermodel/charts/ValueAxis.java
  27. 1
    1
      src/testcases/org/apache/poi/ss/formula/functions/TestAreas.java
  28. 0
    147
      src/testcases/org/apache/poi/ss/usermodel/charts/TestDataSources.java

+ 1
- 13
src/java/org/apache/poi/ss/usermodel/CellValue.java 查看文件

@@ -18,7 +18,6 @@
package org.apache.poi.ss.usermodel;

import org.apache.poi.ss.formula.eval.ErrorEval;
import org.apache.poi.util.Removal;

/**
* Mimics the 'data view' of a cell. This allows formula evaluator
@@ -27,7 +26,7 @@ import org.apache.poi.util.Removal;
*/
public final class CellValue {
public static final CellValue TRUE = new CellValue(CellType.BOOLEAN, 0.0, true, null, 0);
public static final CellValue FALSE= new CellValue(CellType.BOOLEAN, 0.0, false, null, 0);
public static final CellValue FALSE = new CellValue(CellType.BOOLEAN, 0.0, false, null, 0);

private final CellType _cellType;
private final double _numberValue;
@@ -83,17 +82,6 @@ public final class CellValue {
return _textValue;
}

/**
* Return the cell type.
*
* @return the cell type
* @since POI 3.15
* @deprecated use <code>getCellType</code> instead
*/
@Deprecated
@Removal(version="4.2")
public CellType getCellTypeEnum() { return getCellType(); }

/**
* Return the cell type.
*

+ 0
- 70
src/java/org/apache/poi/ss/usermodel/Chart.java 查看文件

@@ -1,70 +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.ss.usermodel;

import java.util.List;

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.ss.usermodel.charts.ChartDataFactory;
import org.apache.poi.ss.usermodel.charts.ChartLegend;
import org.apache.poi.ss.usermodel.charts.ManuallyPositionable;
import org.apache.poi.util.Removal;

/**
* High level representation of a chart.
*
* @deprecated
*/
@Deprecated
@Removal(version="4.2")
public interface Chart extends ManuallyPositionable {

/**
* @return an appropriate ChartDataFactory implementation
*/
ChartDataFactory getChartDataFactory();

/**
* @return an appropriate ChartAxisFactory implementation
*/
ChartAxisFactory getChartAxisFactory();

/**
* @return chart legend instance
*/
ChartLegend getOrCreateLegend();

/**
* Delete current chart legend.
*/
void deleteLegend();

/**
* @return list of all chart axis
*/
List<? extends ChartAxis> getAxis();

/**
* Plots specified data on the chart.
*
* @param data a data to plot
*/
void plot(ChartData data, ChartAxis... axis);
}

+ 0
- 40
src/java/org/apache/poi/ss/usermodel/charts/AxisCrossBetween.java 查看文件

@@ -1,40 +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.ss.usermodel.charts;

import org.apache.poi.util.Removal;

/**
* Specifies the possible crossing states of an axis.
*
* @deprecated use XDDF AxisCrossBetween
*/
@Deprecated
@Removal(version="4.2")
public enum AxisCrossBetween {
/**
* Specifies the value axis shall cross the category axis
* between data markers.
*/
BETWEEN,
/**
* Specifies the value axis shall cross the category axis at
* the midpoint of a category.
*/
MIDPOINT_CATEGORY
}

+ 0
- 44
src/java/org/apache/poi/ss/usermodel/charts/AxisCrosses.java 查看文件

@@ -1,44 +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.ss.usermodel.charts;

import org.apache.poi.util.Removal;

/**
* Specifies the possible crossing points for an axis.
*
* @deprecated use XDDF AxisCrosses instead
*/
@Deprecated
@Removal(version="4.2")
public enum AxisCrosses {
/**
* The category axis crosses at the zero point of the value axis (if
* possible), or the minimum value (if the minimum is greater than zero) or
* the maximum (if the maximum is less than zero).
*/
AUTO_ZERO,
/**
* The axis crosses at the maximum value.
*/
MIN,
/**
* Axis crosses at the minimum value of the chart.
*/
MAX
}

+ 0
- 40
src/java/org/apache/poi/ss/usermodel/charts/AxisOrientation.java 查看文件

@@ -1,40 +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.ss.usermodel.charts;

import org.apache.poi.util.Removal;

/**
* Specifies the possible ways to place a picture on a data point, series, wall, or floor.
*
* @deprecated use XDDF AxisOrientation
*/
@Deprecated
@Removal(version="4.2")
public enum AxisOrientation {
/**
* Specifies that the values on the axis shall be reversed
* so they go from maximum to minimum.
*/
MAX_MIN,
/**
* Specifies that the axis values shall be in the usual
* order, minimum to maximum.
*/
MIN_MAX
}

+ 0
- 34
src/java/org/apache/poi/ss/usermodel/charts/AxisPosition.java 查看文件

@@ -1,34 +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.ss.usermodel.charts;

import org.apache.poi.util.Removal;

/**
* Enumeration of all possible axis positions.
*
* @deprecated use XDDF AxisPosition instead
*/
@Deprecated
@Removal(version="4.2")
public enum AxisPosition {
BOTTOM,
LEFT,
RIGHT,
TOP
}

+ 0
- 34
src/java/org/apache/poi/ss/usermodel/charts/AxisTickMark.java 查看文件

@@ -1,34 +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.ss.usermodel.charts;

import org.apache.poi.util.Removal;

/**
* Enumeration of possible axis tick marks.
*
* @deprecated use XDDF AxisTickMark instead
*/
@Deprecated
@Removal(version="4.2")
public enum AxisTickMark {
NONE,
CROSS,
IN,
OUT
}

+ 0
- 163
src/java/org/apache/poi/ss/usermodel/charts/ChartAxis.java 查看文件

@@ -1,163 +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.ss.usermodel.charts;

import org.apache.poi.util.Removal;

/**
* High level representation of chart axis.
*
* @deprecated use XDDFChartAxis instead
*/
@Deprecated
@Removal(version="4.2")
public interface ChartAxis {

/**
* @return axis id
*/
long getId();

/**
* @return axis position
*/
AxisPosition getPosition();

/**
* @param position new axis position
*/
void setPosition(AxisPosition position);

/**
* @return axis number format
*/
String getNumberFormat();

/**
* @param format axis number format
*/
void setNumberFormat(String format);

/**
* @return true if log base is defined, false otherwise
*/
boolean isSetLogBase();

/**
* @param logBase a number between 2 and 1000 (inclusive)
* @throws IllegalArgumentException if log base not within allowed range
*/
void setLogBase(double logBase);

/**
* @return axis log base or 0.0 if not set
*/
double getLogBase();

/**
* @return true if minimum value is defined, false otherwise
*/
boolean isSetMinimum();

/**
* @return axis minimum or 0.0 if not set
*/
double getMinimum();

/**
* @param min axis minimum
*/
void setMinimum(double min);

/**
* @return true if maximum value is defined, false otherwise
*/
boolean isSetMaximum();

/**
* @return axis maximum or 0.0 if not set
*/
double getMaximum();

/**
* @param max axis maximum
*/
void setMaximum(double max);

/**
* @return axis orientation
*/
AxisOrientation getOrientation();

/**
* @param orientation axis orientation
*/
void setOrientation(AxisOrientation orientation);

/**
* @param crosses axis cross type
*/
void setCrosses(AxisCrosses crosses);

/**
* @return axis cross type
*/
AxisCrosses getCrosses();

/**
* Declare this axis cross another axis.
* @param axis that this axis should cross
*/
void crossAxis(ChartAxis axis);

/**
* @return visibility of the axis.
*/
boolean isVisible();

/**
* @param value visibility of the axis.
*/
void setVisible(boolean value);

/**
* @return major tick mark.
*/
AxisTickMark getMajorTickMark();

/**
* @param tickMark major tick mark type.
*/
void setMajorTickMark(AxisTickMark tickMark);

/**
* @return minor tick mark.
*/
AxisTickMark getMinorTickMark();

/**
* @param tickMark minor tick mark type.
*/
void setMinorTickMark(AxisTickMark tickMark);

/**
* Use this to check before retrieving a number format, as calling {@link #getNumberFormat()} may create a default one if none exists.
* @return true if a number format element is defined, false if not
*/
boolean hasNumberFormat();
}

+ 0
- 49
src/java/org/apache/poi/ss/usermodel/charts/ChartAxisFactory.java 查看文件

@@ -1,49 +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.ss.usermodel.charts;

import org.apache.poi.util.Removal;

/**
* A factory for different chart axis.
*
* @deprecated
*/
@Deprecated
@Removal(version="4.2")
public interface ChartAxisFactory {

/**
* @param pos
* @return new value axis at the end of the list at the specified chart position
*/
ValueAxis createValueAxis(AxisPosition pos);

/**
* @param pos
* @return new category axis at the end of the list at the specified chart position
*/
ChartAxis createCategoryAxis(AxisPosition pos);

/**
* @param pos
* @return new date category axis at the end of the list at the specified chart position
*/
ChartAxis createDateAxis(AxisPosition pos);

}

+ 0
- 39
src/java/org/apache/poi/ss/usermodel/charts/ChartData.java 查看文件

@@ -1,39 +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.ss.usermodel.charts;

import org.apache.poi.ss.usermodel.Chart;
import org.apache.poi.util.Removal;

/**
* A base for all charts data types.
*
* @deprecated use XDDFChartData instead
*/
@Deprecated
@Removal(version="4.2")
public interface ChartData {

/**
* Fills a charts with data specified by implementation.
*
* @param chart a charts to fill in
* @param axis charts axis to use
*/
void fillChart(Chart chart, ChartAxis... axis);
}

+ 0
- 41
src/java/org/apache/poi/ss/usermodel/charts/ChartDataFactory.java 查看文件

@@ -1,41 +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.ss.usermodel.charts;

import org.apache.poi.util.Removal;

/**
* A factory for different charts data types.
*
* @deprecated
*/
@Deprecated
@Removal(version="4.2")
public interface ChartDataFactory {

/**
* @return an appropriate ScatterChartData instance
*/
ScatterChartData createScatterChartData();

/**
* @return a LineChartData instance
*/
LineChartData createLineChartData();

}

+ 0
- 73
src/java/org/apache/poi/ss/usermodel/charts/ChartDataSource.java 查看文件

@@ -1,73 +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.ss.usermodel.charts;

import org.apache.poi.util.Removal;

/**
* Represents data model of the charts.
*
* @param <T> type of points the data source contents
* @deprecated use XDDFDataSource instead
*/
@Deprecated
@Removal(version="4.2")
public interface ChartDataSource<T> {

/**
* Return number of points contained by data source.
*
* @return number of points contained by data source
*/
int getPointCount();

/**
* Returns point value at specified index.
*
* @param index index to value from
* @return point value at specified index.
* @throws {@code IndexOutOfBoundsException} if index
* parameter not in range {@code 0 <= index <= pointCount}
*/
T getPointAt(int index);

/**
* Returns {@code true} if charts data source is valid cell range.
*
* @return {@code true} if charts data source is valid cell range
*/
boolean isReference();

/**
* Returns {@code true} if data source points should be treated as numbers.
*
* @return {@code true} if data source points should be treated as numbers
*/
boolean isNumeric();

/**
* Returns formula representation of the data source. It is only applicable
* for data source that is valid cell range.
*
* @return formula representation of the data source
* @throws {@code UnsupportedOperationException} if the data source is not a
* reference.
*/
String getFormulaString();
}

+ 0
- 55
src/java/org/apache/poi/ss/usermodel/charts/ChartLegend.java 查看文件

@@ -1,55 +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.ss.usermodel.charts;

import org.apache.poi.util.Removal;

/**
* High level representation of chart legend.
*
* @deprecated use XDDFChartLegend instead
*/
@Deprecated
@Removal(version="4.2")
public interface ChartLegend extends ManuallyPositionable {

/**
* @return legend position
*/
LegendPosition getPosition();

/**
* @param position new legend position
*/
void setPosition(LegendPosition position);

/**
* @return overlay value.
*/
boolean isOverlay();

/**
* If true the legend is positioned over the chart area otherwise
* the legend is displayed next to it.
*
* Default is no overlay.
*
* @param value
*/
void setOverlay(boolean value);
}

+ 0
- 59
src/java/org/apache/poi/ss/usermodel/charts/ChartSeries.java 查看文件

@@ -1,59 +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.ss.usermodel.charts;

import org.apache.poi.ss.util.CellReference;
import org.apache.poi.util.Removal;

/**
* Basic settings for all chart series.
* @deprecated
*/
@Deprecated
@Removal(version="4.2")
public interface ChartSeries {

/**
* Sets the title of the series as a string literal.
*
* @param title
*/
void setTitle(String title);

/**
* Sets the title of the series as a cell reference.
*
* @param titleReference
*/
void setTitle(CellReference titleReference);

/**
* @return title as string literal.
*/
String getTitleString();

/**
* @return title as cell reference.
*/
CellReference getTitleCellReference();

/**
* @return title type.
*/
TitleType getTitleType();
}

+ 0
- 163
src/java/org/apache/poi/ss/usermodel/charts/DataSources.java 查看文件

@@ -1,163 +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.ss.usermodel.charts;

import org.apache.poi.ss.usermodel.CellType;
import org.apache.poi.ss.usermodel.CellValue;
import org.apache.poi.ss.usermodel.FormulaEvaluator;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.util.Removal;

/**
* Class {@code DataSources} is a factory for {@link ChartDataSource} instances.
*
*@deprecated use XDDFDataSourcesFactory instead
*/
@Deprecated
@Removal(version="4.2")
public class DataSources {

private DataSources() {
}

public static <T> ChartDataSource<T> fromArray(T[] elements) {
return new ArrayDataSource<>(elements);
}

public static ChartDataSource<Number> fromNumericCellRange(Sheet sheet, CellRangeAddress cellRangeAddress) {
return new AbstractCellRangeDataSource<Number>(sheet, cellRangeAddress) {
@Override
public Number getPointAt(int index) {
CellValue cellValue = getCellValueAt(index);
if (cellValue != null && cellValue.getCellType() == CellType.NUMERIC) {
return Double.valueOf(cellValue.getNumberValue());
} else {
return null;
}
}

@Override
public boolean isNumeric() {
return true;
}
};
}

public static ChartDataSource<String> fromStringCellRange(Sheet sheet, CellRangeAddress cellRangeAddress) {
return new AbstractCellRangeDataSource<String>(sheet, cellRangeAddress) {
@Override
public String getPointAt(int index) {
CellValue cellValue = getCellValueAt(index);
if (cellValue != null && cellValue.getCellType() == CellType.STRING) {
return cellValue.getStringValue();
} else {
return null;
}
}

@Override
public boolean isNumeric() {
return false;
}
};
}

private static class ArrayDataSource<T> implements ChartDataSource<T> {

private final T[] elements;

public ArrayDataSource(T[] elements) {
this.elements = elements.clone();
}

@Override
public int getPointCount() {
return elements.length;
}

@Override
public T getPointAt(int index) {
return elements[index];
}

@Override
public boolean isReference() {
return false;
}

@Override
public boolean isNumeric() {
Class<?> arrayComponentType = elements.getClass().getComponentType();
return (Number.class.isAssignableFrom(arrayComponentType));
}

@Override
public String getFormulaString() {
throw new UnsupportedOperationException("Literal data source can not be expressed by reference.");
}
}

private abstract static class AbstractCellRangeDataSource<T> implements ChartDataSource<T> {
private final Sheet sheet;
private final CellRangeAddress cellRangeAddress;
private final int numOfCells;
private FormulaEvaluator evaluator;

protected AbstractCellRangeDataSource(Sheet sheet, CellRangeAddress cellRangeAddress) {
this.sheet = sheet;
// Make copy since CellRangeAddress is mutable.
this.cellRangeAddress = cellRangeAddress.copy();
this.numOfCells = this.cellRangeAddress.getNumberOfCells();
this.evaluator = sheet.getWorkbook().getCreationHelper().createFormulaEvaluator();
}

@Override
public int getPointCount() {
return numOfCells;
}

@Override
public boolean isReference() {
return true;
}

@Override
public String getFormulaString() {
return cellRangeAddress.formatAsString(sheet.getSheetName(), true);
}

protected CellValue getCellValueAt(int index) {
if (index < 0 || index >= numOfCells) {
throw new IndexOutOfBoundsException("Index must be between 0 and " +
(numOfCells - 1) + " (inclusive), given: " + index);
}
int firstRow = cellRangeAddress.getFirstRow();
int firstCol = cellRangeAddress.getFirstColumn();
int lastCol = cellRangeAddress.getLastColumn();
int width = lastCol - firstCol + 1;
int rowIndex = firstRow + index / width;
int cellIndex = firstCol + index % width;
Row row = sheet.getRow(rowIndex);
return (row == null) ? null : evaluator.evaluate(row.getCell(cellIndex));
}
}
}

+ 0
- 39
src/java/org/apache/poi/ss/usermodel/charts/LayoutMode.java 查看文件

@@ -1,39 +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.ss.usermodel.charts;

import org.apache.poi.util.Removal;

/**
* Specifies the possible ways to store a chart element's position.
* @see org.apache.poi.xddf.usermodel.chart.LayoutMode XDDF LayoutMode instead
*/
@Deprecated
@Removal(version="4.2")
public enum LayoutMode {
/**
* Specifies that the Width or Height shall be interpreted as the
* Right or Bottom of the chart element.
*/
EDGE,
/**
* Specifies that the Width or Height shall be interpreted as the
* Width or Height of the chart element.
*/
FACTOR
}

+ 0
- 43
src/java/org/apache/poi/ss/usermodel/charts/LayoutTarget.java 查看文件

@@ -1,43 +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.ss.usermodel.charts;

import org.apache.poi.util.Removal;

/**
* Specifies whether to layout the plot area by its inside (not including axis
* and axis labels) or outside (including axis and axis labels).
*
* @deprecated use XDDF LayoutTarget instead
*/
@Deprecated
@Removal(version="4.2")
public enum LayoutTarget {
/**
* Specifies that the plot area size shall determine the
* size of the plot area, not including the tick marks and
* axis labels.
*/
INNER,
/**
* Specifies that the plot area size shall determine the
* size of the plot area, the tick marks, and the axis
* labels.
*/
OUTER
}

+ 0
- 35
src/java/org/apache/poi/ss/usermodel/charts/LegendPosition.java 查看文件

@@ -1,35 +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.ss.usermodel.charts;

import org.apache.poi.util.Removal;

/**
* Enumeration of all possible chart legend positions.
*
* @deprecated use XDDF LayoutPosition instead
*/
@Deprecated
@Removal(version="4.2")
public enum LegendPosition {
BOTTOM,
LEFT,
RIGHT,
TOP,
TOP_RIGHT
}

+ 0
- 44
src/java/org/apache/poi/ss/usermodel/charts/LineChartData.java 查看文件

@@ -1,44 +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.ss.usermodel.charts;

import java.util.List;

import org.apache.poi.util.Removal;

/**
* Data for a Line Chart
*
* @deprecated use XDDFLineChartData instead
*/
@Deprecated
@Removal(version="4.2")
public interface LineChartData extends ChartData {

/**
* @param categories data source for categories.
* @param values data source for values.
* @return a new line chart serie.
*/
LineChartSeries addSeries(ChartDataSource<?> categories, ChartDataSource<? extends Number> values);

/**
* @return list of all series.
*/
List<? extends LineChartSeries> getSeries();
}

+ 0
- 41
src/java/org/apache/poi/ss/usermodel/charts/LineChartSeries.java 查看文件

@@ -1,41 +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.ss.usermodel.charts;

import org.apache.poi.util.Removal;

/**
* Represents a line chart series.
*
* @deprecated use XDDFLineChartData.Series instead
*/
@Deprecated
@Removal(version="4.2")
public interface LineChartSeries extends ChartSeries {

/**
* @return data source used for category axis data.
*/
ChartDataSource<?> getCategoryAxisData();

/**
* @return data source used for value axis.
*/
ChartDataSource<? extends Number> getValues();

}

+ 0
- 154
src/java/org/apache/poi/ss/usermodel/charts/ManualLayout.java 查看文件

@@ -1,154 +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.ss.usermodel.charts;

import org.apache.poi.util.Removal;

/**
* High level representation of chart element manual layout.
*
* @deprecated use XDDFManualLayout instead
*/
@Deprecated
@Removal(version="4.2")
public interface ManualLayout {

/**
* Sets the layout target.
* @param target new layout target.
*/
public void setTarget(LayoutTarget target);

/**
* Returns current layout target.
* @return current layout target
*/
public LayoutTarget getTarget();

/**
* Sets the x-coordinate layout mode.
* @param mode new x-coordinate layout mode.
*/
public void setXMode(LayoutMode mode);

/**
* Returns current x-coordinnate layout mode.
* @return current x-coordinate layout mode.
*/
public LayoutMode getXMode();

/**
* Sets the y-coordinate layout mode.
* @param mode new y-coordinate layout mode.
*/
public void setYMode(LayoutMode mode);

/**
* Returns current y-coordinate layout mode.
* @return current y-coordinate layout mode.
*/
public LayoutMode getYMode();

/**
* Returns the x location of the chart element.
* @return the x location (left) of the chart element or 0.0 if
* not set.
*/
public double getX();

/**
* Specifies the x location (left) of the chart element as a
* fraction of the width of the chart. If Left Mode is Factor,
* then the position is relative to the default position for the
* chart element.
*/
public void setX(double x);


/**
* Returns current y location of the chart element.
* @return the y location (top) of the chart element or 0.0 if not
* set.
*/
public double getY();

/**
* Specifies the y location (top) of the chart element as a
* fraction of the height of the chart. If Top Mode is Factor,
* then the position is relative to the default position for the
* chart element.
*/
public void setY(double y);


/**
* Specifies how to interpret the Width element for this manual
* layout.
* @param mode new width layout mode of this manual layout.
*/
public void setWidthMode(LayoutMode mode);


/**
* Returns current width mode of this manual layout.
* @return width mode of this manual layout.
*/
public LayoutMode getWidthMode();

/**
* Specifies how to interpret the Height element for this manual
* layout.
* @param mode new height mode of this manual layout.
*/
public void setHeightMode(LayoutMode mode);

/**
* Returns current height mode of this
* @return height mode of this manual layout.
*/
public LayoutMode getHeightMode();

/**
* Specifies the width (if Width Mode is Factor) or right (if
* Width Mode is Edge) of the chart element as a fraction of the
* width of the chart.
* @param ratio a fraction of the width of the chart.
*/
public void setWidthRatio(double ratio);

/**
* Returns current fraction of the width of the chart.
* @return fraction of the width of the chart or 0.0 if not set.
*/
public double getWidthRatio();

/**
* Specifies the height (if Height Mode is Factor) or bottom (if
* Height Mode is edge) of the chart element as a fraction of the
* height of the chart.
* @param ratio a fraction of the height of the chart.
*/
public void setHeightRatio(double ratio);

/**
* Returns current fraction of the height of the chart.
* @return fraction of the height of the chart or 0.0 if not set.
*/
public double getHeightRatio();

}

+ 0
- 37
src/java/org/apache/poi/ss/usermodel/charts/ManuallyPositionable.java 查看文件

@@ -1,37 +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.ss.usermodel.charts;

import org.apache.poi.util.Removal;

/**
* Abstraction of chart element that can be positioned with manual
* layout.
*
* @deprecated
*/
@Deprecated
@Removal(version="4.2")
public interface ManuallyPositionable {

/**
* Returns manual layout for the chart element.
* @return manual layout for the chart element.
*/
public ManualLayout getManualLayout();
}

+ 0
- 43
src/java/org/apache/poi/ss/usermodel/charts/ScatterChartData.java 查看文件

@@ -1,43 +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.ss.usermodel.charts;

import java.util.List;

import org.apache.poi.util.Removal;

/**
* Data for a Scatter Chart
*
* @deprecated use XDDFScatterChartData instead
*/
@Deprecated
@Removal(version="4.2")
public interface ScatterChartData extends ChartData {
/**
* @param xs data source to be used for X axis values
* @param ys data source to be used for Y axis values
* @return a new scatter charts series
*/
ScatterChartSeries addSerie(ChartDataSource<?> xs, ChartDataSource<? extends Number> ys);

/**
* @return list of all series
*/
List<? extends ScatterChartSeries> getSeries();
}

+ 0
- 41
src/java/org/apache/poi/ss/usermodel/charts/ScatterChartSeries.java 查看文件

@@ -1,41 +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.ss.usermodel.charts;

import org.apache.poi.util.Removal;

/**
* Represents scatter charts series.
*
* @deprecated use XDFFScatterChartData.Series instead
*/
@Deprecated
@Removal(version="4.2")
public interface ScatterChartSeries extends ChartSeries {

/**
* @return data source used for X axis values
*/
ChartDataSource<?> getXValues();

/**
* @return data source used for Y axis values
*/
ChartDataSource<? extends Number> getYValues();

}

+ 0
- 32
src/java/org/apache/poi/ss/usermodel/charts/TitleType.java 查看文件

@@ -1,32 +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.ss.usermodel.charts;

import org.apache.poi.util.Removal;

/**
* Title types for charts.
*
* @deprecated
*/
@Deprecated
@Removal(version="4.2")
public enum TitleType {
STRING,
CELL_REFERENCE
}

+ 0
- 38
src/java/org/apache/poi/ss/usermodel/charts/ValueAxis.java 查看文件

@@ -1,38 +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.ss.usermodel.charts;

import org.apache.poi.util.Removal;

/**
* @deprecated use XDDFValueAxis instead
*/
@Deprecated
@Removal(version="4.2")
public interface ValueAxis extends ChartAxis {

/**
* @return cross between type
*/
AxisCrossBetween getCrossBetween();

/**
* @param crossBetween cross between type
*/
void setCrossBetween(AxisCrossBetween crossBetween);
}

+ 1
- 1
src/testcases/org/apache/poi/ss/formula/functions/TestAreas.java 查看文件

@@ -54,7 +54,7 @@ public final class TestAreas {
cell.setCellFormula(formulaText);
fe.notifyUpdateCell(cell);
CellValue result = fe.evaluate(cell);
assertEquals(result.getCellTypeEnum(), CellType.NUMERIC);
assertEquals(result.getCellType(), CellType.NUMERIC);
assertEquals(expectedResult, result.getNumberValue(), 0);
}
}

+ 0
- 147
src/testcases/org/apache/poi/ss/usermodel/charts/TestDataSources.java 查看文件

@@ -1,147 +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.ss.usermodel.charts;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;

import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.ss.util.SheetBuilder;
import org.junit.Test;

/**
* Tests for {@link org.apache.poi.ss.usermodel.charts.DataSources}.
*/
@SuppressWarnings("deprecation")
public class TestDataSources {

private static final Object[][] numericCells = {
{0.0, 1.0, 2.0, 3.0, 4.0},
{0.0, "=B1*2", "=C1*2", "=D1*2", "=E1*2"}
};

private static final Object[][] stringCells = {
{ 1, 2, 3, 4, 5},
{"A", "B", "C", "D", "E"}
};

private static final Object[][] mixedCells = {
{1.0, "2.0", 3.0, "4.0", 5.0, "6.0"}
};

@Test
public void testNumericArrayDataSource() {
Double[] doubles = new Double[]{1.0, 2.0, 3.0, 4.0, 5.0};
ChartDataSource<Double> doubleDataSource = DataSources.fromArray(doubles);
assertTrue(doubleDataSource.isNumeric());
assertFalse(doubleDataSource.isReference());
assertDataSourceIsEqualToArray(doubleDataSource, doubles);
}

@Test
public void testStringArrayDataSource() {
String[] strings = new String[]{"one", "two", "three", "four", "five"};
ChartDataSource<String> stringDataSource = DataSources.fromArray(strings);
assertFalse(stringDataSource.isNumeric());
assertFalse(stringDataSource.isReference());
assertDataSourceIsEqualToArray(stringDataSource, strings);
}

@Test
public void testNumericCellDataSource() {
Workbook wb = new HSSFWorkbook();
Sheet sheet = new SheetBuilder(wb, numericCells).build();
CellRangeAddress numCellRange = CellRangeAddress.valueOf("A2:E2");
ChartDataSource<Number> numDataSource = DataSources.fromNumericCellRange(sheet, numCellRange);
assertTrue(numDataSource.isReference());
assertTrue(numDataSource.isNumeric());
assertEquals(numericCells[0].length, numDataSource.getPointCount());
for (int i = 0; i < numericCells[0].length; ++i) {
assertEquals(((Number) numericCells[0][i]).doubleValue() * 2,
numDataSource.getPointAt(i).doubleValue(), 0.00001);
}
}

@Test
public void testStringCellDataSource() {
Workbook wb = new HSSFWorkbook();
Sheet sheet = new SheetBuilder(wb, stringCells).build();
CellRangeAddress numCellRange = CellRangeAddress.valueOf("A2:E2");
ChartDataSource<String> numDataSource = DataSources.fromStringCellRange(sheet, numCellRange);
assertTrue(numDataSource.isReference());
assertFalse(numDataSource.isNumeric());
assertEquals(numericCells[0].length, numDataSource.getPointCount());
for (int i = 0; i < stringCells[1].length; ++i) {
assertEquals(stringCells[1][i], numDataSource.getPointAt(i));
}
}

@Test
public void testMixedCellDataSource() {
Workbook wb = new HSSFWorkbook();
Sheet sheet = new SheetBuilder(wb, mixedCells).build();
CellRangeAddress mixedCellRange = CellRangeAddress.valueOf("A1:F1");
ChartDataSource<String> strDataSource = DataSources.fromStringCellRange(sheet, mixedCellRange);
ChartDataSource<Number> numDataSource = DataSources.fromNumericCellRange(sheet, mixedCellRange);
for (int i = 0; i < mixedCells[0].length; ++i) {
if (i % 2 == 0) {
assertNull(strDataSource.getPointAt(i));
assertEquals(((Number) mixedCells[0][i]).doubleValue(),
numDataSource.getPointAt(i).doubleValue(), 0.00001);
} else {
assertNull(numDataSource.getPointAt(i));
assertEquals(mixedCells[0][i], strDataSource.getPointAt(i));
}
}
}

@Test
public void testIOBExceptionOnInvalidIndex() {
Workbook wb = new HSSFWorkbook();
Sheet sheet = new SheetBuilder(wb, numericCells).build();
CellRangeAddress rangeAddress = CellRangeAddress.valueOf("A2:E2");
ChartDataSource<Number> numDataSource = DataSources.fromNumericCellRange(sheet, rangeAddress);
IndexOutOfBoundsException exception = null;
try {
numDataSource.getPointAt(-1);
} catch (IndexOutOfBoundsException e) {
exception = e;
}
assertNotNull(exception);

exception = null;
try {
numDataSource.getPointAt(numDataSource.getPointCount());
} catch (IndexOutOfBoundsException e) {
exception = e;
}
assertNotNull(exception);
}

private <T> void assertDataSourceIsEqualToArray(ChartDataSource<T> ds, T[] array) {
assertEquals(ds.getPointCount(), array.length);
for (int i = 0; i < array.length; ++i) {
assertEquals(ds.getPointAt(i), array[i]);
}
}
}

Loading…
取消
儲存