Search in sources :

Example 46 with CyTable

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

the class StringToModelImpl method getTable.

@Override
public CyTable getTable(String strTable) {
    if (strTable == null || strTable.length() == 0 || strTable.equalsIgnoreCase(CURRENT))
        return serviceRegistrar.getService(CyApplicationManager.class).getCurrentTable();
    // Look for any special prefix
    CyNetwork network;
    String[] splitString = strTable.split(":");
    if (splitString.length > 1) {
        if (splitString[0].equalsIgnoreCase("node")) {
            network = getNetwork(splitString[1]);
            if (network != null)
                return network.getDefaultNodeTable();
        }
        if (splitString[0].equalsIgnoreCase("edge")) {
            network = getNetwork(splitString[1]);
            if (network != null)
                return network.getDefaultEdgeTable();
        }
        if (splitString[0].equalsIgnoreCase("network")) {
            network = getNetwork(splitString[1]);
            if (network != null)
                return network.getDefaultNetworkTable();
        }
    } else {
        final CyTableManager tableMgr = serviceRegistrar.getService(CyTableManager.class);
        for (CyTable tab : tableMgr.getGlobalTables()) {
            if (tab.getTitle().contains(strTable))
                return tab;
        }
    }
    return null;
}
Also used : CyTable(org.cytoscape.model.CyTable) CyTableManager(org.cytoscape.model.CyTableManager) CyNetwork(org.cytoscape.model.CyNetwork)

Example 47 with CyTable

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

the class ThumbnailView method handleEvent.

@Override
public void handleEvent(RowsSetEvent e) {
    if (!e.containsColumn(CyNetwork.SELECTED))
        return;
    CyTable source = e.getSource();
    CyNetwork model = viewModel.getModel();
    if (!viewModel.getComponent().isShowing() && (source == model.getDefaultNodeTable() || source == model.getDefaultEdgeTable())) {
        forceRender = true;
        repaint();
    }
}
Also used : CyTable(org.cytoscape.model.CyTable) CyNetwork(org.cytoscape.model.CyNetwork)

Example 48 with CyTable

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

the class DGraphView method select.

public void select(Collection<? extends CyIdentifiable> nodesOrEdges, Class<? extends CyIdentifiable> type, boolean selected) {
    if (nodesOrEdges.isEmpty())
        return;
    List<RowSetRecord> records = new ArrayList<>();
    CyTable table = type.equals(CyNode.class) ? getModel().getDefaultNodeTable() : getModel().getDefaultEdgeTable();
    // Disable events
    final CyEventHelper eventHelper = serviceRegistrar.getService(CyEventHelper.class);
    eventHelper.silenceEventSource(table);
    try {
        for (final CyIdentifiable nodeOrEdge : nodesOrEdges) {
            CyRow row = getModel().getRow(nodeOrEdge);
            row.set(CyNetwork.SELECTED, selected);
            // Add to paylod
            records.add(new RowSetRecord(row, CyNetwork.SELECTED, selected, selected));
        }
    } finally {
        eventHelper.unsilenceEventSource(table);
    }
    // Update the selection before firing the event to prevent race conditions
    updateSelection(type, records);
    // Only now it can fire the RowsSetEvent
    fireRowsSetEvent(table, records, eventHelper);
}
Also used : RowSetRecord(org.cytoscape.model.events.RowSetRecord) CyTable(org.cytoscape.model.CyTable) CyEventHelper(org.cytoscape.event.CyEventHelper) ArrayList(java.util.ArrayList) CyNode(org.cytoscape.model.CyNode) CyRow(org.cytoscape.model.CyRow) CyIdentifiable(org.cytoscape.model.CyIdentifiable)

Example 49 with CyTable

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

the class CyRootNetworkImpl method createRootNetworkTables.

private void createRootNetworkTables() {
    final CyTable rawEdgeSharedTable = tableFactory.createTable(suid + " shared edge", CyIdentifiable.SUID, Long.class, false, /*all root tables are private*/
    false, getInitialTableSize(subNetworks.size()));
    final CyTable edgeSharedTable = new SharedTableFacade(rawEdgeSharedTable, this, CyEdge.class, networkTableMgr, eventHelper);
    edgeSharedTable.setPublic(false);
    networkTableMgr.setTable(this, CyEdge.class, CyRootNetwork.SHARED_ATTRS, rawEdgeSharedTable);
    networkTableMgr.setTable(this, CyEdge.class, CyRootNetwork.SHARED_DEFAULT_ATTRS, edgeSharedTable);
    edgeSharedTable.createColumn(CyRootNetwork.SHARED_NAME, String.class, true);
    edgeSharedTable.createColumn(CyRootNetwork.SHARED_INTERACTION, String.class, true);
    final CyTable rawNetworkSharedTable = tableFactory.createTable(suid + " shared network", CyIdentifiable.SUID, Long.class, false, /*all root tables are private*/
    false, InitialTableSize.SMALL);
    final CyTable networkSharedTable = new SharedTableFacade(rawNetworkSharedTable, this, CyNetwork.class, networkTableMgr, eventHelper);
    networkSharedTable.setPublic(false);
    networkTableMgr.setTable(this, CyNetwork.class, CyRootNetwork.SHARED_ATTRS, rawNetworkSharedTable);
    networkTableMgr.setTable(this, CyNetwork.class, CyRootNetwork.SHARED_DEFAULT_ATTRS, networkSharedTable);
    networkSharedTable.createColumn(CyRootNetwork.SHARED_NAME, String.class, true);
    final CyTable rawNodeSharedTable = tableFactory.createTable(suid + " shared node", CyIdentifiable.SUID, Long.class, false, /*all root tables are private*/
    false, getInitialTableSize(subNetworks.size()));
    final CyTable nodeSharedTable = new SharedTableFacade(rawNodeSharedTable, this, CyNode.class, networkTableMgr, eventHelper);
    nodeSharedTable.setPublic(false);
    networkTableMgr.setTable(this, CyNode.class, CyRootNetwork.SHARED_ATTRS, rawNodeSharedTable);
    networkTableMgr.setTable(this, CyNode.class, CyRootNetwork.SHARED_DEFAULT_ATTRS, nodeSharedTable);
    nodeSharedTable.createColumn(CyRootNetwork.SHARED_NAME, String.class, true);
}
Also used : CyTable(org.cytoscape.model.CyTable)

Example 50 with CyTable

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

the class CySubNetworkImpl method removeEdges.

@Override
public boolean removeEdges(final Collection<CyEdge> edges) {
    if (edges == null || edges.isEmpty())
        return false;
    // Possible error if one of the edges isn't contained in subnetwork, but
    // since this is only a notification, maybe that's OK.
    eventHelper.fireEvent(new AboutToRemoveEdgesEvent(this, edges));
    CyTable hiddenTable = getTable(CyEdge.class, CyNetwork.HIDDEN_ATTRS);
    CyTable localTable = getTable(CyEdge.class, CyNetwork.LOCAL_ATTRS);
    CyTable defaultTable = getTable(CyEdge.class, CyNetwork.DEFAULT_ATTRS);
    List<Long> suids = new ArrayList<>();
    for (CyEdge edge : edges) {
        if (containsEdge(edge)) {
            // getRow(edge).set(CyNetwork.SELECTED, false);
            suids.add(edge.getSUID());
        }
    }
    boolean ret = removeEdgesInternal(edges);
    hiddenTable.deleteRows(suids);
    defaultTable.deleteRows(suids);
    if (ret) {
        parent.subnetworkEdgesRemoved(edges);
    }
    if (ret) {
        eventHelper.fireEvent(new RemovedEdgesEvent(this));
    }
    return ret;
}
Also used : CyTable(org.cytoscape.model.CyTable) RemovedEdgesEvent(org.cytoscape.model.events.RemovedEdgesEvent) AboutToRemoveEdgesEvent(org.cytoscape.model.events.AboutToRemoveEdgesEvent) ArrayList(java.util.ArrayList) 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