org.extex.typesetter.type.node
Class AbstractNode

java.lang.Object
  extended by org.extex.typesetter.type.node.AbstractNode
All Implemented Interfaces:
java.io.Serializable, Node
Direct Known Subclasses:
AbstractExpandableNode, AbstractKernNode, AdjustNode, AfterMathNode, BeforeMathNode, CharNode, DiscretionaryNode, GenericNodeList, InsertionNode, MarkNode, PenaltyNode, RuleNode, WhatsItNode

public abstract class AbstractNode
extends java.lang.Object
implements Node

This abstract class provides some methods common to all Nodes.

Version:
$Revision: 4739 $
Author:
Gerd Neugebauer
See Also:
Serialized Form

Field Summary
protected static CharNode[] NO_CHARS
          The constant NO_CHAR contains the empty array of CharNode.
 
Constructor Summary
AbstractNode()
          Creates a new object.
AbstractNode(FixedDimen aWidth)
          Creates a new object.
AbstractNode(FixedDimen aWidth, FixedDimen aHeight, FixedDimen aDepth)
          Creates a new object.
 
Method Summary
 void addDepthTo(WideGlue glue)
          Add the flexible depth of the current node to the given glue.
 void addHeightTo(WideGlue glue)
          Add the flexible height of the current node to the given glue.
 void addWidthTo(WideGlue glue)
          Add the flexible width of the current node to the given glue.
 void advanceNaturalDepth(FixedDimen x)
          Advance the depth by some length.
 void advanceNaturalHeight(FixedDimen x)
          Advance the height by some length.
 void advanceNaturalWidth(FixedDimen x)
          Advance the width by some length.
 Node atShipping(PageContext context, Typesetter typesetter, FixedDimen posX, FixedDimen posY)
          This method performs any action which are required to executed at the time of shipping the node to the DocumentWriter.
protected  java.lang.Object clone()
          
protected  long computeAdjustment(long size, FixedGlue glue, FixedGlueComponent sum)
          Compute the amount of adjustment needed to achieve a certain size.
 int countChars()
          This method determines the number of characters contained in a node.
 CharNode[] getChars()
          Getter for the array of characters enclosed in this node.
 FixedDimen getDepth()
          Getter for the depth of the node.
 FixedDimen getHeight()
          Getter for the height of the node.
protected  Localizer getLocalizer()
          Getter for localizer.
 FixedDimen getNaturalDepth()
          Getter for the natural depth of the node.
 FixedDimen getNaturalHeight()
          Getter for the natural height of the node.
 FixedDimen getNaturalWidth()
          Getter for the natural width of the node.
 FixedDimen getVerticalSize()
          Compute the vertical size of a node.
 FixedDimen getWidth()
          Getter for the width of the node.
 void maxDepth(FixedDimen x)
          Assign the maximum of the current value and a comparison value to the depth.
 void maxHeight(FixedDimen x)
          Assign the maximum of the current value and a comparison value to the height.
 void maxWidth(FixedDimen x)
          Assign the maximum of the current value and a comparison value to the width.
 void setDepth(FixedDimen depth)
          Setter for the depth of the node.
 void setHeight(FixedDimen height)
          Setter for the height of the node.
 void setWidth(FixedDimen width)
          Setter for the width of the node.
 void spreadHeight(FixedDimen h, FixedGlueComponent sum)
          Adjust the height of a flexible node.
 void spreadWidth(FixedDimen w, FixedGlueComponent sum)
          Adjust the width of a flexible node.
 java.lang.String toString()
          This method returns the printable representation.
 void toString(java.lang.StringBuffer sb, java.lang.String prefix, int breadth, int d)
          This method puts the printable representation into the string buffer.
protected  java.lang.String toText(java.lang.String prefix)
          Compute a text representation of this object.
 void toText(java.lang.StringBuffer sb, java.lang.String prefix)
          Puts a text representation of the object into a string buffer.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.extex.typesetter.type.Node
visit
 

Field Detail

NO_CHARS

protected static final CharNode[] NO_CHARS
The constant NO_CHAR contains the empty array of CharNode.

Constructor Detail

AbstractNode

public AbstractNode()
Creates a new object. All dimensions (width, height, depth) are initially set to 0pt.


AbstractNode

public AbstractNode(FixedDimen aWidth)
Creates a new object.

Parameters:
aWidth - the width of the node

AbstractNode

public AbstractNode(FixedDimen aWidth,
                    FixedDimen aHeight,
                    FixedDimen aDepth)
Creates a new object.

Parameters:
aWidth - the width of the node
aHeight - the height of the node
aDepth - the depth of the node
Method Detail

addDepthTo

public void addDepthTo(WideGlue glue)
Add the flexible depth of the current node to the given glue.

Specified by:
addDepthTo in interface Node
Parameters:
glue - the glue to add to.
See Also:
Node.addDepthTo( org.extex.core.glue.WideGlue)

addHeightTo

public void addHeightTo(WideGlue glue)
Add the flexible height of the current node to the given glue.

Specified by:
addHeightTo in interface Node
Parameters:
glue - the glue to add to.
See Also:
Node.addHeightTo( org.extex.core.glue.WideGlue)

addWidthTo

public void addWidthTo(WideGlue glue)
Add the flexible width of the current node to the given glue.

Specified by:
addWidthTo in interface Node
Parameters:
glue - the glue to add to.
See Also:
Node.addWidthTo( org.extex.core.glue.WideGlue)

advanceNaturalDepth

public void advanceNaturalDepth(FixedDimen x)
Advance the depth by some length. The length can also be negative.

Parameters:
x - the length to add

advanceNaturalHeight

public void advanceNaturalHeight(FixedDimen x)
Advance the height by some length. The length can also be negative.

Parameters:
x - the length to add

advanceNaturalWidth

public void advanceNaturalWidth(FixedDimen x)
Advance the width by some length. The length can also be negative.

Parameters:
x - the length to add

atShipping

public Node atShipping(PageContext context,
                       Typesetter typesetter,
                       FixedDimen posX,
                       FixedDimen posY)
                throws GeneralException
This method performs any action which are required to executed at the time of shipping the node to the DocumentWriter. It is a NOOP in the abstract base class and should be overwritten by sub-classes if required.

Specified by:
atShipping in interface Node
Parameters:
context - the interpreter context encapsulated as page context
typesetter - the typesetter
posX - the horizontal position on the page
posY - the vertical position on the page
Returns:
the node to be used instead of the current one in the output list. If the value is null then the node is deleted. If the value is the node itself then it is preserved.
Throws:
GeneralException - in case of an error
See Also:
Node.atShipping( org.extex.typesetter.PageContext, org.extex.typesetter.Typesetter, org.extex.core.dimen.FixedDimen, org.extex.core.dimen.FixedDimen)

clone

protected java.lang.Object clone()
                          throws java.lang.CloneNotSupportedException

Overrides:
clone in class java.lang.Object
Throws:
java.lang.CloneNotSupportedException
See Also:
Object.clone()

computeAdjustment

protected long computeAdjustment(long size,
                                 FixedGlue glue,
                                 FixedGlueComponent sum)
Compute the amount of adjustment needed to achieve a certain size.

Parameters:
size - the current size in scaled points
glue - the glue
sum - the total stretchability or shrinkability
Returns:
the adjustment

countChars

public int countChars()
This method determines the number of characters contained in a node.

Specified by:
countChars in interface Node
Returns:
the number of characters contained
See Also:
Node.countChars()

getChars

public CharNode[] getChars()
Getter for the array of characters enclosed in this node.

Specified by:
getChars in interface Node
Returns:
the array of characters
See Also:
Node.getChars()

getDepth

public FixedDimen getDepth()
Getter for the depth of the node.

Specified by:
getDepth in interface Node
Returns:
the depth
See Also:
Node.getDepth()

getHeight

public FixedDimen getHeight()
Getter for the height of the node.

Specified by:
getHeight in interface Node
Returns:
the height
See Also:
Node.getHeight()

getLocalizer

protected Localizer getLocalizer()
Getter for localizer.

Returns:
the localizer

getNaturalDepth

public FixedDimen getNaturalDepth()
Getter for the natural depth of the node.

Specified by:
getNaturalDepth in interface Node
Returns:
the natural depth
See Also:
Node.getNaturalDepth()

getNaturalHeight

public FixedDimen getNaturalHeight()
Getter for the natural height of the node.

Specified by:
getNaturalHeight in interface Node
Returns:
the natural height
See Also:
Node.getNaturalHeight()

getNaturalWidth

public FixedDimen getNaturalWidth()
Getter for the natural width of the node.

Specified by:
getNaturalWidth in interface Node
Returns:
the width
See Also:
getWidth()

getVerticalSize

public FixedDimen getVerticalSize()
Compute the vertical size of a node.

Specified by:
getVerticalSize in interface Node
Returns:
the vertical size
See Also:
Node.getVerticalSize()

getWidth

public FixedDimen getWidth()
Getter for the width of the node.

Specified by:
getWidth in interface Node
Returns:
the width
See Also:
Node.getWidth()

maxDepth

public void maxDepth(FixedDimen x)
Assign the maximum of the current value and a comparison value to the depth.

Parameters:
x - the length to compare to

maxHeight

public void maxHeight(FixedDimen x)
Assign the maximum of the current value and a comparison value to the height.

Parameters:
x - the length to compare to

maxWidth

public void maxWidth(FixedDimen x)
Assign the maximum of the current value and a comparison value to the width.

Parameters:
x - the length to compare to

setDepth

public void setDepth(FixedDimen depth)
Setter for the depth of the node.

Specified by:
setDepth in interface Node
Parameters:
depth - the node depth
See Also:
Node.setDepth( org.extex.core.dimen.FixedDimen)

setHeight

public void setHeight(FixedDimen height)
Setter for the height of the node.

Specified by:
setHeight in interface Node
Parameters:
height - the new height
See Also:
Node.setHeight( org.extex.core.dimen.FixedDimen)

setWidth

public void setWidth(FixedDimen width)
Setter for the width of the node.

Specified by:
setWidth in interface Node
Parameters:
width - the new width
See Also:
Node.setWidth( org.extex.core.dimen.FixedDimen)

spreadHeight

public void spreadHeight(FixedDimen h,
                         FixedGlueComponent sum)
Adjust the height of a flexible node. This method is a noop for any but the flexible nodes.

Specified by:
spreadHeight in interface Node
Parameters:
h - the desired height
sum - the total sum of the glues
See Also:
Node.spreadHeight( org.extex.core.dimen.FixedDimen, FixedGlueComponent)

spreadWidth

public void spreadWidth(FixedDimen w,
                        FixedGlueComponent sum)
Adjust the width of a flexible node. This method is a noop for any but the flexible nodes.

Specified by:
spreadWidth in interface Node
Parameters:
w - the desired width
sum - the total sum of the glues
See Also:
Node.spreadWidth( org.extex.core.dimen.FixedDimen, org.extex.core.glue.FixedGlueComponent)

toString

public java.lang.String toString()
This method returns the printable representation. This is meant to produce a exhaustive form as it is used in tracing output to the log file.

Overrides:
toString in class java.lang.Object
Returns:
the printable representation

toString

public void toString(java.lang.StringBuffer sb,
                     java.lang.String prefix,
                     int breadth,
                     int d)
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
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
d - the depth of the nodes to display
See Also:
Node.toString(java.lang.StringBuffer, java.lang.String, int, int)

toText

protected java.lang.String toText(java.lang.String prefix)
Compute a text representation of this object.

Parameters:
prefix - the string prepended to each line of the resulting text
Returns:
the text representation of this object

toText

public void toText(java.lang.StringBuffer sb,
                   java.lang.String prefix)
Puts a text representation of the object into a string buffer.

Specified by:
toText in interface Node
Parameters:
sb - the output string buffer
prefix - the string prepended to each line of the resulting text
See Also:
Node.toText(java.lang.StringBuffer, java.lang.String)