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 |
Insets | border
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 Insets | INSETS_ZERO Special name, points to INSETS[0]. |
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).
|
Insets | padding
Internal space inside border, with same background as content (counted in bounding box dimensions).
|
Method Summary |
Node | addCategory(Node n, String category) Add child to correct category, as in UI panel or menu with groups. |
void | appendChild(Node child)
Adds child to end of list of children.
|
boolean | breakAfter() |
boolean | breakBefore() |
boolean | checkRep() |
Node | childAt(int num) Returns child at given offset, 0 .. size()-1, inclusive. |
int | childNum(Node n) Returns sequence number node in list of children, -1 iff no such child. |
void | clipboardNode(StringBuffer txt) To select structural region, select all children |
protected Object | clone() |
boolean | contains(Node n) Passed node (null OK) somewhere in subtree? |
void | dump(int level, int maxlevel) |
int | dx() Skip over border, padding to content area. |
int | dy() Skip over border, padding to content area. |
boolean | eventBeforeAfter(AWTEvent e, Point rel) Adjust for bbox (which itself has been adjusted for margins), padding, border. |
boolean | eventNode(AWTEvent e, Point rel)
Internal nodes pass on to children.
|
protected Node | findDFS(String searchname, String attrname, String attrval, int level, int maxlevel) |
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. |
boolean | formatNode(int width, int height, Context cx)
Children report dimensions (width and height), parent places at (x,y).
|
Node | getElementById(String elementId) |
Node | getFirstChild() Returns first child, or null if no children. |
Leaf | getFirstLeaf() If first child is leaf, returns that. |
Node | getLastChild() Returns last child, or null if no children. |
Leaf | getLastLeaf() If last child is leaf, returns that. |
Node | getNextSibling() DOM2 -- childAt() more efficient. |
Node | getPreviousSibling() DOM2 -- childAt() more efficient. |
void | insertChildAt(Node child, int num) |
boolean | isStruct() |
void | markDirtySubtreeDown(boolean leavestoo) |
void | paintBeforeAfter(Rectangle docclip, Context cx)
- Check to see subtree area within clipping region.
|
void | paintNode(Rectangle docclip, Context cx) To paint internal node, paint all children. |
void | removeAllChildren() Faster than removing one at a time. |
void | removeChild(Node child) Removes child if it exists among list of children. |
Node | removeChildAt(int num) |
void | setChildAt(Node child, int num) |
void | setName(String name)
Names of internal nodes are normalized to all-lowercase (but not interned).
|
int | size() |
Node | structChildAt(int num)
Some nonstructural nodes (internal nodes with name==null) may be used to better balance trees for better performance.
|
int | structChildNum(Node n) |
int | structsize() WARNING: This doesn't climb up to lowest structural parent, inconsistently with structChildNum |
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.
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.
public static final Insets INSETS_ZERO
Special name, points to INSETS[0].
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;
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.
public INode(String name, Map<String,Object> attr,
INode parent)
public
Node addCategory(
Node n, String category)
Add child to correct category, as in UI panel or menu with groups.
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.
public boolean breakAfter()
public boolean breakBefore()
public boolean checkRep()
public
Node childAt(int num)
Returns child at given offset, 0 .. size()-1, inclusive.
public int childNum(
Node n)
Returns sequence number node in list of children, -1 iff no such child.
public void clipboardNode(StringBuffer txt)
To select structural region, select all children
protected Object clone()
public boolean contains(
Node n)
Passed node (null OK) somewhere in subtree?
public void dump(int level, int maxlevel)
public int dx()
Skip over border, padding to content area.
public int dy()
Skip over border, padding to content area.
public boolean eventBeforeAfter(AWTEvent e, Point rel)
Adjust for bbox (which itself has been adjusted for margins), padding, border.
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).
protected
Node findDFS(String searchname, String attrname, String attrval, int level, int maxlevel)
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.
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
public
Node getElementById(String elementId)
public final
Node getFirstChild()
Returns first child, or null if no children. Same as childAt(0)
.
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.
public final
Node getLastChild()
Returns last child, or null if no children. Same as childAt(size()-1)
.
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.
public
Node getNextSibling()
DOM2 -- childAt() more efficient.
public
Node getPreviousSibling()
DOM2 -- childAt() more efficient.
public void insertChildAt(
Node child, int num)
public final boolean isStruct()
public void markDirtySubtreeDown(boolean leavestoo)
public void paintBeforeAfter(Rectangle docclip,
Context cx)
- Check to see subtree area within clipping region. If not and span transitions, mark cx.valid=false and return.
- Add styles from style sheet, if any.
- Draw background if differs from enclosing subtree.
- Call superclass paintBeforeAfter, which sets coordinate space, calls observers, calls paintNode.
- Draw border, if any.
- Undo styles
public void paintNode(Rectangle docclip,
Context cx)
To paint internal node, paint all children.
public void removeAllChildren()
Faster than removing one at a time.
public void removeChild(
Node child)
Removes child if it exists among list of children.
public
Node removeChildAt(int num)
public void setChildAt(
Node child, int num)
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.
public int size()
Returns: number of children.
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.
public int structChildNum(
Node n)
public int structsize()
WARNING: This doesn't climb up to lowest structural parent, inconsistently with structChildNum