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.

RegionSE.java 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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.fo.pagination;
  19. // Java
  20. import java.awt.Rectangle;
  21. import org.apache.fop.apps.FOPException;
  22. import org.apache.fop.datatypes.PercentBaseContext;
  23. import org.apache.fop.fo.FONode;
  24. import org.apache.fop.fo.PropertyList;
  25. /**
  26. * Abstract base class for <a href="http://www.w3.org/TR/xsl/#fo_region-start">
  27. * <code>fo:region-start</code></a> and <a href="http://www.w3.org/TR/xsl/#fo_region-end">
  28. * <code>fo:region-end</code></a>.
  29. */
  30. public abstract class RegionSE extends SideRegion {
  31. // The value of properties relevant for fo:region-[start|end].
  32. // End of property values
  33. /**
  34. * Create a RegionSE instance that is a child of the
  35. * given parent {@link FONode}.
  36. * @param parent the {@link FONode} that is to be the parent
  37. */
  38. protected RegionSE(FONode parent) {
  39. super(parent);
  40. }
  41. /** {@inheritDoc} */
  42. public void bind(PropertyList pList) throws FOPException {
  43. super.bind(pList);
  44. }
  45. /**
  46. * Adjust the viewport reference rectangle for a region as a function
  47. * of precedence.
  48. * If before and after have precedence = true, the start and end
  49. * regions only go to the limits of their extents, otherwise
  50. * they extend in the BPD to the page reference rectangle
  51. * diminish by extend of start and end if present.
  52. * @param vpRefRect viewport reference rectangle
  53. * @param wm writing mode
  54. * @param siblingContext the context to use to resolve extent on siblings
  55. */
  56. protected void adjustIPD(Rectangle vpRefRect, int wm, PercentBaseContext siblingContext) {
  57. int offset = 0;
  58. RegionBefore before = (RegionBefore) getSiblingRegion(FO_REGION_BEFORE);
  59. if (before != null && before.getPrecedence() == EN_TRUE) {
  60. offset = before.getExtent().getValue(siblingContext);
  61. vpRefRect.translate(0, offset);
  62. }
  63. RegionAfter after = (RegionAfter) getSiblingRegion(FO_REGION_AFTER);
  64. if (after != null && after.getPrecedence() == EN_TRUE) {
  65. offset += after.getExtent().getValue(siblingContext);
  66. }
  67. if (offset > 0) {
  68. if (wm == EN_LR_TB || wm == EN_RL_TB) {
  69. vpRefRect.height -= offset;
  70. } else {
  71. vpRefRect.width -= offset;
  72. }
  73. }
  74. }
  75. }