Interface CyNetworkViewSnapshot
- All Superinterfaces:
CyDisposable
,CyIdentifiable
,CyNetworkView
,View<CyNetwork>
An immutable snapshot of a CyNetworkView
created using the
CyNetworkView.createSnapshot()
method. The snapshot represents
the state of the CyNetworkView at the moment that createSnapshot() was called.
Any subsequent updates to the mutable CyNetworkView will not be reflected
in the snapshot, making the snapshot safe to read without locks.
The intention is that a renderer can create a snapshot at the start of
rendering a frame and then safely read from the snapshot without the threat of
other threads updating the CyNetworkView while the frame is being rendered.
Creating a snapshot is intended to be relatively fast and not use a significant amount of memory. CyNetworkViewSnapshot also provides several methods for querying the state of the snapshot that are not available on mutable CyNetworkView objects.
The snapshot cannot be updated in any way. Calling any 'set' method such as
View.setVisualProperty(VisualProperty, Object)
will cause
an UnsupportedOperationException to be thrown. Also it is not possible to directly
access the underlying model objects using the getModel() method because the underlying
model objects are mutable. To acquire the mutable version of a View object use the following
example:
CyNetworkView mutableNetworkView = snapshot.getMutableNetworkView(); View<CyNode> mutableNodeView = mutableNetworkView.getNodeView(snapshotNodeView.getSUID()); if(mutableNodeView != null) { doSomethingWith(mutableNodeView); }
- Since:
- 3.8
- See Also:
CyNetworkView.createSnapshot()
,CyNetworkView#isDirty()
Cytoscape Backwards Compatibility (SPI Interface): We expect that this interface will be implemented. Therefore to maintain backwards compatibility this interface will only be modified for major version updates.
Module: viewmodel-api
To use this in your app, include the following dependency in your POM:
<dependency> <groupId>org.cytoscape</groupId> <artifactId>viewmodel-api</artifactId> </dependency>
-
Field Summary
Fields inherited from interface org.cytoscape.model.CyIdentifiable
SUID
-
Method Summary
Modifier and TypeMethodDescriptiongetAdjacentEdgeIterable(long nodeSuid)
Returns an Iterable that contains the edges that are adjacent (connected) to the given node.getAdjacentEdgeIterable(View<CyNode> node)
Returns an Iterable that contains the edges that are adjacent (connected) to the given node.int
Returns the number of edges in the network view.getEdgeInfo(View<CyEdge> edge)
Returns an object that provides more information about the given edge.getEdgeView(long suid)
Returns the immutable edge View for the given view SUID.getMutableEdgeView(long suid)
Returns the mutable edge View for the given view SUID, or null if the edge view no longer exists in the mutable network view.Returns the mutable CyNetworkView that was used to create this snapshot.getMutableNodeView(long suid)
Returns the mutable node View for the given view SUID, or null if the node view no longer exists in the mutable network view.int
Returns the number of nodes in the network view.getNodeInfo(View<CyNode> node)
Returns an object that provides more information about the given node.getNodeView(long suid)
Returns the immutable node View for the given view SUID.Returns an immutable NetworkSpacialIndex2D object that can be used to query the bounds of nodes in the network view, or null if the SpacialIndex has been turned off.int
getTrackedEdgeCount(Object key)
Returns the number of edges that are being tracked using the given key.getTrackedEdges(Object key)
Returns edges that were configured to have their VisualProperties tracked usingCyNetworkViewFactoryConfig.addTrackedVisualProperty(Object, VisualProperty, java.util.function.Predicate)
and pass the predicate.int
getTrackedNodeCount(Object key)
Returns the number of nodes that are being tracked using the given key.getTrackedNodes(Object key)
Returns nodes that were configured to have their VisualProperties tracked usingCyNetworkViewFactoryConfig.addTrackedVisualProperty(Object, VisualProperty, java.util.function.Predicate)
and pass the predicate.<T> T
getViewDefault(VisualProperty<T> vp)
Returns the default value of the VisualProperty that was set usingCyNetworkView.setViewDefault(VisualProperty, Object)
.boolean
isTrackedEdgeKey(Object key)
Returns true if edges were configured to have their VisualProperties tracked using the given key.boolean
isTrackedNodeKey(Object key)
Returns true if nodes were configured to have their VisualProperties tracked using the given key.Methods inherited from interface org.cytoscape.model.CyDisposable
dispose
Methods inherited from interface org.cytoscape.model.CyIdentifiable
getSUID
Methods inherited from interface org.cytoscape.view.model.CyNetworkView
addNetworkViewListener, createSnapshot, dirty, fitContent, fitSelected, getAllViews, getEdgeView, getEdgeViews, getEdgeViewsIterable, getNodeView, getNodeViews, getNodeViewsIterable, getRendererId, removeNetworkViewListener, setViewDefault, supportsSnapshots, updateView
Methods inherited from interface org.cytoscape.view.model.View
batch, batch, clearValueLock, clearVisualProperties, getModel, getVisualProperty, isDirectlyLocked, isSet, isValueLocked, setLockedValue, setVisualProperty
-
Method Details
-
getMutableNetworkView
CyNetworkView getMutableNetworkView()Returns the mutable CyNetworkView that was used to create this snapshot. -
getSpacialIndex2D
NetworkSpacialIndex2D getSpacialIndex2D()Returns an immutable NetworkSpacialIndex2D object that can be used to query the bounds of nodes in the network view, or null if the SpacialIndex has been turned off.- See Also:
CyNetworkViewFactoryConfig#setEnableSpacialIndex2D(boolean)
-
getNodeView
Returns the immutable node View for the given view SUID.- Parameters:
suid
- SUID of the node view- Returns:
- View for the given node object.
-
getMutableNodeView
Returns the mutable node View for the given view SUID, or null if the node view no longer exists in the mutable network view.- Parameters:
suid
- SUID of the node view- Returns:
- View for the given node object, or null
-
getEdgeView
Returns the immutable edge View for the given view SUID.- Parameters:
suid
- SUID of the edge view- Returns:
- View for the given edge object.
-
getMutableEdgeView
Returns the mutable edge View for the given view SUID, or null if the edge view no longer exists in the mutable network view.- Parameters:
suid
- SUID of the edge view- Returns:
- View for the given edge object.
-
getNodeCount
int getNodeCount()Returns the number of nodes in the network view. -
getEdgeCount
int getEdgeCount()Returns the number of edges in the network view. -
getTrackedNodes
Returns nodes that were configured to have their VisualProperties tracked usingCyNetworkViewFactoryConfig.addTrackedVisualProperty(Object, VisualProperty, java.util.function.Predicate)
and pass the predicate.
If using the default configuration then selected nodes can be retrieved like in this example:Collection<View<CyNode>> selectedNodes = netViewSnapshot.getTrackedNodes(CyNetworkViewConfig.SELECTED_NODES);
- Parameters:
key
- The same key object that was passed to CyNetworkViewConfig.addTrackedVisualProperty()
-
getTrackedNodeCount
Returns the number of nodes that are being tracked using the given key. This is the number of nodes that pass the predicate that was given toCyNetworkViewFactoryConfig.addTrackedVisualProperty(Object, VisualProperty, java.util.function.Predicate)
. -
getTrackedEdges
Returns edges that were configured to have their VisualProperties tracked usingCyNetworkViewFactoryConfig.addTrackedVisualProperty(Object, VisualProperty, java.util.function.Predicate)
and pass the predicate.
If using the default configuration then selected edges can be retrieved like in this example:Collection<View<CyEdge>> selectedEdges = netViewSnapshot.getTrackedEdges(CyNetworkViewConfig.SELECTED_EDGES);
- Parameters:
key
- The same key object that was passed to CyNetworkViewConfig.addTrackedVisualProperty()
-
getTrackedEdgeCount
Returns the number of edges that are being tracked using the given key. This is the number of edges that pass the predicate that was given toCyNetworkViewFactoryConfig.addTrackedVisualProperty(Object, VisualProperty, java.util.function.Predicate)
. -
getAdjacentEdgeIterable
Returns an Iterable that contains the edges that are adjacent (connected) to the given node. -
getAdjacentEdgeIterable
Returns an Iterable that contains the edges that are adjacent (connected) to the given node. -
getEdgeInfo
Returns an object that provides more information about the given edge. -
getNodeInfo
Returns an object that provides more information about the given node. -
getViewDefault
Returns the default value of the VisualProperty that was set usingCyNetworkView.setViewDefault(VisualProperty, Object)
. -
isTrackedNodeKey
Returns true if nodes were configured to have their VisualProperties tracked using the given key.- Parameters:
key
- The same key object that was passed to CyNetworkViewConfig.addTrackedVisualProperty()
-
isTrackedEdgeKey
Returns true if edges were configured to have their VisualProperties tracked using the given key.- Parameters:
key
- The same key object that was passed to CyNetworkViewConfig.addTrackedVisualProperty()
-