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