org.extex.typesetter.type.node
Class HorizontalListNode

java.lang.Object
  extended by org.extex.typesetter.type.node.AbstractNode
      extended by org.extex.typesetter.type.node.GenericNodeList
          extended by org.extex.typesetter.type.node.HorizontalListNode
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Iterable<Node>, Node, NodeList, OrientedNode, OrientedNodeList

public class HorizontalListNode
extends GenericNodeList
implements OrientedNodeList

This class provides a container for nodes which is interpreted as horizontal list.

The horizontal list maintains its natural dimensions (width height and depth) as well as the target dimensions. Whenever a node is added or removed the natural width is adjusted accordingly. If a target width is set then this width is the width reported as the width of the list. Otherwise the natural width is reported.

The TeX definition of a hlist states that a box is not variable neither in width nor in height. Thus this method is simply a noop.

Version:
$Revision: 4739 $
Author:
Gerd Neugebauer, Michael Niedermair
See Also:
"TeX – The Program [135]", Serialized Form

Field Summary
protected static long serialVersionUID
          The constant serialVersionUID contains the id for serialization.
 
Fields inherited from class org.extex.typesetter.type.node.AbstractNode
NO_CHARS
 
Constructor Summary
HorizontalListNode()
          Creates a new object.
HorizontalListNode(FixedDimen width)
          Creates a new object.
HorizontalListNode(Node node)
          Creates a new object.
HorizontalListNode(Node node1, Node node2)
          Creates a new object.
 
Method Summary
 void add(int index, Node node)
          Add a node to the node list at a given position.
 void add(Node node)
          Add a node to the node list.
 void addSkip(FixedGlue glue)
          Add some glue to the node list.
 void hpack()
          Adjust the variable nodes to achieve a given target width.
 void hpack(FixedDimen width)
          Adjust the variable nodes to achieve a given target width.
 boolean isHorizontal()
          Check whether this node is in horizontal mode.
 Node remove(int index)
          Remove an element at a given position.
 void toString(java.lang.StringBuffer sb, java.lang.String prefix, int breadth, int depth)
          This method puts the printable representation into the string buffer.
 void toText(java.lang.StringBuffer sb, java.lang.String prefix)
          This method puts the printable representation into the string buffer.
 java.lang.Object visit(NodeVisitor visitor, java.lang.Object value)
          This method provides an entry point for the visitor pattern.
 
Methods inherited from class org.extex.typesetter.type.node.GenericNodeList
clear, clone, copy, countChars, get, getChars, getDepth, getHeight, getMove, getNaturalDepth, getNaturalHeight, getShift, getTargetDepth, getTargetHeight, getTargetWidth, getWidth, isEmpty, iterator, setDepth, setHeight, setMove, setNaturalDepth, setNaturalHeight, setNaturalWidth, setShift, setTargetDepth, setTargetHeight, setTargetWidth, setWidth, size, toString, toText
 
Methods inherited from class org.extex.typesetter.type.node.AbstractNode
addDepthTo, addHeightTo, addWidthTo, advanceNaturalDepth, advanceNaturalHeight, advanceNaturalWidth, atShipping, computeAdjustment, getLocalizer, getNaturalWidth, getVerticalSize, maxDepth, maxHeight, maxWidth, spreadHeight, spreadWidth, toText
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.extex.typesetter.type.NodeList
clear, copy, get, getMove, getShift, isEmpty, iterator, setMove, setShift, size, toText
 
Methods inherited from interface org.extex.typesetter.type.Node
addDepthTo, addHeightTo, addWidthTo, atShipping, countChars, getChars, getDepth, getHeight, getNaturalDepth, getNaturalHeight, getNaturalWidth, getVerticalSize, getWidth, setDepth, setHeight, setWidth, spreadHeight, spreadWidth
 
Methods inherited from interface org.extex.typesetter.type.Node
addDepthTo, addHeightTo, addWidthTo, atShipping, countChars, getChars, getDepth, getHeight, getNaturalDepth, getNaturalHeight, getNaturalWidth, getVerticalSize, getWidth, setDepth, setHeight, setWidth, spreadHeight, spreadWidth
 

Field Detail

serialVersionUID

protected static final long serialVersionUID
The constant serialVersionUID contains the id for serialization.

See Also:
Constant Field Values
Constructor Detail

HorizontalListNode

public HorizontalListNode()
Creates a new object. The list is empty initially.

See Also:
"TeX – The Program [136]"

HorizontalListNode

public HorizontalListNode(FixedDimen width)
Creates a new object. The list receives a natural width and no contents yet.

Parameters:
width - the width of the box

HorizontalListNode

public HorizontalListNode(Node node)
Creates a new object. The hlist is filled with the node given.

Parameters:
node - the initial node to add

HorizontalListNode

public HorizontalListNode(Node node1,
                          Node node2)
Creates a new object. The hlist is initially filled with two nodes.

Parameters:
node1 - the initial node
node2 - the node to add after node1
Method Detail

add

public void add(int index,
                Node node)
         throws java.lang.IndexOutOfBoundsException
Add a node to the node list at a given position. The position starts with a value of 0 to insert the node before the first existing node and goes up to the length of the list to insert the new node at the end.

If the node is null then it is silently ignored. This means that a horizontal list will never contain null values.

Specified by:
add in interface NodeList
Overrides:
add in class GenericNodeList
Parameters:
index - the position of insertion
node - the node to add
Throws:
java.lang.IndexOutOfBoundsException - in case that the index is negative or greater than the length of the list
See Also:
GenericNodeList.add( int, org.extex.typesetter.type.Node)

add

public void add(Node node)
Add a node to the node list. The other attributes (width, height, depth) are not modified.

If the node is null then it is silently ignored. This means that a horizontal list will never contain null values.

Specified by:
add in interface NodeList
Overrides:
add in class GenericNodeList
Parameters:
node - the node to add
See Also:
GenericNodeList.add( org.extex.typesetter.type.Node)

addSkip

public void addSkip(FixedGlue glue)
Add some glue to the node list. The other attributes (width, height, depth) are not modified.

Specified by:
addSkip in interface NodeList
Overrides:
addSkip in class GenericNodeList
Parameters:
glue - the glue to add
See Also:
NodeList.addSkip( FixedGlue)

hpack

public void hpack()
Adjust the variable nodes to achieve a given target width.


hpack

public void hpack(FixedDimen width)
Adjust the variable nodes to achieve a given target width.

Parameters:
width - the new target width

isHorizontal

public boolean isHorizontal()
Check whether this node is in horizontal mode. Otherwise it is in vertical mode.

Specified by:
isHorizontal in interface OrientedNode
Returns:
the horizontal indicator
See Also:
OrientedNode.isHorizontal()

remove

public Node remove(int index)
Remove an element at a given position. The other attributes (width, height, depth) are not modified.

Specified by:
remove in interface NodeList
Overrides:
remove in class GenericNodeList
Parameters:
index - the position
Returns:
the element previously located at position index
See Also:
GenericNodeList.remove(int)

toString

public void toString(java.lang.StringBuffer sb,
                     java.lang.String prefix,
                     int breadth,
                     int depth)
This method puts the printable representation into the string buffer. This is meant to produce a exhaustive form as it is used in tracing output to the log file.

Specified by:
toString in interface Node
Specified by:
toString in interface NodeList
Overrides:
toString in class GenericNodeList
Parameters:
sb - the output string buffer
prefix - the prefix string inserted at the beginning of each line
breadth - the breadth of the nodes to display
depth - the depth of the nodes to display
See Also:
Node.toString( java.lang.StringBuffer, java.lang.String, int, int)

toText

public void toText(java.lang.StringBuffer sb,
                   java.lang.String prefix)
This method puts the printable representation into the string buffer. This is meant to produce a short form only as it is used in error messages to the user.

Specified by:
toText in interface Node
Overrides:
toText in class GenericNodeList
Parameters:
sb - the output string buffer
prefix - the prefix string inserted at the beginning of each line
See Also:
Node.toText( java.lang.StringBuffer, java.lang.String)

visit

public java.lang.Object visit(NodeVisitor visitor,
                              java.lang.Object value)
                       throws GeneralException
This method provides an entry point for the visitor pattern.

Specified by:
visit in interface Node
Overrides:
visit in class GenericNodeList
Parameters:
visitor - the visitor to apply
value - the argument for the visitor
Returns:
the result of the method invocation of the visitor
Throws:
GeneralException - in case of an error
See Also:
Node.visit( org.extex.typesetter.type.NodeVisitor, java.lang.Object)