use of edu.ucsf.rbvi.clusterMaker2.internal.treeview.HeaderInfo in project clusterMaker2 by RBVI.
the class TreeView method setNodeSelection.
private void setNodeSelection(List<CyNode> nodeArray, boolean select) {
// System.out.println("Selecting "+nodeArray.size()+" nodes in network "+myNetwork);
HeaderInfo geneInfo = dataModel.getGeneHeaderInfo();
geneSelection.deleteObserver(this);
geneSelection.setSelectedNode(null);
geneSelection.deselectAllIndexes();
for (CyNode cyNode : nodeArray) {
if (!myNetwork.containsNode(cyNode))
continue;
int geneIndex = geneInfo.getHeaderIndex(ModelUtils.getName(myNetwork, cyNode));
// System.out.println("setting "+cyNode+"("+geneIndex+") to "+select);
geneSelection.setIndex(geneIndex, select);
}
geneSelection.deleteObserver(this);
geneSelection.notifyObservers();
geneSelection.addObserver(this);
}
use of edu.ucsf.rbvi.clusterMaker2.internal.treeview.HeaderInfo in project clusterMaker2 by RBVI.
the class TreeView method update.
public void update(Observable o, Object arg) {
CyNetworkView currentView = manager.getNetworkView();
CyNetwork currentNetwork = manager.getNetwork();
// See if we're supposed to disable our listeners
if ((o == arraySelection) && (arg instanceof Boolean)) {
// System.out.println("Changing disable listeners to: "+arg.toString());
disableListeners = ((Boolean) arg).booleanValue();
}
if (disableListeners)
return;
if (o == geneSelection) {
// System.out.println("Gene selection");
selectedNodes.clear();
int[] selections = geneSelection.getSelectedIndexes();
HeaderInfo geneInfo = dataModel.getGeneHeaderInfo();
String[] names = geneInfo.getNames();
for (int i = 0; i < selections.length; i++) {
String nodeName = geneInfo.getHeader(selections[i])[0];
CyNode node = (CyNode) ModelUtils.getNetworkObjectWithName(currentNetwork, nodeName, CyNode.class);
// Now see if this network has this node
if (node != null && !currentNetwork.containsNode(node)) {
// No, try dropping any suffixes from the node name
String[] tokens = nodeName.split(" ");
node = (CyNode) ModelUtils.getNetworkObjectWithName(currentNetwork, tokens[0], CyNode.class);
}
if (node != null)
selectedNodes.add(node);
}
// System.out.println("Selecting "+selectedNodes.size()+" nodes");
if (dataModel.isAssymetricEdge() || !dataModel.isSymmetrical() || selectedArrays.size() == 0) {
// System.out.println("Adding "+selectedNodes.size()+" gene nodes to current network");
selectNodes(currentNetwork, selectedNodes, true);
if (currentView != null)
currentView.updateView();
}
return;
} else if (o == arraySelection) {
// We only care about array selection for symmetrical models
if (!dataModel.isSymmetrical() && !dataModel.isAssymetricEdge())
return;
selectedArrays.clear();
int[] selections = arraySelection.getSelectedIndexes();
if (selections.length == dataModel.nExpr())
return;
HeaderInfo arrayInfo = dataModel.getArrayHeaderInfo();
String[] names = arrayInfo.getNames();
for (int i = 0; i < selections.length; i++) {
String nodeName = arrayInfo.getHeader(selections[i])[0];
CyNode node = (CyNode) ModelUtils.getNetworkObjectWithName(currentNetwork, nodeName, CyNode.class);
if (node != null && !currentNetwork.containsNode(node)) {
// No, try dropping any suffixes from the node name
String[] tokens = nodeName.split(" ");
node = (CyNode) ModelUtils.getNetworkObjectWithName(currentNetwork, tokens[0], CyNode.class);
}
if (node != null)
selectedArrays.add(node);
}
if (selectedNodes.size() > 0)
selectNodes(currentNetwork, selectedArrays, false);
else
selectNodes(currentNetwork, selectedArrays, true);
}
HashMap<CyEdge, CyEdge> edgesToSelect = new HashMap<CyEdge, CyEdge>();
ignoreSelection = true;
List<CyEdge> edgesToClear = CyTableUtil.getEdgesInState(currentNetwork, CyNetwork.SELECTED, true);
for (CyEdge edge : edgesToClear) {
if (myNetwork.containsEdge(edge))
myNetwork.getRow(edge).set(CyNetwork.SELECTED, Boolean.FALSE);
if (currentNetwork.containsEdge(edge))
currentNetwork.getRow(edge).set(CyNetwork.SELECTED, Boolean.FALSE);
}
for (CyNode node1 : selectedNodes) {
for (CyNode node2 : selectedArrays) {
List<CyEdge> edges = currentNetwork.getConnectingEdgeList(node1, node2, CyEdge.Type.ANY);
if (edges == null) {
continue;
}
for (CyEdge edge : edges) {
if (currentNetwork.containsEdge(edge))
currentNetwork.getRow(edge).set(CyNetwork.SELECTED, Boolean.TRUE);
if (myNetwork.containsEdge(edge))
myNetwork.getRow(edge).set(CyNetwork.SELECTED, Boolean.TRUE);
}
}
}
manager.getService(CyEventHelper.class).flushPayloadEvents();
ignoreSelection = false;
if (currentView != null)
currentView.updateView();
selectedNodes.clear();
selectedArrays.clear();
}
use of edu.ucsf.rbvi.clusterMaker2.internal.treeview.HeaderInfo in project clusterMaker2 by RBVI.
the class TreeView method setEdgeSelection.
private void setEdgeSelection(List<CyEdge> edgeArray, boolean select) {
HeaderInfo geneInfo = dataModel.getGeneHeaderInfo();
HeaderInfo arrayInfo = dataModel.getArrayHeaderInfo();
// Avoid loops -- delete ourselves as observers
geneSelection.deleteObserver(this);
arraySelection.deleteObserver(this);
// Clear everything that's currently selected
geneSelection.setSelectedNode(null);
geneSelection.deselectAllIndexes();
arraySelection.setSelectedNode(null);
arraySelection.deselectAllIndexes();
// Do the actual selection
for (CyEdge cyEdge : edgeArray) {
if (!myNetwork.containsEdge(cyEdge))
continue;
CyNode source = cyEdge.getSource();
CyNode target = cyEdge.getTarget();
int geneIndex = geneInfo.getHeaderIndex(ModelUtils.getName(myNetwork, source));
int arrayIndex = arrayInfo.getHeaderIndex(ModelUtils.getName(myNetwork, target));
geneSelection.setIndex(geneIndex, select);
arraySelection.setIndex(arrayIndex, select);
}
// Notify all of the observers
geneSelection.notifyObservers();
arraySelection.notifyObservers();
// OK, now we can listen again
geneSelection.addObserver(this);
arraySelection.addObserver(this);
}
use of edu.ucsf.rbvi.clusterMaker2.internal.treeview.HeaderInfo in project clusterMaker2 by RBVI.
the class HeatMapView method setNodeSelection.
private void setNodeSelection(List<CyNode> nodeArray, boolean select) {
HeaderInfo geneInfo = dataModel.getGeneHeaderInfo();
geneSelection.deleteObserver(this);
geneSelection.setSelectedNode(null);
geneSelection.deselectAllIndexes();
for (CyNode cyNode : nodeArray) {
if (!myNetwork.containsNode(cyNode))
continue;
int geneIndex = geneInfo.getHeaderIndex(ModelUtils.getName(myNetwork, cyNode));
// System.out.println("setting "+cyNode.getIdentifier()+"("+geneIndex+") to "+select);
geneSelection.setIndex(geneIndex, select);
}
geneSelection.deleteObserver(this);
geneSelection.notifyObservers();
geneSelection.addObserver(this);
}
use of edu.ucsf.rbvi.clusterMaker2.internal.treeview.HeaderInfo in project clusterMaker2 by RBVI.
the class HeatMapView method update.
public void update(Observable o, Object arg) {
CyNetworkView currentView = manager.getNetworkView();
CyNetwork currentNetwork = manager.getNetwork();
// See if we're supposed to disable our listeners
if ((o == arraySelection) && (arg instanceof Boolean)) {
// System.out.println("Changing disable listeners to: "+arg.toString());
disableListeners = ((Boolean) arg).booleanValue();
}
if (disableListeners)
return;
if (o == geneSelection) {
// System.out.println("gene selection");
selectedNodes.clear();
int[] selections = geneSelection.getSelectedIndexes();
HeaderInfo geneInfo = dataModel.getGeneHeaderInfo();
String[] names = geneInfo.getNames();
for (int i = 0; i < selections.length; i++) {
String nodeName = geneInfo.getHeader(selections[i])[0];
CyNode node = (CyNode) ModelUtils.getNetworkObjectWithName(currentNetwork, nodeName, CyNode.class);
// Now see if this network has this node
if (node != null && !currentNetwork.containsNode(node)) {
// No, try dropping any suffixes from the node name
String[] tokens = nodeName.split(" ");
node = (CyNode) ModelUtils.getNetworkObjectWithName(currentNetwork, tokens[0], CyNode.class);
}
if (node != null)
selectedNodes.add(node);
}
// System.out.println("Selecting "+selectedNodes.size()+" nodes");
if (!dataModel.isSymmetrical() || selectedArrays.size() == 0) {
List<CyNode> nodesToClear = CyTableUtil.getNodesInState(currentNetwork, CyNetwork.SELECTED, true);
ignoreSelection = true;
for (CyNode node : nodesToClear) {
myNetwork.getRow(node).set(CyNetwork.SELECTED, Boolean.FALSE);
if (currentNetwork.containsNode(node))
currentNetwork.getRow(node).set(CyNetwork.SELECTED, Boolean.FALSE);
}
for (CyNode node : selectedNodes) {
if (currentNetwork.containsNode(node))
currentNetwork.getRow(node).set(CyNetwork.SELECTED, Boolean.TRUE);
myNetwork.getRow(node).set(CyNetwork.SELECTED, Boolean.TRUE);
}
manager.getService(CyEventHelper.class).flushPayloadEvents();
ignoreSelection = false;
if (currentView != null)
currentView.updateView();
}
return;
} else if (o == arraySelection) {
// We only care about array selection for symmetrical models
if (!dataModel.isSymmetrical())
return;
selectedArrays.clear();
int[] selections = arraySelection.getSelectedIndexes();
if (selections.length == dataModel.nExpr())
return;
HeaderInfo arrayInfo = dataModel.getArrayHeaderInfo();
String[] names = arrayInfo.getNames();
for (int i = 0; i < selections.length; i++) {
String nodeName = arrayInfo.getHeader(selections[i])[0];
CyNode node = (CyNode) ModelUtils.getNetworkObjectWithName(currentNetwork, nodeName, CyNode.class);
if (node != null && !currentNetwork.containsNode(node)) {
// No, try dropping any suffixes from the node name
String[] tokens = nodeName.split(" ");
node = (CyNode) ModelUtils.getNetworkObjectWithName(currentNetwork, tokens[0], CyNode.class);
}
if (node != null)
selectedArrays.add(node);
}
}
HashMap<CyEdge, CyEdge> edgesToSelect = new HashMap<CyEdge, CyEdge>();
ignoreSelection = true;
List<CyEdge> edgesToClear = CyTableUtil.getEdgesInState(currentNetwork, CyNetwork.SELECTED, true);
for (CyEdge edge : edgesToClear) {
myNetwork.getRow(edge).set(CyNetwork.SELECTED, Boolean.FALSE);
if (currentNetwork.containsEdge(edge))
currentNetwork.getRow(edge).set(CyNetwork.SELECTED, Boolean.FALSE);
}
for (CyNode node1 : selectedNodes) {
for (CyNode node2 : selectedArrays) {
List<CyEdge> edges = currentNetwork.getConnectingEdgeList(node1, node2, CyEdge.Type.ANY);
if (edges == null) {
continue;
}
for (CyEdge edge : edges) {
myNetwork.getRow(edge).set(CyNetwork.SELECTED, Boolean.TRUE);
if (currentNetwork.containsEdge(edge))
currentNetwork.getRow(edge).set(CyNetwork.SELECTED, Boolean.TRUE);
}
}
}
manager.getService(CyEventHelper.class).flushPayloadEvents();
ignoreSelection = false;
if (currentView != null)
currentView.updateView();
selectedNodes.clear();
selectedArrays.clear();
}
Aggregations