multivalent

Class INode

public class INode extends Node

Internal nodes have children. To implement most protocols, pass protocol on to children. Superclass for all internal--that is, structural--nodes in the doc tree.

Bounding box contains border, padding, and content, but not margin, which is taken into account in (x,y) location.

Version: $Revision: 1.10 $ $Date: 2003/06/02 05:06:47 $

See Also: Leaf Span

Field Summary
Insetsborder
Border, with possible different widths on each side (counted in bounding box dimensions).
static Insets[]INSETS
Canonical Insets with equal bounds to use to save space over creating new Insets for these common cases.
static InsetsINSETS_ZERO
Special name, points to INSETS[0].
Insetsmargin
Transparent external space around bounding box (not part of bounding box width or height, as effects incorporated into bounding box (x,y) location).
Insetspadding
Internal space inside border, with same background as content (counted in bounding box dimensions).
Constructor Summary
INode(String name, Map<String,Object> attr, INode parent)
Method Summary
NodeaddCategory(Node n, String category)
Add child to correct category, as in UI panel or menu with groups.
voidappendChild(Node child)
Adds child to end of list of children.
booleanbreakAfter()
booleanbreakBefore()
booleancheckRep()
NodechildAt(int num)
Returns child at given offset, 0 .. size()-1, inclusive.
intchildNum(Node n)
Returns sequence number node in list of children, -1 iff no such child.
voidclipboardNode(StringBuffer txt)
To select structural region, select all children
protected Objectclone()
booleancontains(Node n)
Passed node (null OK) somewhere in subtree?
voiddump(int level, int maxlevel)
intdx()
Skip over border, padding to content area.
intdy()
Skip over border, padding to content area.
booleaneventBeforeAfter(AWTEvent e, Point rel)
Adjust for bbox (which itself has been adjusted for margins), padding, border.
booleaneventNode(AWTEvent e, Point rel)
Internal nodes pass on to children.
protected NodefindDFS(String searchname, String attrname, String attrval, int level, int maxlevel)
booleanformatBeforeAfter(int width, int height, Context cx)
Internal nodes might have a structural style LATER: externalize format to a behavior and choose with style sheet.
booleanformatNode(int width, int height, Context cx)
Children report dimensions (width and height), parent places at (x,y).
NodegetElementById(String elementId)
NodegetFirstChild()
Returns first child, or null if no children.
LeafgetFirstLeaf()
If first child is leaf, returns that.
NodegetLastChild()
Returns last child, or null if no children.
LeafgetLastLeaf()
If last child is leaf, returns that.
NodegetNextSibling()
DOM2 -- childAt() more efficient.
NodegetPreviousSibling()
DOM2 -- childAt() more efficient.
voidinsertChildAt(Node child, int num)
booleanisStruct()
voidmarkDirtySubtreeDown(boolean leavestoo)
voidpaintBeforeAfter(Rectangle docclip, Context cx)
  1. Check to see subtree area within clipping region.
voidpaintNode(Rectangle docclip, Context cx)
To paint internal node, paint all children.
voidremoveAllChildren()
Faster than removing one at a time.
voidremoveChild(Node child)
Removes child if it exists among list of children.
NoderemoveChildAt(int num)
voidsetChildAt(Node child, int num)
voidsetName(String name)
Names of internal nodes are normalized to all-lowercase (but not interned).
intsize()
NodestructChildAt(int num)
Some nonstructural nodes (internal nodes with name==null) may be used to better balance trees for better performance.
intstructChildNum(Node n)
intstructsize()
WARNING: This doesn't climb up to lowest structural parent, inconsistently with structChildNum

Field Detail

border

public Insets border
Border, with possible different widths on each side (counted in bounding box dimensions). Components (top, left, bottom, right) should be treated read only.

INSETS

public static final Insets[] INSETS
Canonical Insets with equal bounds to use to save space over creating new Insets for these common cases. For example, INSETS[5] has top == bottom == left == right == 5. Treat all Insets as read-only.

INSETS_ZERO

public static final Insets INSETS_ZERO
Special name, points to INSETS[0].

margin

public Insets margin
Transparent external space around bounding box (not part of bounding box width or height, as effects incorporated into bounding box (x,y) location). Usually layout node will collapse bottom margin of previous Node and top of this; likewise with left and right. Stored here rather than being passed about during formatting so that incremental formatting is simpler (and there aren't that many internal nodes). In other words, margin is used during formatting, but otherwise drops out as its effect is incorporated into bbox.x and bbox.y. Components (top, left, bottom, right) should be treated read only;

padding

public Insets padding
Internal space inside border, with same background as content (counted in bounding box dimensions). Components (top, left, bottom, right) should be treated read only.

Constructor Detail

INode

public INode(String name, Map<String,Object> attr, INode parent)

Method Detail

addCategory

public Node addCategory(Node n, String category)
Add child to correct category, as in UI panel or menu with groups.

appendChild

public void appendChild(Node child)
Adds child to end of list of children. Child automatically removed from old parent, if any. If child alread among children, child moved to end of child list. Node constructors take a parent, which automatically calls appendChild(), or you can pass null as parent and appendChild() or insertChildAt() later.

breakAfter

public boolean breakAfter()

breakBefore

public boolean breakBefore()

checkRep

public boolean checkRep()

childAt

public Node childAt(int num)
Returns child at given offset, 0 .. size()-1, inclusive.

childNum

public int childNum(Node n)
Returns sequence number node in list of children, -1 iff no such child.

clipboardNode

public void clipboardNode(StringBuffer txt)
To select structural region, select all children

clone

protected Object clone()

contains

public boolean contains(Node n)
Passed node (null OK) somewhere in subtree?

dump

public void dump(int level, int maxlevel)

dx

public int dx()
Skip over border, padding to content area.

dy

public int dy()
Skip over border, padding to content area.

eventBeforeAfter

public boolean eventBeforeAfter(AWTEvent e, Point rel)
Adjust for bbox (which itself has been adjusted for margins), padding, border.

eventNode

public boolean eventNode(AWTEvent e, Point rel)
Internal nodes pass on to children. Events are propogated from last child to first (and painted first to last), which means that later children have implicitly higher priority as they get first chance at setting a grab. Event passed on only if (x,y) within child's bounding box, or if TreeEvent.VALIDATE event. Event is translated to be in child's coordinate system (that is, (0,0) corresponds to the child's origin).

findDFS

protected Node findDFS(String searchname, String attrname, String attrval, int level, int maxlevel)

formatBeforeAfter

public boolean formatBeforeAfter(int width, int height, Context cx)
Internal nodes might have a structural style LATER: externalize format to a behavior and choose with style sheet.

formatNode

public boolean formatNode(int width, int height, Context cx)
Children report dimensions (width and height), parent places at (x,y). Bbox = union of children's bboxes Children stacked vertically like TeX vbox; override to implement other layout strategies To implement a new layout manager, override this method.

See Also: FixedI

getElementById

public Node getElementById(String elementId)

getFirstChild

public final Node getFirstChild()
Returns first child, or null if no children. Same as childAt(0).

getFirstLeaf

public final Leaf getFirstLeaf()
If first child is leaf, returns that. If first child is INode, recursively returns that node's getFirstLeaf(). If no chldren, returns null.

getLastChild

public final Node getLastChild()
Returns last child, or null if no children. Same as childAt(size()-1).

getLastLeaf

public final Leaf getLastLeaf()
If last child is leaf, returns that. If last child is INode, recursively returns that node's getLastLeaf(). If no chldren, returns null.

getNextSibling

public Node getNextSibling()
DOM2 -- childAt() more efficient.

getPreviousSibling

public Node getPreviousSibling()
DOM2 -- childAt() more efficient.

insertChildAt

public void insertChildAt(Node child, int num)

isStruct

public final boolean isStruct()

markDirtySubtreeDown

public void markDirtySubtreeDown(boolean leavestoo)

paintBeforeAfter

public void paintBeforeAfter(Rectangle docclip, Context cx)
  1. Check to see subtree area within clipping region. If not and span transitions, mark cx.valid=false and return.
  2. Add styles from style sheet, if any.
  3. Draw background if differs from enclosing subtree.
  4. Call superclass paintBeforeAfter, which sets coordinate space, calls observers, calls paintNode.
  5. Draw border, if any.
  6. Undo styles

paintNode

public void paintNode(Rectangle docclip, Context cx)
To paint internal node, paint all children.

removeAllChildren

public void removeAllChildren()
Faster than removing one at a time.

removeChild

public void removeChild(Node child)
Removes child if it exists among list of children.

removeChildAt

public Node removeChildAt(int num)

Returns: child removed

setChildAt

public void setChildAt(Node child, int num)

setName

public void setName(String name)
Names of internal nodes are normalized to all-lowercase (but not interned). If name set to null, this indicates a nonstructural node in an otherwise structural tree. Nonstructural nodes can be useful to better balance trees leaning to improved performance. Nonstructural nodes are ignored by Location and other classes.

size

public int size()

Returns: number of children.

structChildAt

public final Node structChildAt(int num)
Some nonstructural nodes (internal nodes with name==null) may be used to better balance trees for better performance. This method bypasses nonstructural nodes.

structChildNum

public int structChildNum(Node n)

structsize

public int structsize()
WARNING: This doesn't climb up to lowest structural parent, inconsistently with structChildNum