Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

HSSFColorScaleFormatting.java 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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.ColorGradientFormatting;
  18. import org.apache.poi.hssf.record.cf.Threshold;
  19. import org.apache.poi.ss.usermodel.Color;
  20. import org.apache.poi.ss.usermodel.ConditionalFormattingThreshold;
  21. /**
  22. * High level representation for Color Scale / Color Gradient
  23. * Formatting component of Conditional Formatting settings
  24. */
  25. public final class HSSFColorScaleFormatting implements org.apache.poi.ss.usermodel.ColorScaleFormatting {
  26. private final HSSFSheet sheet;
  27. private final CFRule12Record cfRule12Record;
  28. private final ColorGradientFormatting colorFormatting;
  29. protected HSSFColorScaleFormatting(CFRule12Record cfRule12Record, HSSFSheet sheet) {
  30. this.sheet = sheet;
  31. this.cfRule12Record = cfRule12Record;
  32. this.colorFormatting = this.cfRule12Record.getColorGradientFormatting();
  33. }
  34. public int getNumControlPoints() {
  35. return colorFormatting.getNumControlPoints();
  36. }
  37. public void setNumControlPoints(int num) {
  38. colorFormatting.setNumControlPoints(num);
  39. }
  40. public Color[] getColors() {
  41. return null; // TODO
  42. }
  43. public void setColors(Color[] colors) {
  44. // TODO
  45. }
  46. public HSSFConditionalFormattingThreshold[] getThresholds() {
  47. Threshold[] t = colorFormatting.getThresholds();
  48. HSSFConditionalFormattingThreshold[] ht = new HSSFConditionalFormattingThreshold[t.length];
  49. for (int i=0; i<t.length; i++) {
  50. ht[i] = new HSSFConditionalFormattingThreshold(t[i], sheet);
  51. }
  52. return ht;
  53. }
  54. public void setThresholds(ConditionalFormattingThreshold[] thresholds) {
  55. Threshold[] t = new Threshold[thresholds.length];
  56. for (int i=0; i<t.length; i++) {
  57. t[i] = ((HSSFConditionalFormattingThreshold)thresholds[i]).getThreshold();
  58. }
  59. colorFormatting.setThresholds(t);
  60. }
  61. public HSSFConditionalFormattingThreshold createThreshold() {
  62. return new HSSFConditionalFormattingThreshold(new Threshold(), sheet);
  63. }
  64. }