Multivalent API

multivalent.node
Class Root

java.lang.Object
  extended by multivalent.VObject
      extended by multivalent.Node
          extended by multivalent.INode
              extended by multivalent.IScrollPane
                  extended by multivalent.Document
                      extended by multivalent.node.Root
All Implemented Interfaces:
java.lang.Cloneable

public class Root
extends Document

Documents can contain other documents, and this is the topmost instance. Within the Root are subdocuments corresponding to the user interface and content. Each Root corresponds to exactly one Browser and vice-versa. All Documents have shared variables; as the topmost Document, Root holds Browser-wide variables.

Version:
$Revision: 1.7 $ $Date: 2003/02/06 05:30:24 $
See Also:
Browser

Field Summary
 
Fields inherited from class multivalent.Document
ATTR_AUTHOR, ATTR_GENRE, ATTR_LOADING, ATTR_PAGE, ATTR_PAGECOUNT, ATTR_STOP, ATTR_TITLE, ATTR_URI, MSG_BUILD, MSG_CLOSE, MSG_CURRENT, MSG_FORMATTED, MSG_OPEN, MSG_OPENED, MSG_REDIRECTED, MSG_REFORMAT, MSG_RELOAD, MSG_REPAINT, MSG_STOP, styleSheet_, uri, VAR_HEADERS
 
Fields inherited from class multivalent.IScrollPane
editable, hchars_, ibbox, MSG_SCROLL_TO, wchars_
 
Fields inherited from class multivalent.INode
border, INSETS, INSETS_ZERO, margin, padding
 
Fields inherited from class multivalent.Node
align, ALIGN_INVALID, ATTR_ID, ATTR_SCRIPT, baseline, BASELINE, bbox, BOTH, BOTTOM, CENTER, CHAR, FILL, floats, INHERIT, JUSTIFY, LEFT, MAXNONSTRUCTDEPTH, MIDDLE, name_, NONE, observers_, parent_, PROBEWIDTH, RIGHT, sticky_, stickycnt_, TOP, valid_, valign
 
Fields inherited from class multivalent.VObject
attr_
 
Constructor Summary
Root(java.util.Map<java.lang.String,java.lang.Object> attr, Browser br)
           
 
Method Summary
 boolean checkRep()
          Checks "representation invariant" (see MIT SE), and returns true iff object is valid, which should be always
 boolean formatBeforeAfter(int width, int height, Context cx)
          Takes width and height from containing Browser Window.
 Root getRoot()
          Ends chain up tree, returning self.
 void reformat(Node dirty)
          High performance reformatting of subtree.
 void repaint(long ms, int x, int y, int w, int h)
          Ends chain up tree and calls redraws in Browser/Canvas.
 
Methods inherited from class multivalent.Document
clear, eventNode, formatNode, getBrowser, getDocument, getLayer, getLayers, getMediaAdaptor, getStyleSheet, getURI, getVar, getVisualLayer, getVisualLayer, paintBeforeAfter, paintNode, putVar, removeVar, setMediaAdaptor, setParentNode, setStyleSheet
 
Methods inherited from class multivalent.IScrollPane
dump, dx, dy, getHsb, getIScrollPane, getVsb, scrollBy, scrollTo, scrollTo, setScrollbarShowPolicy, setSizeChars
 
Methods inherited from class multivalent.INode
addCategory, appendChild, breakAfter, breakBefore, childAt, childNum, clipboardNode, clone, contains, eventBeforeAfter, findDFS, getElementById, getFirstChild, getFirstLeaf, getLastChild, getLastLeaf, getNextSibling, getPreviousSibling, insertChildAt, isStruct, markDirtySubtreeDown, removeAllChildren, removeChild, removeChildAt, setChildAt, setName, size, structChildAt, structChildNum, structsize
 
Methods inherited from class multivalent.Node
addObserver, addSticky, addSticky, childNum, clipboardBeforeAfter, cmp, commonAncestor, commonAncestor, contains, deleteObserver, dump, dump, findBFS, findBFS, findBFS, findDFS, findDFS, findDFS, getAbsLocation, getActivesAt, getActivesAt, getActivesAt, getBbox, getName, getNextLeaf, getNextNode, getNodeName, getObservers, getParentNode, getPrevLeaf, getPrevNode, getRelLocation, getSticky, indexSticky, intersects, isLeaf, isValid, markDirty, markDirtySubtree, markDirtyTo, morphInto, remove, removeSticky, removeSticky, removeTidy, repaint, repaint, repaint, scrollTo, scrollTo, setValid, sizeSticky, spanChunky, spanChunky, structChildNum, toString
 
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
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Root

public Root(java.util.Map<java.lang.String,java.lang.Object> attr,
            Browser br)
Method Detail

getRoot

public Root getRoot()
Ends chain up tree, returning self.

Overrides:
getRoot in class Document

repaint

public void repaint(long ms,
                    int x,
                    int y,
                    int w,
                    int h)
Ends chain up tree and calls redraws in Browser/Canvas.

Overrides:
repaint in class Node

formatBeforeAfter

public boolean formatBeforeAfter(int width,
                                 int height,
                                 Context cx)
Takes width and height from containing Browser Window.

Overrides:
formatBeforeAfter in class Document
Parameters:
width - of screen, or fraction thereof available to be taken by node
height - of screen, or fraction thereof available to be taken by node (largely ignored in HTML, which has infinitely long scroll, except in FRAME)
See Also:
Behavior

reformat

public void reformat(Node dirty)
Description copied from class: Node
High performance reformatting of subtree. Edits to the document tree need to reformat the tree to update the display. Ordinarily this is quite efficient. The path from the change to the root is marked dirty, all changes are batch together in a format that happens at the next paint, and during reformatting nodes that are still clean are not reformatted.

However some applications, such as interactive editing and the display of status messages, need the best possible performance. If the range of changes can be bounded in some subtree, such that if the dimensions (width and height) of the subtree remain the same after reformatting, then reformatting can be speeded up. This rules out floats and HTML tables that compute cell widths based on the needs of their contents. (If the new dimensions are not the same, then fall back to the above guaranteed correct but possibly slower reformatting.)

Subclasses override this method for correctness for that node or for greater performance. An HTML table may compute cell widths based on the relative needs of cell contents, and so for correctness, in general, needs a complete reformat of the table. IParaBox can improve performance by skipping over previous words in the paragraph, and stop reformatting if the change fits on the same line.

To use, first Node.setValid(boolean) with false on node that contains all the changes, then make changes in the subtree, and then invoke this method on that node.

Overrides:
reformat in class Node

checkRep

public boolean checkRep()
Description copied from class: VObject
Checks "representation invariant" (see MIT SE), and returns true iff object is valid, which should be always.

Overrides:
checkRep in class Document

Multivalent API