final static String clickto_options[][] = {
{ "Display Node Data", "display" }, { "Collapse/Uncollapse", "display" }, { "Root/Reroot", "display" },
{ "Sub/Super Tree", "display" }, { "Swap Descendants", "display" }, { "Colorize Subtree", "display" },
- { "Open Sequence Web", "nodisplay" }, { "Open Taxonomy Web", "nodisplay" }, { "Cut Subtree", "display" },
+ { "Open Sequence Web", "display" }, { "Open Taxonomy Web", "display" }, { "Cut Subtree", "display" },
{ "Copy Subtree", "display" }, { "Paste Subtree", "display" }, { "Delete Subtree/Node", "display" },
- { "Add New Node", "display" }, { "Edit Node Data", "display" }, { "Blast", "display" } };
+ { "Add New Node", "display" }, { "Edit Node Data", "display" }, { "Blast", "nodisplay" } };
// This option is selected in the dropdown
int default_clickto = Configuration.display_node_data;
// --------------
public final static boolean __SNAPSHOT_RELEASE = true; // TODO remove me
public final static boolean __SYNTH_LF = false; // TODO remove me
public final static String PRG_NAME = "Archaeopteryx";
- final static String VERSION = "0.962 beta B48";
- final static String PRG_DATE = "2011.05.27";
+ final static String VERSION = "0.962 beta 2N";
+ final static String PRG_DATE = "2011.09.17";
final static String DEFAULT_CONFIGURATION_FILE_NAME = "_aptx_configuration_file";
final static String[] DEFAULT_FONT_CHOICES = { "Verdana", "Tahoma",
"Arial", "Helvetica", "Dialog", "Lucida Sans", "SansSerif", "Sans-serif", "Sans" };
JMenuItem _midpoint_root_item;
JMenuItem _taxcolor_item;
JMenuItem _confcolor_item;
+ JMenuItem _color_rank_jmi;
JMenuItem _infer_common_sn_names_item;
JMenuItem _collapse_species_specific_subtrees;
JMenuItem _collapse_below_threshold; //TODO implememt me
else if ( o == _confcolor_item ) {
confColor();
}
+ else if ( o == _color_rank_jmi ) {
+ colorRank();
+ }
else if ( o == _infer_common_sn_names_item ) {
if ( isSubtreeDisplayed() ) {
return;
}
}
+ void colorRank() {
+ if ( _mainpanel.getCurrentTreePanel() != null ) {
+ final String[] ranks = Util.getAllRanks( _mainpanel.getCurrentTreePanel().getPhylogeny() );
+ if ( ranks.length < 1 ) {
+ JOptionPane.showMessageDialog( this,
+ "No rank information was found",
+ "No Rank Inoformation",
+ JOptionPane.WARNING_MESSAGE );
+ return;
+ }
+ final String rank = ( String ) JOptionPane
+ .showInputDialog( this,
+ "What rank should the colorization be based on",
+ "Rank Selection",
+ JOptionPane.PLAIN_MESSAGE,
+ null,
+ ranks,
+ null );
+ if ( !ForesterUtil.isEmpty( rank ) ) {
+ _mainpanel.getCurrentTreePanel().colorRank( rank );
+ }
+ }
+ }
+
void customizeCheckBoxMenuItem( final JCheckBoxMenuItem item, final boolean is_selected ) {
if ( item != null ) {
item.setFont( MainFrame.menu_font );
_tools_menu = createMenu( "Tools", getConfiguration() );
_tools_menu.add( _confcolor_item = new JMenuItem( "Colorize Branches Depending on Confidence" ) );
customizeJMenuItem( _confcolor_item );
+ _tools_menu.add( _color_rank_jmi = new JMenuItem( "Colorize Subtrees via Taxonomic Rank" ) );
+ customizeJMenuItem( _color_rank_jmi );
+ _color_rank_jmi.setToolTipText( "for example, at \"Class\" level, colorize mammal specific subtree red" );
_tools_menu.add( _taxcolor_item = new JMenuItem( "Taxonomy Colorize Branches" ) );
customizeJMenuItem( _taxcolor_item );
_tools_menu.add( _remove_branch_color_item = new JMenuItem( "Delete Branch Colors" ) );
repaint();
}
+ final void colorRank( final String rank ) {
+ if ( ( _phylogeny == null ) || ( _phylogeny.getNumberOfExternalNodes() < 2 ) ) {
+ return;
+ }
+ setWaitCursor();
+ Util.colorPhylogenyAccordingToRanks( _phylogeny, rank, this );
+ _control_panel.setColorBranches( true );
+ if ( _control_panel.getColorBranchesCb() != null ) {
+ _control_panel.getColorBranchesCb().setSelected( true );
+ }
+ setArrowCursor();
+ repaint();
+ }
+
final private void copySubtree( final PhylogenyNode node ) {
if ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) {
errorMessageNoCutCopyPasteInUnrootedDisplay();
import java.util.List;
import java.util.Locale;
import java.util.Set;
+import java.util.SortedSet;
+import java.util.TreeSet;
import javax.imageio.IIOImage;
import javax.imageio.ImageIO;
}
}
+ final static void colorPhylogenyAccordingToRanks( final Phylogeny tree,
+ final String rank,
+ final TreePanel tree_panel ) {
+ 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<PhylogenyNode> descs = PhylogenyMethods.getAllDescendants( n );
+ for( final PhylogenyNode desc : descs ) {
+ desc.getBranchData().setBranchColor( c );
+ }
+ }
+ }
+ }
+
+ final static String[] getAllRanks( final Phylogeny tree ) {
+ final SortedSet<String> ranks = new TreeSet<String>();
+ for( final PhylogenyNodeIterator it = tree.iteratorPreorder(); it.hasNext(); ) {
+ final PhylogenyNode n = it.next();
+ if ( n.getNodeData().isHasTaxonomy() && !ForesterUtil.isEmpty( n.getNodeData().getTaxonomy().getRank() ) ) {
+ ranks.add( n.getNodeData().getTaxonomy().getRank() );
+ }
+ }
+ return ForesterUtil.stringSetToArray( ranks );
+ }
+
final static void colorPhylogenyAccordingToExternalTaxonomy( final Phylogeny tree, final TreePanel tree_panel ) {
for( final PhylogenyNodeIterator it = tree.iteratorPreorder(); it.hasNext(); ) {
it.next().getBranchData().setBranchColor( null );
private ForesterUtil() {
}
- public final static Phylogeny[] readPhylogenies( final PhylogenyParser parser, final File file ) throws IOException {
- final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
- final Phylogeny[] trees = factory.create( file, parser );
- if ( ( trees == null ) || ( trees.length == 0 ) ) {
- throw new PhylogenyParserException( "Unable to parse phylogeny from file: " + file );
- }
- return trees;
- }
-
final public static void appendSeparatorIfNotEmpty( final StringBuffer sb, final char separator ) {
if ( sb.length() > 0 ) {
sb.append( separator );
}
}
- final public static boolean isEmpty( final List<?> l ) {
- if ( ( l == null ) || l.isEmpty() ) {
- return true;
- }
- for( final Object o : l ) {
- if ( o != null ) {
- return false;
- }
- }
- return true;
- }
-
- final public static boolean isEmpty( final Set<?> s ) {
- if ( ( s == null ) || s.isEmpty() ) {
- return true;
- }
- for( final Object o : s ) {
- if ( o != null ) {
- return false;
- }
- }
- return true;
- }
-
/**
* This calculates a color. If value is equal to min the returned color is
* minColor, if value is equal to max the returned color is maxColor,
return true;
}
+ final public static boolean isContainsParanthesesableNhCharacter( final String nh ) {
+ return PARANTHESESABLE_NH_CHARS_PATTERN.matcher( nh ).find();
+ }
+
+ final public static boolean isEmpty( final List<?> l ) {
+ if ( ( l == null ) || l.isEmpty() ) {
+ return true;
+ }
+ for( final Object o : l ) {
+ if ( o != null ) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ final public static boolean isEmpty( final Set<?> s ) {
+ if ( ( s == null ) || s.isEmpty() ) {
+ return true;
+ }
+ for( final Object o : s ) {
+ if ( o != null ) {
+ return false;
+ }
+ }
+ return true;
+ }
+
final public static boolean isEmpty( final String s ) {
return ( ( s == null ) || ( s.length() < 1 ) );
}
System.out.println( "[" + prg_name + "] > " + message );
}
+ public final static Phylogeny[] readPhylogenies( final PhylogenyParser parser, final File file ) throws IOException {
+ final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
+ final Phylogeny[] trees = factory.create( file, parser );
+ if ( ( trees == null ) || ( trees.length == 0 ) ) {
+ throw new PhylogenyParserException( "Unable to parse phylogeny from file: " + file );
+ }
+ return trees;
+ }
+
final public static String removeSuffix( final String file_name ) {
final int i = file_name.lastIndexOf( '.' );
if ( i > 1 ) {
return s;
}
- final public static boolean isContainsParanthesesableNhCharacter( final String nh ) {
- return PARANTHESESABLE_NH_CHARS_PATTERN.matcher( nh ).find();
- }
-
final public static String replaceIllegalNhCharacters( final String nh ) {
if ( nh == null ) {
return "";
return ( int ) ( d + 0.5 );
}
- final public static short roundToShort( final double d ) {
- return ( short ) ( d + 0.5 );
- }
-
final public static int roundToInt( final float f ) {
return ( int ) ( f + 0.5f );
}
+ final public static short roundToShort( final double d ) {
+ return ( short ) ( d + 0.5 );
+ }
+
final public static String sanitizeString( final String s ) {
if ( s == null ) {
return "";
return sb.toString();
}
+ final public static String[] stringSetToArray( final Set<String> strings ) {
+ final String[] str_array = new String[ strings.size() ];
+ int i = 0;
+ for( final String e : strings ) {
+ str_array[ i++ ] = e;
+ }
+ return str_array;
+ }
+
final static public void transferInternalNamesToBootstrapSupport( final Phylogeny phy ) {
final PhylogenyNodeIterator it = phy.iteratorPostorder();
while ( it.hasNext() ) {