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;
}
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();
}
}
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);
}
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);
}
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;
}
Aggregations