|
Search this API | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objecty.view.ModelViewManager
public class ModelViewManager
Utility class that performs automatic synchronization of graph element insertion and removal between a distinguished graph (the model) and one or more satellite graphs (the views).
Additionally, ModelViewManager supports filtered views
of its model by associating an appropriate implementation of
ModelViewManager.Filter to a view. Filtering provides a
convenient way to create views whose element sets are disjoint from the
element set of the manager's model (where element set means the
nodes and edges in a graph).
Note: Synchronization is triggered by special
GraphListener implementations; using the various hide/unhide
methods provided by Graph to manipulate either model or views
will therefore prevent the manager from working properly.
![]() |
![]() |
![]() |
![]() |
| Nested Class Summary | |
|---|---|
static interface |
ModelViewManager.Filter
Specifies the contract of graph element filters for views handled by ModelViewManager instances. |
| Method Summary | |
|---|---|
void |
addViewGraph(Graph view,
ModelViewManager.Filter filter,
boolean updateModelOnStructuralChange)
Adds the specified Graph to the list of views handled by this
manager. |
void |
addViewGraph(Graph view,
ModelViewManager.Filter filter,
boolean updateModelOnStructuralChange,
boolean updateViewOnStructuralChange)
Adds the specified Graph to the list of views handled by this
manager. |
void |
bindModelToView(Edge model,
Edge view)
Binds the specified model edge to the specified view edge. |
void |
bindModelToView(Node model,
Node view)
Binds the specified model node to the specified view node. |
Edge |
createModelEdge(Node src,
Node tgt,
boolean updateViewGraphs)
Creates a new edge in this manager's model graph connecting the specified nodes. |
Node |
createModelNode(boolean updateViewGraphs)
Creates a new node in this manager's model graph. |
Edge |
createViewEdge(Node src,
Node tgt,
boolean updateModel)
Creates a new edge connecting the specified nodes. |
Graph |
createViewGraph(GraphCopier.CopyFactory factory,
ModelViewManager.Filter filter,
boolean updateModelOnStructuralChange)
Creates a new view for the model of this manager. |
Graph |
createViewGraph(GraphCopier.CopyFactory factory,
ModelViewManager.Filter filter,
boolean updateModelOnStructuralChange,
boolean updateViewOnStructuralChange)
Creates a new view for the model of this manager. |
Node |
createViewNode(Graph view,
boolean updateModel)
Creates a new node in the specified Graph. |
void |
dispose()
Disposes this ModelViewManager. |
GraphCopier.CopyFactory |
getCopyFactory(Graph viewGraph)
Returns the GraphCopier.CopyFactory that is currently used to
create graph elements in the specified view graph, or null if
the default copy factory is used. |
GraphCopier.CopyFactory |
getDefaultCopyFactory()
Returns the default CopyFactory used by this manager. |
ModelViewManager.Filter |
getFilter(Graph viewGraph)
Returns the Filter that is currently associated to the
specified graph, or null if no filtering is applied to the
contents of the specified graph. |
static ModelViewManager |
getInstance(Graph graph)
Returns a ModelViewManager instance for the specified graph. |
Graph |
getModel()
Returns the model graph used by this manager. |
Edge |
getModelEdge(Edge viewEdge)
Returns the edge in the model managed by this ModelViewManager
that corresponds to viewEdge or null if no such
edge exists. |
Node |
getModelNode(Node viewNode)
Returns the node in the model managed by this ModelViewManager
that corresponds to viewNode or null if there is
no such node. |
Edge |
getViewEdge(Edge model,
Graph viewGraph)
Returns the edge in viewGraph corresponding to edge
model or null if no such edge exists in
viewGraph (due to filtering). |
Node |
getViewNode(Node model,
Graph viewGraph)
Returns the node in viewGraph corresponding to node
model or null if there is no such node in
viewGraph (due to filtering). |
static boolean |
hasInstance(Graph graph)
Returns true if the specified graph has an associated
ModelViewManager and is that manager's model graph;
false otherwise. |
boolean |
isInnerGraphBindingAllowed()
Determines whether it is possible to bind model and view of inner/ancestor graphs. |
boolean |
isUpdateModelOnStructuralChangeEnabled(Graph viewGraph)
Returns true, iff structural changes in the specified view
graph are automatically propagated to the model graph; false
otherwise. |
boolean |
isUpdateViewOnStructuralChangeEnabled(Graph viewGraph)
Returns true, iff structural changes in the model graph
are automatically propagated to the specified view graph;
false otherwise. |
boolean |
isUpdateViewsOnStructuralChangeEnabled()
Returns true, iff structural changes in the model graph
are automatically propagated to interested view graphs; false
otherwise. |
boolean |
isViewGraph(Graph view)
Returns true if the specified Graph has been
registered as a view for this manager's model; false
otherwise. |
void |
removeModelEdge(Edge edge,
boolean updateViewGraphs)
Removes the specified edge from this manager's model graph. |
void |
removeModelNode(Node node,
boolean updateViewGraphs)
Removes the specified node from this manager's model graph. |
void |
removeViewEdge(Edge edge,
boolean updateModel)
Removes the specified edge from its associated graph. |
void |
removeViewGraph(Graph view)
Removes the specified Graph from the list of views handled
by this manager. |
void |
removeViewNode(Node node,
boolean updateModel)
Removes the specified node from its associated graph. |
void |
setCopyFactory(Graph viewGraph,
GraphCopier.CopyFactory factory)
Specifies the GraphCopier.CopyFactory that is used to create
any graph elements in the specified view graph. |
void |
setDefaultCopyFactory(GraphCopier.CopyFactory factory)
Specifies the default CopyFactory used by this manager. |
void |
setFilter(Graph viewGraph,
ModelViewManager.Filter filter)
Specifies the Filter that should be applied when elements in
viewGraph are created by this manager. |
void |
setInnerGraphBindingAllowed(boolean innerGraphBindingAllowed)
Determines whether it is possible to bind model and view of inner/ancestor graphs. |
void |
setUpdateModelOnStructuralChangeEnabled(Graph viewGraph,
boolean enabled)
Specifies whether structural changes in the specified view graph should be automatically propagated to the model graph (and from there to all other view graphs, as usual). |
void |
setUpdateViewOnStructuralChangeEnabled(Graph viewGraph,
boolean enabled)
Specifies whether structural changes in the model graph should be automatically propagated to the specified view graph. |
void |
setUpdateViewsOnStructuralChangeEnabled(boolean enabled)
Specifies whether structural changes in the model graph should be automatically propagated to interested view graphs. |
void |
synchronizeModelToViewGraph(Graph viewGraph)
Updates the specified graph to include all model elements accepted by the filter associated to it exclusively. |
void |
synchronizeModelToViewGraph(NodeCursor modelNodes,
EdgeCursor modelEdges,
Graph viewGraph)
Updates the specified graph to include the specified model elements that are accepted by its associated filter. |
void |
synchronizeModelToViewGraphs()
Updates all view graphs handled by this manager to include all model elements accepted by their associated filters exclusively. |
void |
synchronizeViewGraphToModel(Graph viewGraph)
Updates the model graph of this manager to include all elements currently contained in the specified graph exclusively. |
java.util.Iterator |
viewEdges(Edge model)
Returns a read-only Iterator for all the view edges
corresponding to edge model. |
java.util.Iterator |
viewGraphs()
Returns a read-only Iterator for the views handled by this
manager. |
java.util.Iterator |
viewNodes(Node model)
Returns a read-only Iterator for all the view nodes
corresponding to node model. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public Graph getModel()
public Graph createViewGraph(GraphCopier.CopyFactory factory,
ModelViewManager.Filter filter,
boolean updateModelOnStructuralChange)
createViewGraph(factory, filter, updateModelOnStructuralChange, true);
factory - a GraphCopier.CopyFactory that is used to create the
new view and any graph elements in it. If null, the
default copy factory is used.filter - a Filter that determines which model elements are to
be included in the created view.
If null, all model elements are included.updateModelOnStructuralChange - determines whether structural changes in the created view are to be
automatically synchronized to the model.
public Graph createViewGraph(GraphCopier.CopyFactory factory,
ModelViewManager.Filter filter,
boolean updateModelOnStructuralChange,
boolean updateViewOnStructuralChange)
factory - a GraphCopier.CopyFactory that is used to create the
new view and any graph elements in it. If null, the
default copy factory is used.filter - a Filter that determines which model elements are to
be included in the created view.
If null, all model elements are included.updateModelOnStructuralChange - determines whether structural changes in the created view are to be
automatically synchronized to the model.updateViewOnStructuralChange - determines whether structural changes in the model are to be
automatically synchronized to the created view.
public void addViewGraph(Graph view,
ModelViewManager.Filter filter,
boolean updateModelOnStructuralChange)
Graph to the list of views handled by this
manager.
Invoking this method is equivalent to:
addViewGraph(view, filter, updateModelOnStructuralChange, true);
The CopyFactory currently set
on the specified Graph is used for all subsequent view
element creation operations.
The view is added as is, i.e. existing view elements are not removed,
neither are existing model elements added.
Use methods bindModelToView(y.base.Node, y.base.Node) and
bindModelToView(y.base.Edge, y.base.Edge) to bind existing
model elements to existing view elements.
Use method synchronizeModelToViewGraph(y.base.Graph) to clear
and recreate the view complete with appropriate model-to-view bindings.
view - a Graph to be registered as a view for this manager's
model.filter - a Filter that determines which model elements are to
be included in the created view.
If null, all model elements are included.updateModelOnStructuralChange - determines whether structural changes in the added view are to be
automatically synchronized to the model.
java.lang.IllegalArgumentException - if view is null
or if view has already been registered as a view in the
context of a ModelViewManager.
public void addViewGraph(Graph view,
ModelViewManager.Filter filter,
boolean updateModelOnStructuralChange,
boolean updateViewOnStructuralChange)
Graph to the list of views handled by this
manager.
The CopyFactory currently set
on the specified Graph is used for all subsequent view
element creation operations.
The view is added as is, i.e. existing view elements are not removed,
neither are existing model elements added.
Use methods bindModelToView(y.base.Node, y.base.Node) and
bindModelToView(y.base.Edge, y.base.Edge) to bind existing
model elements to existing view elements.
Use method synchronizeModelToViewGraph(y.base.Graph) to clear
and recreate the view complete with appropriate model-to-view bindings.
view - a Graph to be registered as a view for this manager's
model.filter - a Filter that determines which model elements are to
be included in the created view.
If null, all model elements are included.updateModelOnStructuralChange - determines whether structural changes in the added view are to be
automatically synchronized to the model.updateViewOnStructuralChange - determines whether structural changes in the model are to be
automatically synchronized to the added view.
java.lang.IllegalArgumentException - if view is null
or if view has already been registered as a view in the
context of a ModelViewManager.public void removeViewGraph(Graph view)
Graph from the list of views handled
by this manager. All model-to-view binding information concerning the
specified Graph is deleted, too.
view - the Graph to be deregistered as a view for this
manager's model.public java.util.Iterator viewGraphs()
Iterator for the views handled by this
manager.
Iterator for the views handled by this
manager.public boolean isViewGraph(Graph view)
true if the specified Graph has been
registered as a view for this manager's model; false
otherwise.
view - the Graph to check.
true if the specified Graph has been
registered as a view for this manager's model; false
otherwise.public java.util.Iterator viewEdges(Edge model)
Iterator for all the view edges
corresponding to edge model.
Note, the iterators created with this method are not fail-fast as one is used to from the Java™ Collections Framework, because there is no reliable way to check for concurrent modifications of the view graphs that actually hold the view edges.
model - an Edge in the model of this
ModelViewManager.
Iterator for all the view edges
corresponding to edge model.public java.util.Iterator viewNodes(Node model)
Iterator for all the view nodes
corresponding to node model.
Note, the iterators created with this method are not fail-fast as one is used to from the Java™ Collections Framework, because there is no reliable way to check for concurrent modifications of the view graphs that actually hold the view nodes.
model - a Node in the model of this
ModelViewManager.
Iterator for all the view nodes
corresponding to edge model.public GraphCopier.CopyFactory getDefaultCopyFactory()
CopyFactory used by this manager.
- Returns:
- the default
CopyFactory used by this manager.
public void setDefaultCopyFactory(GraphCopier.CopyFactory factory)
CopyFactory used by this manager.
- Parameters:
factory - the default CopyFactory used by this manager.
public Edge getViewEdge(Edge model,
Graph viewGraph)
viewGraph corresponding to edge
model or null if no such edge exists in
viewGraph (due to filtering).
model - an Edge in the model of this
ModelViewManager.viewGraph - a Graph from the list of views handled by this
ModelViewManager.
viewGraph corresponding to edge
viewGraph (due to filtering).
model or null if no such edge exists in
java.lang.IllegalArgumentException - if viewGraph is not one of
the views handled by this ModelViewManager.public Edge getModelEdge(Edge viewEdge)
ModelViewManager
that corresponds to viewEdge or null if no such
edge exists.
viewEdge - an Edge in a view that is handled by this
ModelViewManager
ModelViewManager
that corresponds to viewEdge or null if there is
no such edge.
java.lang.IllegalArgumentException - if viewEdge does not belong
to a graph at all or if said graph is not one of the views handled by this
ModelViewManager.
public Node getViewNode(Node model,
Graph viewGraph)
viewGraph corresponding to node
model or null if there is no such node in
viewGraph (due to filtering).
model - a Node in the model of this
ModelViewManagerviewGraph - a Graph from the list of views handled by this
ModelViewManager.
viewGraph corresponding to node
model or null if there is no such node in
viewGraph (due to filtering).
java.lang.IllegalArgumentException - if viewGraph is not one of
the views handled by this ModelViewManager.public Node getModelNode(Node viewNode)
ModelViewManager
that corresponds to viewNode or null if there is
no such node.
viewNode - a Node in a view that is handled by this
ModelViewManager
ModelViewManager
that corresponds to viewNode or null if there is
no such node.
java.lang.IllegalArgumentException - if viewNode does not belong
to a graph at all or if said graph is not one of the views handled by this
ModelViewManager.public Node createModelNode(boolean updateViewGraphs)
updateViewGraphs - determines whether or not the creation of the new node should be
propagated to the views associated to the model graph.
public Edge createModelEdge(Node src,
Node tgt,
boolean updateViewGraphs)
src - the source node of the new edge.tgt - the target node of the new edge.updateViewGraphs - determines whether or not the creation of the new edge should be
propagated to the views associated to the model graph.
java.lang.IllegalArgumentException - if either src or
tgt is null.
public Node createViewNode(Graph view,
boolean updateModel)
Graph.
view - a Graph from the list of views handled by this
ModelViewManager in which the new node is to be
created.updateModel - determines whether or not the creation of the new node should be
propagated to the model graph.
java.lang.IllegalArgumentException - is view is null
or if view is not one of the views handled by this
ModelViewManager.
public Edge createViewEdge(Node src,
Node tgt,
boolean updateModel)
src - the source node of the new edge.tgt - the target node of the new edge.updateModel - determines whether or not the creation of the new edge should be
propagated to the model graph.
java.lang.IllegalArgumentException - if either src or
tgt is null or src does not belong
to one of the views handled by this ModelViewManager.
public void removeModelEdge(Edge edge,
boolean updateViewGraphs)
edge - the Edge to be removed.updateViewGraphs - determines whether or not the removal of the edge should be
propagated to the views associated to the model graph.
public void removeModelNode(Node node,
boolean updateViewGraphs)
node - the Node to be removed.updateViewGraphs - determines whether or not the removal of the node should be
propagated to the views associated to the model graph.
public void removeViewEdge(Edge edge,
boolean updateModel)
edge - the Edge to be removed.updateModel - determines whether or not the removal of the edge should be
propagated to the model graph.
java.lang.IllegalArgumentException - if edge does not belong
to one of the views handled by this ModelViewManager.
public void removeViewNode(Node node,
boolean updateModel)
node - the Node to be removed.updateModel - determines whether or not the removal of the node should be
propagated to the model graph.
java.lang.IllegalArgumentException - if node does not belong
to one of the views handled by this ModelViewManager.
public void bindModelToView(Node model,
Node view)
model has been bound to view a call to
getModelNode(view) will
return model and a call to
getViewNode(model, view.getGraph())
will return view
model - the model node.view - the view node.
java.lang.IllegalArgumentException - if model does not belong
to this ModelViewManager's model graph or if view
does not belong to one of the views handled by this
ModelViewManager.
public void bindModelToView(Edge model,
Edge view)
model has been bound to view a call to
getModelEdge(view) will
return model and a call to
getViewEdge(model, view.getGraph())
will return view
model - the model edge.view - the view edge.
java.lang.IllegalArgumentException - if model does not belong
to this ModelViewManager's model graph or if view
does not belong to one of the views handled by this
ModelViewManager.public void synchronizeModelToViewGraphs()
public void synchronizeModelToViewGraph(Graph viewGraph)
viewGraph,
representatives of these elements are created in viewGraph.
Moreover, all elements in viewGraph for which no model
representatives exist are removed from viewGraph.
viewGraph - a Graph from the list of views handled by this
ModelViewManager that is to be updated.
java.lang.IllegalArgumentException - if viewGraph is not one
of the views handled by this ModelViewManager.
public void synchronizeModelToViewGraph(NodeCursor modelNodes,
EdgeCursor modelEdges,
Graph viewGraph)
modelNodes - the model nodes for which to create representatives in the
specified graph.modelEdges - the model edges for which to create representatives in the
specified graph.viewGraph - a Graph from the list of views handled by this
ModelViewManager that is to be updated.
java.lang.IllegalArgumentException - if viewGraph is not one
of the views handled by this ModelViewManager.public void synchronizeViewGraphToModel(Graph viewGraph)
viewGraph for which no
model-to-view bindings exist, representatives of these elements are
created in the model. Moreover, all elements in the model for which no
representatives exist in viewGraph are removed from the model.
Note: Structural changes in the model due to the synchronization process triggered by this method will be propagated to all other views as usual.
viewGraph - a Graph from the list of views handled by this
ModelViewManager whose structure is to be replicated
in the model graph.
java.lang.IllegalArgumentException - if viewGraph is not one
of the views handled by this ModelViewManager.public boolean isUpdateModelOnStructuralChangeEnabled(Graph viewGraph)
true, iff structural changes in the specified view
graph are automatically propagated to the model graph; false
otherwise.
viewGraph - a Graph from the list of views handled by this
ModelViewManager.
true, iff structural changes in the specified view
graph are automatically propagated to the model graph; false
otherwise.
java.lang.IllegalArgumentException - if viewGraph is not one
of the views handled by this ModelViewManager.
public void setUpdateModelOnStructuralChangeEnabled(Graph viewGraph,
boolean enabled)
viewGraph - a Graph from the list of views handled by this
ModelViewManager.enabled - if true, structural changes are automatically
propagated from the specified view graph to the model graph.
java.lang.IllegalArgumentException - if viewGraph is not one
of the views handled by this ModelViewManager.public boolean isUpdateViewOnStructuralChangeEnabled(Graph viewGraph)
true, iff structural changes in the model graph
are automatically propagated to the specified view graph;
false otherwise.
viewGraph - a Graph from the list of views handled by this
ModelViewManager.
true, iff structural changes in the model graph
are automatically propagated to the specified view graph;
false otherwise.
java.lang.IllegalArgumentException - if viewGraph is not one
of the views handled by this ModelViewManager.
public void setUpdateViewOnStructuralChangeEnabled(Graph viewGraph,
boolean enabled)
viewGraph - a Graph from the list of views handled by this
ModelViewManager.enabled - if true, structural changes are automatically
propagated from the model graph to the specified view graph.
java.lang.IllegalArgumentException - if viewGraph is not one
of the views handled by this ModelViewManager.public boolean isUpdateViewsOnStructuralChangeEnabled()
true, iff structural changes in the model graph
are automatically propagated to interested view graphs; false
otherwise. A view graph is considered interested in automatic updates
if isUpdateViewOnStructuralChangeEnabled returns
true for said graph.
true, iff structural changes in the model graph
are automatically propagated to interested view graphs; false
otherwise.public void setUpdateViewsOnStructuralChangeEnabled(boolean enabled)
isUpdateViewOnStructuralChangeEnabled returns
true for said graph.
enabled - if true, structural changes are automatically
propagated from the model graph to interested view graphs.public ModelViewManager.Filter getFilter(Graph viewGraph)
Filter that is currently associated to the
specified graph, or null if no filtering is applied to the
contents of the specified graph.
viewGraph - a Graph from the list of views handled by this
ModelViewManager.
Filter that is currently associated to the
specified graph, or null if no filtering is applied to the
contents of the specified graph.
java.lang.IllegalArgumentException - if viewGraph is not one
of the views handled by this ModelViewManager.
public void setFilter(Graph viewGraph,
ModelViewManager.Filter filter)
Filter that should be applied when elements in
viewGraph are created by this manager.
Note: Setting a new filter has no effect on the current contents of the specified graph, but only on possible future element creations.
viewGraph - a Graph from the list of views handled by this
ModelViewManager.filter - the Filter that determines whether or not model
elements should be included in the specified view.
May be null, indicating that no filtering should occur
for the specified graph (i.e. all model elements are included).
java.lang.IllegalArgumentException - if viewGraph is not one
of the views handled by this ModelViewManager.public GraphCopier.CopyFactory getCopyFactory(Graph viewGraph)
GraphCopier.CopyFactory that is currently used to
create graph elements in the specified view graph, or null if
the default copy factory is used.
viewGraph - a Graph from the list of views handled by this
ModelViewManager.
GraphCopier.CopyFactory that is currently used to
create graph elements in the specified view graph, or null if
the default copy factory is used.
java.lang.IllegalArgumentException - if viewGraph is not one
of the views handled by this ModelViewManager.
public void setCopyFactory(Graph viewGraph,
GraphCopier.CopyFactory factory)
GraphCopier.CopyFactory that is used to create
any graph elements in the specified view graph.
viewGraph - a Graph from the list of views handled by this
ModelViewManager.factory - a GraphCopier.CopyFactory that is used to create any
graph elements in the specified view graph. If null,
the default copy factory is used.
java.lang.IllegalArgumentException - if viewGraph is not one
of the views handled by this ModelViewManager.public void dispose()
ModelViewManager. All model-to-view bindings
stored by this manager are removed.
public static ModelViewManager getInstance(Graph graph)
ModelViewManager instance for the specified graph.
The specified graph will serve as the manager's model graph for all
future purposes.
graph - the Graph that should serve as the returned
ModelViewManager's model. May not be null.
ModelViewManager instance for the specified graph.
java.lang.IllegalArgumentException - if graph is null.public static boolean hasInstance(Graph graph)
true if the specified graph has an associated
ModelViewManager and is that manager's model graph;
false otherwise.
graph - the Graph that is checked for an associated
ModelViewManager.
true if the specified graph has an associated
ModelViewManager and is that manager's model graph;
false otherwise.public boolean isInnerGraphBindingAllowed()
true if inner graph binding is set, false otherwisesetInnerGraphBindingAllowed(boolean)public void setInnerGraphBindingAllowed(boolean innerGraphBindingAllowed)
innerGraphBindingAllowed - determines if inner binding are createdisInnerGraphBindingAllowed()
|
© Copyright 2000-2025, yWorks GmbH. All rights reserved. |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||