multivalent

Class Leaf

public class Leaf extends Node

Leaf nodes are words of text, XDOC words, images, and so on. Many media adaptors subclass Leaf for their own type of nodes.

Version: $Revision: 1.11 $ $Date: 2003/06/02 05:07:40 $

Constructor Summary
Leaf(String name, Map<String,Object> attrs, INode parent)
In most cases a Leaf's attributes are null, as in a word of text, but image nodes have attributes.
Method Summary
voidappend(Leaf l)
Append leaf to the end of this one, adjusting content, spans, and so on.
booleancheckRep()
voidclipboardBeforeAfter(StringBuffer txt, int start, int end)
voidclipboardNode(StringBuffer sb)
Stringcopy(int startoff, Leaf endn, int endoff)
Stringcut(int startoff, Leaf endn, int endoff)
voiddelete(int startoff, Leaf endn, int endoff)
intdx()
intdy()
Stringeatme(int startoff, Leaf endn, int endoff)
booleaneventBeforeAfter(AWTEvent e, Point rel)
Point can be null when it's a semantic event sent to tree nodes.
booleaneventNode(AWTEvent e, Point rel)
unless overridden, leaves see if owner is interested
booleanformatBeforeAfter(int width, int height, Context cx)
booleanformatNode(int width, int height, Context cx)
Handles span transitions on node and elided portions.
booleanformatNodeContent(Context cx, int start, int end)
LeafgetFirstLeaf()
LeafgetLastLeaf()
voidinsert(int startoff, char ch, INode bounds)
Insert character at point.
voidinsert(int startoff, String txt, INode bounds)
Insert string of possibly many words at point.
booleanisLeaf()
intlengthTo(int starti, Leaf endn, int endi)
voidmarkDirtySubtreeDown(boolean leavestoo)
Pointoffset2rel(int offset)
Given an offset into a Leaf, return corresponding subcomponent geometric point.
voidpaintBeforeAfter(Rectangle docclip, Context cx)
The logical size of the node.
voidpaintNode(Rectangle docclip, Context cx)
Call paintNodeContent with longest range of unchanged Context.
booleanpaintNodeContent(Context cx, int start, int end)
voidpaste(int startoff)
voidpaste(String txt, int startoff)
voidremoveTidy(INode root)
Remove node from tree tidily: don't leave behind empty INode, recursively up to root, and brush span transitions to the size (Span).
voidsetName(String name)
voidsplit(int off)
Split this node into two nodes starting at same position under current parent, and handling content, spans, and so on.
protected voidsubelement()
voidsubelementCalc(Context cx)
Media leaves override this to map an (x,y) point into an internal location.
intsubelementHit(Point rel)
Given a geometric point within the leaf, return index of corresponding subcomponent (e.g., letter within word).

Constructor Detail

Leaf

public Leaf(String name, Map<String,Object> attrs, INode parent)
In most cases a Leaf's attributes are null, as in a word of text, but image nodes have attributes.

Method Detail

append

public void append(Leaf l)
Append leaf to the end of this one, adjusting content, spans, and so on. The appended leaf must either immediately follow this one in the tree, or be unattached to the tree. The appended leaf should be considered invalid and not used subsequently.

checkRep

public boolean checkRep()

clipboardBeforeAfter

public void clipboardBeforeAfter(StringBuffer txt, int start, int end)

clipboardNode

public void clipboardNode(StringBuffer sb)

copy

public String copy(int startoff, Leaf endn, int endoff)

cut

public String cut(int startoff, Leaf endn, int endoff)

delete

public void delete(int startoff, Leaf endn, int endoff)

dx

public int dx()

dy

public int dy()

eatme

public String eatme(int startoff, Leaf endn, int endoff)

eventBeforeAfter

public boolean eventBeforeAfter(AWTEvent e, Point rel)
Point can be null when it's a semantic event sent to tree nodes.

eventNode

public boolean eventNode(AWTEvent e, Point rel)
unless overridden, leaves see if owner is interested

formatBeforeAfter

public boolean formatBeforeAfter(int width, int height, Context cx)

formatNode

public boolean formatNode(int width, int height, Context cx)
Handles span transitions on node and elided portions. Called medium-specific leaf formatNodeContent in hunks of maximum-length homogeneous span coverage to get content size. Marks node valid, so if node not (e.g., LeafImage's image not loaded), set valid_=false in formatNodeContent.

formatNodeContent

public boolean formatNodeContent(Context cx, int start, int end)

getFirstLeaf

public final Leaf getFirstLeaf()

getLastLeaf

public final Leaf getLastLeaf()

insert

public void insert(int startoff, char ch, INode bounds)
Insert character at point.

Returns: endpoint of inserted text, so if cursor at startoff, it should move to return value.

insert

public void insert(int startoff, String txt, INode bounds)
Insert string of possibly many words at point. Preserves validity of marks and spans. If inserting at cursor, cursor moved to point after inserted text (that may be too much policy, or centralizing that at the lowest level here is exactly the right place).. MOVE TO LeafText, since bogus for everything else (images, ...).

isLeaf

public final boolean isLeaf()

lengthTo

public int lengthTo(int starti, Leaf endn, int endi)

markDirtySubtreeDown

public void markDirtySubtreeDown(boolean leavestoo)

offset2rel

public Point offset2rel(int offset)
Given an offset into a Leaf, return corresponding subcomponent geometric point. See offset2rel().

paintBeforeAfter

public void paintBeforeAfter(Rectangle docclip, Context cx)
The logical size of the node. Spans can be anchored from 0..size().

paintNode

public void paintNode(Rectangle docclip, Context cx)
Call paintNodeContent with longest range of unchanged Context.

paintNodeContent

public boolean paintNodeContent(Context cx, int start, int end)

paste

public void paste(int startoff)

paste

public void paste(String txt, int startoff)

removeTidy

public void removeTidy(INode root)
Remove node from tree tidily: don't leave behind empty INode, recursively up to root, and brush span transitions to the size (Span).

setName

public void setName(String name)

split

public void split(int off)
Split this node into two nodes starting at same position under current parent, and handling content, spans, and so on.

subelement

protected void subelement()

subelementCalc

public void subelementCalc(Context cx)
Media leaves override this to map an (x,y) point into an internal location. For example, ASCII maps the point into a character position. Since the internal location must be represented as an integer, an image could encode an internal (x,y) position as (y*width)+x

subelementHit

public int subelementHit(Point rel)
Given a geometric point within the leaf, return index of corresponding subcomponent (e.g., letter within word). See offset2rel().