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.

HSSFIconMultiStateFormatting.java 3.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /* ====================================================================
  2. Licensed to the Apache Software Foundation (ASF) under one or more
  3. contributor license agreements. See the NOTICE file distributed with
  4. this work for additional information regarding copyright ownership.
  5. The ASF licenses this file to You under the Apache License, Version 2.0
  6. (the "License"); you may not use this file except in compliance with
  7. the License. You may obtain a copy of the License at
  8. http://www.apache.org/licenses/LICENSE-2.0
  9. Unless required by applicable law or agreed to in writing, software
  10. distributed under the License is distributed on an "AS IS" BASIS,
  11. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. See the License for the specific language governing permissions and
  13. limitations under the License.
  14. ==================================================================== */
  15. package org.apache.poi.hssf.usermodel;
  16. import org.apache.poi.hssf.record.CFRule12Record;
  17. import org.apache.poi.hssf.record.cf.IconMultiStateFormatting;
  18. import org.apache.poi.hssf.record.cf.IconMultiStateThreshold;
  19. import org.apache.poi.hssf.record.cf.Threshold;
  20. import org.apache.poi.ss.usermodel.ConditionalFormattingThreshold;
  21. /**
  22. * High level representation for Icon / Multi-State Formatting
  23. * component of Conditional Formatting settings
  24. */
  25. public final class HSSFIconMultiStateFormatting implements org.apache.poi.ss.usermodel.IconMultiStateFormatting {
  26. private final HSSFSheet sheet;
  27. private final IconMultiStateFormatting iconFormatting;
  28. HSSFIconMultiStateFormatting(CFRule12Record cfRule12Record, HSSFSheet sheet) {
  29. this.sheet = sheet;
  30. this.iconFormatting = cfRule12Record.getMultiStateFormatting();
  31. }
  32. @Override
  33. public IconSet getIconSet() {
  34. return iconFormatting.getIconSet();
  35. }
  36. @Override
  37. public void setIconSet(IconSet set) {
  38. iconFormatting.setIconSet(set);
  39. }
  40. @Override
  41. public boolean isIconOnly() {
  42. return iconFormatting.isIconOnly();
  43. }
  44. @Override
  45. public void setIconOnly(boolean only) {
  46. iconFormatting.setIconOnly(only);
  47. }
  48. @Override
  49. public boolean isReversed() {
  50. return iconFormatting.isReversed();
  51. }
  52. @Override
  53. public void setReversed(boolean reversed) {
  54. iconFormatting.setReversed(reversed);
  55. }
  56. @Override
  57. public HSSFConditionalFormattingThreshold[] getThresholds() {
  58. Threshold[] t = iconFormatting.getThresholds();
  59. HSSFConditionalFormattingThreshold[] ht = new HSSFConditionalFormattingThreshold[t.length];
  60. for (int i=0; i<t.length; i++) {
  61. ht[i] = new HSSFConditionalFormattingThreshold(t[i], sheet);
  62. }
  63. return ht;
  64. }
  65. @Override
  66. public void setThresholds(ConditionalFormattingThreshold[] thresholds) {
  67. Threshold[] t = new Threshold[thresholds.length];
  68. for (int i=0; i<t.length; i++) {
  69. t[i] = ((HSSFConditionalFormattingThreshold)thresholds[i]).getThreshold();
  70. }
  71. iconFormatting.setThresholds(t);
  72. }
  73. @Override
  74. public HSSFConditionalFormattingThreshold createThreshold() {
  75. return new HSSFConditionalFormattingThreshold(new IconMultiStateThreshold(), sheet);
  76. }
  77. }