You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

XSSFIconMultiStateFormatting.java 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*
  2. * ====================================================================
  3. * Licensed to the Apache Software Foundation (ASF) under one or more
  4. * contributor license agreements. See the NOTICE file distributed with
  5. * this work for additional information regarding copyright ownership.
  6. * The ASF licenses this file to You under the Apache License, Version 2.0
  7. * (the "License"); you may not use this file except in compliance with
  8. * the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. * ====================================================================
  18. */
  19. package org.apache.poi.xssf.usermodel;
  20. import org.apache.poi.ss.usermodel.ConditionalFormattingThreshold;
  21. import org.apache.poi.ss.usermodel.IconMultiStateFormatting;
  22. import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCfvo;
  23. import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTIconSet;
  24. import org.openxmlformats.schemas.spreadsheetml.x2006.main.STIconSetType;
  25. /**
  26. * High level representation for Icon / Multi-State Formatting
  27. * component of Conditional Formatting settings
  28. */
  29. public class XSSFIconMultiStateFormatting implements IconMultiStateFormatting {
  30. CTIconSet _iconset;
  31. /*package*/ XSSFIconMultiStateFormatting(CTIconSet iconset){
  32. _iconset = iconset;
  33. }
  34. @Override
  35. public IconSet getIconSet() {
  36. String set = _iconset.getIconSet().toString();
  37. return IconSet.byName(set);
  38. }
  39. @Override
  40. public void setIconSet(IconSet set) {
  41. STIconSetType.Enum xIconSet = STIconSetType.Enum.forString(set.name);
  42. _iconset.setIconSet(xIconSet);
  43. }
  44. @Override
  45. public boolean isIconOnly() {
  46. if (_iconset.isSetShowValue())
  47. return !_iconset.getShowValue();
  48. return false;
  49. }
  50. @Override
  51. public void setIconOnly(boolean only) {
  52. _iconset.setShowValue(!only);
  53. }
  54. @Override
  55. public boolean isReversed() {
  56. if (_iconset.isSetReverse())
  57. return _iconset.getReverse();
  58. return false;
  59. }
  60. @Override
  61. public void setReversed(boolean reversed) {
  62. _iconset.setReverse(reversed);
  63. }
  64. @Override
  65. public XSSFConditionalFormattingThreshold[] getThresholds() {
  66. CTCfvo[] cfvos = _iconset.getCfvoArray();
  67. XSSFConditionalFormattingThreshold[] t =
  68. new XSSFConditionalFormattingThreshold[cfvos.length];
  69. for (int i=0; i<cfvos.length; i++) {
  70. t[i] = new XSSFConditionalFormattingThreshold(cfvos[i]);
  71. }
  72. return t;
  73. }
  74. @Override
  75. public void setThresholds(ConditionalFormattingThreshold[] thresholds) {
  76. CTCfvo[] cfvos = new CTCfvo[thresholds.length];
  77. for (int i=0; i<thresholds.length; i++) {
  78. cfvos[i] = ((XSSFConditionalFormattingThreshold)thresholds[i]).getCTCfvo();
  79. }
  80. _iconset.setCfvoArray(cfvos);
  81. }
  82. @Override
  83. public XSSFConditionalFormattingThreshold createThreshold() {
  84. return new XSSFConditionalFormattingThreshold(_iconset.addNewCfvo());
  85. }
  86. }