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.

BorderCommonWidth.java 2.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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 org.apache.fop.datatypes.Length;
  23. import org.apache.fop.datatypes.Numeric;
  24. import org.apache.fop.fo.FONode;
  25. import org.apache.fop.fo.expr.PropertyException;
  26. /**
  27. * Pseudo-property class for common border width values occurring in a
  28. * number of classes.
  29. */
  30. public abstract class BorderCommonWidth extends AbstractCorrespondingProperty {
  31. public static final int THIN = 1;
  32. public static final int MEDIUM = 2;
  33. public static final int THICK = 3;
  34. private static final String[] rwEnums = {
  35. null
  36. ,"thin"
  37. ,"medium"
  38. ,"thick"
  39. };
  40. private static final double[] mappedPoints = {
  41. 0d
  42. ,0.5d
  43. ,1d
  44. ,2d
  45. };
  46. // N.B. If these values change, all initial values expressed in these
  47. // terms must be manually changed.
  48. /**
  49. * @param node the FONode with an expressing the property
  50. * @param property the property index
  51. * @param enumval the mappedEnum enumeration value
  52. * @return <tt>Numeric[]</tt> containing the values corresponding
  53. * to the MappedNumeric enumeration constants for border width
  54. */
  55. public Numeric getMappedLength(FONode node, int property, int enumval)
  56. throws PropertyException
  57. {
  58. return
  59. Length.makeLength(property, mappedPoints[enumval], Length.PT);
  60. }
  61. public int getEnumIndex(String enumval) throws PropertyException {
  62. return enumValueToIndex(enumval, rwEnums);
  63. }
  64. public String getEnumText(int index) {
  65. return rwEnums[index];
  66. }
  67. }