Search in sources :

Example 31 with CySubNetwork

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

the class GenericXGMMLWriter method getRowFromNetOrRoot.

protected CyRow getRowFromNetOrRoot(final CyNetwork network, final CyIdentifiable entry, String namespace) {
    CyRow row = null;
    try {
        row = namespace == null ? network.getRow(entry) : network.getRow(entry, namespace);
    } catch (final IllegalArgumentException e) {
    // Ignore this exception
    } catch (final RuntimeException e) {
        logger.error("Cannot get \"" + namespace + "\" row for entry \"" + entry + "\" in network \"" + network + "\".", e);
    }
    if (row == null && network instanceof CySubNetwork) {
        // Doesn't exist in subnetwork? Try to get it from the root network.
        final CyRootNetwork root = ((CySubNetwork) network).getRootNetwork();
        row = namespace == null ? root.getRow(entry) : root.getRow(entry, namespace);
    }
    return row;
}
Also used : CyRow(org.cytoscape.model.CyRow) CySubNetwork(org.cytoscape.model.subnetwork.CySubNetwork) CyRootNetwork(org.cytoscape.model.subnetwork.CyRootNetwork)

Example 32 with CySubNetwork

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

the class GenericXGMMLWriter method getSerializableSubNetworks.

/**
 * @param rootNet
 * @return A set with all the subnetworks that should be serialized.
 */
protected Set<CySubNetwork> getSerializableSubNetworks(final CyRootNetwork rootNet) {
    final Set<CySubNetwork> serializableSet = new LinkedHashSet<CySubNetwork>();
    final List<CySubNetwork> subNetList = rootNet.getSubNetworkList();
    final CySubNetwork baseNetwork = rootNet.getBaseNetwork();
    // The base network must be the first one!
    if (isSerializable(baseNetwork))
        serializableSet.add(baseNetwork);
    for (final CySubNetwork sn : subNetList) {
        if (isSerializable(sn))
            serializableSet.add(sn);
    }
    return serializableSet;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) CySubNetwork(org.cytoscape.model.subnetwork.CySubNetwork)

Example 33 with CySubNetwork

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

the class ReadDataManager method createNode.

protected CyNode createNode(final Object oldId, final String label, final CyNetwork net) {
    if (oldId == null)
        throw new NullPointerException("'oldId' is null.");
    CyNode node = null;
    if (net instanceof CySubNetwork && getParentNetwork() != null) {
        // Do not create the element again if the network is a sub-network!
        node = cache.getNode(oldId);
        if (node != null)
            ((CySubNetwork) net).addNode(node);
    }
    if (node == null) {
        node = this.nMap.get(label);
        if (node == null) {
            // OK, create it
            node = net.addNode();
        }
    }
    if (net instanceof CySubNetwork && getParentNetwork() != null) {
        // cache the parent node, not the node from subnetwork
        CySubNetwork subnet = (CySubNetwork) net;
        node = subnet.getRootNetwork().getNode(node.getSUID());
    }
    // Add to internal cache:
    cache.cache(oldId, node);
    cache.cacheNodeByName(label, node);
    mapSUIDs(oldId, node.getSUID());
    return node;
}
Also used : CyNode(org.cytoscape.model.CyNode) CySubNetwork(org.cytoscape.model.subnetwork.CySubNetwork)

Example 34 with CySubNetwork

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

the class GroupUtil method updateGroupNodeLocation.

private void updateGroupNodeLocation(final CyNetworkView view, final CyNode groupNode) {
    if (view == null)
        return;
    CyRootNetwork rootNetwork = ((CySubNetwork) view.getModel()).getRootNetwork();
    View<CyNode> nView = view.getNodeView(groupNode);
    double x = nView.getVisualProperty(BasicVisualLexicon.NODE_X_LOCATION);
    double y = nView.getVisualProperty(BasicVisualLexicon.NODE_Y_LOCATION);
    // Save it
    // TODO these attributes will not work with multiple views per network!
    CyRow hRow = rootNetwork.getRow(groupNode, CyNetwork.HIDDEN_ATTRS);
    createColumn(hRow.getTable(), X_LOCATION_ATTR, Double.class);
    createColumn(hRow.getTable(), Y_LOCATION_ATTR, Double.class);
    hRow.set(X_LOCATION_ATTR, new Double(x));
    hRow.set(Y_LOCATION_ATTR, new Double(y));
}
Also used : CyNode(org.cytoscape.model.CyNode) CyRow(org.cytoscape.model.CyRow) CySubNetwork(org.cytoscape.model.subnetwork.CySubNetwork) CyRootNetwork(org.cytoscape.model.subnetwork.CyRootNetwork)

Example 35 with CySubNetwork

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

the class GroupUtil method getGroupNodeEdges.

public List<CyEdge> getGroupNodeEdges(final CyNetwork network) {
    CyRootNetwork rootNetwork = ((CySubNetwork) network).getRootNetwork();
    // Don't need to worry about this for collapsed groups
    List<CyNode> groupNodes = getExpandedGroups(network);
    List<CyEdge> groupNodeEdges = new ArrayList<>();
    for (CyNode groupNode : groupNodes) {
        groupNodeEdges.addAll(rootNetwork.getAdjacentEdgeList(groupNode, CyEdge.Type.ANY));
    }
    return groupNodeEdges;
}
Also used : ArrayList(java.util.ArrayList) CyNode(org.cytoscape.model.CyNode) CyEdge(org.cytoscape.model.CyEdge) CySubNetwork(org.cytoscape.model.subnetwork.CySubNetwork) CyRootNetwork(org.cytoscape.model.subnetwork.CyRootNetwork)

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