aboutsummaryrefslogtreecommitdiffstats
path: root/src/ooxml/java/org/apache/poi/xssf/usermodel/charts
diff options
context:
space:
mode:
authorCédric Walter <cedricwalter@apache.org>2013-11-22 17:45:00 +0000
committerCédric Walter <cedricwalter@apache.org>2013-11-22 17:45:00 +0000
commit4a55b25fd8e1a1f554ae3b39d2be1531de909808 (patch)
treef3b5fea733ffe29cfbadc11edc7ae7a3125d5c7f /src/ooxml/java/org/apache/poi/xssf/usermodel/charts
parentbb7d33fe7c17d9ae154a8f3dbddc418b1348afd4 (diff)
downloadpoi-4a55b25fd8e1a1f554ae3b39d2be1531de909808.tar.gz
poi-4a55b25fd8e1a1f554ae3b39d2be1531de909808.zip
Bug 54676: added new chart axis type: Category axis
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1544612 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/ooxml/java/org/apache/poi/xssf/usermodel/charts')
-rw-r--r--src/ooxml/java/org/apache/poi/xssf/usermodel/charts/XSSFCategoryAxis.java93
1 files changed, 93 insertions, 0 deletions
diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/charts/XSSFCategoryAxis.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/charts/XSSFCategoryAxis.java
new file mode 100644
index 0000000000..d8193a5a03
--- /dev/null
+++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/charts/XSSFCategoryAxis.java
@@ -0,0 +1,93 @@
+/* ====================================================================
+ 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.AxisCrosses;
+import org.apache.poi.ss.usermodel.charts.AxisOrientation;
+import org.apache.poi.ss.usermodel.charts.AxisPosition;
+import org.apache.poi.ss.usermodel.charts.ChartAxis;
+import org.apache.poi.util.Beta;
+import org.apache.poi.xssf.usermodel.XSSFChart;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTAxPos;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTCatAx;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTCrosses;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTNumFmt;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTScaling;
+import org.openxmlformats.schemas.drawingml.x2006.chart.STTickLblPos;
+
+/**
+ * Category axis type.
+ *
+ * @author Martin Andersson
+ */
+@Beta
+public class XSSFCategoryAxis extends XSSFChartAxis {
+
+ private CTCatAx ctCatAx;
+
+ public XSSFCategoryAxis(XSSFChart chart, long id, AxisPosition pos) {
+ super(chart);
+ createAxis(id, pos);
+ }
+
+ public XSSFCategoryAxis(XSSFChart chart, CTCatAx ctCatAx) {
+ super(chart);
+ this.ctCatAx = ctCatAx;
+ }
+
+ public long getId() {
+ return ctCatAx.getAxId().getVal();
+ }
+
+ protected CTAxPos getCTAxPos() {
+ return ctCatAx.getAxPos();
+ }
+
+ protected CTNumFmt getCTNumFmt() {
+ if (ctCatAx.isSetNumFmt()) {
+ return ctCatAx.getNumFmt();
+ }
+ return ctCatAx.addNewNumFmt();
+ }
+
+ protected CTScaling getCTScaling() {
+ return ctCatAx.getScaling();
+ }
+
+ protected CTCrosses getCTCrosses() {
+ return ctCatAx.getCrosses();
+ }
+
+ public void crossAxis(ChartAxis axis) {
+ ctCatAx.getCrossAx().setVal(axis.getId());
+ }
+
+ private void createAxis(long id, AxisPosition pos) {
+ ctCatAx = chart.getCTChart().getPlotArea().addNewCatAx();
+ ctCatAx.addNewAxId().setVal(id);
+ ctCatAx.addNewAxPos();
+ ctCatAx.addNewScaling();
+ ctCatAx.addNewCrosses();
+ ctCatAx.addNewCrossAx();
+ ctCatAx.addNewTickLblPos().setVal(STTickLblPos.NEXT_TO);
+
+ setPosition(pos);
+ setOrientation(AxisOrientation.MIN_MAX);
+ setCrosses(AxisCrosses.AUTO_ZERO);
+ }
+}