edu.rit.compbio.phyl
Class TreeDrawing

java.lang.Object
  extended by edu.rit.compbio.phyl.TreeDrawing

public class TreeDrawing
extends Object

Class TreeDrawing provides an object that draws a picture of a phylogenetic tree. The tree is specified either as a DnaSequenceTree object or as a string in a subset of Newick Standard format.

Note: Class TreeDrawing is not multiple thread safe.

Newick Standard format. The subset of Newick Standard format class TreeDrawing supports is described by this BNF syntax. Nonterminal symbols are in italic font, terminal symbols are in typewriter font, | designates alternatives.

tree ::= node ;
node ::= ( childList ) nameLength
childList ::= child | child , childList
child ::= tip | node
tip ::= nameLength
nameLength ::= empty | name | : length | name : length
name ::= Any sequence of non-whitespace characters except ( ) , : ;
length ::= Floating point number, as in the Double.valueOf() method

This subset only supports non-quoted names with no whitespace; however, any underscore character _ in a name is replaced with a space character. The full Newick Standard format supports quoted names including whitespace. For further information about Newick Standard format, see:

Here is an example tree:

"(Gibbon:10,(Orangutan:8,(Gorilla:6,(Chimp:4,Human:4)))apes)primates;"

Here is the resulting drawing:


Nested Class Summary
static class TreeDrawing.SyntaxException
          Class TreeDrawing.SyntaxException is an exception thrown if there was a syntax error in a tree string.
 
Constructor Summary
TreeDrawing()
          Construct a new tree drawing object.
 
Method Summary
 void draw(DnaSequenceTree tree)
          Draw a picture of the given tree.
 void draw(DnaSequenceTree tree, Drawing dwg)
          Draw a picture of the given tree.
 void draw(DnaSequenceTree tree, Group group)
          Draw a picture of the given tree.
 void draw(String tree)
          Draw a picture of the given tree string.
 void draw(String tree, Drawing dwg)
          Draw a picture of the given tree string.
 void draw(String tree, Group group)
          Draw a picture of the given tree string.
 void setBranchLengthFormat(String format)
          Specify the format with which to draw branch lengths.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TreeDrawing

public TreeDrawing()
Construct a new tree drawing object.

Method Detail

setBranchLengthFormat

public void setBranchLengthFormat(String format)
Specify the format with which to draw branch lengths. The format string is used to construct a java.text.DecimalFormat object. If not specified, the default format string is "0.00".

Parameters:
format - Format string.

draw

public void draw(DnaSequenceTree tree)
Draw a picture of the given tree. The picture is added to the default Drawing object.

Parameters:
tree - DNA sequence tree.

draw

public void draw(DnaSequenceTree tree,
                 Drawing dwg)
Draw a picture of the given tree. The picture is added to the given Drawing object.

Parameters:
tree - DNA sequence tree.
dwg - Drawing object.

draw

public void draw(DnaSequenceTree tree,
                 Group group)
Draw a picture of the given tree. The picture is added to the given Group object.

Parameters:
tree - DNA sequence tree.
group - Drawing group object.

draw

public void draw(String tree)
          throws TreeDrawing.SyntaxException
Draw a picture of the given tree string. The picture is added to the default Drawing object.

Parameters:
tree - Tree as a string in Newick Standard format.
Throws:
TreeDrawing.SyntaxException - Thrown if there was a syntax error in tree.

draw

public void draw(String tree,
                 Drawing dwg)
          throws TreeDrawing.SyntaxException
Draw a picture of the given tree string. The picture is added to the given Drawing object.

Parameters:
tree - Tree as a string in Newick Standard format.
dwg - Drawing object.
Throws:
TreeDrawing.SyntaxException - Thrown if there was a syntax error in tree.

draw

public void draw(String tree,
                 Group group)
          throws TreeDrawing.SyntaxException
Draw a picture of the given tree string. The picture is added to the given Group object.

Parameters:
tree - Tree as a string in Newick Standard format.
group - Drawing group object.
Throws:
TreeDrawing.SyntaxException - Thrown if there was a syntax error in tree.


Copyright © 2005-2012 by Alan Kaminsky. All rights reserved. Send comments to ark­@­cs.rit.edu.