[Jtreeview-cvs] jtreeview commit notification
Brought to you by:
alokito
From: Alok S. <al...@us...> - 2008-04-23 23:29:23
|
Update of /cvsroot/jtreeview/LinkedView/src/edu/stanford/genetics/treeview/plugin/dendroview In directory sc8-pr-cvs17.sourceforge.net:/tmp/cvs-serv809/src/edu/stanford/genetics/treeview/plugin/dendroview Modified Files: DendrogramFactory.java DendroView.java Log Message: added support for flipping gene nodes Index: DendroView.java =================================================================== RCS file: /cvsroot/jtreeview/LinkedView/src/edu/stanford/genetics/treeview/plugin/dendroview/DendroView.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** DendroView.java 4 Oct 2006 16:17:58 -0000 1.4 --- DendroView.java 23 Apr 2008 23:29:19 -0000 1.5 *************** *** 207,210 **** --- 207,261 ---- /** + * Finds the currently selected genes, mirror image flips them, and then rebuilds all necessary trees and saved data to the .jtv file. + * + */ + private void flipSelectedGTRNode() + { + int leftIndex, rightIndex; + String selectedID; + TreeDrawerNode geneNode = leftTreeDrawer.getNodeById(getGeneSelection().getSelectedNode()); + + if(geneNode == null || geneNode.isLeaf()) + { + return; + } + + selectedID = geneNode.getId(); + + //find the starting index of the left array tree, the ending index of the right array tree + leftIndex = getDataModel().getGeneHeaderInfo().getHeaderIndex(geneNode.getLeft().getLeftLeaf().getId()); + rightIndex = getDataModel().getGeneHeaderInfo().getHeaderIndex(geneNode.getRight().getRightLeaf().getId()); + + int num = getDataModel().getDataMatrix().getNumRow(); + + int [] newOrder = SetupInvertedArray(num, leftIndex, rightIndex); + + /*System.out.print("Fliping to: "); + for(int i = 0; i < newOrder.length; i++) + { + System.out.print(newOrder[i] + " "); + } + System.out.println("");*/ + + ((TVModel)getDataModel()).reorderGenes(newOrder); + // ((TVModel)getDataModel()).saveGeneOrder(newOrder); + ((Observable)getDataModel()).notifyObservers(); + + updateGTRDrawer(selectedID); + } + + private int [] SetupInvertedArray(int num, int leftIndex, int rightIndex) { + 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; + return newOrder; + } + + + + + /** * Finds the currently selected arrays, mirror image flips them, and then rebuilds all necessary trees and saved data to the .jtv file. * *************** *** 327,330 **** --- 378,418 ---- /** + * Updates the GTRDrawer to reflect changes in the DataModel gene 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 updateGTRDrawer(String selectedID) + { + try { + TVModel tvmodel = (TVModel)getDataModel(); + leftTreeDrawer.setData(tvmodel.getGtrHeaderInfo(), tvmodel.getGeneHeaderInfo()); + HeaderInfo trHeaderInfo = tvmodel.getGtrHeaderInfo(); + if (trHeaderInfo.getIndex("NODECOLOR") >= 0) { + TreeColorer.colorUsingHeader (leftTreeDrawer.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 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) {} + } + + TreeDrawerNode arrayNode = leftTreeDrawer.getRootNode().findNode(selectedID); + geneSelection.setSelectedNode(arrayNode.getId()); + gtrview.setSelectedNode(arrayNode); + geneSelection.notifyObservers(); + + + leftTreeDrawer.notifyObservers(); + } + + + /** * 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. *************** *** 1146,1150 **** */ public void populateAnalysisMenu(Menu menu) { ! MenuItem flipNodeItem = new MenuItem("Flip Tree Node", new MenuShortcut(KeyEvent.VK_L)); flipNodeItem.addActionListener( new ActionListener() --- 1234,1238 ---- */ public void populateAnalysisMenu(Menu menu) { ! MenuItem flipNodeItem = new MenuItem("Flip Array Tree Node", new MenuShortcut(KeyEvent.VK_L)); flipNodeItem.addActionListener( new ActionListener() *************** *** 1152,1156 **** public void actionPerformed(ActionEvent ae) { ! flipSelectedATRNode(); } } --- 1240,1259 ---- public void actionPerformed(ActionEvent ae) { ! if (getGtrview().hasFocus()) ! flipSelectedGTRNode(); ! else ! flipSelectedATRNode(); ! } ! } ! ); ! menu.add(flipNodeItem); ! ! flipNodeItem = new MenuItem("Flip Gene Tree Node"); ! flipNodeItem.addActionListener( ! new ActionListener() ! { ! public void actionPerformed(ActionEvent ae) ! { ! flipSelectedGTRNode(); } } Index: DendrogramFactory.java =================================================================== RCS file: /cvsroot/jtreeview/LinkedView/src/edu/stanford/genetics/treeview/plugin/dendroview/DendrogramFactory.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** DendrogramFactory.java 9 Mar 2008 21:06:33 -0000 1.4 --- DendrogramFactory.java 23 Apr 2008 23:29:19 -0000 1.5 *************** *** 18,21 **** --- 18,22 ---- * @author aloksaldanha * + * * TODO To change the template for this generated type comment go to * Window - Preferences - Java - Code Style - Code Templates |