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.

KnuthBlockBox.java 4.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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.layoutmgr;
  19. import java.util.LinkedList;
  20. import java.util.List;
  21. import org.apache.fop.traits.MinOptMax;
  22. /**
  23. * Knuth box used to represent a line in block-progression-dimension (i.e. the width is its height).
  24. */
  25. public class KnuthBlockBox extends KnuthBox {
  26. private MinOptMax ipdRange;
  27. /**
  28. * Natural width of the line represented by this box. In addition to ipdRange because
  29. * it isn't possible to get the opt value stored in a MinOptMax object.
  30. */
  31. private int bpd;
  32. private List<FootnoteBodyLayoutManager> footnoteList;
  33. private List<FloatContentLayoutManager> floatContentLMs;
  34. /** List of Knuth elements. This is a list of LinkedList elements. */
  35. private List elementLists;
  36. /**
  37. * Creates a new box.
  38. *
  39. * @param width block progression dimension of this box
  40. * @param range min, opt, max inline progression dimension of this box
  41. * @param bpdim natural width of the line represented by this box.
  42. * @param pos the Position stored in this box
  43. * @param auxiliary is this box auxiliary?
  44. */
  45. public KnuthBlockBox(int width, MinOptMax range, int bpdim, Position pos, boolean auxiliary) {
  46. super(width, pos, auxiliary);
  47. ipdRange = range;
  48. bpd = bpdim;
  49. footnoteList = new LinkedList<FootnoteBodyLayoutManager>();
  50. floatContentLMs = new LinkedList<FloatContentLayoutManager>();
  51. }
  52. /**
  53. * Creates a new box.
  54. *
  55. * @param width block progression dimension of this box
  56. * @param list footnotes cited by elements in this box. The list contains the corresponding
  57. * FootnoteBodyLayoutManagers
  58. * @param pos the Position stored in this box
  59. * @param auxiliary is this box auxiliary?
  60. */
  61. public KnuthBlockBox(int width, List list, Position pos, boolean auxiliary) {
  62. super(width, pos, auxiliary);
  63. ipdRange = MinOptMax.ZERO;
  64. bpd = 0;
  65. footnoteList = new LinkedList<FootnoteBodyLayoutManager>(list);
  66. floatContentLMs = new LinkedList<FloatContentLayoutManager>();
  67. }
  68. public KnuthBlockBox(int width, List list, Position pos, boolean auxiliary,
  69. List<FloatContentLayoutManager> fclms) {
  70. super(width, pos, auxiliary);
  71. ipdRange = MinOptMax.ZERO;
  72. bpd = 0;
  73. footnoteList = new LinkedList<FootnoteBodyLayoutManager>(list);
  74. floatContentLMs = new LinkedList<FloatContentLayoutManager>(fclms);
  75. }
  76. /**
  77. * @return the LMs for the footnotes cited in this box.
  78. */
  79. public List<FootnoteBodyLayoutManager> getFootnoteBodyLMs() {
  80. return footnoteList;
  81. }
  82. /**
  83. * @return true if this box contains footnote citations.
  84. */
  85. public boolean hasAnchors() {
  86. return (footnoteList.size() > 0);
  87. }
  88. /**
  89. * Adds the given list of Knuth elements to this box' list of elements.
  90. *
  91. * @param list elements corresponding to a footnote body
  92. */
  93. public void addElementList(List list) {
  94. if (elementLists == null) {
  95. elementLists = new LinkedList();
  96. }
  97. elementLists.add(list);
  98. }
  99. /**
  100. * Returns the list of Knuth sequences registered by this box.
  101. *
  102. * @return a list of KnuthElement sequences corresponding to footnotes cited in this box
  103. */
  104. public List getElementLists() {
  105. return elementLists;
  106. }
  107. /**
  108. * @return the inline progression dimension of this box.
  109. */
  110. public MinOptMax getIPDRange() {
  111. return ipdRange;
  112. }
  113. /**
  114. * Returns the natural width (without stretching nor shrinking) of the line represented by this
  115. * box.
  116. *
  117. * @return the line width
  118. */
  119. public int getBPD() {
  120. return bpd;
  121. }
  122. public List<FloatContentLayoutManager> getFloatContentLMs() {
  123. return floatContentLMs;
  124. }
  125. public boolean hasFloatAnchors() {
  126. return (floatContentLMs.size() > 0);
  127. }
  128. }