use of edu.ucsf.rbvi.clusterMaker2.internal.treeview.TreeDrawerNode in project clusterMaker2 by RBVI.
the class DendroView method updateATRDrawer.
/**
* Updates the ATRDrawer to reflect changes in the DataMode
* array order; rebuilds the TreeDrawerNode tree.
* @param selectedID ID of the node selected before a change in
* tree structure was made. This node is then
* found and reselected after the ATR tree is rebuilt.
*/
private void updateATRDrawer(String selectedID) {
try {
TVModel tvmodel = (TVModel) getDataModel();
invertedTreeDrawer.setData(tvmodel.getAtrHeaderInfo(), tvmodel.getArrayHeaderInfo());
HeaderInfo trHeaderInfo = tvmodel.getAtrHeaderInfo();
if (trHeaderInfo.getIndex("NODECOLOR") >= 0) {
TreeColorer.colorUsingHeader(invertedTreeDrawer.getRootNode(), trHeaderInfo, trHeaderInfo.getIndex("NODECOLOR"));
}
} catch (DendroException e) {
// LogPanel.println("Had problem setting up the array tree : " + e.getMessage());
// e.printStackTrace();
Box mismatch = new Box(BoxLayout.Y_AXIS);
mismatch.add(new JLabel(e.getMessage()));
mismatch.add(new JLabel("Perhaps there is a mismatch between your ATR and CDT files?"));
mismatch.add(new JLabel("Ditching Array Tree, since it's lame."));
JOptionPane.showMessageDialog(viewFrame, mismatch, "Tree Construction Error", JOptionPane.ERROR_MESSAGE);
atrview.setEnabled(false);
atrzview.setEnabled(false);
try {
invertedTreeDrawer.setData(null, null);
} catch (DendroException ex) {
}
}
TreeDrawerNode arrayNode = invertedTreeDrawer.getRootNode().findNode(selectedID);
arraySelection.setSelectedNode(arrayNode.getId());
atrzview.setSelectedNode(arrayNode);
atrview.setSelectedNode(arrayNode);
arraySelection.notifyObservers();
invertedTreeDrawer.notifyObservers();
}
use of edu.ucsf.rbvi.clusterMaker2.internal.treeview.TreeDrawerNode in project clusterMaker2 by RBVI.
the class GTRView method selectLeft.
private void selectLeft() {
if (selectedNode.isLeaf())
return;
TreeDrawerNode current = selectedNode;
selectedNode = current.getLeft();
drawer.paintSingle(offscreenGraphics, getXScaleEq(), getYScaleEq(), destRect, current, false);
drawer.paintSubtree(offscreenGraphics, getXScaleEq(), getYScaleEq(), destRect, current.getRight(), false);
synchMap();
repaint();
}
use of edu.ucsf.rbvi.clusterMaker2.internal.treeview.TreeDrawerNode in project clusterMaker2 by RBVI.
the class GTRView method update.
/**
* expect updates to come from map, geneSelection and drawer
*/
public void update(Observable o, Object arg) {
if (o == map) {
// System.out.println("Got an update from map");
offscreenValid = false;
repaint();
} else if (o == drawer) {
// System.out.println("Got an update from drawer");
offscreenValid = false;
repaint();
} else if (o == geneSelection) {
TreeDrawerNode cand = null;
if (geneSelection.getNSelectedIndexes() > 0) {
// This clause selects the array node if only a single array is selected.
if (geneSelection.getMinIndex() == geneSelection.getMaxIndex()) {
cand = drawer.getLeaf(geneSelection.getMinIndex());
// this clause selects the root node if all genes are selected.
} else if ((geneSelection.getMinIndex() == map.getMinIndex()) && (geneSelection.getMaxIndex() == map.getMaxIndex())) {
cand = drawer.getRootNode();
}
}
if ((cand != null) && (cand.getId() != geneSelection.getSelectedNode())) {
String id = cand.getId();
geneSelection.setSelectedNode(id);
geneSelection.notifyObservers();
} else {
setSelectedNode(drawer.getNodeById(geneSelection.getSelectedNode()));
}
} else {
// CyLogger.getLogger(GTRView.class).warn(viewName() + "Got an update from unknown " + o);
}
}
use of edu.ucsf.rbvi.clusterMaker2.internal.treeview.TreeDrawerNode in project clusterMaker2 by RBVI.
the class GTRView method selectRight.
private void selectRight() {
if (selectedNode.isLeaf())
return;
TreeDrawerNode current = selectedNode;
selectedNode = current.getRight();
drawer.paintSingle(offscreenGraphics, getXScaleEq(), getYScaleEq(), destRect, current, false);
drawer.paintSubtree(offscreenGraphics, getXScaleEq(), getYScaleEq(), destRect, current.getLeft(), false);
synchMap();
repaint();
}
use of edu.ucsf.rbvi.clusterMaker2.internal.treeview.TreeDrawerNode in project clusterMaker2 by RBVI.
the class ATRView method keyPressed.
// method from KeyListener
/**
* Arrow keys are used to change the selected node.
*
* up selects parent of current.
* left selects left child.
* right selects right child
* down selects child with most descendants.
*/
public void keyPressed(KeyEvent e) {
if (selectedNode == null) {
return;
}
int c = e.getKeyCode();
TreeDrawerNode cand = null;
switch(c) {
case KeyEvent.VK_UP:
selectParent();
break;
case KeyEvent.VK_LEFT:
if (selectedNode.isLeaf() == false) {
selectLeft();
}
break;
case KeyEvent.VK_RIGHT:
if (selectedNode.isLeaf() == false) {
selectRight();
}
break;
case KeyEvent.VK_DOWN:
if (selectedNode.isLeaf() == false) {
TreeDrawerNode right = selectedNode.getRight();
TreeDrawerNode left = selectedNode.getLeft();
if (right.getRange() > left.getRange()) {
selectRight();
} else {
selectLeft();
}
}
break;
}
}
Aggregations