GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing maxgraph.github.io — GraphDataModel | @maxgraph/core
Class GraphDataModelExtends EventSource to implement a graph model. The graph model acts as a wrapper around the cells which are in charge of storing the actual graph data structure. The model acts as a transactional wrapper with event notification for all changes, whereas the cells contain the atomic operations for updating the actual data structure. LayersThe cell hierarchy in the model must have a top-level root cell which contains the layers (typically one default layer), which in turn contain the top-level cells of the layers. This means each cell is contained in a layer. If no layers are required, then all new cells should be added to the default layer. Layers are useful for hiding and showing groups of cells, or for placing groups of cells on top of other cells in the display. To identify a layer, the isLayer function is used. It returns true if the parent of the given cell is the root of the model. EventsSee events section for more details. There is a new set of events for tracking transactional changes as they happen. The events are called startEdit for the initial beginUpdate, executed for each executed change and endEdit for the terminal endUpdate. The executed event contains a property called change which represents the change after execution. Encoding the modelTo encode a graph model, use the following code:
This will create an XML node that contains all the model information. Encoding and decoding changes:For the encoding of changes, a graph model listener is required that encodes each change from the given array of changes.
For the decoding and execution of changes, the codec needs a lookup function that allows it to resolve cell IDs as follows:
For each encoded change (represented by a node), the following code can be used to carry out the decoding and create a change object.
The changes can then be dispatched using the model as follows.
Event: InternalEvent.CHANGE Fires when an undoable edit is dispatched. The ExampleFor finding newly inserted cells, the following code can be used:
Event: InternalEvent.NOTIFY Same as Event#CHANGE, this event can be used for classes that need to implement a sync mechanism between this model and, say, a remote model. In such a setup, only local changes should trigger a notify event and all changes should trigger a change event. Event: InternalEvent.EXECUTE Fires between begin- and endUpdate and after an atomic change was executed
in the model. The Event: InternalEvent.EXECUTED Fires between START_EDIT and END_EDIT after an atomic change was executed.
The Event: InternalEvent.BEGIN_UPDATE Fires after the updateLevel was incremented in beginUpdate. This event contains no properties. Event: InternalEvent.START_EDIT Fires after the updateLevel was changed from 0 to 1. This event contains no properties. Event: InternalEvent.END_UPDATE Fires after the updateLevel was decreased in endUpdate but before any
notification or change dispatching. The Event: InternalEvent.END_EDIT Fires after the updateLevel was changed from 1 to 0. This event contains no properties. Event: InternalEvent.BEFORE_UNDO Fires before the change is dispatched after the update level has reached 0
in endUpdate. The Event: InternalEvent.UNDO Fires after the change was dispatched in endUpdate. The GraphDataModel Hierarchy (View Summary)
|
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |