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.

FontUnderline.java 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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.ss.usermodel;
  16. /**
  17. * the different types of possible underline formatting
  18. *
  19. * @author Gisella Bronzetti
  20. */
  21. public enum FontUnderline {
  22. /**
  23. * Single-line underlining under each character in the cell.
  24. * The underline is drawn through the descenders of
  25. * characters such as g and p..
  26. */
  27. SINGLE(1),
  28. /**
  29. * Double-line underlining under each character in the
  30. * cell. underlines are drawn through the descenders of
  31. * characters such as g and p.
  32. */
  33. DOUBLE(2),
  34. /**
  35. * Single-line accounting underlining under each
  36. * character in the cell. The underline is drawn under the
  37. * descenders of characters such as g and p.
  38. */
  39. SINGLE_ACCOUNTING(3),
  40. /**
  41. * Double-line accounting underlining under each
  42. * character in the cell. The underlines are drawn under
  43. * the descenders of characters such as g and p.
  44. */
  45. DOUBLE_ACCOUNTING(4),
  46. /**
  47. * No underline.
  48. */
  49. NONE(5);
  50. private int value;
  51. private FontUnderline(int val) {
  52. value = val;
  53. }
  54. public int getValue() {
  55. return value;
  56. }
  57. public byte getByteValue() {
  58. switch (this) {
  59. case DOUBLE:
  60. return Font.U_DOUBLE;
  61. case DOUBLE_ACCOUNTING:
  62. return Font.U_DOUBLE_ACCOUNTING;
  63. case SINGLE_ACCOUNTING:
  64. return Font.U_SINGLE_ACCOUNTING;
  65. case NONE:
  66. return Font.U_NONE;
  67. case SINGLE:
  68. return Font.U_SINGLE;
  69. default:
  70. return Font.U_SINGLE;
  71. }
  72. }
  73. private static FontUnderline[] _table = new FontUnderline[6];
  74. static {
  75. for (FontUnderline c : values()) {
  76. _table[c.getValue()] = c;
  77. }
  78. }
  79. public static FontUnderline valueOf(int value){
  80. return _table[value];
  81. }
  82. public static FontUnderline valueOf(byte value){
  83. FontUnderline val;
  84. switch (value) {
  85. case Font.U_DOUBLE:
  86. val = FontUnderline.DOUBLE;
  87. break;
  88. case Font.U_DOUBLE_ACCOUNTING:
  89. val = FontUnderline.DOUBLE_ACCOUNTING;
  90. break;
  91. case Font.U_SINGLE_ACCOUNTING:
  92. val = FontUnderline.SINGLE_ACCOUNTING;
  93. break;
  94. case Font.U_SINGLE:
  95. val = FontUnderline.SINGLE;
  96. break;
  97. default:
  98. val = FontUnderline.NONE;
  99. break;
  100. }
  101. return val;
  102. }
  103. }