Re: [Jtreeview-users] Highlighting specific edges in JTV
Brought to you by:
alokito
|
From: Alok S. <al...@ca...> - 2007-02-13 23:21:50
|
Hi Itamar, First of all, you should look at this example: http://jtreeview.sourceforge.net/examples/index.html#ex5 You can probably achieve the display that you want by actually hard- coding the colors in the GTR (gene tree) file. For example, > NODEID LEFT RIGHT CORRELATION NODECOLOR > NODE1X GENE2268X GENE2269X 0.989404 #9900FF This indicates that the node named "NODE1X" which is formed by joining "GENE2268X" and "GENE2269X" should be colored "#9900FF" or bright purple. However, rather than preprocessing the GTR files and adding a column, you may want to add functionality to do this on the fly. The best way to do this is to write a plugin. I have written an example plugin that you should be able to read through as it is under 200 lines of code: https://sourceforge.net/docman/display_doc.php? docid=35149&group_id=84593 Your plugin shouldn't be too hard, depending on how exactly the coloring works. Here's one scheme that could work: 1) Write a class that extends PluginFactory. Look at the code for DataTableFactory from the example plugin to see how easy it can be. There are two ways you could make it work: 1a) The selection of the file and coloring of the tree can happen within dialogs triggered by restorePlugin, which would then return null, or 1b) restorePlugin returns a MainPanel that has a button that opens a file search dialog to locate the file with the color info, and a second button that loads it. The advantage of 1b is that you can then have a list of common presets, if there are particular sorts of colorings you use often 2) Your write a method either in the PluginFactory or MainPanel that gets called with two parameters, 1) the name of the file with the coloring info, and 2) The viewFrame reference that was passed in to restorePlugin. It loads up the coloring info, and then calls viewFrame.getDataModel().getGtrHeaderInfo() to get the HeaderInfo representing the headers for the gene tree. 3) Call HeaderInfo.getHeaderIndex("NODECOLOR") to see if column exists, if not call HeaderInfo.addName("NODECOLOR", getNumHeaders()), and check to make sure it returns true. 4) Traverse the gene tree headers to figure out which nodes to color what, and then call HeaderInfo.setHeader(nodeNumber, "NODECOLOR", "#9900FF"), with the appropriate node number and color of course. This may or may not work as planned... in particular, the updates from calling setHeader may not propagate all the way, as I don't have a plugin that works in quite this way yet. If you think it would be helpful, I could write up a quick test plugin that implements the above four steps and colors the nodes using a user-specified correlation threshold on the fly- i have been meaning to do this at some point anyways. I should also mention that you can get access to the state and data structures of the dendrogram (and in particular its in-memory tree of TreeDrawerNodes) by calling viewFrame.getMainPanelsByName ("Dendrogram"). it's straightforward, but a little more coding (although less coding than building your own tree of TreeDrawerNodes). All of the above only applies to the version of the code checked into CVS, there are a number of fixes made since the last release... in fact, I was planning to do a new release soon, since there are a few big problems in the last release. If there are any issues that need to be addressed for your plugin, it would be nice to do it before then. -Alok On Feb 13, 2007, at 12:53 PM, Itamar Cohen wrote: > Hi Alok, > > First of all, thanks for your response about height of subtrees, it > was very helpful. We have a project now in which we are trying to > highlight specific edges in a tree. I'm trying to alter the JTV > code so it would read a list of node pairs and would show these > edges in a different color. Could you suggest a simple way to > enable this? > > Thanks, > Itamar > > Live Search: New search found Try it! |