您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

Page.java 5.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  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.layout;
  8. // FOP
  9. import org.apache.fop.render.Renderer;
  10. import org.apache.fop.fo.flow.*;
  11. import org.apache.fop.fo.*;
  12. import org.apache.fop.apps.*;
  13. import org.apache.fop.datatypes.IDReferences;
  14. import org.apache.fop.fo.pagination.PageSequence;
  15. // Java
  16. import java.util.Vector;
  17. import java.util.Enumeration;
  18. /*Modified by Mark Lillywhite mark-fop@inomial.com. Added getIDReferences.
  19. This is just a convenience method for renderers who no longer have access
  20. to the AreaTree when rendering.
  21. */
  22. public class Page {
  23. private int height;
  24. private int width;
  25. private BodyAreaContainer body;
  26. private AreaContainer before;
  27. private AreaContainer after;
  28. private AreaContainer start;
  29. private AreaContainer end;
  30. private AreaTree areaTree;
  31. private Vector rootExtensions;
  32. private PageSequence pageSequence;
  33. protected int pageNumber = 0;
  34. protected String formattedPageNumber;
  35. protected Vector linkSets = new Vector();
  36. private Vector idList = new Vector();
  37. private Vector footnotes = null;
  38. private Vector markers = null;
  39. Page(AreaTree areaTree, int height, int width) {
  40. this.areaTree = areaTree;
  41. this.height = height;
  42. this.width = width;
  43. markers = new Vector();
  44. }
  45. public IDReferences getIDReferences() {
  46. return areaTree.getIDReferences();
  47. }
  48. public void setPageSequence(PageSequence pageSequence) {
  49. this.pageSequence = pageSequence;
  50. }
  51. public PageSequence getPageSequence() {
  52. return pageSequence;
  53. }
  54. public AreaTree getAreaTree() {
  55. return areaTree;
  56. }
  57. public void setNumber(int number) {
  58. this.pageNumber = number;
  59. }
  60. public int getNumber() {
  61. return this.pageNumber;
  62. }
  63. public void setFormattedNumber(String number) {
  64. this.formattedPageNumber = number;
  65. }
  66. public String getFormattedNumber() {
  67. return this.formattedPageNumber;
  68. }
  69. void addAfter(AreaContainer area) {
  70. this.after = area;
  71. area.setPage(this);
  72. }
  73. void addBefore(AreaContainer area) {
  74. this.before = area;
  75. area.setPage(this);
  76. }
  77. /**
  78. * Ensure that page is set not only on B.A.C. but also on the
  79. * three top-level reference areas.
  80. * @param area The region-body area container (special)
  81. */
  82. public void addBody(BodyAreaContainer area) {
  83. this.body = area;
  84. area.setPage(this);
  85. ((BodyAreaContainer)area).getMainReferenceArea().setPage(this);
  86. ((BodyAreaContainer)area).getBeforeFloatReferenceArea().setPage(this);
  87. ((BodyAreaContainer)area).getFootnoteReferenceArea().setPage(this);
  88. }
  89. void addEnd(AreaContainer area) {
  90. this.end = area;
  91. area.setPage(this);
  92. }
  93. void addStart(AreaContainer area) {
  94. this.start = area;
  95. area.setPage(this);
  96. }
  97. public AreaContainer getAfter() {
  98. return this.after;
  99. }
  100. public AreaContainer getBefore() {
  101. return this.before;
  102. }
  103. public AreaContainer getStart() {
  104. return this.start;
  105. }
  106. public AreaContainer getEnd() {
  107. return this.end;
  108. }
  109. public BodyAreaContainer getBody() {
  110. return this.body;
  111. }
  112. public int getHeight() {
  113. return this.height;
  114. }
  115. public int getWidth() {
  116. return this.width;
  117. }
  118. public FontInfo getFontInfo() {
  119. return this.areaTree.getFontInfo();
  120. }
  121. public void addLinkSet(LinkSet linkSet) {
  122. this.linkSets.addElement(linkSet);
  123. }
  124. public Vector getLinkSets() {
  125. return this.linkSets;
  126. }
  127. public boolean hasLinks() {
  128. return (!this.linkSets.isEmpty());
  129. }
  130. public void addToIDList(String id) {
  131. idList.addElement(id);
  132. }
  133. public Vector getIDList() {
  134. return idList;
  135. }
  136. public Vector getPendingFootnotes() {
  137. return footnotes;
  138. }
  139. public Vector getExtensions() {
  140. return rootExtensions;
  141. }
  142. public void setExtensions(Vector extensions) {
  143. this.rootExtensions = extensions;
  144. }
  145. public void setPendingFootnotes(Vector v) {
  146. footnotes = v;
  147. if (footnotes != null) {
  148. for (Enumeration e = footnotes.elements();
  149. e.hasMoreElements(); ) {
  150. FootnoteBody fb = (FootnoteBody)e.nextElement();
  151. if (!Footnote.layoutFootnote(this, fb, null)) {
  152. // footnotes are too large to fit on empty page
  153. }
  154. }
  155. footnotes = null;
  156. }
  157. }
  158. public void addPendingFootnote(FootnoteBody fb) {
  159. if (footnotes == null) {
  160. footnotes = new Vector();
  161. }
  162. footnotes.addElement(fb);
  163. }
  164. public void registerMarker(Marker marker) {
  165. markers.addElement(marker);
  166. }
  167. public Vector getMarkers() {
  168. return this.markers;
  169. }
  170. }