Package org.apache.fop.layoutmgr
Class KnuthSequence
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractList<E>
-
- java.util.ArrayList
-
- org.apache.fop.layoutmgr.KnuthSequence
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
,java.lang.Iterable
,java.util.Collection
,java.util.List
,java.util.RandomAccess
- Direct Known Subclasses:
BlockKnuthSequence
,InlineKnuthSequence
public abstract class KnuthSequence extends java.util.ArrayList
Represents a list ofKnuth elements
.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description KnuthSequence()
Creates a new and empty list.KnuthSequence(java.util.List list)
Creates a new list from an existing list.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract boolean
appendSequence(KnuthSequence sequence)
Append sequence to this sequence if it can be appended.abstract boolean
appendSequence(KnuthSequence sequence, boolean keepTogether, BreakElement breakElement)
Append sequence to this sequence if it can be appended.boolean
appendSequenceOrClose(KnuthSequence sequence)
Append sequence to this sequence if it can be appended.boolean
appendSequenceOrClose(KnuthSequence sequence, boolean keepTogether, BreakElement breakElement)
Append sequence to this sequence if it can be appended.abstract boolean
canAppendSequence(KnuthSequence sequence)
Can sequence be appended to this sequence?abstract KnuthSequence
endSequence()
Finalizes a Knuth sequence.ListElement
getElement(int index)
protected int
getFirstBoxIndex(int startIndex)
Returns the position index of the first box in this sequence, starting at the given index.ListElement
getLast()
abstract boolean
isInlineSequence()
Is this an inline or a block sequence?ListElement
removeLast()
Remove the last element of this sequence.void
startSequence()
Marks the start of the sequence.java.lang.String
toString()
void
wrapPositions(LayoutManager lm)
Wrap 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, clear, clone, contains, ensureCapacity, equals, forEach, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeIf, removeRange, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray, trimToSize
-
-
-
-
Method Detail
-
startSequence
public void startSequence()
Marks the start of the sequence.
-
endSequence
public abstract KnuthSequence endSequence()
Finalizes a Knuth sequence.- Returns:
- a finalized sequence.
-
canAppendSequence
public abstract boolean canAppendSequence(KnuthSequence sequence)
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
public abstract boolean appendSequence(KnuthSequence sequence)
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
public boolean appendSequenceOrClose(KnuthSequence sequence)
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
public void wrapPositions(LayoutManager lm)
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
public ListElement getLast()
- Returns:
- the last element of this sequence.
-
removeLast
public ListElement removeLast()
Remove the last element of this sequence.- Returns:
- the removed element.
-
getElement
public ListElement getElement(int index)
- 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. IfstartIndex
is 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,startIndex
if(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
public java.lang.String toString()
- Overrides:
toString
in classjava.util.AbstractCollection
-
-