|
Multivalent API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectmultivalent.VObject
multivalent.Behavior
multivalent.Span
A Span (aka Range aka Tk tag), such as a hyperlink or executable copy editor mark, is a linear range of content that can control appearance and receives events. It efficiently covers any amount of tree, not restricted by structural node hierarchy. Spans are robust to insertions and deletions, during runtime and across save/restore editing of base document.
Span is not an abstract class, and in fact should be heavily used itself. It can be used to store metadata, via attributes. It can be created with a semantic name and its properties set in the style sheet. If a style sheet is independent of a style sheet (as with a user annotation), one should use a "general span". If different behavior is needed, as opposed to appearance, then subclasses are appropriate.
open(Node)
, close(Node)
/ closeAll(Node)
,
move(Leaf,int, Leaf,int)
/ Span
/ Mark
,
moveq(Leaf,int, Leaf,int)
/ Span
/ Mark
getStart()
, getEnd()
, isSet()
,
contains(Node,int)
/ Mark
stretch(Leaf,INode)
,
getPriority()
, appearance(Context, boolean)
,
repaint()
/ long
, markDirty()
,
getPriority()
, event(AWTEvent)
Mark
Field Summary | |
---|---|
static java.lang.String |
GI_END
|
static java.lang.String |
GI_START
|
static java.lang.String |
MSG_DELETE
For use in interactive editing, deletes span, moving selection to old extent. |
static java.lang.String |
MSG_EDIT
Request for interactive editing of span attributes. |
static java.lang.String |
MSG_MORPH
For use in interactive editing, moves Span to extent of selection. |
static java.lang.String |
MSG_UNATTACHED
Announce span that could not be reattached with confidence. |
java.util.Map<java.lang.String,java.lang.Object> |
pend
|
java.util.Map<java.lang.String,java.lang.Object> |
pstart
|
Fields inherited from class multivalent.Behavior |
---|
ATTR_BEHAVIOR, name_ |
Fields inherited from class multivalent.VObject |
---|
attr_ |
Fields inherited from interface multivalent.ContextListener |
---|
LITTLE, LOT, PRIORITY_LENS, PRIORITY_MAX, PRIORITY_MIN, PRIORITY_SELECTION, PRIORITY_SPAN, PRIORITY_STRUCT, SOME |
Constructor Summary | |
---|---|
Span()
|
Method Summary | |
---|---|
boolean |
appearance(Context cx,
boolean all)
Resets the graphics context every time the object is added to or dropped from the set active over the portion of the document being drawn. |
void |
buildAfter(Document doc)
Attach to document tree based on saved anchor description. |
boolean |
checkRep()
Checks "representation invariant" (see MIT SE), and returns true iff object is valid, which should be always |
boolean |
close(Node end)
Close span at end of passed Node, and attach Span to tree. |
static int |
closeAll(Node subtree)
Close all spans in subtree. |
boolean |
contains(Mark m)
|
boolean |
contains(Node n,
int off)
Is (Node, offset) contained within span? |
void |
destroy()
Removes span from document and its layer. |
void |
event(java.awt.AWTEvent e)
Receives synthesized MouseEvent.MOUSE_ENTERED , MouseEvent.MOUSE_EXITED , MouseEvent.MOUSE_PRESSED , .... |
Mark |
getEnd()
(Node, offset) of end of span. |
int |
getPriority()
Self-reported priority relative to others of the same class, e.g., other spans. |
Mark |
getStart()
(Node, offset) of start of span. |
boolean |
isSet()
Is Span attached to tree? |
void |
markDirty()
|
void |
move(Leaf ln,
int lo,
Leaf rn,
int ro)
Save move, for interactive use: selection, annotations. |
void |
move(Mark l,
Mark r)
|
void |
move(Span s)
Span endpoints assumed valid; just moveq + reformatting and repainting. |
void |
moveq(Leaf ln,
int lo,
Leaf rn,
int ro)
"move quick" just updates summaries, so more efficient than move(), if caller: guarantees that first node comes before second node (so the system doesn't have to spend time checking this), and handles all reformatting and repainting (including marking tree nodes dirty) Useful using during initial tree builds, when adding spans and formatting in batch(es). |
void |
moveq(Mark start,
Mark end)
|
void |
moveq(Span span)
Useful to morph to the selection. |
void |
moveqSwap(Leaf ln,
int lo,
Leaf rn,
int ro)
Like moveq(), swapping endpoints if necessary, so that left comes before right in tree order. |
void |
open(Node start)
During document creation, open span at first leaf to be created after passed node. |
void |
repaint()
|
void |
repaint(long ms)
Repaints smallest subtree containing both endpoints. |
void |
restore(ESISNode n,
java.util.Map<java.lang.String,java.lang.Object> attr,
Layer layer)
Given ESIS subtree, pluck class-specific information from attributes, call super.restore() for locations. |
ESISNode |
save()
Stuff instance state into attributes; if save buffer not null, write out corresponding XML. |
boolean |
semanticEventAfter(SemanticEvent se,
java.lang.String msg)
Recognize "deleteSpan " and "morphSpan ". |
boolean |
semanticEventBefore(SemanticEvent se,
java.lang.String msg)
Morphing and deletion menu items in popup. |
static void |
stretch(Leaf l,
INode within)
Removing leaf from tree, but preserve its span transitions by stretching end transitions to previous node and start transitions to next node. |
java.lang.String |
toString()
Subclasses should extend to check any attributes they add. |
Methods inherited from class multivalent.Behavior |
---|
buildBefore, clipboardAfter, clipboardBefore, createUI, eventAfter, eventBefore, formatAfter, formatBefore, getBrowser, getDocument, getInstance, getInstance, getLayer, getLogger, getName, getPreference, getRoot, isEditable, paintAfter, paintBefore, putPreference, redo, restoreChildren, setName, undo |
Methods inherited from class multivalent.VObject |
---|
attrEntrySetIterator, attrKeysIterator, clearAttributes, getAttr, getAttr, getAttributes, getGlobal, getValue, hasAttributes, putAttr, removeAttr, setAttributes |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String MSG_DELETE
"deleteSpan".
public static final java.lang.String MSG_MORPH
"morphSpan".
public static final java.lang.String MSG_EDIT
"editSpan".
public static final java.lang.String MSG_UNATTACHED
"unattachedSpan": arg= Span
instance.
public static final java.lang.String GI_START
public static final java.lang.String GI_END
public java.util.Map<java.lang.String,java.lang.Object> pstart
public java.util.Map<java.lang.String,java.lang.Object> pend
Constructor Detail |
---|
public Span()
Method Detail |
---|
public final Mark getStart()
public final Mark getEnd()
public boolean isSet()
public int getPriority()
ContextListener
ContextListener.PRIORITY_LENS
, modified by ContextListener.LITTLE
/ContextListener.SOME
/{#link LOT}.
getPriority
in interface ContextListener
public boolean appearance(Context cx, boolean all)
ContextListener
appearance
in interface ContextListener
all
- all attributes or exclude those that are not inheritedpublic void open(Node start)
close(Node)
adjusts the start point.
If both start and end points already exist, use moveq(Leaf,int, Leaf,int)
.
All spans open
ed should be close
d.
and
,
for examples of use
public boolean close(Node end)
destroy()
it;
however, the HTML media adaptor takes the case of HTML 0-length >a name=...<
spans
and instead attaches and 'id' attribute to the previous node.
public static int closeAll(Node subtree)
public void move(Leaf ln, int lo, Leaf rn, int ro)
public void move(Span s)
public void move(Mark l, Mark r)
public void moveqSwap(Leaf ln, int lo, Leaf rn, int ro)
public void moveq(Leaf ln, int lo, Leaf rn, int ro)
public void moveq(Mark start, Mark end)
public void moveq(Span span)
public boolean contains(Node n, int off)
public boolean contains(Mark m)
public static void stretch(Leaf l, INode within)
public void repaint(long ms)
public void repaint()
public void destroy()
destroy
in class Behavior
public void markDirty()
public ESISNode save()
save
in class Behavior
public void restore(ESISNode n, java.util.Map<java.lang.String,java.lang.Object> attr, Layer layer)
start
and end
are reserved to hold Robust Location data.
restore
in class Behavior
RobustLocation
public void buildAfter(Document doc)
buildAfter
in class Behavior
public boolean semanticEventBefore(SemanticEvent se, java.lang.String msg)
semanticEventBefore
in class Behavior
public boolean semanticEventAfter(SemanticEvent se, java.lang.String msg)
semanticEventAfter
in class Behavior
public void event(java.awt.AWTEvent e)
MouseEvent.MOUSE_ENTERED
, MouseEvent.MOUSE_EXITED
, MouseEvent.MOUSE_PRESSED
, ....
For the purposes of event passing, functions more as tree node than behavior (with before/after).
event
in interface EventListener
public boolean checkRep()
VObject
checkRep
in class Behavior
public java.lang.String toString()
toString
in class Behavior
endpoints
- if false, don't consider endpoints.
public boolean equals(Object o, boolean endpoints) {
return this == o; ?
if (this == o) return true;
if (o==null || !(o instanceof Span)) return false;
Span span2 = (Span)o;
boolean eq = true;
if (eq && endpoints) {
eq = (!isSet() && !span2.isSet()) || (getStart().equals(span2.getStart()) && getEnd().equals(span2.getEnd()));
// check pstart and pend too?
}
if (eq) eq = getName().equals(span2.getName());
// attributes ...
return eq;
}
|
Multivalent API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |