1 17 18 19 20 package org.apache.fop.layoutmgr; 21 22 import org.apache.fop.datatypes.PercentBaseContext; 23 import org.apache.fop.fo.Constants; 24 import org.apache.fop.fo.properties.SpaceProperty; 25 import org.apache.fop.traits.MinOptMax; 26 27 30 public class SpaceElement extends UnresolvedListElementWithLength { 31 32 private int precedence; 33 34 43 public SpaceElement(Position position, SpaceProperty space, RelSide side, 44 boolean isFirst, boolean isLast, 45 PercentBaseContext context) { 46 super(position, 47 MinOptMaxUtil.toMinOptMax( 48 space.getSpace().getLengthRange(), 49 context), side, space.isDiscard(), isFirst, isLast); 50 int en = space.getSpace().getPrecedence().getEnum(); 51 if (en == Constants.EN_FORCE) { 52 this.precedence = Integer.MAX_VALUE; 53 } else { 54 this.precedence = space.getSpace().getPrecedence().getNumber().intValue(); 55 } 56 } 57 58 59 public boolean isForcing() { 60 return this.precedence == Integer.MAX_VALUE; 61 } 62 63 64 public int getPrecedence() { 65 return this.precedence; 66 } 67 68 69 public void notifyLayoutManager(MinOptMax effectiveLength) { 70 LayoutManager lm = getOriginatingLayoutManager(); 71 if (lm instanceof ConditionalElementListener) { 72 ((ConditionalElementListener)lm).notifySpace( 73 getSide(), effectiveLength); 74 } else { 75 log.warn("Cannot notify LM. It does not implement ConditionalElementListener:" 76 + lm.getClass().getName()); 77 } 78 } 79 80 81 public String toString() { 82 StringBuffer sb = new StringBuffer ("Space["); 83 sb.append(super.toString()); 84 sb.append(", precedence="); 85 if (isForcing()) { 86 sb.append("forcing"); 87 } else { 88 sb.append(getPrecedence()); 89 } 90 sb.append("]"); 91 return sb.toString(); 92 } 93 94 } 95 | Popular Tags |