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.

BorderCommonStyleAbsolute.java 3.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /*
  2. *
  3. * Copyright 2004 The Apache Software Foundation.
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License");
  6. * you may not use this file except in compliance with the License.
  7. * 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. * Created on 20/04/2004
  18. * $Id$
  19. */
  20. package org.apache.fop.fo.properties;
  21. import org.apache.fop.datatypes.EnumType;
  22. import org.apache.fop.datatypes.PropertyValue;
  23. import org.apache.fop.fo.FONode;
  24. import org.apache.fop.fo.PropNames;
  25. import org.apache.fop.fo.expr.PropertyException;
  26. /**
  27. * Base class for border-<absolute>-style properties, providing the
  28. * methods necessary to resolve corresponding relative properties.
  29. *
  30. * @author pbw
  31. * @version $Revision$ $Name$
  32. */
  33. public class BorderCommonStyleAbsolute
  34. extends BorderCommonStyle
  35. implements AbsoluteCorrespondingProperty {
  36. /* (non-Javadoc)
  37. * @see org.apache.fop.fo.properties.AbsoluteCorrespondingProperty#getWritingMode()
  38. */
  39. public int getWritingMode(FONode foNode)
  40. throws PropertyException {
  41. PropertyValue wm = foNode.getPropertyValue(PropNames.WRITING_MODE);
  42. return EnumType.getEnumValue(wm);
  43. }
  44. public int getCorrespondingProperty(FONode foNode)
  45. throws PropertyException {
  46. return getCorrespondingRelativeProperty(foNode);
  47. }
  48. /* (non-Javadoc)
  49. * @see org.apache.fop.fo.properties.AbsoluteCorrespondingProperty#getCorrespondingRelativeProperty()
  50. */
  51. public int getCorrespondingRelativeProperty(FONode foNode)
  52. throws PropertyException {
  53. throw new PropertyException("Called from superclass");
  54. }
  55. /** Array of relative border style properties,
  56. * indexed by relative edge constants */
  57. private static int[] relBorderStyleProps = {
  58. PropNames.NO_PROPERTY
  59. ,PropNames.BORDER_BEFORE_STYLE
  60. ,PropNames.BORDER_AFTER_STYLE
  61. ,PropNames.BORDER_START_STYLE
  62. ,PropNames.BORDER_END_STYLE
  63. };
  64. /**
  65. * Gets the relative border style property corresponding to the given
  66. * absolute edge
  67. * @param foNode the node on which the property is being defined
  68. * @param absoluteEdge
  69. * @return the relative border style property index
  70. * @throws PropertyException
  71. */
  72. protected int getCorrespondingRelativeStyleProperty(
  73. FONode foNode, int absoluteEdge)
  74. throws PropertyException {
  75. int relEdge = WritingMode.getCorrespondingRelativeEdge(
  76. getWritingMode(foNode), absoluteEdge);
  77. return relBorderStyleProps[relEdge];
  78. }
  79. /* (non-Javadoc)
  80. * @see org.apache.fop.fo.properties.AbsoluteCorrespondingProperty#overridesCorresponding()
  81. */
  82. public boolean overridesCorresponding(FONode foNode) {
  83. return false;
  84. }
  85. /* (non-Javadoc)
  86. * @see org.apache.fop.fo.properties.Property#isCorrespondingAbsolute()
  87. */
  88. public static boolean isCorrespondingAbsolute() {
  89. return true;
  90. }
  91. }