Package com.mxgraph.sharing
Class mxSharedState
- java.lang.Object
-
- com.mxgraph.util.mxEventSource
-
- com.mxgraph.sharing.mxSharedState
-
- Direct Known Subclasses:
mxSharedGraphModel
public class mxSharedState extends mxEventSource
Implements a diagram that may be shared among multiple sessions. This implementation is based only on string, it does not have a model instance. The diagram is represented by its initial state and the sequence of edits as applied to the diagram.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
mxSharedState.mxDiagramChangeListener
Defines the requirements for an object that listens to changes on the shared diagram.-
Nested classes/interfaces inherited from class com.mxgraph.util.mxEventSource
mxEventSource.mxIEventListener
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.StringBuffer
delta
Holds the history of all changes of initial state.protected java.util.List<mxSharedState.mxDiagramChangeListener>
diagramChangeListeners
Holds a list of diagram change listeners.protected java.lang.String
state
Holds the initial state of the diagram.-
Fields inherited from class com.mxgraph.util.mxEventSource
eventListeners, eventsEnabled, eventSource
-
-
Constructor Summary
Constructors Constructor Description mxSharedState(java.lang.String state)
Constructs a new diagram with the given state.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addDelta(java.lang.String xml)
void
addDiagramChangeListener(mxSharedState.mxDiagramChangeListener listener)
Adds the given listener to the list of diagram change listeners.java.lang.String
getDelta()
Returns the history of all changes as a string.java.lang.String
getState()
Returns the initial state of the diagram.void
processDelta(java.lang.Object sender, org.w3c.dom.Node delta)
Appends the given string to the history and dispatches the change to all sessions that are listening to this shared diagram.protected java.lang.String
processEdit(org.w3c.dom.Node node)
void
removeDiagramChangeListener(mxSharedState.mxDiagramChangeListener listener)
Removes the given listener from the list of diagram change listeners.void
resetDelta()
Clears the history of all changes.-
Methods inherited from class com.mxgraph.util.mxEventSource
addListener, fireEvent, fireEvent, getEventSource, isEventsEnabled, removeListener, removeListener, setEventsEnabled, setEventSource
-
-
-
-
Field Detail
-
diagramChangeListeners
protected java.util.List<mxSharedState.mxDiagramChangeListener> diagramChangeListeners
Holds a list of diagram change listeners.
-
state
protected java.lang.String state
Holds the initial state of the diagram.
-
delta
protected java.lang.StringBuffer delta
Holds the history of all changes of initial state.
-
-
Method Detail
-
getState
public java.lang.String getState()
Returns the initial state of the diagram.
-
getDelta
public java.lang.String getDelta()
Returns the history of all changes as a string.
-
processDelta
public void processDelta(java.lang.Object sender, org.w3c.dom.Node delta)
Appends the given string to the history and dispatches the change to all sessions that are listening to this shared diagram.- Parameters:
sender
- Session where the change originated from.delta
- XML that represents the change.
-
processEdit
protected java.lang.String processEdit(org.w3c.dom.Node node)
-
addDelta
public void addDelta(java.lang.String xml)
-
resetDelta
public void resetDelta()
Clears the history of all changes.
-
addDiagramChangeListener
public void addDiagramChangeListener(mxSharedState.mxDiagramChangeListener listener)
Adds the given listener to the list of diagram change listeners.- Parameters:
listener
- Diagram change listener to be added.
-
removeDiagramChangeListener
public void removeDiagramChangeListener(mxSharedState.mxDiagramChangeListener listener)
Removes the given listener from the list of diagram change listeners.- Parameters:
listener
- Diagram change listener to be removed.
-
-