1 17 18 19 20 package org.apache.fop.layoutmgr; 21 22 import java.util.ArrayList ; 23 import java.util.List ; 24 import java.util.ListIterator ; 25 26 29 32 public abstract class KnuthSequence extends ArrayList { 33 36 public KnuthSequence() { 37 super(); 38 } 39 40 44 public KnuthSequence(List list) { 45 super(list); 46 } 47 48 51 public void startSequence() { 52 } 53 54 58 public abstract KnuthSequence endSequence(); 59 60 65 public abstract boolean canAppendSequence(KnuthSequence sequence); 66 67 74 public abstract boolean appendSequence(KnuthSequence sequence, boolean keepTogether, 75 BreakElement breakElement); 76 77 82 public abstract boolean appendSequence(KnuthSequence sequence); 83 84 90 public boolean appendSequenceOrClose(KnuthSequence sequence) { 91 if (!appendSequence(sequence)) { 92 endSequence(); 93 return false; 94 } else { 95 return true; 96 } 97 } 98 99 107 public boolean appendSequenceOrClose(KnuthSequence sequence, boolean keepTogether, 108 BreakElement breakElement) { 109 if (!appendSequence(sequence, keepTogether, breakElement)) { 110 endSequence(); 111 return false; 112 } else { 113 return true; 114 } 115 } 116 117 121 public void wrapPositions(LayoutManager lm) { 122 ListIterator listIter = listIterator(); 123 ListElement element; 124 while (listIter.hasNext()) { 125 element = (ListElement) listIter.next(); 126 element.setPosition 127 (lm.notifyPos(new NonLeafPosition(lm, element.getPosition()))); 128 } 129 } 130 131 134 public ListElement getLast() { 135 int idx = size(); 136 if (idx == 0) { 137 return null; 138 } 139 return (ListElement) get(idx - 1); 140 } 141 142 146 public ListElement removeLast() { 147 int idx = size(); 148 if (idx == 0) { 149 return null; 150 } 151 return (ListElement) remove(idx - 1); 152 } 153 154 158 public ListElement getElement(int index) { 159 return (ListElement) get(index); 160 } 161 162 166 public abstract boolean isInlineSequence(); 167 168 } 169 | Popular Tags |