@Override /** * Not a deep copy. * */ public PhylogenyData copy() { final BranchColor bc = new BranchColor(); bc.setValue( getValue() ); return bc; }
it.next().getBranchData().setBranchColor( new BranchColor( colors.get( "xx" ) ) );
@Override public PhylogenyData parse( final XmlElement element ) throws PhyloXmlDataFormatException { int red = 0; int green = 0; int blue = 0; for( int j = 0; j < element.getNumberOfChildElements(); ++j ) { final XmlElement c = element.getChildElement( j ); if ( c.getQualifiedName().equals( PhyloXmlMapping.COLOR_RED ) ) { red = c.getValueAsInt(); } else if ( c.getQualifiedName().equals( PhyloXmlMapping.COLOR_GREEN ) ) { green = c.getValueAsInt(); } else if ( c.getQualifiedName().equals( PhyloXmlMapping.COLOR_BLUE ) ) { blue = c.getValueAsInt(); } } final BranchColor color = new BranchColor(); color.setValue( new Color( red, green, blue ) ); return color; }
final PhylogenyNode n = it.next(); if ( colors.containsKey( n.getName() ) ) { n.getBranchData().setBranchColor( new BranchColor( colors.get( n.getName() ) ) );
public static void setBranchColorValue( final PhylogenyNode node, final Color color ) { if ( node.getBranchData().getBranchColor() == null ) { node.getBranchData().setBranchColor( new BranchColor() ); } node.getBranchData().getBranchColor().setValue( color ); }
final private void colorizeSubtree( final Color c, final PhylogenyNode node, final List<PhylogenyNode> additional_nodes ) { _control_panel.setColorBranches( true ); if ( _control_panel.getUseVisualStylesCb() != null ) { _control_panel.getUseVisualStylesCb().setSelected( true ); } if ( node != null ) { for( final PreorderTreeIterator it = new PreorderTreeIterator( node ); it.hasNext(); ) { it.next().getBranchData().setBranchColor( new BranchColor( c ) ); } } if ( additional_nodes != null ) { for( final PhylogenyNode an : additional_nodes ) { for( final PreorderTreeIterator it = new PreorderTreeIterator( an ); it.hasNext(); ) { it.next().getBranchData().setBranchColor( new BranchColor( c ) ); } } } repaint(); }
final static void colorPhylogenyAccordingToExternalTaxonomy( final Phylogeny tree, final TreePanel tree_panel ) { for( final PhylogenyNodeIterator it = tree.iteratorPreorder(); it.hasNext(); ) { it.next().getBranchData().setBranchColor( null ); } for( final PhylogenyNodeIterator it = tree.iteratorPreorder(); it.hasNext(); ) { final PhylogenyNode n = it.next(); if ( !n.getBranchData().isHasBranchColor() ) { final Taxonomy tax = PhylogenyMethods.getExternalDescendantsTaxonomy( n ); if ( tax != null ) { n.getBranchData().setBranchColor( new BranchColor( tree_panel.calculateTaxonomyBasedColor( tax ) ) ); final List<PhylogenyNode> descs = PhylogenyMethods.getAllDescendants( n ); for( final PhylogenyNode desc : descs ) { desc.getBranchData() .setBranchColor( new BranchColor( tree_panel.calculateTaxonomyBasedColor( tax ) ) ); } } } } }
if ( !ForesterUtil.isEmpty( n.getNodeData().getTaxonomy().getRank() ) && n.getNodeData().getTaxonomy().getRank().equalsIgnoreCase( rank ) ) { final BranchColor c = new BranchColor( tree_panel.calculateTaxonomyBasedColor( n.getNodeData() .getTaxonomy() ) ); TreePanelUtil.colorizeSubtree( n, c ); if ( true_lineage_to_color_map.containsKey( lin ) ) { TreePanelUtil .colorizeSubtree( node, new BranchColor( true_lineage_to_color_map.get( lin ) ) ); ++colorizations; success = true; && !ForesterUtil.isEmpty( lineage_to_rank_map.get( lin ) ) && lineage_to_rank_map.get( lin ).equalsIgnoreCase( rank ) ) { final BranchColor c = new BranchColor( tree_panel.calculateTaxonomyBasedColor( temp_tax ) ); TreePanelUtil.colorizeSubtree( node, c ); ++colorizations; lineage_to_rank_map.put( lin, up.getRank() ); if ( up.getRank().equalsIgnoreCase( rank ) ) { final BranchColor c = new BranchColor( tree_panel.calculateTaxonomyBasedColor( temp_tax ) ); TreePanelUtil.colorizeSubtree( node, c ); ++colorizations;
final static void colorPhylogenyAccordingToConfidenceValues( final Phylogeny tree, final TreePanel tree_panel ) { double max_conf = 0.0; for( final PhylogenyNodeIterator it = tree.iteratorPreorder(); it.hasNext(); ) { final PhylogenyNode n = it.next(); n.getBranchData().setBranchColor( null ); if ( n.getBranchData().isHasConfidences() ) { final double conf = PhylogenyMethods.getConfidenceValue( n ); if ( conf > max_conf ) { max_conf = conf; } } } if ( max_conf > 0.0 ) { final Color bg = tree_panel.getTreeColorSet().getBackgroundColor(); final Color br = tree_panel.getTreeColorSet().getBranchColor(); for( final PhylogenyNodeIterator it = tree.iteratorPreorder(); it.hasNext(); ) { final PhylogenyNode n = it.next(); if ( n.getBranchData().isHasConfidences() ) { final double conf = PhylogenyMethods.getConfidenceValue( n ); final BranchColor c = new BranchColor( ForesterUtil.calcColor( conf, 0.0, max_conf, bg, br ) ); TreePanelUtil.colorizeSubtree( n, c ); } } } }