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:
    CyNetworkView.createSnapshot(), CyNetworkView#isDirty()

    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>

    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.
    • Method Detail

      • getMutableNetworkView

        CyNetworkView getMutableNetworkView()
        Returns the mutable CyNetworkView that was used to create this snapshot.
      • getSpacialIndex2D

        SpacialIndex2D<Long> getSpacialIndex2D()
        Returns an immutable SpacialIndex2D 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.
      • 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.
      • 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()