Search in sources :

Example 51 with CyTable

use of org.cytoscape.model.CyTable in project cytoscape-impl by cytoscape.

the class CySubNetworkImpl method removeNodes.

@Override
public boolean removeNodes(final Collection<CyNode> nodes) {
    if (nodes == null || nodes.isEmpty())
        return false;
    eventHelper.fireEvent(new AboutToRemoveNodesEvent(this, nodes));
    CyTable nodeHiddenTable = getTable(CyNode.class, CyNetwork.HIDDEN_ATTRS);
    CyTable nodeDefaultTable = getTable(CyNode.class, CyNetwork.DEFAULT_ATTRS);
    CyTable edgeHiddenTable = getTable(CyEdge.class, CyNetwork.HIDDEN_ATTRS);
    CyTable edgeDefaultTable = getTable(CyEdge.class, CyNetwork.DEFAULT_ATTRS);
    List<Long> nodeSuids = new ArrayList<>();
    Set<Long> edgeSuids = new HashSet<>();
    for (CyNode node : nodes) {
        if (this.containsNode(node)) {
            Long nodeSuid = node.getSUID();
            if (nodeDefaultTable.rowExists(nodeSuid))
                nodeSuids.add(nodeSuid);
            for (CyEdge edge : getAdjacentEdgeIterable(node, Type.ANY)) {
                Long edgeSuid = edge.getSUID();
                if (edgeDefaultTable.rowExists(edgeSuid)) {
                    edgeSuids.add(edgeSuid);
                }
            }
        }
    }
    boolean ret = removeNodesInternal(nodes);
    nodeHiddenTable.deleteRows(nodeSuids);
    nodeDefaultTable.deleteRows(nodeSuids);
    edgeHiddenTable.deleteRows(edgeSuids);
    edgeDefaultTable.deleteRows(edgeSuids);
    if (ret) {
        parent.subnetworkNodesRemoved(nodes);
    }
    if (ret) {
        eventHelper.fireEvent(new RemovedNodesEvent(this));
    }
    return ret;
}
Also used : CyTable(org.cytoscape.model.CyTable) ArrayList(java.util.ArrayList) CyNode(org.cytoscape.model.CyNode) RemovedNodesEvent(org.cytoscape.model.events.RemovedNodesEvent) CyEdge(org.cytoscape.model.CyEdge) AboutToRemoveNodesEvent(org.cytoscape.model.events.AboutToRemoveNodesEvent) HashSet(java.util.HashSet)

Example 52 with CyTable

use of org.cytoscape.model.CyTable in project cytoscape-impl by cytoscape.

the class CyTableManagerImpl method getLocalTables.

@Override
public Set<CyTable> getLocalTables(final Class<? extends CyIdentifiable> type) {
    final Set<CyTable> localTables = new HashSet<CyTable>();
    final Set<CyNetwork> networks = networkManager.getNetworkSet();
    for (final CyNetwork network : networks) {
        final Map<String, CyTable> objTables = networkTableManager.getTables(network, type);
        if (network instanceof CySubNetwork) {
            final CyTable shared = networkTableManager.getTable(((CySubNetwork) network).getRootNetwork(), type, CyRootNetwork.SHARED_ATTRS);
            localTables.add(shared);
        }
        localTables.addAll(objTables.values());
    }
    return localTables;
}
Also used : CyTable(org.cytoscape.model.CyTable) CyNetwork(org.cytoscape.model.CyNetwork) CySubNetwork(org.cytoscape.model.subnetwork.CySubNetwork) HashSet(java.util.HashSet)

Example 53 with CyTable

use of org.cytoscape.model.CyTable in project cytoscape-impl by cytoscape.

the class CyTableManagerImpl method getGlobalTables.

@Override
public Set<CyTable> getGlobalTables() {
    final Set<CyTable> nonGlobalTables = new HashSet<CyTable>();
    final Set<CyTable> globalTables = new HashSet<CyTable>();
    final Set<CyNetwork> networks = networkTableManager.getNetworkSet();
    for (final CyNetwork network : networks) {
        for (final Class<? extends CyIdentifiable> type : COMPATIBLE_TYPES) {
            final Map<String, CyTable> objTables = networkTableManager.getTables(network, type);
            nonGlobalTables.addAll(objTables.values());
        }
    }
    for (final CyTable table : tables.values()) if (nonGlobalTables.contains(table) == false)
        globalTables.add(table);
    return globalTables;
}
Also used : CyTable(org.cytoscape.model.CyTable) CyNetwork(org.cytoscape.model.CyNetwork) HashSet(java.util.HashSet)

Example 54 with CyTable

use of org.cytoscape.model.CyTable in project cytoscape-impl by cytoscape.

the class CyTableManagerImpl method refreshTableEquations.

private void refreshTableEquations() {
    final EquationCompiler compiler = serviceRegistrar.getService(EquationCompiler.class);
    Set<CyTable> tables = getAllTables(true);
    for (CyTable table : tables) {
        EquationUtil.refreshEquations(table, compiler);
    }
}
Also used : CyTable(org.cytoscape.model.CyTable) EquationCompiler(org.cytoscape.equations.EquationCompiler)

Example 55 with CyTable

use of org.cytoscape.model.CyTable in project cytoscape-impl by cytoscape.

the class DefaultTablesNetwork method getRow.

public CyRow getRow(final CyIdentifiable entry, final String tableName) {
    if (entry == null)
        throw new NullPointerException("null entry");
    if (tableName == null)
        throw new NullPointerException("null table name");
    CyTable table;
    // The table returned should be immutable.
    if (entry instanceof CyNode && containsNode((CyNode) entry))
        table = networkTableManager.getTable(networkRef.get(), CyNode.class, tableName);
    else if (entry instanceof CyEdge && containsEdge((CyEdge) entry))
        table = networkTableManager.getTable(networkRef.get(), CyEdge.class, tableName);
    else if (entry instanceof CyNetwork && entry.equals(this)) {
        if (networkRef == null)
            throw new IllegalArgumentException("Network reference is null.  This should not be null.");
        final CyNetwork n = networkRef.get();
        table = networkTableManager.getTable(n, CyNetwork.class, tableName);
    } else
        throw new IllegalArgumentException("unrecognized (table entry): " + entry.toString() + "  (table name): " + tableName);
    if (table == null)
        throw new NullPointerException("Table does not exist: " + tableName);
    return table.getRow(entry.getSUID());
}
Also used : CyTable(org.cytoscape.model.CyTable) CyNetwork(org.cytoscape.model.CyNetwork) CyNode(org.cytoscape.model.CyNode) CyEdge(org.cytoscape.model.CyEdge)

Aggregations

CyTable (org.cytoscape.model.CyTable)282 CyNetwork (org.cytoscape.model.CyNetwork)79 CyRow (org.cytoscape.model.CyRow)73 CyColumn (org.cytoscape.model.CyColumn)71 ArrayList (java.util.ArrayList)55 CyNode (org.cytoscape.model.CyNode)43 CyEdge (org.cytoscape.model.CyEdge)35 Test (org.junit.Test)29 List (java.util.List)26 HashMap (java.util.HashMap)24 CyApplicationManager (org.cytoscape.application.CyApplicationManager)19 HashSet (java.util.HashSet)18 CyIdentifiable (org.cytoscape.model.CyIdentifiable)14 CyNetworkView (org.cytoscape.view.model.CyNetworkView)14 CyNetworkTableManager (org.cytoscape.model.CyNetworkTableManager)13 RowSetRecord (org.cytoscape.model.events.RowSetRecord)11 CyRootNetwork (org.cytoscape.model.subnetwork.CyRootNetwork)11 CySubNetwork (org.cytoscape.model.subnetwork.CySubNetwork)11 CyEventHelper (org.cytoscape.event.CyEventHelper)10 CyTableManager (org.cytoscape.model.CyTableManager)10