use of org.cytoscape.group.CyGroup in project cytoscape-impl by cytoscape.
the class GroupViewCollapseHandler method handleEvent.
/**
* If a group is destroyed, and it's a compound node, we need to fix up a
* bunch of things.
*/
@Override
public void handleEvent(GroupAboutToBeDestroyedEvent e) {
getServices();
CyGroup group = e.getGroup();
GroupViewType groupViewType = cyGroupSettings.getGroupViewType(group);
if (groupViewType.equals(GroupViewType.COMPOUND)) {
removeCompoundNode(group);
return;
}
// for this group
if (cyGroupSettings.getUseNestedNetworks(group)) {
// First, we need to make sure the group is expanded
for (CyNetwork net : group.getNetworkSet()) {
group.expand(net);
}
CyNetwork nn = group.getGroupNetwork();
if (cyNetworkViewManager.viewExists(nn)) {
// Destroy the view(s)
for (CyNetworkView v : cyNetworkViewManager.getNetworkViews(nn)) {
cyNetworkViewManager.destroyNetworkView(v);
}
}
// Now, remove the network
cyNetworkManager.destroyNetwork(nn);
group.getGroupNode().setNetworkPointer(null);
}
}
use of org.cytoscape.group.CyGroup in project cytoscape-impl by cytoscape.
the class NodeChangeListener method getGroupForNode.
private CyGroup getGroupForNode(CyNode node, CyNetworkView networkView) {
CyGroup group = null;
List<CyGroup> groupList = cyGroupManager.getGroupsForNode(node);
if (groupList == null || groupList.size() == 0)
// Shouldn't happen!
return null;
Set<CyNode> groupNodes = groupMap.get(networkView);
for (CyGroup g : groupList) {
if (groupNodes.contains(g.getGroupNode())) {
group = g;
}
}
return group;
}
use of org.cytoscape.group.CyGroup in project cytoscape-impl by cytoscape.
the class NodeChangeListener method addGroup.
public void addGroup(CyGroup group, CyNetworkView networkView) {
if (!groupMap.containsKey(networkView))
groupMap.put(networkView, new HashSet<CyNode>());
groupMap.get(networkView).add(group.getGroupNode());
if (!nodeMap.containsKey(networkView))
nodeMap.put(networkView, new HashSet<CyNode>());
if (!node2GroupMap.containsKey(networkView))
node2GroupMap.put(networkView, new HashMap<CyNode, CyGroup>());
Map<CyNode, CyGroup> node2Group = node2GroupMap.get(networkView);
for (CyNode node : group.getNodeList()) {
// another one
if (!node2Group.containsKey(node)) {
nodeMap.get(networkView).add(node);
node2Group.put(node, group);
}
}
}
use of org.cytoscape.group.CyGroup in project cytoscape-impl by cytoscape.
the class CyGroupManagerImpl method updateGroupAttribute.
private void updateGroupAttribute(CyGroup group) {
CyRootNetwork rootNet = group.getRootNetwork();
// Get the network row
CyRow rhRow = rootNet.getRow(rootNet, CyNetwork.HIDDEN_ATTRS);
if (rhRow.getTable().getColumn(GROUP_LIST_ATTRIBUTE) == null) {
rhRow.getTable().createListColumn(GROUP_LIST_ATTRIBUTE, Long.class, false);
}
List<Long> groupSUIDs = new ArrayList<Long>();
for (CyGroup g : getGroupSet(rootNet)) {
groupSUIDs.add(g.getGroupNode().getSUID());
}
rhRow.set(GROUP_LIST_ATTRIBUTE, groupSUIDs);
}
use of org.cytoscape.group.CyGroup in project cytoscape-impl by cytoscape.
the class GroupIO method writeLockedVisualPropertiesMap.
private void writeLockedVisualPropertiesMap(final File file, final Set<CyGroup> groups) throws JsonGenerationException, JsonMappingException, IOException {
final CyNetworkViewManager netViewMgr = groupMgr.getService(CyNetworkViewManager.class);
final Set<CyIdentifiable> grElements = new HashSet<>();
for (final CyGroup gr : groups) {
final Set<CyNetworkView> netViews = new HashSet<>();
final Set<CyNetwork> networks = gr.getNetworkSet();
for (final CyNetwork net : networks) {
if (netViewMgr.viewExists(net))
netViews.addAll(netViewMgr.getNetworkViews(net));
}
if (netViews.isEmpty())
continue;
grElements.add(gr.getGroupNode());
grElements.addAll(gr.getRootNetwork().getAdjacentEdgeList(gr.getGroupNode(), CyEdge.Type.ANY));
grElements.addAll(gr.getNodeList());
grElements.addAll(gr.getExternalEdgeList());
grElements.addAll(gr.getInternalEdgeList());
for (final CyIdentifiable element : grElements) lvpMgr.saveLockedValues(element, netViews);
}
final Map<Key, Map<VisualProperty<?>, Object>> map = lvpMgr.getLockedVisualPropertiesMap();
if (map != null)
mapper.writeValue(file, map);
}
Aggregations