Search in sources :

Example 46 with CyRootNetwork

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

the class CloneNetworkTask method cloneRow.

private void cloneRow(final CyNetwork newNet, final Class<? extends CyIdentifiable> tableType, final CyRow from, final CyRow to) {
    final CyRootNetwork newRoot = rootNetMgr.getRootNetwork(newNet);
    Map<String, CyTable> rootTables = netTableMgr.getTables(newRoot, tableType);
    for (final CyColumn col : to.getTable().getColumns()) {
        final String name = col.getName();
        if (name.equals(CyIdentifiable.SUID))
            continue;
        final VirtualColumnInfo info = col.getVirtualColumnInfo();
        // then we have to set the value, because the rows of the new root table may not have been copied yet
        if (!info.isVirtual() || rootTables.containsValue(info.getSourceTable()))
            to.set(name, from.getRaw(name));
    }
}
Also used : CyTable(org.cytoscape.model.CyTable) CyColumn(org.cytoscape.model.CyColumn) VirtualColumnInfo(org.cytoscape.model.VirtualColumnInfo) CyRootNetwork(org.cytoscape.model.subnetwork.CyRootNetwork)

Example 47 with CyRootNetwork

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

the class CloneNetworkTask method cloneNetwork.

private CyNetwork cloneNetwork(final CyNetwork origNet) {
    final CyNetwork newNet = netFactory.createNetwork(origNet.getSavePolicy());
    // copy default columns
    addColumns(origNet, newNet, CyNetwork.class, CyNetwork.LOCAL_ATTRS);
    addColumns(origNet, newNet, CyNode.class, CyNetwork.LOCAL_ATTRS);
    addColumns(origNet, newNet, CyEdge.class, CyNetwork.LOCAL_ATTRS);
    final CyRootNetwork origRoot = rootNetMgr.getRootNetwork(origNet);
    final CyRootNetwork newRoot = rootNetMgr.getRootNetwork(newNet);
    addColumns(origRoot, newRoot, CyNetwork.class, CyNetwork.LOCAL_ATTRS);
    addColumns(origRoot, newRoot, CyNode.class, CyNetwork.LOCAL_ATTRS);
    addColumns(origRoot, newRoot, CyEdge.class, CyNetwork.LOCAL_ATTRS);
    cloneNodes(origNet, newNet);
    cloneEdges(origNet, newNet);
    cloneGroups(origNet, newNet);
    // Clone any network columns
    cloneNetwork(origNet, newNet);
    // Now, override the name so we don't have two networks with the same name
    newNet.getRow(newNet).set(CyNetwork.NAME, naming.getSuggestedNetworkTitle(origNet.getRow(origNet).get(CyNetwork.NAME, String.class)));
    return newNet;
}
Also used : CyNetwork(org.cytoscape.model.CyNetwork) CyRootNetwork(org.cytoscape.model.subnetwork.CyRootNetwork)

Example 48 with CyRootNetwork

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

the class AbstractGroupTask method getGroupName.

protected String getGroupName(CyGroup group) {
    CyRootNetwork rootNet = ((CySubNetwork) net).getRootNetwork();
    CyRow groupRow = rootNet.getRow(group.getGroupNode(), CyRootNetwork.SHARED_ATTRS);
    return groupRow.get(CyRootNetwork.SHARED_NAME, String.class);
}
Also used : CyRow(org.cytoscape.model.CyRow) CySubNetwork(org.cytoscape.model.subnetwork.CySubNetwork) CyRootNetwork(org.cytoscape.model.subnetwork.CyRootNetwork)

Example 49 with CyRootNetwork

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

the class ClipboardImpl method pasteEdge.

private CyEdge pasteEdge(final CyNetworkView sourceView, final CyNetworkView targetView, final CyEdge edge, final Map<CyRow, CyRow> rowMap, final Map<CyNode, CyNode> newNodeMap, final List<CyIdentifiable> pastedObjects) {
    CyNetwork sourceNetwork = sourceView.getModel();
    CyRootNetwork sourceRoot = ((CySubNetwork) sourceNetwork).getRootNetwork();
    CySubNetwork targetNetwork = (CySubNetwork) targetView.getModel();
    CyRootNetwork targetRoot = targetNetwork.getRootNetwork();
    CyEdge newEdge = null;
    CyNode sourceNode = edge.getSource();
    CyNode targetNode = edge.getTarget();
    // 3) We're copying edges to a new location in the same network
    if (sourceRoot != targetRoot) {
        if (!newNodeMap.containsKey(sourceNode)) {
            addRows(sourceNode, sourceRoot, sourceNetwork);
            final CyNode newNode = pasteNode(sourceView, targetView, sourceNode, rowMap);
            newNodeMap.put(sourceNode, newNode);
            pastedObjects.add(newNode);
        }
        if (!newNodeMap.containsKey(targetNode)) {
            addRows(targetNode, sourceRoot, sourceNetwork);
            final CyNode newNode = pasteNode(sourceView, targetView, targetNode, rowMap);
            newNodeMap.put(targetNode, newNode);
            pastedObjects.add(newNode);
        }
        // Create the edge
        newEdge = targetNetwork.addEdge(newNodeMap.get(sourceNode), newNodeMap.get(targetNode), edge.isDirected());
        // Copy the attributes over
        rowMap.put(oldSharedRowMap.get(edge), targetNetwork.getRow(newEdge, CyNetwork.DEFAULT_ATTRS));
        rowMap.put(oldLocalRowMap.get(edge), targetNetwork.getRow(newEdge, CyNetwork.LOCAL_ATTRS));
        rowMap.put(oldHiddenRowMap.get(edge), targetNetwork.getRow(newEdge, CyNetwork.HIDDEN_ATTRS));
    } else {
        // First, see if we already have the nodes
        if (!newNodeMap.containsKey(sourceNode)) {
            if (targetNetwork.containsNode(sourceNode)) {
                newNodeMap.put(sourceNode, sourceNode);
            } else {
                addRows(sourceNode, sourceRoot, sourceNetwork);
                final CyNode newNode = pasteNode(sourceView, targetView, sourceNode, rowMap);
                newNodeMap.put(sourceNode, newNode);
                pastedObjects.add(newNode);
            }
        }
        if (!newNodeMap.containsKey(targetNode)) {
            if (targetNetwork.containsNode(targetNode)) {
                newNodeMap.put(targetNode, targetNode);
            } else {
                addRows(targetNode, sourceRoot, sourceNetwork);
                final CyNode newNode = pasteNode(sourceView, targetView, targetNode, rowMap);
                newNodeMap.put(targetNode, newNode);
                pastedObjects.add(newNode);
            }
        }
        if (targetNetwork.containsEdge(edge)) {
            // We want to create another copy of the edge
            newEdge = targetNetwork.addEdge(newNodeMap.get(sourceNode), newNodeMap.get(targetNode), edge.isDirected());
        } else {
            // We just want to add the existing edge to this subnetwork
            targetNetwork.addEdge(edge);
            newEdge = edge;
        }
        // Copy the attributes over
        rowMap.put(oldLocalRowMap.get(edge), targetNetwork.getRow(newEdge, CyNetwork.LOCAL_ATTRS));
        rowMap.put(oldHiddenRowMap.get(edge), targetNetwork.getRow(newEdge, CyNetwork.HIDDEN_ATTRS));
    }
    return newEdge;
}
Also used : CyNetwork(org.cytoscape.model.CyNetwork) CyNode(org.cytoscape.model.CyNode) CyEdge(org.cytoscape.model.CyEdge) CySubNetwork(org.cytoscape.model.subnetwork.CySubNetwork) CyRootNetwork(org.cytoscape.model.subnetwork.CyRootNetwork)

Example 50 with CyRootNetwork

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

the class GroupUtil method updateMetaEdges.

private void updateMetaEdges(final CyNetwork net, final CyNode groupNode) {
    CyRootNetwork rootNetwork = ((CySubNetwork) net).getRootNetwork();
    // Find all of the edges from the group node and if they are
    // meta-edges, mark them as such
    List<CyEdge> edgeList = net.getAdjacentEdgeList(groupNode, CyEdge.Type.ANY);
    for (CyEdge edge : edgeList) {
        String interaction = net.getRow(edge).get(CyEdge.INTERACTION, String.class);
        if (interaction.startsWith("meta-")) {
            createColumn(rootNetwork.getTable(CyEdge.class, CyNetwork.HIDDEN_ATTRS), ISMETA_EDGE_ATTR, Boolean.class);
            rootNetwork.getRow(edge, CyNetwork.HIDDEN_ATTRS).set(ISMETA_EDGE_ATTR, Boolean.TRUE);
        }
    }
}
Also used : CyEdge(org.cytoscape.model.CyEdge) CySubNetwork(org.cytoscape.model.subnetwork.CySubNetwork) CyRootNetwork(org.cytoscape.model.subnetwork.CyRootNetwork)

Aggregations

CyRootNetwork (org.cytoscape.model.subnetwork.CyRootNetwork)86 CyNetwork (org.cytoscape.model.CyNetwork)39 CySubNetwork (org.cytoscape.model.subnetwork.CySubNetwork)38 CyNode (org.cytoscape.model.CyNode)29 CyEdge (org.cytoscape.model.CyEdge)15 CyRow (org.cytoscape.model.CyRow)15 CyRootNetworkManager (org.cytoscape.model.subnetwork.CyRootNetworkManager)15 Test (org.junit.Test)14 ArrayList (java.util.ArrayList)13 CyTable (org.cytoscape.model.CyTable)11 CyNetworkView (org.cytoscape.view.model.CyNetworkView)11 CyGroup (org.cytoscape.group.CyGroup)7 HashSet (java.util.HashSet)6 Dimension (java.awt.Dimension)4 IOException (java.io.IOException)4 CyNetworkManager (org.cytoscape.model.CyNetworkManager)4 Image (java.awt.Image)3 BufferedImage (java.awt.image.BufferedImage)3 CyApplicationManager (org.cytoscape.application.CyApplicationManager)3 CyEventHelper (org.cytoscape.event.CyEventHelper)3