Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

BorderStyle.java 3.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. /* $Id$ */
  18. package org.apache.fop.traits;
  19. import java.io.ObjectStreamException;
  20. import org.apache.fop.fo.Constants;
  21. /** Enumeration class for border styles. */
  22. public final class BorderStyle extends TraitEnum {
  23. private static final long serialVersionUID = 1L;
  24. private static final String[] BORDER_STYLE_NAMES = new String[]
  25. {"none", "hidden", "dotted", "dashed",
  26. "solid", "double", "groove", "ridge",
  27. "inset", "outset"};
  28. private static final int[] BORDER_STYLE_VALUES = new int[]
  29. {Constants.EN_NONE, Constants.EN_HIDDEN, Constants.EN_DOTTED, Constants.EN_DASHED,
  30. Constants.EN_SOLID, Constants.EN_DOUBLE, Constants.EN_GROOVE, Constants.EN_RIDGE,
  31. Constants.EN_INSET, Constants.EN_OUTSET};
  32. /** border-style: none */
  33. public static final BorderStyle NONE = new BorderStyle(0);
  34. /** border-style: hidden */
  35. public static final BorderStyle HIDDEN = new BorderStyle(1);
  36. /** border-style: dotted */
  37. public static final BorderStyle DOTTED = new BorderStyle(2);
  38. /** border-style: dashed */
  39. public static final BorderStyle DASHED = new BorderStyle(3);
  40. /** border-style: solid */
  41. public static final BorderStyle SOLID = new BorderStyle(4);
  42. /** border-style: double */
  43. public static final BorderStyle DOUBLE = new BorderStyle(5);
  44. /** border-style: groove */
  45. public static final BorderStyle GROOVE = new BorderStyle(6);
  46. /** border-style: ridge */
  47. public static final BorderStyle RIDGE = new BorderStyle(7);
  48. /** border-style: inset */
  49. public static final BorderStyle INSET = new BorderStyle(8);
  50. /** border-style: outset */
  51. public static final BorderStyle OUTSET = new BorderStyle(9);
  52. private static final BorderStyle[] STYLES = new BorderStyle[] {
  53. NONE, HIDDEN, DOTTED, DASHED, SOLID, DOUBLE, GROOVE, RIDGE, INSET, OUTSET};
  54. private BorderStyle(int index) {
  55. super(BORDER_STYLE_NAMES[index], BORDER_STYLE_VALUES[index]);
  56. }
  57. /**
  58. * Returns the enumeration/singleton object based on its name.
  59. * @param name the name of the enumeration value
  60. * @return the enumeration object
  61. */
  62. public static BorderStyle valueOf(String name) {
  63. for (BorderStyle style : STYLES) {
  64. if (style.getName().equalsIgnoreCase(name)) {
  65. return style;
  66. }
  67. }
  68. throw new IllegalArgumentException("Illegal border style: " + name);
  69. }
  70. /**
  71. * Returns the enumeration/singleton object based on its name.
  72. * @param enumValue the enumeration value
  73. * @return the enumeration object
  74. */
  75. public static BorderStyle valueOf(int enumValue) {
  76. for (BorderStyle style : STYLES) {
  77. if (style.getEnumValue() == enumValue) {
  78. return style;
  79. }
  80. }
  81. throw new IllegalArgumentException("Illegal border style: " + enumValue);
  82. }
  83. private Object readResolve() throws ObjectStreamException {
  84. return valueOf(getName());
  85. }
  86. /** {@inheritDoc} */
  87. public String toString() {
  88. return "BorderStyle:" + getName();
  89. }
  90. }