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.

BorderCommonStyle.java 2.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*
  2. * $Id$
  3. *
  4. *
  5. * Copyright 1999-2003 The Apache Software Foundation.
  6. *
  7. * Licensed under the Apache License, Version 2.0 (the "License");
  8. * you may not use this file except in compliance with the License.
  9. * You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS,
  15. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. * See the License for the specific language governing permissions and
  17. * limitations under the License.
  18. *
  19. *
  20. */
  21. package org.apache.fop.fo.properties;
  22. import java.util.HashMap;
  23. import org.apache.fop.datatypes.Ints;
  24. import org.apache.fop.fo.FONode;
  25. import org.apache.fop.fo.expr.PropertyException;
  26. /**
  27. * Pseudo-property class for common border style values occurring in a
  28. * number of classes.
  29. */
  30. public class BorderCommonStyle extends AbstractCorrespondingProperty {
  31. public static final int HIDDEN = 1;
  32. public static final int DOTTED = 2;
  33. public static final int DASHED = 3;
  34. public static final int SOLID = 4;
  35. public static final int DOUBLE = 5;
  36. public static final int GROOVE = 6;
  37. public static final int RIDGE = 7;
  38. public static final int INSET = 8;
  39. public static final int OUTSET = 9;
  40. private static final String[] rwEnums = {
  41. null
  42. ,"hidden"
  43. ,"dotted"
  44. ,"dashed"
  45. ,"solid"
  46. ,"double"
  47. ,"groove"
  48. ,"ridge"
  49. ,"inset"
  50. ,"outset"
  51. };
  52. private static final HashMap rwEnumHash;
  53. static {
  54. rwEnumHash = new HashMap((int)(rwEnums.length / 0.75) + 1);
  55. for (int i = 1; i < rwEnums.length; i++ ) {
  56. rwEnumHash.put(rwEnums[i],
  57. Ints.consts.get(i));
  58. }
  59. }
  60. public int getEnumIndex(String enumval)
  61. throws PropertyException
  62. {
  63. Integer ii = (Integer)(rwEnumHash.get(enumval));
  64. if (ii == null)
  65. throw new PropertyException("Unknown ENUM value: " + enumval);
  66. return ii.intValue();
  67. }
  68. public String getEnumText(int index)
  69. throws PropertyException
  70. {
  71. if (index < 1 || index >= rwEnums.length)
  72. throw new PropertyException("index out of range: " + index);
  73. return rwEnums[index];
  74. }
  75. public int getCorrespondingProperty(FONode foNode)
  76. throws PropertyException {
  77. throw new PropertyException("Called from superclass");
  78. }
  79. }