Search in sources :

Example 36 with CySubNetwork

use of org.cytoscape.model.subnetwork.CySubNetwork in project cytoscape-impl by cytoscape.

the class GroupUtil method prepareGroupsForSerialization.

public void prepareGroupsForSerialization(final Collection<CyNetwork> networks) {
    if (networks == null)
        return;
    addedNodes = new HashMap<>();
    for (CyNetwork net : networks) {
        if (!(net instanceof CySubNetwork))
            continue;
        // Get all of our groups
        final CyGroupManager groupMgr = serviceRegistrar.getService(CyGroupManager.class);
        Set<CyGroup> groupSet = groupMgr.getGroupSet(net);
        // For each group, save the list of external edges
        for (CyGroup group : groupSet) {
            updateExternalEdgeAttribute(group);
            updateCollapsedGroupsAttribute(group);
            updateGroupAttribute(net, group);
        }
    }
}
Also used : CyGroup(org.cytoscape.group.CyGroup) CyNetwork(org.cytoscape.model.CyNetwork) CySubNetwork(org.cytoscape.model.subnetwork.CySubNetwork) CyGroupManager(org.cytoscape.group.CyGroupManager)

Example 37 with CySubNetwork

use of org.cytoscape.model.subnetwork.CySubNetwork in project clusterMaker2 by RBVI.

the class ClusterManagerImpl method createGroup.

public CyGroup createGroup(CyNetwork network, String name, List<CyNode> nodeList, List<CyEdge> edgeList, boolean registerGroup) {
    CyGroup group = groupFactory.createGroup(network, nodeList, edgeList, registerGroup);
    if (group != null) {
        CyRootNetwork rootNetwork = ((CySubNetwork) network).getRootNetwork();
        // The name of the group node is the name of the group
        rootNetwork.getRow(group.getGroupNode()).set(CyNetwork.NAME, name);
        rootNetwork.getRow(group.getGroupNode(), CyRootNetwork.SHARED_ATTRS).set(CyRootNetwork.SHARED_NAME, name);
    }
    return group;
}
Also used : CyGroup(org.cytoscape.group.CyGroup) CySubNetwork(org.cytoscape.model.subnetwork.CySubNetwork) CyRootNetwork(org.cytoscape.model.subnetwork.CyRootNetwork)

Example 38 with CySubNetwork

use of org.cytoscape.model.subnetwork.CySubNetwork in project clusterMaker2 by RBVI.

the class ClusterManagerImpl method unlinkNetworkSelection.

public void unlinkNetworkSelection(CyNetwork network) {
    if (!isLinked(network))
        return;
    CyRootNetwork rootNetwork = ((CySubNetwork) network).getRootNetwork();
    unregisterService(linkedNetworks.get(rootNetwork), RowsSetListener.class);
    linkedNetworks.remove(rootNetwork);
}
Also used : CySubNetwork(org.cytoscape.model.subnetwork.CySubNetwork) CyRootNetwork(org.cytoscape.model.subnetwork.CyRootNetwork)

Example 39 with CySubNetwork

use of org.cytoscape.model.subnetwork.CySubNetwork in project clusterMaker2 by RBVI.

the class ClusterManagerImpl method linkNetworkSelection.

public void linkNetworkSelection(CyNetwork network) {
    if (isLinked(network))
        return;
    CyRootNetwork rootNetwork = ((CySubNetwork) network).getRootNetwork();
    CyEventHelper helper = serviceRegistrar.getService(CyEventHelper.class);
    NetworkSelectionLinker linker = new NetworkSelectionLinker(rootNetwork, helper, this);
    registerService(linker, RowsSetListener.class, new Properties());
    linkedNetworks.put(rootNetwork, linker);
}
Also used : CyEventHelper(org.cytoscape.event.CyEventHelper) NetworkSelectionLinker(edu.ucsf.rbvi.clusterMaker2.internal.ui.NetworkSelectionLinker) Properties(java.util.Properties) CySubNetwork(org.cytoscape.model.subnetwork.CySubNetwork) CyRootNetwork(org.cytoscape.model.subnetwork.CyRootNetwork)

Example 40 with CySubNetwork

use of org.cytoscape.model.subnetwork.CySubNetwork in project clusterMaker2 by RBVI.

the class NetworkSelectionLinker method handleEvent.

public void handleEvent(RowsSetEvent e) {
    if (!e.containsColumn(CyNetwork.SELECTED) || ignoreSelection)
        return;
    // System.out.println("Select");
    CyNetworkView currentNetworkView = clusterManager.getNetworkView();
    ignoreSelection = true;
    Map<CyNetwork, Boolean> stateMap = new HashMap<CyNetwork, Boolean>();
    for (CySubNetwork subNetwork : rootNetwork.getSubNetworkList()) {
        if (e.getSource().equals(subNetwork.getTable(CyNode.class, CyNetwork.LOCAL_ATTRS))) {
            for (RowSetRecord record : e.getColumnRecords(CyNetwork.SELECTED)) {
                Long suid = record.getRow().get(CyIdentifiable.SUID, Long.class);
                Boolean value = (Boolean) record.getValue();
                for (CySubNetwork sub2 : rootNetwork.getSubNetworkList()) {
                    if (subNetwork.equals(sub2) || sub2.getDefaultNodeTable().getRow(suid) == null)
                        continue;
                    // System.out.println("Selecting row "+suid);
                    sub2.getDefaultNodeTable().getRow(suid).set(CyNetwork.SELECTED, value);
                }
            }
        }
        if (viewManager.viewExists(subNetwork)) {
            for (CyNetworkView view : viewManager.getNetworkViews(subNetwork)) {
                if (!view.equals(currentNetworkView)) {
                    view.updateView();
                }
            }
        }
    }
    eventHelper.flushPayloadEvents();
    ignoreSelection = false;
}
Also used : RowSetRecord(org.cytoscape.model.events.RowSetRecord) HashMap(java.util.HashMap) CyNetwork(org.cytoscape.model.CyNetwork) CyNode(org.cytoscape.model.CyNode) CyNetworkView(org.cytoscape.view.model.CyNetworkView) CySubNetwork(org.cytoscape.model.subnetwork.CySubNetwork)

Aggregations

CySubNetwork (org.cytoscape.model.subnetwork.CySubNetwork)88 CyNode (org.cytoscape.model.CyNode)44 CyRootNetwork (org.cytoscape.model.subnetwork.CyRootNetwork)35 CyNetwork (org.cytoscape.model.CyNetwork)31 CyEdge (org.cytoscape.model.CyEdge)28 Test (org.junit.Test)19 CyRow (org.cytoscape.model.CyRow)15 ArrayList (java.util.ArrayList)12 CyTable (org.cytoscape.model.CyTable)11 CyNetworkView (org.cytoscape.view.model.CyNetworkView)11 HashSet (java.util.HashSet)7 CyGroup (org.cytoscape.group.CyGroup)7 HashMap (java.util.HashMap)6 CyNetworkManager (org.cytoscape.model.CyNetworkManager)6 CyApplicationManager (org.cytoscape.application.CyApplicationManager)5 CyEventHelper (org.cytoscape.event.CyEventHelper)5 CyNetworkViewManager (org.cytoscape.view.model.CyNetworkViewManager)5 Dimension (java.awt.Dimension)3 GroupCollapsedEvent (org.cytoscape.group.events.GroupCollapsedEvent)3 VisualStyle (org.cytoscape.view.vizmap.VisualStyle)3