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 |
boolean | checkRep() |
void | clipboardBeforeAfter(StringBuffer txt, int start, int end) |
void | clipboardNode(StringBuffer sb) |
String | copy(int startoff, Leaf endn, int endoff) |
String | cut(int startoff, Leaf endn, int endoff) |
void | delete(int startoff, Leaf endn, int endoff) |
int | dx() |
int | dy() |
String | eatme(int startoff, Leaf endn, int endoff) |
boolean | eventBeforeAfter(AWTEvent e, Point rel)
Point can be null when it's a semantic event sent to tree nodes. |
boolean | eventNode(AWTEvent e, Point rel) unless overridden, leaves see if owner is interested |
boolean | formatBeforeAfter(int width, int height, Context cx) |
boolean | formatNode(int width, int height, Context cx)
Handles span transitions on node and elided portions.
|
boolean | formatNodeContent(Context cx, int start, int end) |
Leaf | getFirstLeaf() |
Leaf | getLastLeaf() |
void | insert(int startoff, char ch, INode bounds)
Insert character at point. |
void | insert(int startoff, String txt, INode bounds)
Insert string of possibly many words at point.
|
boolean | isLeaf() |
int | lengthTo(int starti, Leaf endn, int endi) |
void | markDirtySubtreeDown(boolean leavestoo) |
Point | offset2rel(int offset)
Given an offset into a Leaf, return corresponding subcomponent geometric point.
|
void | paintBeforeAfter(Rectangle docclip, Context cx) The logical size of the node. |
void | paintNode(Rectangle docclip, Context cx) Call paintNodeContent with longest range of unchanged Context. |
boolean | paintNodeContent(Context cx, int start, int end) |
void | paste(int startoff) |
void | paste(String txt, int startoff) |
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). |
void | setName(String name) |
void | split(int off) |
protected void | subelement() |
void | subelementCalc(Context cx)
Media leaves override this to map an (x,y) point into an internal location.
|
int | subelementHit(Point rel)
Given a geometric point within the leaf, return index of corresponding subcomponent (e.g., letter within word).
|
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.
public boolean checkRep()
public void clipboardBeforeAfter(StringBuffer txt, int start, int end)
public void clipboardNode(StringBuffer sb)
public String copy(int startoff,
Leaf endn, int endoff)
public String cut(int startoff,
Leaf endn, int endoff)
public void delete(int startoff,
Leaf endn, int endoff)
public int dx()
public int dy()
public String eatme(int startoff,
Leaf endn, int endoff)
public boolean eventBeforeAfter(AWTEvent e, Point rel)
Point can be null when it's a semantic event sent to tree nodes.
public boolean eventNode(AWTEvent e, Point rel)
unless overridden, leaves see if owner is interested
public boolean formatBeforeAfter(int width, int height,
Context cx)
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.
public boolean formatNodeContent(
Context cx, int start, int end)
public final
Leaf getFirstLeaf()
public final
Leaf getLastLeaf()
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.
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, ...).
public final boolean isLeaf()
public int lengthTo(int starti,
Leaf endn, int endi)
public void markDirtySubtreeDown(boolean leavestoo)
public Point offset2rel(int offset)
Given an offset into a Leaf, return corresponding subcomponent geometric point.
See offset2rel().
public void paintBeforeAfter(Rectangle docclip,
Context cx)
The logical size of the node. Spans can be anchored from 0..size().
public void paintNode(Rectangle docclip,
Context cx)
Call paintNodeContent with longest range of unchanged Context.
public boolean paintNodeContent(
Context cx, int start, int end)
public void paste(int startoff)
public void paste(String txt, int startoff)
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).
public void setName(String name)
public void split(int off)
protected void subelement()
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
public int subelementHit(Point rel)
Given a geometric point within the leaf, return index of corresponding subcomponent (e.g., letter within word).
See offset2rel().