multivalent
Class Layer
public
class
Layer
extends Behavior
Special behavior type that groups (1) behaviors (which can be nested Layer's) and (2) data trees of
ESISNodes,
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.
- Operations on the collection of behaviors: addBehavior, removeBehavior,
clearBehaviors, size,
Layer, Layer, Layer, Layer
- Operations on data trees:
Layer, Layer,
addAux, removeAux, Layer,
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 MSG_OPENED and saves everything to disk on "closedDocument".
Version: $Revision: 1.17 $ $Date: 2003/06/02 05:07:21 $
See Also: Multipage
Field Summary |
static String | ATTR_ACTIVE |
static String | BASE Standard name for layer that holds media adaptor for primary document. |
static String | MSG_LOAD
Load a layer as specified in a hub document, such as genre-specific behaviors or a set of annotations.
|
static 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 String | PREFIX |
static String | SCRATCH Standard name for layer that holds behaviors that have no semantic standing in the document. |
static 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 String | SYSTEM Layer names are given by String's and usually known by convention, but some are defined, such as PERSONAL for personal annotations. |
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() |
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(String path) Given a layer pathname, find nested layer. |
Color | getAnnoColor() |
Font | getAnnoFont() |
ESISNode | getAux(String tag) Returns tree of aux tree data with passed tag. |
ESISNode | getAux(String attrname, String attrval) Returns tree of aux tree data with attribute name = val. |
Behavior | getBehavior(int index) |
Behavior | getBehavior(String logicalname) Get behavior of given logical name, null if doesn't exist. |
Behavior | getBehavior(String logicalname, String classname)
Get (first) behavior of given logical name. |
Browser | getBrowser() End of Layer chain. |
Document | getDocument() Often end of Layer chain. |
static Layer | getInstance(String logicalname, Document doc) Constructs top-most Layer of Layers in a Document. |
Layer | getInstance(String logicalname)
Constructs empty layer with given name, unless one by that name already exists, in which case that existing Layer is returned.
|
boolean | isActive() |
boolean | isEditable() For now, a layer is editable if its name is "personal". |
protected void | removeAux(ESISNode e) |
protected void | removeAux(String attrname, String attrval) |
void | removeBehavior(Behavior be) Remove behavior from Layer as soon as pending semanticEvent roundrobins completed; if none, then remove immediately. |
void | restore(ESISNode n, Map<String,Object> attr, Layer layer) |
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, String msg) Iterates over component Behaviors, lowest priority to highest. |
boolean | semanticEventBefore(SemanticEvent se, 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() |
public static final String ATTR_ACTIVE
public static final String BASE
Standard name for layer that holds media adaptor for primary document.
public static final String MSG_LOAD
Load a layer as specified in a hub document, such as genre-specific behaviors or a set of annotations.
"loadLayer": arg= java.net.URI location of hub
public static final String PERSONAL
Layer names are given by String's and usually known by convention, but some are defined, such as PERSONAL for personal annotations.
public static final String PREFIX
public static final String SCRATCH
Standard name for layer that holds behaviors that have no semantic standing in the document.
public static final 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.
public static final String SYSTEM
Layer names are given by String's and usually known by convention, but some are defined, such as PERSONAL for personal annotations.
Add ESISNode tree to aux trees, if not already there (not a multilist).
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.
Behaviors added to layer during a protocol are ignored until the protocol (both before and after phases) cpmpletes in this Layer.
public int auxSize()
Number of auxiliary trees (often 0).
Iterates over component Behaviors (Layer is a subclass of Behavior), lowest priority to highest.
Iterates over component Behaviors (Layer is a subclass of Behavior), highest priority to lowest, if layer is active.
If in multipage document, first clear current behaviors and instantiate those for new page, if any, regardless of active state.
public void buildBeforeAfter(
Document doc)
public boolean checkRep()
public void clear()
Clears everything, behaviors and aux.
public void clearBehaviors()
Removes all active behaviors from Layer, destroy()'ing in the process. Also used in Anno/Wipe.
public void destroy()
Iterates over component Behaviors (including nested Layer's), highest priority to lowest.
public void dump()
public void dump(int level)
public
Behavior findBehavior(String path)
Given a layer pathname, find nested layer.
public Color getAnnoColor()
public Font getAnnoFont()
Returns tree of aux tree data with passed tag.
public
ESISNode getAux(String attrname, String attrval)
Returns tree of aux tree data with attribute name = val. If attrval == null
, anything matches.
public
Behavior getBehavior(String logicalname)
Get behavior of given logical name, null if doesn't exist.
public
Behavior getBehavior(String logicalname, String classname)
Get (first) behavior of given logical name. If one doesn't exist, create with passed class name.
To create a behavior regardless if one by that name already existes, use
Behavior.
To get all behaviors of given logical name, iterate over the list yourself from 0 .. size()-1 with
getBehavior(int)
.
End of Layer chain.
Often end of Layer chain.
public static
Layer getInstance(String logicalname,
Document doc)
Constructs top-most Layer of Layers in a Document.
public
Layer getInstance(String logicalname)
Constructs empty layer with given name, unless one by that name already exists, in which case that existing Layer is returned.
Construction of a new layer nests within this layer.
New layer is populated from all hubs by that name in all JARs and the uer's home directory; if there are no hubs, the result is an empty layer.
See Also: getBehavior
public boolean isActive()
public boolean isEditable()
For now, a layer is editable if its name is "personal".
protected void removeAux(String attrname, String attrval)
Remove behavior from Layer as soon as pending semanticEvent roundrobins completed; if none, then remove immediately.
public void restore(
ESISNode n, Map<String,Object> attr,
Layer layer)
Override definition in Behavior to keep immediate subtrees that aren't behaviors.
Iterate over auxiliary non-behavior trees, then component Behaviors highest priority to lowest.
Trees go first as they may have information needed by behaviors to follow.
If document is multipage, as indicated by a MediaAdapator.PAGE attribute in Document, then stuff aux.
Iterates over component Behaviors, lowest priority to highest.
Iterates over component Behaviors (including nested Layer's), highest priority to lowest.
On
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.)
public void setActive(boolean active)
If a Layer is not active, all its component behaviors are still instantiated but not invoked during protocols.
Layer directly controls build and semanticEvent, and without build there should be no attachments to the document tree for format, paint, ....
Useful to disable Debugging layer, various annotation layers.
public int size()