|
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.Layer
Special behavior type that groups (1) behaviors (which can be nested Layer's) and (2) data trees of ESISNode
s,
and dispatches (round robin) protocol events over its collection.
Every Document has at least one Layer to implement genre and document-specific functionality, and
the Root's Layer holds all-document/pan-genre system functionality.
Some behaviors store data in the trees; for instance, multipage documents store pagewise behaviors, and Note stores its content.
Layers are loaded from
and saved to
hubs,
in which the case a constituant behavior's logical name is the tag or generic identifier (GI) and its attributes the tag's attributes;
trees are stored as is. Because of this, behavior logical names are normalized to all lowercase.
Behaviors are distinguished from data by a BEHAVIOR attribute.
Dispatches round robin (non-tree) protocols (restore, build, save, semantic events, ...) by recursing over the component behaviors. Tree-based protocols (format, paint, low-level events, ...) are handled elsewhere, by the document tree.
addBehavior(Behavior)
, removeBehavior(Behavior)
,
clearBehaviors()
, size()
,
findBehavior(String path)
, getBehavior(int)
, getBehavior(String logicalname)
, getBehavior(String logicalname, String createname)
getAux(String tag)
, getAux(String attrname, String attrval)
,
addAux(ESISNode)
, removeAux(ESISNode)
, removeAux(String attrname, String attrval)
,
auxSize()
Works with Multipage
as follows.
Stores hub encompassing all pages in data tree keyed by page number.
On buildBefore, if PAGE attribute on document, clears behaviors and instantiates relevant portion.
Likewise, on "closedDocumentPage", saves current behaviors to data tree.
Still loads full on Document.MSG_OPENED
and saves everything to disk on "closedDocument".
Multipage
Field Summary | |
---|---|
static java.lang.String |
ATTR_ACTIVE
|
static java.lang.String |
BASE
Standard name for layer that holds media adaptor for primary document. |
static java.lang.String |
MSG_LOAD
Load a layer as specified in a hub document, such as genre-specific behaviors or a set of annotations. |
static java.lang.String |
PERSONAL
Layer names are given by String's and usually known by convention, but some are defined, such as PERSONAL for personal annotations. |
static java.lang.String |
PREFIX
|
static java.lang.String |
SCRATCH
Standard name for layer that holds behaviors that have no semantic standing in the document. |
static java.lang.String |
SHARED
Standard name for layer that holds behaviors shared among other behaviors, although any layer can be shared by asking for the right name. |
static java.lang.String |
SYSTEM
Layer name for core behaviors, usually created by a document's media adaptor. |
Fields inherited from class multivalent.Behavior |
---|
ATTR_BEHAVIOR, name_ |
Fields inherited from class multivalent.VObject |
---|
attr_ |
Constructor Summary | |
---|---|
Layer()
|
Method Summary | |
---|---|
protected void |
addAux(ESISNode e)
Add ESISNode tree to aux trees, if not already there (not a multilist). |
void |
addBehavior(Behavior be)
A Behavior can only be in one layer at a time, so if it's already in a layer, it's removed from that layer first. |
int |
auxSize()
Number of auxiliary trees (often 0). |
void |
buildAfter(Document doc)
Iterates over component Behaviors (Layer is a subclass of Behavior), lowest priority to highest. |
void |
buildBefore(Document doc)
Iterates over component Behaviors (Layer is a subclass of Behavior), highest priority to lowest, if layer is active. |
void |
buildBeforeAfter(Document doc)
|
boolean |
checkRep()
Checks "representation invariant" (see MIT SE), and returns true iff object is valid, which should be always |
void |
clear()
Clears everything, behaviors and aux. |
void |
clearBehaviors()
Removes all active behaviors from Layer, destroy()'ing in the process. |
void |
destroy()
Iterates over component Behaviors (including nested Layer's), highest priority to lowest. |
void |
dump()
|
void |
dump(int level)
|
Behavior |
findBehavior(java.lang.String path)
Given a layer pathname, finds nested layer. |
java.awt.Color |
getAnnoColor()
|
NFont |
getAnnoFont()
|
ESISNode |
getAux(java.lang.String tag)
Returns tree of aux tree data with passed tag. |
ESISNode |
getAux(java.lang.String attrname,
java.lang.String attrval)
Returns tree of aux tree data with attribute name = val. |
Behavior |
getBehavior(int index)
|
Behavior |
getBehavior(java.lang.String logicalname)
Get behavior of given logical name, null if doesn't exist. |
Behavior |
getBehavior(java.lang.String logicalname,
java.lang.String classname)
Get (first) behavior of given logical name. |
Browser |
getBrowser()
End of Layer chain. |
Document |
getDocument()
Often end of Layer chain. |
Layer |
getInstance(java.lang.String logicalname)
Constructs empty layer with given name, unless one by that name already exists, in which case that existing Layer is returned. |
static Layer |
getInstance(java.lang.String logicalname,
Document doc)
Constructs top-most Layer of Layers in a Document. |
boolean |
isActive()
|
boolean |
isEditable()
For now, a layer is editable if its name is "personal". |
protected void |
removeAux(ESISNode e)
|
protected void |
removeAux(java.lang.String attrname,
java.lang.String attrval)
|
void |
removeBehavior(Behavior be)
Removes behavior from Layer as soon as pending semanticEvent roundrobins completed; if none, then remove immediately. |
void |
restore(ESISNode n,
java.util.Map<java.lang.String,java.lang.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)
Override definition in Behavior to keep immediate subtrees that aren't behaviors. |
ESISNode |
save()
Iterate over auxiliary non-behavior trees, then component Behaviors highest priority to lowest. |
boolean |
semanticEventAfter(SemanticEvent se,
java.lang.String msg)
Iterates over component Behaviors, lowest priority to highest. |
boolean |
semanticEventBefore(SemanticEvent se,
java.lang.String msg)
Iterates over component Behaviors (including nested Layer's), highest priority to lowest. |
void |
setActive(boolean active)
If a Layer is not active, all its component behaviors are still instantiated but not invoked during protocols. |
int |
size()
Returns the numbers behaviors in the layer. |
Methods inherited from class multivalent.Behavior |
---|
clipboardAfter, clipboardBefore, createUI, eventAfter, eventBefore, formatAfter, formatBefore, getInstance, getInstance, getLayer, getLogger, getName, getPreference, getRoot, paintAfter, paintBefore, putPreference, redo, setName, toString, 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_LOAD
"loadLayer": arg= URI
location of hub
public static final java.lang.String SYSTEM
public static final java.lang.String PERSONAL
public static final java.lang.String SCRATCH
public static final java.lang.String BASE
public static final java.lang.String SHARED
public static final java.lang.String ATTR_ACTIVE
public static final java.lang.String PREFIX
Constructor Detail |
---|
public Layer()
Method Detail |
---|
public static Layer getInstance(java.lang.String logicalname, Document doc)
public Layer getInstance(java.lang.String logicalname)
getBehavior(String)
public java.awt.Color getAnnoColor()
public NFont getAnnoFont()
public Browser getBrowser()
getBrowser
in class Behavior
public Document getDocument()
getDocument
in class Behavior
public boolean isEditable()
isEditable
in class Behavior
public void setActive(boolean active)
public boolean isActive()
public void addBehavior(Behavior be)
public void removeBehavior(Behavior be)
public void clearBehaviors()
public int size()
public Behavior findBehavior(java.lang.String path)
public Behavior getBehavior(int index)
public Behavior getBehavior(java.lang.String logicalname)
public Behavior getBehavior(java.lang.String logicalname, java.lang.String classname)
Behavior.getInstance(String, String, java.util.Map, Layer)
.
To get all behaviors of given logical name, iterate over the list yourself from 0 .. size()-1 with getBehavior(int)
.
public ESISNode getAux(java.lang.String tag)
public ESISNode getAux(java.lang.String attrname, java.lang.String attrval)
attrval == null
, anything matches.
protected void addAux(ESISNode e)
protected void removeAux(ESISNode e)
protected void removeAux(java.lang.String attrname, java.lang.String attrval)
public int auxSize()
public void clear()
public ESISNode save()
save
in class Behavior
public void restore(ESISNode n, java.util.Map<java.lang.String,java.lang.Object> attr, Layer layer)
Behavior
restore
in class Behavior
public void restoreChildren(ESISNode n, Layer layer)
restoreChildren
in class Behavior
public void buildBeforeAfter(Document doc)
public void buildBefore(Document doc)
buildBefore
in class Behavior
Mark
public void buildAfter(Document doc)
buildAfter
in class Behavior
public boolean semanticEventBefore(SemanticEvent se, java.lang.String msg)
Multipage.MSG_CLOSEPAGE
for isEditable() documents, first saves active behaviors for that page to aux in memory
(behaviors are moved from aux to active in buildBefore).
(Low-level eventBefore/After is a tree-based protocol, so it's not seen by Layer.)
semanticEventBefore
in class Behavior
public boolean semanticEventAfter(SemanticEvent se, java.lang.String msg)
semanticEventAfter
in class Behavior
public void destroy()
destroy
in class Behavior
public boolean checkRep()
VObject
checkRep
in class Behavior
public void dump()
public void dump(int level)
|
Multivalent API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |