Hi - I have added a new GUI component to org.biojava.bio.gui called feature tree. It uses and inner class as its tree model and displays a database of sequences together with their features and annotations as a nested tree. The critical method for the tree is the setSequenceDB() method.
Here is an example of a Frame that renders the tree, add a main method and hey presto! import java.awt.*; import java.awt.event.*; import javax.swing.*; import org.biojava.bio.gui.*; import org.biojava.bio.*; import org.biojava.bio.seq.*; import org.biojava.bio.seq.impl.*; import org.biojava.bio.seq.db.*; import org.biojava.bio.symbol.*; public class TreeDemoFrame extends JFrame { JPanel contentPane; BorderLayout borderLayout1 = new BorderLayout(); JPanel jPanel1 = new JPanel(); JScrollPane jScrollPane1 = new JScrollPane(); FeatureTree featureTree1 = new FeatureTree(); BorderLayout borderLayout2 = new BorderLayout(); /**Construct the frame*/ public TreeDemoFrame() { enableEvents(AWTEvent.WINDOW_EVENT_MASK); try { jbInit(); } catch(Exception e) { e.printStackTrace(); } } /**Component initialization*/ private void jbInit() throws Exception { //setIconImage(Toolkit.getDefaultToolkit().createImage(TreeDemoFrame.cla ss.getResource("[Your Icon]"))); contentPane = (JPanel) this.getContentPane(); contentPane.setLayout(borderLayout1); this.setSize(new Dimension(400, 300)); this.setTitle("FeatureTreeDemo"); jPanel1.setLayout(borderLayout2); contentPane.add(jPanel1, BorderLayout.CENTER); jPanel1.add(jScrollPane1, BorderLayout.CENTER); jScrollPane1.getViewport().add(featureTree1, null); initializeTree(); } private void initializeTree() throws Exception{ SequenceDB db = new HashSequenceDB(); //make Annotations Annotation aa = new SimpleAnnotation(); aa.setProperty("date_submitted","28/6/00"); aa.setProperty("source","foo beast"); Annotation ab = new SimpleAnnotation(aa); ab.setProperty("vector", "pBar"); //make sequences Sequence sa = new SimpleSequence(DNATools.createDNA("accgggccccatcgacgctagc"), "","sequence a",aa); Sequence sb = new SimpleSequence(DNATools.createDNA("ttttacacaagagggaatannn"), "","sequence b",ab); //make features StrandedFeature.Template ft = new StrandedFeature.Template(); Annotation fa = new SimpleAnnotation(); fa.setProperty("algorithm","foobar"); fa.setProperty("score","0.01"); ft.annotation = fa; ft.location = new RangeLocation(4,14); ft.source = "foo_detector"; ft.strand = StrandedFeature.POSITIVE; ft.type = "foo motif"; Feature f = sa.createFeature(ft); ft = (StrandedFeature.Template)f.makeTemplate(); ft.annotation = Annotation.EMPTY_ANNOTATION; ft.location = new PointLocation(12); ft.source = ""; ft.strand = StrandedFeature.POSITIVE; ft.type = "key_residue"; f.createFeature(ft); db.addSequence(sa); db.addSequence(sb); featureTree1.setSequenceDB(db); } /**Overridden so we can exit when window is closed*/ protected void processWindowEvent(WindowEvent e) { super.processWindowEvent(e); if (e.getID() == WindowEvent.WINDOW_CLOSING) { System.exit(0); } } } Mark Schreiber Bioinformatics AgResearch Invermay PO Box 50034 Mosgiel New Zealand PH: +64 3 489 9175 FAX: +64 3 489 3739 ======================================================================= Attention: The information contained in this message and/or attachments from AgResearch Limited is intended only for the persons or entities to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipients is prohibited by AgResearch Limited. If you have received this message in error, please notify the sender immediately. ======================================================================= _______________________________________________ Biojava-l mailing list - [EMAIL PROTECTED] http://biojava.org/mailman/listinfo/biojava-l