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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /*
  2. * $Id$
  3. * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
  4. * For details on use and redistribution please refer to the
  5. * LICENSE file included with these sources.
  6. */
  7. package org.apache.fop.fo.pagination;
  8. // FOP
  9. import org.apache.fop.fo.*;
  10. import org.apache.fop.fo.properties.*;
  11. import org.apache.fop.layout.RegionArea;
  12. import org.apache.fop.layout.BorderAndPadding;
  13. import org.apache.fop.layout.BackgroundProps;
  14. import org.apache.fop.apps.FOPException;
  15. /**
  16. * Class modeling the fo:region-before object.
  17. *
  18. * @see <a href="@XSLFO-STD@#fo_region-before"
  19. target="_xslfostd">@XSLFO-STDID@
  20. * &para;6.4.14</a>
  21. */
  22. public class RegionBefore extends Region {
  23. public static class Maker extends FObj.Maker {
  24. public FObj make(FObj parent,
  25. PropertyList propertyList) throws FOPException {
  26. return new RegionBefore(parent, propertyList);
  27. }
  28. }
  29. public static FObj.Maker maker() {
  30. return new RegionBefore.Maker();
  31. }
  32. public static final String REGION_CLASS = "before";
  33. private int precedence;
  34. protected RegionBefore(FObj parent,
  35. PropertyList propertyList) throws FOPException {
  36. super(parent, propertyList);
  37. precedence = this.properties.get("precedence").getEnum();
  38. }
  39. public String getName() {
  40. return "fo:region-before";
  41. }
  42. RegionArea makeRegionArea(int allocationRectangleXPosition,
  43. int allocationRectangleYPosition,
  44. int allocationRectangleWidth,
  45. int allocationRectangleHeight) {
  46. // Common Border, Padding, and Background Properties
  47. BorderAndPadding bap = propMgr.getBorderAndPadding();
  48. BackgroundProps bProps = propMgr.getBackgroundProps();
  49. // this.properties.get("clip");
  50. // this.properties.get("display-align");
  51. int extent = this.properties.get("extent").getLength().mvalue();
  52. // this.properties.get("overflow");
  53. // this.properties.get("precedence");
  54. // this.properties.get("region-name");
  55. // this.properties.get("reference-orientation");
  56. // this.properties.get("writing-mode");
  57. RegionArea area = new RegionArea(allocationRectangleXPosition,
  58. allocationRectangleYPosition,
  59. allocationRectangleWidth, extent);
  60. area.setBackground(bProps);
  61. return area;
  62. }
  63. RegionArea makeRegionArea(int allocationRectangleXPosition,
  64. int allocationRectangleYPosition,
  65. int allocationRectangleWidth,
  66. int allocationRectangleHeight,
  67. int startExtent, int endExtent) {
  68. if (getPrecedence() == false) {
  69. allocationRectangleXPosition += startExtent;
  70. allocationRectangleWidth -= startExtent + endExtent;
  71. }
  72. return makeRegionArea(allocationRectangleXPosition,
  73. allocationRectangleYPosition,
  74. allocationRectangleWidth,
  75. allocationRectangleHeight);
  76. }
  77. protected String getDefaultRegionName() {
  78. return "xsl-region-before";
  79. }
  80. public String getRegionClass() {
  81. return REGION_CLASS;
  82. }
  83. public boolean getPrecedence() {
  84. return (precedence == Precedence.TRUE ? true : false);
  85. }
  86. public int getExtent() {
  87. return properties.get("extent").getLength().mvalue();
  88. }
  89. }