Package org.apache.fop.layoutmgr
Class KnuthSequence<T extends ListElement>
java.lang.Object
java.util.AbstractCollection<T>
java.util.AbstractList<T>
java.util.ArrayList<T>
org.apache.fop.layoutmgr.KnuthSequence<T>
- All Implemented Interfaces:
Serializable,Cloneable,Iterable<T>,Collection<T>,List<T>,RandomAccess,SequencedCollection<T>
- Direct Known Subclasses:
BlockKnuthSequence,InlineKnuthSequence
Represents a list of
Knuth elements.- See Also:
-
Field Summary
Fields inherited from class java.util.AbstractList
modCount -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new and empty list.KnuthSequence(List<T> list) Creates a new list from an existing list. -
Method Summary
Modifier and TypeMethodDescriptionabstract booleanappendSequence(KnuthSequence sequence) Append sequence to this sequence if it can be appended.abstract booleanappendSequence(KnuthSequence sequence, boolean keepTogether, BreakElement breakElement) Append sequence to this sequence if it can be appended.booleanappendSequenceOrClose(KnuthSequence sequence) Append sequence to this sequence if it can be appended.booleanappendSequenceOrClose(KnuthSequence sequence, boolean keepTogether, BreakElement breakElement) Append sequence to this sequence if it can be appended.abstract booleancanAppendSequence(KnuthSequence sequence) Can sequence be appended to this sequence?abstract KnuthSequenceFinalizes a Knuth sequence.getElement(int index) protected intgetFirstBoxIndex(int startIndex) Returns the position index of the first box in this sequence, starting at the given index.getLast()abstract booleanIs this an inline or a block sequence?Remove the last element of this sequence.voidMarks the start of the sequence.toString()voidWrap the Positions of the elements of this sequence in a Position for LayoutManager lm.Methods inherited from class java.util.ArrayList
add, add, addAll, addAll, addFirst, addLast, clear, clone, contains, ensureCapacity, equals, forEach, get, getFirst, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeFirst, removeIf, removeRange, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray, trimToSizeMethods inherited from class java.util.AbstractCollection
containsAllMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, stream, toArrayMethods inherited from interface java.util.List
containsAll, reversed
-
Constructor Details
-
KnuthSequence
public KnuthSequence()Creates a new and empty list. -
KnuthSequence
Creates a new list from an existing list.- Parameters:
list- The list from which to create the new list.
-
-
Method Details
-
startSequence
public void startSequence()Marks the start of the sequence. -
endSequence
Finalizes a Knuth sequence.- Returns:
- a finalized sequence.
-
canAppendSequence
Can sequence be appended to this sequence?- Parameters:
sequence- The sequence that may be appended.- Returns:
- whether the sequence can be appended to this sequence.
-
appendSequence
public abstract boolean appendSequence(KnuthSequence sequence, boolean keepTogether, BreakElement breakElement) Append sequence to this sequence if it can be appended.- Parameters:
sequence- The sequence that is to be appended.keepTogether- Whether the two sequences must be kept together.breakElement- The BreakElement that may be inserted between the two sequences.- Returns:
- whether the sequence was succesfully appended to this sequence.
-
appendSequence
Append sequence to this sequence if it can be appended.- Parameters:
sequence- The sequence that is to be appended.- Returns:
- whether the sequence was succesfully appended to this sequence.
-
appendSequenceOrClose
Append sequence to this sequence if it can be appended. If that is not possible, close this sequence.- Parameters:
sequence- The sequence that is to be appended.- Returns:
- whether the sequence was succesfully appended to this sequence.
-
appendSequenceOrClose
public boolean appendSequenceOrClose(KnuthSequence sequence, boolean keepTogether, BreakElement breakElement) Append sequence to this sequence if it can be appended. If that is not possible, close this sequence.- Parameters:
sequence- The sequence that is to be appended.keepTogether- Whether the two sequences must be kept together.breakElement- The BreakElement that may be inserted between the two sequences.- Returns:
- whether the sequence was succesfully appended to this sequence.
-
wrapPositions
Wrap the Positions of the elements of this sequence in a Position for LayoutManager lm.- Parameters:
lm- The LayoutManager for the Positions that will be created.
-
getLast
- Specified by:
getLastin interfaceList<T extends ListElement>- Specified by:
getLastin interfaceSequencedCollection<T extends ListElement>- Overrides:
getLastin classArrayList<T extends ListElement>- Returns:
- the last element of this sequence.
-
removeLast
Remove the last element of this sequence.- Specified by:
removeLastin interfaceList<T extends ListElement>- Specified by:
removeLastin interfaceSequencedCollection<T extends ListElement>- Overrides:
removeLastin classArrayList<T extends ListElement>- Returns:
- the removed element.
-
getElement
- Parameters:
index- The index of the element to be returned- Returns:
- the element at index index.
-
getFirstBoxIndex
protected int getFirstBoxIndex(int startIndex) Returns the position index of the first box in this sequence, starting at the given index. IfstartIndexis outside the bounds of this sequence, it is returned.- Parameters:
startIndex- the index from which to start the lookup- Returns:
- the index of the next box element,
ArrayList.size()if there is no such element,startIndexif(startIndex < 0 || startIndex >= size())
-
isInlineSequence
public abstract boolean isInlineSequence()Is this an inline or a block sequence?- Returns:
- true if this is an inline sequence
-
toString
- Overrides:
toStringin classAbstractCollection<T extends ListElement>
-