@Override /** * Not a deep copy. * */ public PhylogenyData copy() { final BranchColor bc = new BranchColor(); bc.setValue( getValue() ); return bc; }
@Override public String toString() { return asText().toString(); } }
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 ); }
it.next().getBranchData().setBranchColor( new BranchColor( colors.get( "xx" ) ) );
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 ); ++colorizations; if ( !ForesterUtil.isEmpty( n.getNodeData().getTaxonomy().getScientificName() ) ) { true_lineage_to_color_map.put( n.getNodeData().getTaxonomy().getScientificName(), c.getValue() ); 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; true_lineage_to_color_map.put( lin, c.getValue() ); break; 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; true_lineage_to_color_map.put( lin, c.getValue() );
@Override public void toPhyloXML( final Writer writer, final int level, final String indentation ) throws IOException { if ( isHasConfidences() ) { for( final Confidence confidence : getConfidences() ) { confidence.toPhyloXML( writer, level, indentation ); } } if ( isHasBranchWidth() ) { getBranchWidth().toPhyloXML( writer, level, indentation ); } if ( isHasBranchColor() ) { getBranchColor().toPhyloXML( writer, level, indentation ); } } }
@Override public PhylogenyData copy() { final BranchData new_bd = new BranchData(); if ( isHasBranchColor() ) { new_bd.setBranchColor( ( BranchColor ) getBranchColor().copy() ); } if ( isHasBranchWidth() ) { new_bd.setBranchWidth( ( BranchWidth ) getBranchWidth().copy() ); } if ( isHasConfidences() ) { for( final Confidence confidence : getConfidences() ) { new_bd.addConfidence( ( Confidence ) confidence.copy() ); } } return new_bd; }
@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; }
@Override public StringBuffer asText() { return new StringBuffer( getValue().toString() ); }
final PhylogenyNode n = it.next(); if ( colors.containsKey( n.getName() ) ) { n.getBranchData().setBranchColor( new BranchColor( colors.get( n.getName() ) ) );
@Override public StringBuffer asSimpleText() { return new StringBuffer( getValue().toString() ); }
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(); }
@Override public void toPhyloXML( final Writer writer, final int level, final String indentation ) throws IOException { writer.write( ForesterUtil.LINE_SEPARATOR ); writer.write( indentation ); PhylogenyDataUtil.appendOpen( writer, PhyloXmlMapping.COLOR ); PhylogenyDataUtil.appendElement( writer, PhyloXmlMapping.COLOR_RED, getValue().getRed() + "", indentation ); PhylogenyDataUtil.appendElement( writer, PhyloXmlMapping.COLOR_GREEN, getValue().getGreen() + "", indentation ); PhylogenyDataUtil.appendElement( writer, PhyloXmlMapping.COLOR_BLUE, getValue().getBlue() + "", indentation ); writer.write( ForesterUtil.LINE_SEPARATOR ); writer.write( indentation ); PhylogenyDataUtil.appendClose( writer, PhyloXmlMapping.COLOR ); }
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 ) ) ); } } } } }
/** * * Convenience method * * @param node * @return */ public static Color getBranchColorValue( final PhylogenyNode node ) { if ( node.getBranchData().getBranchColor() == null ) { return null; } return node.getBranchData().getBranchColor().getValue(); }
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 ); } } } }
final Color c = phylogeny_node.getBranchData().getBranchColor().getValue(); addSubelement( category, NODE_BRANCH_COLOR, c.getRed() + ", " + c.getGreen() + ", " + c.getBlue() );