1 17 18 19 20 package org.apache.fop.layoutmgr; 21 22 import java.util.List ; 23 24 import org.apache.fop.fo.Constants; 25 26 29 public class BreakElement extends UnresolvedListElement { 30 31 private int penaltyWidth; 32 private int penaltyValue; 33 private int breakClass = -1; 34 private List pendingBeforeMarks; 35 private List pendingAfterMarks; 36 37 43 public BreakElement(Position position, int penaltyValue, LayoutContext context) { 44 this(position, 0, penaltyValue, -1, context); 45 } 46 47 55 public BreakElement(Position position, int penaltyWidth, int penaltyValue, 56 int breakClass, LayoutContext context) { 57 super(position); 58 this.penaltyWidth = penaltyWidth; 59 this.penaltyValue = penaltyValue; 60 this.breakClass = breakClass; 61 this.pendingBeforeMarks = context.getPendingBeforeMarks(); 62 this.pendingAfterMarks = context.getPendingAfterMarks(); 63 } 64 65 66 public boolean isConditional() { 67 return false; } 69 70 71 75 76 77 public int getPenaltyWidth() { 78 return this.penaltyWidth; 79 } 80 81 82 public int getPenaltyValue() { 83 return this.penaltyValue; 84 } 85 86 90 public void setPenaltyValue(int p) { 91 this.penaltyValue = p; 92 } 93 94 95 public boolean isForcedBreak() { 96 return penaltyValue == -KnuthElement.INFINITE; 97 } 98 99 100 public int getBreakClass() { 101 return breakClass; 102 } 103 104 108 public void setBreakClass(int breakClass) { 109 this.breakClass = breakClass; 110 } 111 112 113 public List getPendingBeforeMarks() { 114 return this.pendingBeforeMarks; 115 } 116 117 118 public List getPendingAfterMarks() { 119 return this.pendingAfterMarks; 120 } 121 122 123 public String toString() { 124 StringBuffer sb = new StringBuffer (); 125 sb.append("BreakPossibility[p:"); 126 sb.append(this.penaltyValue); 127 if (isForcedBreak()) { 128 sb.append(" (forced break"); 129 switch (getBreakClass()) { 130 case Constants.EN_PAGE: 131 sb.append(", page"); 132 break; 133 case Constants.EN_COLUMN: 134 sb.append(", column"); 135 break; 136 case Constants.EN_EVEN_PAGE: 137 sb.append(", even page"); 138 break; 139 case Constants.EN_ODD_PAGE: 140 sb.append(", odd page"); 141 break; 142 default: 143 } 144 sb.append(")"); 145 } 146 sb.append("]"); 147 return sb.toString(); 148 } 149 150 } 151 | Popular Tags |