use of edu.ucsf.rbvi.clusterMaker2.internal.treeview.model.TVModel in project clusterMaker2 by RBVI.
the class DendroView method flipSelectedATRNode.
/**
* Finds the currently selected arrays, mirror image flips them, and then
* rebuilds all necessary trees and saved data to the .jtv file.
*/
private void flipSelectedATRNode() {
int leftIndex, rightIndex;
String selectedID;
TreeDrawerNode arrayNode = invertedTreeDrawer.getNodeById(getArraySelection().getSelectedNode());
if (arrayNode == null || arrayNode.isLeaf()) {
return;
}
selectedID = arrayNode.getId();
// find the starting index of the left array tree, the ending index of the right array tree
leftIndex = getDataModel().getArrayHeaderInfo().getHeaderIndex(arrayNode.getLeft().getLeftLeaf().getId());
rightIndex = getDataModel().getArrayHeaderInfo().getHeaderIndex(arrayNode.getRight().getRightLeaf().getId());
int num = getDataModel().getDataMatrix().getNumUnappendedCol();
int[] newOrder = new int[num];
for (int i = 0; i < num; i++) {
newOrder[i] = i;
}
for (int i = 0; i <= (rightIndex - leftIndex); i++) {
newOrder[leftIndex + i] = rightIndex - i;
}
/*System.out.print("Fliping to: ");
for(int i = 0; i < newOrder.length; i++)
{
System.out.print(newOrder[i] + " ");
}
System.out.println("");*/
((TVModel) getDataModel()).reorderArrays(newOrder);
((TVModel) getDataModel()).saveOrder(newOrder);
((Observable) getDataModel()).notifyObservers();
updateATRDrawer(selectedID);
}
use of edu.ucsf.rbvi.clusterMaker2.internal.treeview.model.TVModel in project clusterMaker2 by RBVI.
the class DendroView method bindTrees.
/**
* this is meant to be called from setupViews.
* It make sure that the trees are generated from the current model,
* and enables/disables them as required.
*
* I factored it out because it is common betwen DendroView and KnnDendroView.
*/
protected void bindTrees() {
DataModel tvmodel = getDataModel();
if ((tvmodel != null) && tvmodel.aidFound()) {
try {
atrview.setEnabled(true);
atrzview.setEnabled(true);
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) {
throw new RuntimeException("Had problem setting up the array tree: " + e.getMessage());
/*
// 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) {}
*/
}
} else {
atrview.setEnabled(false);
atrzview.setEnabled(false);
try {
invertedTreeDrawer.setData(null, null);
} catch (DendroException ex) {
}
}
invertedTreeDrawer.notifyObservers();
if ((tvmodel != null) && tvmodel.gidFound()) {
try {
leftTreeDrawer.setData(tvmodel.getGtrHeaderInfo(), tvmodel.getGeneHeaderInfo());
HeaderInfo gtrHeaderInfo = tvmodel.getGtrHeaderInfo();
if (gtrHeaderInfo.getIndex("NODECOLOR") >= 0) {
TreeColorer.colorUsingHeader(leftTreeDrawer.getRootNode(), tvmodel.getGtrHeaderInfo(), gtrHeaderInfo.getIndex("NODECOLOR"));
} else {
TreeColorer.colorUsingLeaf(leftTreeDrawer.getRootNode(), tvmodel.getGeneHeaderInfo(), tvmodel.getGeneHeaderInfo().getIndex("FGCOLOR"));
}
gtrview.setEnabled(true);
} catch (DendroException e) {
throw new RuntimeException("Had problem setting up the gene tree: " + e.getMessage());
// LogPanel.println("Had problem setting up the gene 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 GTR and CDT files?"));
mismatch.add(new JLabel("Ditching Gene Tree, since it's lame."));
JOptionPane.showMessageDialog(viewFrame, mismatch, "Tree Construction Error", JOptionPane.ERROR_MESSAGE);
gtrview.setEnabled(false);
try{leftTreeDrawer.setData(null, null);} catch (DendroException ex) {}
*/
}
} else {
gtrview.setEnabled(false);
try {
leftTreeDrawer.setData(null, null);
} catch (DendroException ex) {
}
}
leftTreeDrawer.notifyObservers();
}
use of edu.ucsf.rbvi.clusterMaker2.internal.treeview.model.TVModel 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();
}
Aggregations