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.

BodyRegion.java 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /*
  2. * Copyright 1999-2005 The Apache Software Foundation.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. /* $Id: BodyRegion.java,v 1.4 2004/02/27 17:41:26 jeremias Exp $ */
  17. package org.apache.fop.area;
  18. import org.apache.fop.fo.Constants;
  19. /**
  20. * This class is a container for the areas that may be generated by
  21. * an fo:region-body. It extends the RegionReference that is used
  22. * directly by the other region classes.
  23. * See fo:region-body definition in the XSL Rec for more information.
  24. */
  25. public class BodyRegion extends RegionReference {
  26. private BeforeFloat beforeFloat; // optional
  27. private MainReference mainReference; // mandatory
  28. private Footnote footnote; // optional
  29. private int columnGap;
  30. private int columnCount;
  31. /**
  32. * Constructor which can read traits directly
  33. * from an fo:region-body formatting object.
  34. */
  35. public BodyRegion(int columnCount, int columnGap, RegionViewport parent) {
  36. super(Constants.FO_REGION_BODY, parent);
  37. this.columnCount = columnCount;
  38. this.columnGap = columnGap;
  39. mainReference = new MainReference(this);
  40. }
  41. /**
  42. * Set the number of columns for blocks when not spanning
  43. *
  44. * @param colCount the number of columns
  45. */
  46. public void setColumnCount(int colCount) {
  47. this.columnCount = colCount;
  48. }
  49. /**
  50. * Get the number of columns when not spanning
  51. *
  52. * @return the number of columns
  53. */
  54. public int getColumnCount() {
  55. return this.columnCount;
  56. }
  57. /**
  58. * Set the column gap between columns
  59. * The length is in millipoints.
  60. *
  61. * @param colGap the column gap in millipoints
  62. */
  63. public void setColumnGap(int colGap) {
  64. this.columnGap = colGap;
  65. }
  66. /** @return the column-gap value */
  67. public int getColumnGap() {
  68. return this.columnGap;
  69. }
  70. /**
  71. * Get the main reference area.
  72. *
  73. * @return the main reference area
  74. */
  75. public MainReference getMainReference() {
  76. return mainReference;
  77. }
  78. /**
  79. * indicates whether the main reference area has any child areas added to it
  80. *
  81. * @return whether the main reference area has any child areas added to it
  82. */
  83. public boolean isEmpty() {
  84. return mainReference == null || mainReference.isEmpty();
  85. }
  86. /**
  87. * Get the before float area.
  88. *
  89. * @return the before float area
  90. */
  91. public BeforeFloat getBeforeFloat() {
  92. if (beforeFloat == null) {
  93. beforeFloat = new BeforeFloat();
  94. }
  95. return beforeFloat;
  96. }
  97. /**
  98. * Get the footnote area.
  99. *
  100. * @return the footnote area
  101. */
  102. public Footnote getFootnote() {
  103. if (footnote == null) {
  104. footnote = new Footnote();
  105. }
  106. return footnote;
  107. }
  108. /**
  109. * Clone this object.
  110. *
  111. * @return a shallow copy of this object
  112. */
  113. public Object clone() {
  114. BodyRegion br = new BodyRegion(columnCount, columnGap, regionViewport);
  115. br.setCTM(getCTM());
  116. br.setIPD(getIPD());
  117. br.beforeFloat = beforeFloat;
  118. br.mainReference = mainReference;
  119. br.footnote = footnote;
  120. return br;
  121. }
  122. }