Search in sources :

Example 16 with CySubNetwork

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

the class AbstractGroupTask method getGroup.

protected CyGroup getGroup(String groupName) {
    CyRootNetwork rootNet = ((CySubNetwork) net).getRootNetwork();
    Set<CyGroup> allGroups = groupMgr.getGroupSet(net);
    for (CyGroup group : allGroups) {
        CyRow groupRow = rootNet.getRow(group.getGroupNode(), CyRootNetwork.SHARED_ATTRS);
        if (groupName.length() > 5 && groupName.substring(0, 5).equalsIgnoreCase("suid:")) {
            String suidString = groupRow.get(CyNetwork.SUID, Long.class).toString();
            if (suidString != null && groupName.substring(5).equals(suidString))
                return group;
        } else if (groupName.equals(groupRow.get(CyRootNetwork.SHARED_NAME, String.class)))
            return group;
    }
    return null;
}
Also used : CyGroup(org.cytoscape.group.CyGroup) CyRow(org.cytoscape.model.CyRow) CySubNetwork(org.cytoscape.model.subnetwork.CySubNetwork) CyRootNetwork(org.cytoscape.model.subnetwork.CyRootNetwork)

Example 17 with CySubNetwork

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

the class NetworkMainPanel method getNetworkListOrder.

public Map<Long, Integer> getNetworkListOrder() {
    final Map<Long, Integer> order = new HashMap<>();
    final List<SubNetworkPanel> items = getAllSubNetworkItems();
    int count = 0;
    for (SubNetworkPanel snp : items) {
        final CySubNetwork net = snp.getModel().getNetwork();
        order.put(net.getSUID(), count++);
    }
    return order;
}
Also used : HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) WeakHashMap(java.util.WeakHashMap) Point(java.awt.Point) CySubNetwork(org.cytoscape.model.subnetwork.CySubNetwork)

Example 18 with CySubNetwork

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

the class NetworkMainPanel method getSubNetworkPanel.

SubNetworkPanel getSubNetworkPanel(final CyNetwork net) {
    if (net instanceof CySubNetwork) {
        final CySubNetwork subNet = (CySubNetwork) net;
        final CyRootNetwork rootNet = subNet.getRootNetwork();
        final RootNetworkPanel rootNetPanel = getRootNetworkPanel(rootNet);
        if (rootNetPanel != null)
            return rootNetPanel.getItem(subNet);
    }
    return null;
}
Also used : CySubNetwork(org.cytoscape.model.subnetwork.CySubNetwork) CyRootNetwork(org.cytoscape.model.subnetwork.CyRootNetwork)

Example 19 with CySubNetwork

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

the class ViewUtil method getParent.

public static CySubNetwork getParent(final CySubNetwork net, final CyServiceRegistrar serviceRegistrar) {
    final CyTable hiddenTable = net.getTable(CyNetwork.class, CyNetwork.HIDDEN_ATTRS);
    final CyRow row = hiddenTable != null ? hiddenTable.getRow(net.getSUID()) : null;
    final Long suid = row != null ? row.get(PARENT_NETWORK_COLUMN, Long.class) : null;
    if (suid != null) {
        final CyNetwork parent = serviceRegistrar.getService(CyNetworkManager.class).getNetwork(suid);
        if (parent instanceof CySubNetwork)
            return (CySubNetwork) parent;
    }
    return null;
}
Also used : CyTable(org.cytoscape.model.CyTable) CyNetworkManager(org.cytoscape.model.CyNetworkManager) CyNetwork(org.cytoscape.model.CyNetwork) CyRow(org.cytoscape.model.CyRow) CySubNetwork(org.cytoscape.model.subnetwork.CySubNetwork)

Example 20 with CySubNetwork

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

the class GraphMLReader method run.

@Override
public void run(final TaskMonitor taskMonitor) throws Exception {
    this.taskMonitor = taskMonitor;
    try {
        final SAXParserFactory spf = SAXParserFactory.newInstance();
        spf.setNamespaceAware(true);
        final SAXParser sp = spf.newSAXParser();
        final XMLReader xmlReader = sp.getXMLReader();
        CyRootNetwork root = getRootNetwork();
        final CySubNetwork newNetwork;
        if (root != null) {
            newNetwork = root.addSubNetwork();
        } else {
            // Need to create new network with new root.
            newNetwork = (CySubNetwork) cyNetworkFactory.createNetwork();
            root = newNetwork.getRootNetwork();
        }
        parser = new GraphMLParser(taskMonitor, cyNetworkFactory, cyRootNetworkManager, root, newNetwork);
        xmlReader.setContentHandler(parser);
        final InputSource inputSource = new InputSource(inputStream);
        inputSource.setEncoding("UTF-8");
        xmlReader.parse(inputSource);
    } finally {
        if (inputStream != null) {
            inputStream.close();
            inputStream = null;
        }
    }
}
Also used : InputSource(org.xml.sax.InputSource) SAXParser(javax.xml.parsers.SAXParser) XMLReader(org.xml.sax.XMLReader) CySubNetwork(org.cytoscape.model.subnetwork.CySubNetwork) SAXParserFactory(javax.xml.parsers.SAXParserFactory) 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