Interface CyNetworkViewSnapshot

All Superinterfaces:
CyDisposable, CyIdentifiable, CyNetworkView, View<CyNetwork>

public interface CyNetworkViewSnapshot extends CyNetworkView

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:

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>
  • 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

      View<CyNode> getNodeView(long suid)
      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

      View<CyNode> 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.
      Parameters:
      suid - SUID of the node view
      Returns:
      View for the given node object, or null
    • getEdgeView

      View<CyEdge> getEdgeView(long suid)
      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

      View<CyEdge> 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.
      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

      Collection<View<CyNode>> getTrackedNodes(Object key)
      Returns nodes that were configured to have their VisualProperties tracked using CyNetworkViewFactoryConfig.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

      int getTrackedNodeCount(Object key)
      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 to CyNetworkViewFactoryConfig.addTrackedVisualProperty(Object, VisualProperty, java.util.function.Predicate).
    • getTrackedEdges

      Collection<View<CyEdge>> getTrackedEdges(Object key)
      Returns edges that were configured to have their VisualProperties tracked using CyNetworkViewFactoryConfig.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

      int getTrackedEdgeCount(Object key)
      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 to CyNetworkViewFactoryConfig.addTrackedVisualProperty(Object, VisualProperty, java.util.function.Predicate).
    • getAdjacentEdgeIterable

      Iterable<View<CyEdge>> getAdjacentEdgeIterable(View<CyNode> node)
      Returns an Iterable that contains the edges that are adjacent (connected) to the given node.
    • getAdjacentEdgeIterable

      Iterable<View<CyEdge>> getAdjacentEdgeIterable(long nodeSuid)
      Returns an Iterable that contains the edges that are adjacent (connected) to the given node.
    • getEdgeInfo

      SnapshotEdgeInfo getEdgeInfo(View<CyEdge> edge)
      Returns an object that provides more information about the given edge.
    • getNodeInfo

      SnapshotNodeInfo getNodeInfo(View<CyNode> node)
      Returns an object that provides more information about the given node.
    • getViewDefault

      <T> T getViewDefault(VisualProperty<T> vp)
      Returns the default value of the VisualProperty that was set using CyNetworkView.setViewDefault(VisualProperty, Object).
    • isTrackedNodeKey

      boolean isTrackedNodeKey(Object key)
      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

      boolean isTrackedEdgeKey(Object key)
      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()