multivalent
public abstract class Behavior extends VObject
Protocols:
restore
,
build (before
/ after
,
format (before
/ after
,
paint (before
/ Behavior,
clipboard (Behavior / Behavior,
semantic events (Behavior / Behavior,
low-level events (Behavior / Behavior),
destroy
.
All behaviors must subclass this class and override the proper protocol methods (build, format, paint, and so on, most with before and after phases) and take the appropriate action when called upon by the system framework. The system framework coordinates behaviors along protocols, and if a behavior adheres to proper implementation of the protocols, it should cooperate well with arbitrary other behaviors.
Behaviors should not define constructors. The system needs a public no-argument constructor, to restore by name (with Behavior which in turn uses Class#forName(String) and Class#newInstance()). The easiest way to accomplish this is to declare the class public and rely on the default no-argument constructor. (Do initialization in Behavior.)
The file multivalent/devel/MyBehavior.java in the source code .zip file is a convenient template for writing general behaviors. If a behavior is a Span or Lens or resembles the function of another behavior, you can instead copy that source code and modify it.
Version: $Revision: 1.13 $ $Date: 2003/06/02 04:43:07 $
Field Summary | |
---|---|
static String | ATTR_BEHAVIOR Class name to instantiate for behavior. |
protected String | name_ Logical name. |
Method Summary | |
---|---|
void | buildAfter(Document doc) Traverses all behaviors from lowest to highest priority, during which tweaks hack their content into the tree, |
void | buildBefore(Document doc)
A round robin protocol, here traversing all behaviors from highest to lowest priority, during which main contributors of document content (called media adaptors) hack their content into the tree,
and annotators set Marks to robust anchor to locations to hack in buildAfter so as not to disturb positioning by other annotations.
|
boolean | checkRep() |
boolean | clipboardAfter(StringBuffer sb, Node node)
A tree walk protocol, called after observed node has been given a chance to contribute to the growing selection content in the passed StringBuffer.
|
boolean | clipboardBefore(StringBuffer sb, Node node)
A tree walk protocol, called before observed node has been given a chance to contribute to the growing selection content in the passed StringBuffer.
|
Node | createUI(String type, String title, Object script, INode parent, String category, boolean disabled)
Convenience function for UI building. |
void | destroy()
Protocol.
|
boolean | eventAfter(AWTEvent e, Point rel, Node n)
During Behavior, the behaviors that take primary action to that event should do so,
after having given other behaviors the opportunity to filter it during eventBefore. |
boolean | eventBefore(AWTEvent e, Point rel, Node n) |
boolean | formatAfter(Node node)
A tree walk protocol, called after observed node has been formatted.
|
boolean | formatBefore(Node node)
A tree walk protocol, called before observed node has been formatted. |
Browser | getBrowser() Convenience method to fetch Browser from Layer. |
Document | getDocument() Convenience method to fetch Document from Layer. |
static Behavior | getInstance(String logicalname, String behaviorclass, ESISNode children, Map<String,Object> attr, Layer layer)
Centralized behavior instantiation factory: instantiate all behaviors through this method
-- never use new behavior(...) |
static Behavior | getInstance(String logicalname, String behaviorclass, Map<String,Object> attr, Layer layer) Used in hub instantiation. |
Layer | getLayer() Link to containing layer, which links to Document and so on to Root, Browser, Multivalent. |
String | getName()
Returns the String used to instantiate the Behavior via Behavior.
|
String | getPreference(String name, String defaultval) Convenience method for getting preference in class Multivalent. |
Root | getRoot() Convenience method to fetch Root from Browser. |
boolean | isEditable() |
boolean | paintAfter(Context cx, Node node)
A tree walk protocol, called before observed node has been painted.
|
boolean | paintBefore(Context cx, Node node)
A tree walk protocol, called before observed node has been painted.
|
void | putPreference(String name, String val) Convenience method for putting preference in class Multivalent. |
void | redo() Future protocol: Name and all overloads reserved for future use. |
void | restore(ESISNode n, Map<String,Object> attr, Layer layer)
Takes the place of a constructor's initialization functions; that is, it is invoked exactly once immediately after object instantiation.
|
void | restoreChildren(ESISNode n, Layer layer)
Recursively process ESIS children, restore children as behaviors.
|
ESISNode | save()
Build up save data as ESIS tree, then write that out. |
boolean | semanticEventAfter(SemanticEvent se, String msg)
Round robin distribution to all behaviors.
|
boolean | semanticEventBefore(SemanticEvent se, String msg)
Round robin distribution to all behaviors.
|
void | setName(String name) |
String | toString() Dump name of behavior and identifying/distinguishing short excerpt of content. |
void | undo() Future protocol: Name and all overloads reserved for future use. |
See Also: Mark
Returns: true to short-circuit to selectAfter at that node, bypassing selection of the subtree. For instance, if you're selecting bibliographic entries, you might want to generate BibTeX or IEEE formatting rather than straight text; likewise, on math, generate Lisp, TeX, or Mathematica.
Parameters: type is one of "button", "checkbox", "radiobox", "menubutton", "separator", "entry", "label". title can be HTML fragment. script can be a java.lang.String or SemanticEvent
See Also: SemanticUI
See Also: SemanticEvent java.awt.AWTEvent Browser LensMan
Returns: true to short-circuit formatting of rest of protocol, which consists exclusively of higher-priority behaviors, which almost never want to do.
Returns: true to short-circuit to formatAfter at that node, bypassing formatting of the subtree. Could be used on collapsed outline sections to save work formatting content that wouldn't be displayed anyhow.
new behavior(...)
.
multivalent.std.lens.Note
,
but usually should be a short name referring to the type of behavior, such as "Note",
which can then be mapped into a specific Java class name via the table in a user's Preferences.txt file.Returns: true to short-circuit to paintAfter at that node, bypassing painting of the subtree.
super.save()
.
Always have ATTR_BEHAVIOR from save (short) classname.