From: cmzmasek@gmail.com Date: Mon, 19 Sep 2011 22:24:29 +0000 (+0000) Subject: colors X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=25154700d0f00e9b949edd56762415743c191bc7;p=jalview.git colors --- diff --git a/forester/java/src/org/forester/archaeopteryx/MainFrame.java b/forester/java/src/org/forester/archaeopteryx/MainFrame.java index 0e8f328..1c67316 100644 --- a/forester/java/src/org/forester/archaeopteryx/MainFrame.java +++ b/forester/java/src/org/forester/archaeopteryx/MainFrame.java @@ -649,7 +649,7 @@ public abstract class MainFrame extends JFrame implements ActionListener { if ( ranks.length < 1 ) { JOptionPane.showMessageDialog( this, "No rank information was found", - "No Rank Inoformation", + "No Rank Information", JOptionPane.WARNING_MESSAGE ); return; } @@ -657,7 +657,7 @@ public abstract class MainFrame extends JFrame implements ActionListener { .showInputDialog( this, "What rank should the colorization be based on", "Rank Selection", - JOptionPane.PLAIN_MESSAGE, + JOptionPane.QUESTION_MESSAGE, null, ranks, null ); diff --git a/forester/java/src/org/forester/archaeopteryx/Util.java b/forester/java/src/org/forester/archaeopteryx/Util.java index 05823d0..daceb3e 100644 --- a/forester/java/src/org/forester/archaeopteryx/Util.java +++ b/forester/java/src/org/forester/archaeopteryx/Util.java @@ -41,9 +41,11 @@ import java.net.URI; import java.net.URL; import java.text.ParseException; import java.util.Arrays; +import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Locale; +import java.util.Map; import java.util.Set; import java.util.SortedSet; import java.util.TreeSet; @@ -293,20 +295,43 @@ public final class Util { final static void colorPhylogenyAccordingToRanks( final Phylogeny tree, final String rank, final TreePanel tree_panel ) { + final Map m = new HashMap(); for( final PhylogenyNodeIterator it = tree.iteratorPostorder(); it.hasNext(); ) { final PhylogenyNode n = it.next(); if ( n.getNodeData().isHasTaxonomy() - && ( !ForesterUtil.isEmpty( n.getNodeData().getTaxonomy().getRank() ) && n.getNodeData() - .getTaxonomy().getRank().equalsIgnoreCase( rank ) ) && ( !ForesterUtil.isEmpty( n.getNodeData().getTaxonomy().getScientificName() ) || !ForesterUtil.isEmpty( n.getNodeData().getTaxonomy().getCommonName() ) || !ForesterUtil .isEmpty( n.getNodeData().getTaxonomy().getTaxonomyCode() ) ) ) { - final BranchColor c = new BranchColor( tree_panel.calculateTaxonomyBasedColor( n.getNodeData() - .getTaxonomy() ) ); - n.getBranchData().setBranchColor( c ); - final List descs = PhylogenyMethods.getAllDescendants( n ); - for( final PhylogenyNode desc : descs ) { - desc.getBranchData().setBranchColor( c ); + if ( !ForesterUtil.isEmpty( n.getNodeData().getTaxonomy().getRank() ) + && n.getNodeData().getTaxonomy().getRank().equalsIgnoreCase( rank ) ) { + final BranchColor c = new BranchColor( tree_panel.calculateTaxonomyBasedColor( n.getNodeData() + .getTaxonomy() ) ); + n.getBranchData().setBranchColor( c ); + final List descs = PhylogenyMethods.getAllDescendants( n ); + for( final PhylogenyNode desc : descs ) { + desc.getBranchData().setBranchColor( c ); + } + if ( !ForesterUtil.isEmpty( n.getNodeData().getTaxonomy().getScientificName() ) ) { + m.put( n.getNodeData().getTaxonomy().getScientificName(), c.getValue() ); + } + } + } + } + if ( !m.isEmpty() ) { + for( final PhylogenyNodeIterator it = tree.iteratorPostorder(); it.hasNext(); ) { + final PhylogenyNode n = it.next(); + if ( ( n.getBranchData().getBranchColor() == null ) && n.getNodeData().isHasTaxonomy() + && !ForesterUtil.isEmpty( n.getNodeData().getTaxonomy().getLineage() ) ) { + for( final String lin : n.getNodeData().getTaxonomy().getLineage() ) { + if ( m.containsKey( lin ) ) { + final BranchColor c = new BranchColor( m.get( lin ) ); + n.getBranchData().setBranchColor( c ); + final List descs = PhylogenyMethods.getAllDescendants( n ); + for( final PhylogenyNode desc : descs ) { + desc.getBranchData().setBranchColor( c ); + } + } + } } } }