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.

HSSFDataBarFormatting.java 3.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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.DataBarFormatting;
  18. import org.apache.poi.hssf.record.cf.DataBarThreshold;
  19. import org.apache.poi.ss.usermodel.Color;
  20. /**
  21. * High level representation for DataBar / Data-Bar Formatting
  22. * component of Conditional Formatting settings
  23. */
  24. public final class HSSFDataBarFormatting implements org.apache.poi.ss.usermodel.DataBarFormatting {
  25. private final HSSFSheet sheet;
  26. private final CFRule12Record cfRule12Record;
  27. private final DataBarFormatting databarFormatting;
  28. protected HSSFDataBarFormatting(CFRule12Record cfRule12Record, HSSFSheet sheet) {
  29. this.sheet = sheet;
  30. this.cfRule12Record = cfRule12Record;
  31. this.databarFormatting = this.cfRule12Record.getDataBarFormatting();
  32. }
  33. public boolean isLeftToRight() {
  34. return !databarFormatting.isReversed();
  35. }
  36. public void setLeftToRight(boolean ltr) {
  37. databarFormatting.setReversed(!ltr);
  38. }
  39. public int getWidthMin() {
  40. return databarFormatting.getPercentMin();
  41. }
  42. public void setWidthMin(int width) {
  43. databarFormatting.setPercentMin((byte)width);
  44. }
  45. public int getWidthMax() {
  46. return databarFormatting.getPercentMax();
  47. }
  48. public void setWidthMax(int width) {
  49. databarFormatting.setPercentMax((byte)width);
  50. }
  51. public HSSFExtendedColor getColor() {
  52. return new HSSFExtendedColor(databarFormatting.getColor());
  53. }
  54. public void setColor(Color color) {
  55. HSSFExtendedColor hcolor = (HSSFExtendedColor)color;
  56. databarFormatting.setColor(hcolor.getExtendedColor());
  57. }
  58. public HSSFConditionalFormattingThreshold getMinThreshold() {
  59. return new HSSFConditionalFormattingThreshold(databarFormatting.getThresholdMin(), sheet);
  60. }
  61. public HSSFConditionalFormattingThreshold getMaxThreshold() {
  62. return new HSSFConditionalFormattingThreshold(databarFormatting.getThresholdMax(), sheet);
  63. }
  64. public boolean isIconOnly() {
  65. return databarFormatting.isIconOnly();
  66. }
  67. public void setIconOnly(boolean only) {
  68. databarFormatting.setIconOnly(only);
  69. }
  70. public HSSFConditionalFormattingThreshold createThreshold() {
  71. return new HSSFConditionalFormattingThreshold(new DataBarThreshold(), sheet);
  72. }
  73. }