public interface IFoldingView extends ILookup
managed view
of an IGraph
that supports folding operations like expanding
and collapsing
of nodes.
The FoldingManager
creates views of a MasterGraph
which is created using
copies of the original "master" entities. The views are being synchronized via the
MasterGraph
, but may contain additional
view state
. Typically nodes and edges are being copied from the MasterGraph
and they share many of their properties by reference (e.g. Style
). However if group nodes are
being represented by collapsed
group nodes in this view, they maintain a separate set of
labels
, ports
, bends
, and geometry
. This
view-local state is shared between all views that have been created
by the same Manager
and can be obtained and modified via the FoldingManager
's GetFoldingEdgeState
methods for folding edges
and folder nodes
in the absence of a corresponding IFoldingView
view instance. Developers typically don't need to implement this
interface themselves, rather an implementation is provided by the framework and can be obtained from the
FoldingManager
. Use FoldingManager.createFoldingView(INode, java.util.function.Predicate)
to obtain
an IGraph
implementation that contains an implementation of this class in its ILookup.lookup(java.lang.Class)
method:
This interface supports the PropertyChanged
event. This can be used
to easily monitor the validity
of this view. Also changes to the LocalRoot
property will be published via this event.
A brief description of the interface's API and some usage aspects is given in the section
Working with Folding. Class
FoldingManager
's central role for folding support in general is discussed in the section
Folding Revisited.
FoldingManager
Modifier and Type | Method and Description |
---|---|
void |
addGroupCollapsedListener(IEventHandler<ItemEventArgs<INode>> groupCollapsedEvent)
Adds the given listener for the
GroupCollapsed event that occurs whenever a group has been
collapse(INode) d. |
void |
addGroupExpandedListener(IEventHandler<ItemEventArgs<INode>> groupExpandedEvent)
Adds the given listener for the
GroupExpanded event that occurs whenever a group has been
expand(INode) ed. |
void |
addPropertyChangedListener(IEventHandler<PropertyChangedEventArgs> propertyChangedEvent)
Adds the given listener for the
PropertyChanged event that occurs whenever the view becomes invalid or the LocalRoot
property changes. |
void |
collapse(INode groupNode)
This method will collapse the
children of a group node into the group node. |
default INode |
createFolderNode()
Directly creates a collapsed node on this instance with the given parameters.
|
default INode |
createFolderNode(INode parent)
Directly creates a collapsed node on this instance with the given parameters.
|
default INode |
createFolderNode(INode parent,
RectD layout)
Directly creates a collapsed node on this instance with the given parameters.
|
default INode |
createFolderNode(INode parent,
RectD layout,
INodeStyle style)
Directly creates a collapsed node on this instance with the given parameters.
|
INode |
createFolderNode(INode parent,
RectD layout,
INodeStyle style,
Object tag)
Directly creates a collapsed node on this instance with the given parameters.
|
void |
dispose()
Disposes of this view explicitly.
|
void |
expand(INode groupNode)
This method will expand a previously
collapsed group node to make its contents appear in this
view. |
IGraph |
getGraph()
Provides a reference to the
IGraph implementation that provides the actual view data. |
INode |
getLocalRoot()
Gets an entity of the
MasterGraph hierarchy to serve as the virtual root for the
view's local hierarchy. |
FoldingManager |
getManager()
Provides access to the manager that created this view and that contains a reference to the
MasterGraph . |
IEnumerable<IEdge> |
getMasterEdges(IEdge foldingEdge)
Helper method that corresponds to the
getMasterItem(IModelItem) method, but is used for folding edges, only. |
<T extends IModelItem> |
getMasterItem(T item)
Helper method that can be used to retrieve the original "master" items in the
MasterGraph
that is managed by the Manager associated with this view. |
<T extends IModelItem> |
getViewItem(T item)
Helper method that can be used to retrieve the items in this
Graph -view for all items that are part
of the MasterGraph that is associated with the Manager of
this instance. |
boolean |
isAutoSwitchingToAncestorEnabled()
|
boolean |
isExpanded(INode groupNode)
Determines whether the provided node is currently expanded or will be displayed in
expand(INode) ed state the next time it will be included in this view. |
boolean |
isInFoldingState(IModelItem item)
Determines whether the specified item is a folding state in this view.
|
boolean |
isInvalid()
Determines if this view is currently valid and can be edited.
|
boolean |
isNavigationalUndoUnitsEnqueuingEnabled()
Determines whether changes to the
LocalRoot property and calls to collapse(INode) and expand(INode)
should be recorded in undo history. |
void |
removeGroupCollapsedListener(IEventHandler<ItemEventArgs<INode>> groupCollapsedEvent)
Removes the given listener for the
GroupCollapsed event that occurs whenever a group has been
collapse(INode) d. |
void |
removeGroupExpandedListener(IEventHandler<ItemEventArgs<INode>> groupExpandedEvent)
Removes the given listener for the
GroupExpanded event that occurs whenever a group has been
expand(INode) ed. |
void |
removePropertyChangedListener(IEventHandler<PropertyChangedEventArgs> propertyChangedEvent)
Removes the given listener for the
PropertyChanged event that occurs whenever the view becomes invalid or the LocalRoot
property changes. |
void |
setAutoSwitchingToAncestorEnabled(boolean value)
|
void |
setLocalRoot(INode value)
Sets an entity of the
MasterGraph hierarchy to serve as the virtual root for the
view's local hierarchy. |
void |
setNavigationalUndoUnitsEnqueuingEnabled(boolean value)
Determines whether changes to the
LocalRoot property and calls to collapse(INode) and expand(INode)
should be recorded in undo history. |
createDictionaryLookup, createDynamic, createSingle, createSingle, createWrapped, lookup, lookup, lookup, safeLookup
void addGroupCollapsedListener(IEventHandler<ItemEventArgs<INode>> groupCollapsedEvent)
GroupCollapsed
event that occurs whenever a group has been
collapse(INode)
d.groupCollapsedEvent
- The listener to add.removeGroupCollapsedListener(IEventHandler)
void addGroupExpandedListener(IEventHandler<ItemEventArgs<INode>> groupExpandedEvent)
GroupExpanded
event that occurs whenever a group has been
expand(INode)
ed.groupExpandedEvent
- The listener to add.removeGroupExpandedListener(IEventHandler)
void addPropertyChangedListener(IEventHandler<PropertyChangedEventArgs> propertyChangedEvent)
PropertyChanged
event that occurs whenever the view becomes invalid or the LocalRoot
property changes.propertyChangedEvent
- The listener to add.removePropertyChangedListener(IEventHandler)
void collapse(INode groupNode)
children
of a group node into the group node.
If a group
node that belongs to this view's hierarchy is in expanded
state, calling this method will remove the children
from this
view
. This method will do nothing if the node is already collapsed. Note that collapsing a group
node will make it a non-group
node in the hierarchy. The collapsed group node has its
own separate set of attributes, which can be obtained using the FoldingManager.getFolderNodeState(INode)
method.
Therefore it may appear that the node changes its location during a collapse operation. This behavior ensures that
collapsing a node does not modify the state of the model (only the state in the view is changed), but depending on the
application this may confuse the user because he might loose his mental map of the diagram. In order to customize the
behavior custom code can register with the GroupCollapsed
event to
perform the necessary modifications, like adjusting the view port or moving the node to the desired location.
In addition to that this method can also be used for master
nodes which are
currently not represented in this view. In this case these nodes will be displayed as collapsed the next time they will
be included in this view.
groupNode
- A group node that is part of the Graph
or the master graph
.isExpanded(INode)
default INode createFolderNode()
This will implicitly create a new empty group node on the MasterGraph
with the
defaults for such a group node. The parent
must be part of the Folded Graph View
or null
to create a folder at the root of the current hierarchy. It will be converted into a group node if necessary. The
returned INode
is also part of the Folded Graph View
.
Graph
default INode createFolderNode(INode parent)
This will implicitly create a new empty group node on the MasterGraph
with the
defaults for such a group node. The parent
must be part of the Folded Graph View
or null
to create a folder at the root of the current hierarchy. It will be converted into a group node if necessary. The
returned INode
is also part of the Folded Graph View
.
default INode createFolderNode(INode parent, RectD layout)
This will implicitly create a new empty group node on the MasterGraph
with the
defaults for such a group node. The parent
must be part of the Folded Graph View
or null
to create a folder at the root of the current hierarchy. It will be converted into a group node if necessary. The
returned INode
is also part of the Folded Graph View
.
default INode createFolderNode(INode parent, RectD layout, INodeStyle style)
This will implicitly create a new empty group node on the MasterGraph
with the
defaults for such a group node. The parent
must be part of the Folded Graph View
or null
to create a folder at the root of the current hierarchy. It will be converted into a group node if necessary. The
returned INode
is also part of the Folded Graph View
.
INode createFolderNode(INode parent, RectD layout, INodeStyle style, Object tag)
This will implicitly create a new empty group node on the MasterGraph
with the
defaults for such a group node. The parent
must be part of the Folded Graph View
or null
to create a folder at the root of the current hierarchy. It will be converted into a group node if necessary. The
returned INode
is also part of the Folded Graph View
.
void dispose()
Normally it is not necessary to do so, because the view will be garbage collected automatically. However if the view
still displays contents, this might have unwanted negative side effects (group node sizes being calculated, etc.) A
disposed of instance is not synchronized with the FoldingManager
anymore and should not be used anymore.
void expand(INode groupNode)
collapsed
group node to make its contents appear in this
view.
If a node that belongs to this view is in collapsed
state, calling this method will make the children
appear in this view
. This method will do nothing if the node is already expanded. Note that
expanding a collapsed group node will make the node a group node
, whereas a collapsed
group node is no group node in this hierarchy and thus cannot have visible children. The expanded group node has its own
separate set of attributes, which may be different from the collapsed state that can be obtained using the FoldingManager.getFolderNodeState(INode)
method. The expanded state is always the same as the state of the master node
.
Because of these differences it may appear that the node changes its location during an expand operation. This behavior
ensures that expanding a node does not modify the state of the model by moving the node or its descendants (only the
state in the view is changed), but depending on the application this may confuse the user because he might loose his
mental map of the diagram. In order to customize the behavior custom code can register with the GroupExpanded
event to perform the necessary modifications, like adjusting the view port or moving the node and its descendants to the
desired location.
In addition to that this method can also be used for master
nodes which are
currently not represented in this view. In this case these nodes will be displayed as expanded the next time they will
be included in this view.
groupNode
- A group node that is part of the Graph
or the master graph
.isExpanded(INode)
,
collapse(INode)
IGraph getGraph()
IGraph
implementation that provides the actual view data.
The instance has an implementation of this interface in its ILookup
that has been obtained from the
FoldingManager
's FoldingManager.createFoldingView(INode, java.util.function.Predicate)
set of
methods. The instance holds the elements in the view only, which in general is a subset of the
MasterGraph
. Also note that the elements are not the same references as
their masters
, they are copies that may share the same attributes.
INode getLocalRoot()
MasterGraph
hierarchy to serve as the virtual root for the
view's local hierarchy.
This property can be set to any group
node in the
MasterGraph
's hierarchy whose contents will then be represented in this
view. Note that the root of the view's local hierarchy is not set to the same instance.
setLocalRoot(INode)
FoldingManager getManager()
MasterGraph
.IEnumerable<IEdge> getMasterEdges(IEdge foldingEdge)
getMasterItem(IModelItem)
method, but is used for folding edges, only.
Since folding edges can represent more than one master edge, this method can be used to query all of the master edges that the provided folding edge represents. If the folding edge corresponds to a single master edge, the result will enumerate that edge, only.
foldingEdge
- The folding edge for which the master edges should be returned.MasterGraph
that are
being represented by the folding edge in this view
.IFoldingEdgeFactory.addToExistingFoldingEdge(IEdge)
,
getViewItem(IModelItem)
<T extends IModelItem> T getMasterItem(T item)
MasterGraph
that is managed by the Manager
associated with this view.
Since the Graph
view that is associated with this instance maintains a copy of the entities in the
Manager
's MasterGraph
, there is a mapping between
elements that belong to this view's Graph
and the elements in the master graph. This method can be
called for the elements contained in this IGraph
and will return the corresponding item in the master graph that
the element corresponds to, if any. Note that for some items in the Graph
, there is no master item
in the MasterGraph
, e.g. the IPort
instances to
which folding edges
connect have no corresponding ports in the master
graph. The same holds true for the bends
and labels
of folding edges and folder nodes. For folding edges, this method will yield the main representing edge in the master,
if the folding edge represents more than one master edge. For nodes, the master node will be returned, no matter whether
the node is currently collapsed
or not.
T
- The type of the argument, which is typically INode
, IEdge
, ILabel
,
IBend
, or IPort
.item
- The item that is part of this Graph
for which the original "master" item in the MasterGraph
will be returned.MasterGraph
that corresponds to the item
or
null
, if there is no such item.getViewItem(IModelItem)
<T extends IModelItem> T getViewItem(T item)
Graph
-view for all items that are part
of the MasterGraph
that is associated with the Manager
of
this instance.
Since the Graph
view that is associated with this instance maintains a copy of the entities in the
Manager
's MasterGraph
, there is a mapping between
elements that belong to master graph and the elements in the Graph
of this view. This method can be
called for the elements contained in this master graph's
items and will return
the corresponding item in this view's Graph
if the element is represented by an item in this view.
Note that for some items in the MasterGraph
, there may be no item in the Graph
instance, e.g. those elements which are part of a collapsed
subtree in the MasterGraph
hierarchy or those items that do not belong to the subtree that is induced by the LocalRoot
of
this view. Also, for nodes and edges that are being represented by dummies in this view, labels, ports, and bends are
not being represented directly by corresponding entities in this graph. If more than one edge is represented by a
folding edge in this view, this method will yield the same folding edge instance for each of them.
T
- The type of the argument, which is typically INode
, IEdge
, ILabel
,
IBend
, or IPort
.item
- An item that is part of the MasterGraph
that is associated with the Manager
of this instance.local graph view
that corresponds to the item
or
null
, if the item is not currently being represented in this view.getMasterItem(IModelItem)
,
getMasterEdges(IEdge)
boolean isAutoSwitchingToAncestorEnabled()
LocalRoot
to an ancestor of the
current root, if this view becomes Invalid
.
By default this property is set to true
which assures that this view will never become
Invalid
. It is the responsibility of the client code to check for the validity of this view
before trying to modify it if this feature is disabled.
setAutoSwitchingToAncestorEnabled(boolean)
boolean isExpanded(INode groupNode)
expand(INode)
ed state the next time it will be included in this view.
Expanded group nodes will have all of their children
visible in this
view
.
The groupNode
can be either a node of the view
or the
master graph
. If the node is from the master graph and is currently not
represented in this view, this method will return the
expand(INode)
ed state it will have the next time it will be included in this view.
boolean isInFoldingState(IModelItem item)
This method can be used to determine if an INode
, IEdge
, IPort
,
ILabel
, or IBend
has a view local state
and is not a direct copy of the master item
, if any. Note that collapsed
group nodes are in folding state, even though they do have a master
item in the
master graph and folding edges always have at least one
master edge
, while all other folding items don't have a corresponding master item in
the master graph.
item
- One of the items that are contained
in the Graph
.MasterGraph
.boolean isInvalid()
A view is invalid if the LocalRoot
is not currently part of the MasterGraph
hierarchy. This can happen if the root node is removed from the
MasterGraph
. Note that the view can become valid again if the removal is
undone.
isAutoSwitchingToAncestorEnabled()
boolean isNavigationalUndoUnitsEnqueuingEnabled()
LocalRoot
property and calls to collapse(INode)
and expand(INode)
should be recorded in undo history.
By default this property is set to false
, however depending on the use case it may make sense to enqueue
IUndoUnit
s for this type of operations.
isAutoSwitchingToAncestorEnabled()
,
setNavigationalUndoUnitsEnqueuingEnabled(boolean)
void removeGroupCollapsedListener(IEventHandler<ItemEventArgs<INode>> groupCollapsedEvent)
GroupCollapsed
event that occurs whenever a group has been
collapse(INode)
d.groupCollapsedEvent
- The listener to remove.addGroupCollapsedListener(IEventHandler)
void removeGroupExpandedListener(IEventHandler<ItemEventArgs<INode>> groupExpandedEvent)
GroupExpanded
event that occurs whenever a group has been
expand(INode)
ed.groupExpandedEvent
- The listener to remove.addGroupExpandedListener(IEventHandler)
void removePropertyChangedListener(IEventHandler<PropertyChangedEventArgs> propertyChangedEvent)
PropertyChanged
event that occurs whenever the view becomes invalid or the LocalRoot
property changes.propertyChangedEvent
- The listener to remove.addPropertyChangedListener(IEventHandler)
void setAutoSwitchingToAncestorEnabled(boolean value)
LocalRoot
to an ancestor of the
current root, if this view becomes Invalid
.
By default this property is set to true
which assures that this view will never become
Invalid
. It is the responsibility of the client code to check for the validity of this view
before trying to modify it if this feature is disabled.
value
- The AutoSwitchingToAncestorEnabled to set.isAutoSwitchingToAncestorEnabled()
void setLocalRoot(INode value)
MasterGraph
hierarchy to serve as the virtual root for the
view's local hierarchy.
This property can be set to any group
node in the
MasterGraph
's hierarchy whose contents will then be represented in this
view. Note that the root of the view's local hierarchy is not set to the same instance.
value
- The LocalRoot to set.getLocalRoot()
void setNavigationalUndoUnitsEnqueuingEnabled(boolean value)
LocalRoot
property and calls to collapse(INode)
and expand(INode)
should be recorded in undo history.
By default this property is set to false
, however depending on the use case it may make sense to enqueue
IUndoUnit
s for this type of operations.
value
- The NavigationalUndoUnitsEnqueuingEnabled to set.isAutoSwitchingToAncestorEnabled()
,
isNavigationalUndoUnitsEnqueuingEnabled()