use of org.cytoscape.model.CyTable in project cytoscape-impl by cytoscape.
the class NNFParser method setNestedNetwork.
private void setNestedNetwork(CyNetwork sourceNetwork, CyNode node, CyNetwork targetNetwork) {
// TODO: We should consider exposing a nested network API so we don't
// have to do this everywhere we establish this link.
node.setNetworkPointer(targetNetwork);
CyTable nodeTable = sourceNetwork.getDefaultNodeTable();
boolean attributeExists = nodeTable.getColumn(HAS_NESTED_NETWORK_ATTRIBUTE) != null;
if (targetNetwork == null && attributeExists) {
nodeTable.getRow(node.getSUID()).set(HAS_NESTED_NETWORK_ATTRIBUTE, false);
} else if (targetNetwork != null) {
if (!attributeExists) {
nodeTable.createColumn(HAS_NESTED_NETWORK_ATTRIBUTE, Boolean.class, false);
}
CyRow row = nodeTable.getRow(node.getSUID());
row.set(HAS_NESTED_NETWORK_ATTRIBUTE, true);
}
}
use of org.cytoscape.model.CyTable in project cytoscape-impl by cytoscape.
the class Cy2SessionReaderImpl method extractNetworksAndViews.
/**
* @param is
* @param entryName
* @param parent
* @param createView
* @return The top-level network that was extracted from the XGMML file.
* @throws Exception
*/
private CyNetwork extractNetworksAndViews(final InputStream is, final String entryName, final CyNetwork parent, final boolean createView) throws Exception {
CyNetwork topNetwork = null;
final CyNetworkReader reader = networkReaderMgr.getReader(is, entryName);
if (parent != null) {
if (reader instanceof SessionXGMMLNetworkReader) {
((SessionXGMMLNetworkReader) reader).setParent(parent);
} else {
logger.error("CyNetworkReader should be an instance of XGMMLNetworkReader. " + "Cannot extract network as sub-nertwork of: " + entryName);
}
}
reader.run(taskMonitor);
final CyNetwork[] netArray = reader.getNetworks();
if (netArray != null && netArray.length > 0) {
topNetwork = netArray[0];
for (int i = 0; i < netArray.length; i++) {
// Process each CyNetwork
final CyNetwork net = netArray[i];
final String netName = net.getRow(net).get(CyNetwork.NAME, String.class);
networkLookup.put(netName, net);
// Add parent network attribute to a column in the hidden table,
// to preserve the network hierarchy info from Cytoscape 2.x
final CyRow hRow = net.getRow(net, CyNetwork.HIDDEN_ATTRS);
final CyTable hTbl = hRow.getTable();
if (parent instanceof CySubNetwork) {
if (hTbl.getColumn(CY3_PARENT_NETWORK_COLUMN) == null)
hTbl.createColumn(CY3_PARENT_NETWORK_COLUMN, Long.class, false);
hRow.set(CY3_PARENT_NETWORK_COLUMN, parent.getSUID());
}
final CyTable tbl = net.getRow(net, CyNetwork.LOCAL_ATTRS).getTable();
// (e.g. the user imported a Cy3 XGMML that contains this attribute into Cy2)
if (tbl.getColumn(CY2_PARENT_NETWORK_COLUMN) != null && parent instanceof CySubNetwork == false)
tbl.deleteColumn(CY2_PARENT_NETWORK_COLUMN);
// Restore node/edge selection
List<Node> selNodes = nodeSelectionLookup.get(netName);
List<Edge> selEdges = edgeSelectionLookup.get(netName);
if (selNodes != null)
setBooleanNodeAttr(net, selNodes, SELECTED, DEFAULT_ATTRS);
if (selEdges != null)
setBooleanEdgeAttr(net, selEdges, SELECTED, DEFAULT_ATTRS);
networks.add(net);
if (!cancelled && i == 0 && createView) {
// Create a network view for the first network only,
// which is supposed to be the top-level one
final CyNetworkView view = reader.buildCyNetworkView(net);
networkViewLookup.put(netName, view);
networkViews.add(view);
cache.cache(netName, view);
}
}
}
return topNetwork;
}
use of org.cytoscape.model.CyTable in project cytoscape-impl by cytoscape.
the class Cy3SessionReaderImpl method mergeNetworkTable.
@SuppressWarnings("unchecked")
private final void mergeNetworkTable(CyNetwork network, CyTableMetadataBuilder builder, CyNetworkTableManager networkTableMgr) {
final Class<? extends CyIdentifiable> type = (Class<? extends CyIdentifiable>) builder.getType();
final String namespace = builder.getNamespace();
final CyTable src = builder.getTable();
final CyTable tgt = networkTableMgr.getTable(network, type, namespace);
if (tgt == null) {
// Just use the source table
networkTableMgr.setTable(network, type, namespace, src);
builder.setCyTable(src);
suidUpdater.addTable(src);
} else {
mergeTables(src, tgt, type);
builder.setCyTable(tgt);
suidUpdater.addTable(tgt);
}
}
use of org.cytoscape.model.CyTable in project cytoscape-impl by cytoscape.
the class NetworkMediator method handleEvent.
@Override
public void handleEvent(final RowsSetEvent e) {
if (loadingSession || networkMainPanel.getRootNetworkListPanel().isEmpty())
return;
// We only care about network name changes
final Collection<RowSetRecord> nameRecords = e.getColumnRecords(CyNetwork.NAME);
if (nameRecords == null || nameRecords.isEmpty())
return;
final CyTable tbl = e.getSource();
final CyNetworkTableManager netTblMgr = serviceRegistrar.getService(CyNetworkTableManager.class);
final CyNetwork net = netTblMgr.getNetworkForTable(tbl);
// And if there is no related network, nothing needs to be done
if (net != null && tbl.equals(net.getDefaultNetworkTable())) {
invokeOnEDT(() -> {
final AbstractNetworkPanel<?> item = networkMainPanel.getNetworkItem(net);
if (item != null)
item.update();
});
}
}
use of org.cytoscape.model.CyTable in project cytoscape-impl by cytoscape.
the class DefaultTableBrowser method getPublicTables.
private Set<CyTable> getPublicTables(CyNetwork currentNetwork) {
final Set<CyTable> tables = new LinkedHashSet<>();
if (currentNetwork == null)
return tables;
final CyNetworkTableManager netTableManager = serviceRegistrar.getService(CyNetworkTableManager.class);
final Map<String, CyTable> map = netTableManager.getTables(currentNetwork, objType);
if (showPrivateTables()) {
tables.addAll(map.values());
} else {
for (final CyTable tbl : map.values()) {
if (tbl.isPublic())
tables.add(tbl);
}
}
return tables;
}
Aggregations