Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Multivalent API
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## multivalent
Class Document

    java.lang.Object
      multivalent.VObject
          multivalent.Node
              multivalent.INode
                  multivalent.IScrollPane
                      multivalent.Document

All Implemented Interfaces:
  java.lang.Cloneable

Direct Known Subclasses:
  Root

public class Document
extends IScrollPane

An independent document, generally with content subtree, stylesheet, `URI` (not `URL`), `Layer`s of behaviors that implementing genre- or document-specific functionality, and document-wide variables. Documents can contain other documents, as for a HTML FRAMESET. The topmost containing document is the `Root`, of which there is exactly one in a `Browser`.

`Document`s contain:

- `link` to document-specific behaviors
- state: `URI`, `stylesheet`, `global variables` in addition to attributes, primary `media adaptor`

Version:
  $Revision: 1.8 $ $Date: 2003/06/02 05:04:14 $

Field Summary
`static java.lang.String` | `ATTR_AUTHOR` Metadata: document author.
`static java.lang.String` | `ATTR_GENRE` Document genre, such as "HTML" or "ManualPage".
`static java.lang.String` | `ATTR_LOADING` Non-null while loading is in progress.
`static java.lang.String` | `ATTR_PAGE` Attribute in `Document` giving current page number in a multipage document.
`static java.lang.String` | `ATTR_PAGECOUNT` Attribute in `Document` giving number of pages in a multipage document.
`static java.lang.String` | `ATTR_STOP` Non-null if loading has been aborted.
`static java.lang.String` | `ATTR_TITLE` Metadata: document title.
`static java.lang.String` | `ATTR_URI` Document URI.
`static java.lang.String` | `MSG_BUILD` Request build of document, which comes after successful `open`.
`static java.lang.String` | `MSG_CLOSE` Close current document, stopping loading if necessary, saving annotations and so on.
`static java.lang.String` | `MSG_CURRENT` Announce document has taken the active one, taking the focus.
`static java.lang.String` | `MSG_FORMATTED` Announce document has been formatted, which means all geometric posisions are valid.
`static java.lang.String` | `MSG_OPEN` Open new document; if this is the a different point in the current document, a shortcut may bypass "openedDocument"
`static java.lang.String` | `MSG_OPENED` Announce opening of document has finished, before it has been formatted (completely -- there may be incremental displays)
`static java.lang.String` | `MSG_REDIRECTED` Announce a redirection has taken place.
`static java.lang.String` | `MSG_REFORMAT` Request reformat of "current" document.
`static java.lang.String` | `MSG_RELOAD` Create new browser window.
`static java.lang.String` | `MSG_REPAINT` Request repaint of "current" document, which will invoke reformat if document layout is dirty.
`static java.lang.String` | `MSG_STOP` Stop loading of current document.
`protected StyleSheet` | `styleSheet_`
`java.net.URI` | `uri` ???
`static java.lang.String` | `VAR_HEADERS` Key to `Map` of HTTP headers (perhaps simulated if loading from file system).

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
`Document(java.lang.String name, java.util.Map<java.lang.String,java.lang.Object> attr, INode parent)`
`Document(java.lang.String name, java.util.Map<java.lang.String,java.lang.Object> attr, INode parent, Browser br)`

Method Summary
`boolean` | `checkRep()` Checks "representation invariant" (see MIT SE), and returns true iff object is valid, which should be always
`void` | `clear()` Clean up state (globals, children, ...), `Behavior.destroy()` genre and document-specific behaviors, and recursively close sub-`Document`s.
`boolean` | `eventNode(java.awt.AWTEvent e, java.awt.Point rel)` On mouse click, set this document to the current one.
`boolean` | `formatBeforeAfter(int width, int height, Context cx)` `Document`s have own StyleSheet and associated Context.
`boolean` | `formatNode(int width, int height, Context cx)` If length of dimension set in characters or to dynamic (these mutually cancel each other out--last one set wins), use that to set corresponding bounding box dimension.
`Browser` | `getBrowser()` Chains up parent links.
`Document` | `getDocument()` End `Node`'s chain up tree by returning this.
`Layer` | `getLayer(java.lang.String name)` Convenience method for `getLayers()` plus `Layer.getInstance(String)`.
`Layer` | `getLayers()` Returns the topmost layer, which holds useful layers (system, genre, annotations, ...).
`MediaAdaptor` | `getMediaAdaptor()` Returns (primary) media adaptor that created document tree.
`Root` | `getRoot()` Chains up parent links.
`StyleSheet` | `getStyleSheet()`
`java.net.URI` | `getURI()`
`java.lang.Object` | `getVar(java.lang.Object key)`
`INode` | `getVisualLayer(java.lang.String name)` Deprecated. visual layers not special
`INode` | `getVisualLayer(java.lang.String name, java.lang.String classname)`
`void` | `paintBeforeAfter(java.awt.Rectangle docclip, Context cx)` Substitutes own `StyleSheet` and associated `Context` in place of one in prevailing `Context`.
`void` | `paintNode(java.awt.Rectangle docclip, Context cx)` Paints contents in scrolled, clipped `Graphics2D`.
`void` | `putVar(java.lang.Object key, java.lang.Object val)`
`void` | `removeVar(java.lang.Object key)`
`void` | `setMediaAdaptor(MediaAdaptor me)`
`void` | `setParentNode(INode p)` Used by IScrollPane to point scrollbars at it without it pointing at scrollbar.
`void` | `setStyleSheet(StyleSheet ss)`

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, reformat, remove, removeSticky, removeSticky, removeTidy, repaint, 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`

Field Detail

### MSG_OPEN

    public static final java.lang.String MSG_OPEN

  Open new document; if this is the a different point in the current document, a shortcut may bypass "openedDocument".

  `"openDocument"`: `arg=` `HashMap` null - same as reload
  `"openDocument"`: `arg=` `String` URI to open - translated into...
  `"openDocument"`: `arg=` `URL` URI to open - translated into...
  `"openDocument"`: `arg=` `URI` URI to open - translated into..., replacing the current document
  `"openDocument"`: `arg=` `DocInfo` URI, document to replace, and other details - final form of all "openDocument"'s

  See Also:
    Constant Field Values

### MSG_OPENED

    public static final java.lang.String MSG_OPENED

  Announce opening of document has finished, before it has been formatted (completely -- there may be incremental displays).

  `"openedDocument"`: `arg=` `DocInfo` data of document just opened

  See Also:
    Constant Field Values

### MSG_BUILD

    public static final java.lang.String MSG_BUILD

  Request build of document, which comes after successful `open`.

  `"buildDocument"`: `arg=` `Document` instance

  See Also:
    Constant Field Values

### MSG_CLOSE

    public static final java.lang.String MSG_CLOSE

  Close current document, stopping loading if necessary, saving annotations and so on. Document data structures can then be safely destroyed.

  `"closeDocument"`: `arg=` `HashMap` attributes, `in=` `INode` root of tree, `out=`unused.

  See Also:
    Constant Field Values

### MSG_RELOAD

    public static final java.lang.String MSG_RELOAD

  Create new browser window.

  `"reloadDocument"`: `arg=` `Node` replace this document, or current document if null.

  See Also:
    Constant Field Values

### MSG_REDIRECTED

    public static final java.lang.String MSG_REDIRECTED

  Announce a redirection has taken place.

  `"redirectedDocument"`: `arg=` URI of new address, as in `MSG_OPEN`

  See Also:
    Constant Field Values

### MSG_STOP

    public static final java.lang.String MSG_STOP

  Stop loading of current document.

  `"stopDocument"`: `arg=` `HashMap` attributes, `in=` `INode` root of tree, `out=`unused.

  See Also:
    Constant Field Values

### MSG_FORMATTED

    public static final java.lang.String MSG_FORMATTED

  Announce document has been formatted, which means all geometric posisions are valid.

  `"formattedDocument"`: `arg=` `Document` instance.

  See Also:
    Constant Field Values

### MSG_REFORMAT

    public static final java.lang.String MSG_REFORMAT

  Request reformat of "current" document.

  `"reloadDocument"`: `arg=` `URI` location of hub

  See Also:
    Constant Field Values

### MSG_REPAINT

    public static final java.lang.String MSG_REPAINT

  Request repaint of "current" document, which will invoke reformat if document layout is dirty.

  `"repaintDocument"`: `arg=` `URI` location of hub

  See Also:
    Constant Field Values

### MSG_CURRENT

    public static final java.lang.String MSG_CURRENT

  Announce document has taken the active one, taking the focus.

  `"currentDocument"`: `arg=` `Document` instance.

  See Also:
    `Browser.setCurDocument(Document)`, Constant Field Values

### VAR_HEADERS

    public static final java.lang.String VAR_HEADERS

  Key to `Map` of HTTP headers (perhaps simulated if loading from file system).

  See Also:
    Constant Field Values

### ATTR_PAGE

    public static final java.lang.String ATTR_PAGE

  Attribute in `Document` giving current page number in a multipage document. Pages are logically numbered starting from 1 to total-pages inclusive, regardless of "printed" page numbers. Media adaptors translate between this and their internal numbering scheme.

  See Also:
    Constant Field Values

### ATTR_PAGECOUNT

    public static final java.lang.String ATTR_PAGECOUNT

  Attribute in `Document` giving number of pages in a multipage document. This is set by the media adaptor, if intrinsic to the document (as in DVI, PDF), or otherwise must be set in a hub.

  See Also:
    Constant Field Values

### ATTR_AUTHOR

    public static final java.lang.String ATTR_AUTHOR

  Metadata: document author.

  See Also:
    Constant Field Values

### ATTR_TITLE

    public static final java.lang.String ATTR_TITLE

  Metadata: document title.

  See Also:
    Constant Field Values

### ATTR_URI

    public static final java.lang.String ATTR_URI

  Document URI.

  See Also:
    Constant Field Values

### ATTR_GENRE

    public static final java.lang.String ATTR_GENRE

  Document genre, such as "HTML" or "ManualPage".

  See Also:
    Constant Field Values

### ATTR_LOADING

    public static final java.lang.String ATTR_LOADING

  Non-null while loading is in progress.

  See Also:
    Constant Field Values

### ATTR_STOP

    public static final java.lang.String ATTR_STOP

  Non-null if loading has been aborted. Document is left in a partially loaded state. Behaviors that depend on a well-formed document should abort.

  See Also:
    Constant Field Values

### uri

    public java.net.URI uri

  ??? Actual URI of content, after redirects and whatever else, as opposed to logical URI which is an attribute. ??? Used when saving, and as base for relative URIs.

### styleSheet_

    protected StyleSheet styleSheet_

Constructor Detail

### Document

    public Document(java.lang.String name,
                    java.util.Map<java.lang.String,java.lang.Object> attr,
                    INode parent)

### Document

    public Document(java.lang.String name,
                    java.util.Map<java.lang.String,java.lang.Object> attr,
                    INode parent,
                    Browser br)

Method Detail

### clear

    public void clear()

  Clean up state (globals, children, ...), `Behavior.destroy()` genre and document-specific behaviors, and recursively close sub-`Document`s. Whatever saving needs to be done should have already taken place.

### setParentNode

    public void setParentNode(INode p)

  Description copied from class: `Node`
  Used by IScrollPane to point scrollbars at it without it pointing at scrollbar. Not for general use.

  Overrides:
    `setParentNode` in class `Node`

### getLayers

    public Layer getLayers()

  Returns the topmost layer, which holds useful layers (system, genre, annotations, ...).

### getBrowser

    public Browser getBrowser()

  Description copied from class: `Node`
  Chains up parent links. @return null if none.

  Overrides:
    `getBrowser` in class `Node`

### getRoot

    public Root getRoot()

  Description copied from class: `Node`
  Chains up parent links. @return null if none.

  Overrides:
    `getRoot` in class `Node`

### getURI

    public java.net.URI getURI()

### getDocument

    public Document getDocument()

  End `Node`'s chain up tree by returning this.

  Overrides:
    `getDocument` in class `Node`

### getLayer

    public Layer getLayer(java.lang.String name)

  Convenience method for `getLayers()` plus `Layer.getInstance(String)`.

### getStyleSheet

    public StyleSheet getStyleSheet()

### setStyleSheet

    public void setStyleSheet(StyleSheet ss)

### getMediaAdaptor

    public MediaAdaptor getMediaAdaptor()

  Returns (primary) media adaptor that created document tree.

### setMediaAdaptor

    public void setMediaAdaptor(MediaAdaptor me)

### getVar

    public final java.lang.Object getVar(java.lang.Object key)

### putVar

    public final void putVar(java.lang.Object key,
                             java.lang.Object val)

### removeVar

    public final void removeVar(java.lang.Object key)

### formatBeforeAfter

    public boolean formatBeforeAfter(int width,
                                     int height,
                                     Context cx)

  `Document`s have own StyleSheet and associated Context.

  Overrides:
    `formatBeforeAfter` in class `INode`
  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`

### formatNode

    public boolean formatNode(int width,
                              int height,
                              Context cx)

  Description copied from class: `IScrollPane`
  If length of dimension set in characters or to dynamic (these mutually cancel each other out--last one set wins), use that to set corresponding bounding box dimension. Else maintain length, which should have been set externally beforehand. Sends `IScrollPane.MSG_FORMATTED`.

  Overrides:
    `formatNode` in class `IScrollPane`
  See Also:
    `FixedI`

### paintBeforeAfter

    public void paintBeforeAfter(java.awt.Rectangle docclip,
                                 Context cx)

  Substitutes own `StyleSheet` and associated `Context` in place of one in prevailing `Context`.

  Overrides:
    `paintBeforeAfter` in class `IScrollPane`

### paintNode

    public void paintNode(java.awt.Rectangle docclip,
                          Context cx)

  Description copied from class: `IScrollPane`
  Paints contents in scrolled, clipped `Graphics2D`.

  Overrides:
    `paintNode` in class `IScrollPane`

### eventNode

    public boolean eventNode(java.awt.AWTEvent e,
                             java.awt.Point rel)

  On mouse click, set this document to the current one. Have to do this before behaviors that would rely on document being set so right behaviors get called, which means can't do it in BindingsDefault because that would be too late, and can't do in BindingsDefault.eventBefore() because don't know right document.

  Overrides:
    `eventNode` in class `IScrollPane`
  See Also:
    `TreeEvent`, `SemanticEvent`

### getVisualLayer

    public INode getVisualLayer(java.lang.String name)

  Deprecated. visual layers not special

  Returns visual layer of passed name, creating if necessary. Maybe move this to IScrollPane.

### getVisualLayer

    public INode getVisualLayer(java.lang.String name,
                                java.lang.String classname)

### 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 `IScrollPane`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Multivalent API
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD