use of org.cytoscape.model.subnetwork.CySubNetwork in project cytoscape-impl by cytoscape.
the class GenericXGMMLWriter method getRowFromNetOrRoot.
protected CyRow getRowFromNetOrRoot(final CyNetwork network, final CyIdentifiable entry, String namespace) {
CyRow row = null;
try {
row = namespace == null ? network.getRow(entry) : network.getRow(entry, namespace);
} catch (final IllegalArgumentException e) {
// Ignore this exception
} catch (final RuntimeException e) {
logger.error("Cannot get \"" + namespace + "\" row for entry \"" + entry + "\" in network \"" + network + "\".", e);
}
if (row == null && network instanceof CySubNetwork) {
// Doesn't exist in subnetwork? Try to get it from the root network.
final CyRootNetwork root = ((CySubNetwork) network).getRootNetwork();
row = namespace == null ? root.getRow(entry) : root.getRow(entry, namespace);
}
return row;
}
use of org.cytoscape.model.subnetwork.CySubNetwork in project cytoscape-impl by cytoscape.
the class GenericXGMMLWriter method getSerializableSubNetworks.
/**
* @param rootNet
* @return A set with all the subnetworks that should be serialized.
*/
protected Set<CySubNetwork> getSerializableSubNetworks(final CyRootNetwork rootNet) {
final Set<CySubNetwork> serializableSet = new LinkedHashSet<CySubNetwork>();
final List<CySubNetwork> subNetList = rootNet.getSubNetworkList();
final CySubNetwork baseNetwork = rootNet.getBaseNetwork();
// The base network must be the first one!
if (isSerializable(baseNetwork))
serializableSet.add(baseNetwork);
for (final CySubNetwork sn : subNetList) {
if (isSerializable(sn))
serializableSet.add(sn);
}
return serializableSet;
}
use of org.cytoscape.model.subnetwork.CySubNetwork in project cytoscape-impl by cytoscape.
the class ReadDataManager method createNode.
protected CyNode createNode(final Object oldId, final String label, final CyNetwork net) {
if (oldId == null)
throw new NullPointerException("'oldId' is null.");
CyNode node = null;
if (net instanceof CySubNetwork && getParentNetwork() != null) {
// Do not create the element again if the network is a sub-network!
node = cache.getNode(oldId);
if (node != null)
((CySubNetwork) net).addNode(node);
}
if (node == null) {
node = this.nMap.get(label);
if (node == null) {
// OK, create it
node = net.addNode();
}
}
if (net instanceof CySubNetwork && getParentNetwork() != null) {
// cache the parent node, not the node from subnetwork
CySubNetwork subnet = (CySubNetwork) net;
node = subnet.getRootNetwork().getNode(node.getSUID());
}
// Add to internal cache:
cache.cache(oldId, node);
cache.cacheNodeByName(label, node);
mapSUIDs(oldId, node.getSUID());
return node;
}
use of org.cytoscape.model.subnetwork.CySubNetwork in project cytoscape-impl by cytoscape.
the class GroupUtil method updateGroupNodeLocation.
private void updateGroupNodeLocation(final CyNetworkView view, final CyNode groupNode) {
if (view == null)
return;
CyRootNetwork rootNetwork = ((CySubNetwork) view.getModel()).getRootNetwork();
View<CyNode> nView = view.getNodeView(groupNode);
double x = nView.getVisualProperty(BasicVisualLexicon.NODE_X_LOCATION);
double y = nView.getVisualProperty(BasicVisualLexicon.NODE_Y_LOCATION);
// Save it
// TODO these attributes will not work with multiple views per network!
CyRow hRow = rootNetwork.getRow(groupNode, CyNetwork.HIDDEN_ATTRS);
createColumn(hRow.getTable(), X_LOCATION_ATTR, Double.class);
createColumn(hRow.getTable(), Y_LOCATION_ATTR, Double.class);
hRow.set(X_LOCATION_ATTR, new Double(x));
hRow.set(Y_LOCATION_ATTR, new Double(y));
}
use of org.cytoscape.model.subnetwork.CySubNetwork in project cytoscape-impl by cytoscape.
the class GroupUtil method getGroupNodeEdges.
public List<CyEdge> getGroupNodeEdges(final CyNetwork network) {
CyRootNetwork rootNetwork = ((CySubNetwork) network).getRootNetwork();
// Don't need to worry about this for collapsed groups
List<CyNode> groupNodes = getExpandedGroups(network);
List<CyEdge> groupNodeEdges = new ArrayList<>();
for (CyNode groupNode : groupNodes) {
groupNodeEdges.addAll(rootNetwork.getAdjacentEdgeList(groupNode, CyEdge.Type.ANY));
}
return groupNodeEdges;
}
Aggregations