Search in sources :

Example 6 with CyRootNetwork

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

the class DestroyNetworkTask method destroyNetwork.

private void destroyNetwork(final CyNetwork net, CyNetworkManager netManager) {
    CyRootNetwork rootNet = null;
    CySubNetwork parentNet = null;
    if (net instanceof CySubNetwork) {
        rootNet = ((CySubNetwork) net).getRootNetwork();
        final Long suid = DataUtils.getParentNetworkSUID((CySubNetwork) net);
        if (suid != null && netManager.getNetwork(suid) instanceof CySubNetwork)
            parentNet = (CySubNetwork) netManager.getNetwork(suid);
    }
    netManager.destroyNetwork(net);
    if (net instanceof CySubNetwork)
        updateParentNetworkData(net.getSUID(), rootNet, (parentNet != null ? parentNet.getSUID() : null));
}
Also used : CySubNetwork(org.cytoscape.model.subnetwork.CySubNetwork) CyRootNetwork(org.cytoscape.model.subnetwork.CyRootNetwork)

Example 7 with CyRootNetwork

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

the class GroupViewCollapseHandler method addMemberEdges.

private void addMemberEdges(CyGroup group, CyNetwork network) {
    CyRootNetwork rootNetwork = ((CySubNetwork) network).getRootNetwork();
    CyNode groupNode = group.getGroupNode();
    List<CyEdge> newEdges = new ArrayList<CyEdge>();
    for (CyNode node : group.getNodeList()) {
        if (!network.containsEdge(groupNode, node)) {
            CyEdge edge = network.addEdge(groupNode, node, true);
            CyRow edgeRow = network.getRow(edge);
            CyRow edgeRootRow = rootNetwork.getRow(edge, CyRootNetwork.SHARED_ATTRS);
            // Add a name
            String name = getNodeName(groupNode, network) + " (member) " + getNodeName(node, network);
            edgeRow.set(CyNetwork.NAME, name);
            edgeRootRow.set(CyRootNetwork.SHARED_NAME, name);
            // Set the interaction
            edgeRow.set(CyEdge.INTERACTION, "member");
            edgeRootRow.set(CyRootNetwork.SHARED_INTERACTION, "member");
            newEdges.add(edge);
        }
    }
    if (newEdges.size() > 0)
        group.addEdges(newEdges);
}
Also used : ArrayList(java.util.ArrayList) CyNode(org.cytoscape.model.CyNode) CyRow(org.cytoscape.model.CyRow) CyEdge(org.cytoscape.model.CyEdge) CySubNetwork(org.cytoscape.model.subnetwork.CySubNetwork) CyRootNetwork(org.cytoscape.model.subnetwork.CyRootNetwork)

Example 8 with CyRootNetwork

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

the class GroupViewCollapseHandler method handleEvent.

@Override
public void handleEvent(GroupAboutToCollapseEvent e) {
    getServices();
    CyNetwork network = e.getNetwork();
    CyGroup group = e.getSource();
    CyRootNetwork rootNetwork = group.getRootNetwork();
    final Collection<CyNetworkView> views = cyNetworkViewManager.getNetworkViews(network);
    CyNetworkView view = null;
    if (views.size() == 0)
        return;
    for (CyNetworkView v : views) {
        if (v.getRendererId().equals("org.cytoscape.ding")) {
            view = v;
        }
    }
    if (view == null)
        return;
    GroupViewType groupViewType = cyGroupSettings.getGroupViewType(group);
    if (e.collapsing()) {
        // Calculate the center position of all of the
        // member nodes
        Dimension center = ViewUtils.calculateCenter(view, group.getNodeList());
        if (center != null) {
            // Save it in the groupNode attribute
            ViewUtils.updateGroupLocation(network, group, center);
            // save it in the node's attribute
            for (CyNode node : group.getNodeList()) {
                if (!network.containsNode(node))
                    continue;
                Dimension offset = ViewUtils.calculateOffset(center, view, node);
                ViewUtils.updateNodeOffset(network, group, node, offset);
            }
        }
    } else {
        // Get the current position of the groupNode
        View<CyNode> nView = view.getNodeView(group.getGroupNode());
        if (nView == null)
            return;
        double x = nView.getVisualProperty(xLoc);
        double y = nView.getVisualProperty(yLoc);
        // Save it in the groupNode attribute
        ViewUtils.updateGroupLocation(network, group, x, y);
    }
}
Also used : CyGroup(org.cytoscape.group.CyGroup) GroupViewType(org.cytoscape.group.CyGroupSettingsManager.GroupViewType) CyNetwork(org.cytoscape.model.CyNetwork) CyNode(org.cytoscape.model.CyNode) Dimension(java.awt.Dimension) CyNetworkView(org.cytoscape.view.model.CyNetworkView) CyRootNetwork(org.cytoscape.model.subnetwork.CyRootNetwork)

Example 9 with CyRootNetwork

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

the class GroupViewDoubleClickListener method getGroupName.

String getGroupName(CyGroup group) {
    CyRootNetwork rootNetwork = group.getRootNetwork();
    String name = rootNetwork.getRow(group.getGroupNode(), CyRootNetwork.SHARED_ATTRS).get(CyRootNetwork.SHARED_NAME, String.class);
    return name;
}
Also used : CyRootNetwork(org.cytoscape.model.subnetwork.CyRootNetwork)

Example 10 with CyRootNetwork

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

the class AbstractSessionReader method cleanUp.

/**
 * Use this methods to dispose temporary resources.
 * This method must always be invoked, even if this task is cancelled.
 */
protected void cleanUp(TaskMonitor tm) {
    try {
        ((ReusableInputStream) sourceInputStream).reallyClose();
    } catch (Exception e) {
        logger.error("Error closing source input stream.", e);
    }
    if (cancelled) {
        // Destroy groups
        final Set<CyGroup> groups = groupUtil.getGroups(cache.getNetworks());
        groupUtil.destroyGroups(groups);
        // Dispose CyNetworkViews and CyNetworks
        for (final CyNetworkView view : networkViews) view.dispose();
        final CyRootNetworkManager rootNetworkManager = serviceRegistrar.getService(CyRootNetworkManager.class);
        final Set<CyRootNetwork> rootNetworks = new HashSet<>();
        // such as group networks.
        for (final CyNetwork net : cache.getNetworks()) {
            net.dispose();
            rootNetworks.add(rootNetworkManager.getRootNetwork(net));
        }
        for (final CyRootNetwork rootNet : rootNetworks) rootNet.dispose();
        networkViews.clear();
        networks.clear();
    }
    cache.dispose();
    SessionUtil.setReadingSessionFile(false);
}
Also used : CyGroup(org.cytoscape.group.CyGroup) CyRootNetworkManager(org.cytoscape.model.subnetwork.CyRootNetworkManager) CyNetwork(org.cytoscape.model.CyNetwork) CyNetworkView(org.cytoscape.view.model.CyNetworkView) IOException(java.io.IOException) CyRootNetwork(org.cytoscape.model.subnetwork.CyRootNetwork) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

Aggregations

CyRootNetwork (org.cytoscape.model.subnetwork.CyRootNetwork)83 CySubNetwork (org.cytoscape.model.subnetwork.CySubNetwork)37 CyNetwork (org.cytoscape.model.CyNetwork)36 CyNode (org.cytoscape.model.CyNode)28 CyEdge (org.cytoscape.model.CyEdge)15 CyRow (org.cytoscape.model.CyRow)15 CyRootNetworkManager (org.cytoscape.model.subnetwork.CyRootNetworkManager)15 ArrayList (java.util.ArrayList)13 Test (org.junit.Test)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