}
}
+ final static void removeVisualStyles( final Phylogeny phy ) {
+ for( final PhylogenyNodeIterator it = phy.iteratorPreorder(); it.hasNext(); ) {
+ it.next().getNodeData().setNodeVisualData( null );
+ }
+ }
+
final static void unexpectedError( final Error e ) {
System.err.println();
e.printStackTrace( System.err );
private JMenuItem _phyloxml_ref_item;
private JMenuItem _aptx_ref_item;
private JMenuItem _remove_branch_color_item;
+ private JMenuItem _remove_visual_styles_item;
private JCheckBoxMenuItem _show_domain_labels;
private JCheckBoxMenuItem _show_annotation_ref_source;
private JCheckBoxMenuItem _color_labels_same_as_parent_branch;
else if ( o == _remove_branch_color_item ) {
removeBranchColors();
}
+ else if ( o == _remove_visual_styles_item ) {
+ removeVisualStyles();
+ }
else if ( o == _switch_colors_mi ) {
switchColors();
}
customizeJMenuItem( _confcolor_item );
_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" ) );
- _remove_branch_color_item.setToolTipText( "To delete branch color values from the current phylogeny." );
+ _tools_menu.addSeparator();
+ _tools_menu.add( _remove_visual_styles_item = new JMenuItem( "Delete All Visual Styles From Nodes" ) );
+ _remove_visual_styles_item
+ .setToolTipText( "To remove all node visual styles (fonts, colors) from the current phylogeny." );
+ customizeJMenuItem( _remove_visual_styles_item );
+ _tools_menu.add( _remove_branch_color_item = new JMenuItem( "Delete All Colors From Branches" ) );
+ _remove_branch_color_item.setToolTipText( "To remove all branch color values from the current phylogeny." );
customizeJMenuItem( _remove_branch_color_item );
_tools_menu.addSeparator();
_tools_menu.add( _midpoint_root_item = new JMenuItem( "Midpoint-Root" ) );
}
}
+ private void removeVisualStyles() {
+ if ( getMainPanel().getCurrentPhylogeny() != null ) {
+ AptxUtil.removeVisualStyles( getMainPanel().getCurrentPhylogeny() );
+ }
+ }
+
private void setMainPanel( final MainPanelApplets main_panel ) {
_mainpanel = main_panel;
}
final static String clickto_options[][] = {
{ "Display Node Data", "display" }, { "Collapse/Uncollapse", "display" }, { "Root/Reroot", "display" },
- { "Sub/Super Tree", "display" }, { "Swap Descendants", "display" }, { "Colorize Subtree(s)", "display" },
- { "Colorize Node(s)", "display" }, { "Change Node Font", "display" }, { "Open Sequence DB", "display" },
- { "Go to PDB", "display" }, { "Open Taxonomy DB", "display" }, { "Blast", "display" },
- { "Cut Subtree", "display" }, { "Copy Subtree", "display" }, { "Paste Subtree", "display" },
- { "Delete Subtree/Node", "display" }, { "Add New Node", "display" }, { "Edit Node Data", "display" },
- { "Sort Descendants", "display" }, { "Return", "display" }, { "Select Node(s)", "display" } };
+ { "Go to Sub-/Super-Tree", "display" }, { "Swap Descendants", "display" },
+ { "Colorize Node(s)", "display" }, { "Change Node Font(s)", "display" },
+ { "Colorize Subtree(s)", "display" }, { "Open Sequence DB", "display" }, { "Open PDB", "display" },
+ { "Open Taxonomy DB", "display" }, { "Launch BLAST", "display" }, { "Cut Subtree", "display" },
+ { "Copy Subtree", "display" }, { "Paste Subtree", "display" }, { "Delete Subtree/Node", "display" },
+ { "Add New Node", "display" }, { "Edit Node Data", "display" }, { "Sort Descendants", "display" },
+ { "Return", "display" }, { "Select Node(s)", "display" } };
final static int display_node_data = 0;
final static int collapse_uncollapse = 1;
final static int reroot = 2;
final static int subtree = 3;
final static int swap = 4;
- final static int color_subtree = 5;
- final static int color_node_font = 6;
- final static int change_node_font = 7;
+ final static int color_node_font = 5;
+ final static int change_node_font = 6;
+ final static int color_subtree = 7;
final static int open_seq_web = 8;
final static int open_pdb_web = 9;
final static int open_tax_web = 10;
{ "Phylogram", "display", "?" }, { "Node Name", "display", "yes" }, { "Taxonomy Code", "display", "yes" },
{ "Seq Annotations", "nodisplay", "no" }, { "Confidence Values", "display", "?" },
{ "Node Events", "display", "?" }, { "Colorize by Taxonomy", "display", "no" },
- { "Use Visual Styles", "display", "no" }, { "Use Branch Widths", "display", "no" },
+ { "Visual Styles/Branch Colors", "display", "no" }, { "Branch Widths", "display", "no" },
{ "Show Custom Nodes", "display", "yes" }, { "Protein Domains", "nodisplay", "no" },
{ "Binary Characters", "nodisplay", "no" }, { "Binary Char Counts", "nodisplay", "no" },
{ "Seq Name", "display", "yes" }, { "Seq Accession", "display", "no" },
break;
case Configuration.use_style:
_use_visual_styles_cb = new JCheckBox( title );
- getUseVisualStylesCb().setToolTipText( "To use visual styles (colors, fonts), if present" );
+ getUseVisualStylesCb()
+ .setToolTipText( "To use visual styles (node colors, fonts) and branch colors, if present" );
addJCheckBox( getUseVisualStylesCb(), ch_panel );
add( ch_panel );
break;
}
cb_index++;
}
- if ( _configuration.doDisplayClickToOption( Configuration.color_subtree ) ) {
- _color_subtree_cb_item = cb_index;
- addClickToOption( Configuration.color_subtree, _configuration.getClickToTitle( Configuration.color_subtree ) );
- if ( default_option == Configuration.color_subtree ) {
- selected_index = cb_index;
- }
- cb_index++;
- }
if ( _configuration.doDisplayClickToOption( Configuration.color_node_font ) ) {
_color_node_font_item = cb_index;
addClickToOption( Configuration.color_node_font,
}
cb_index++;
}
+ if ( _configuration.doDisplayClickToOption( Configuration.color_subtree ) ) {
+ _color_subtree_cb_item = cb_index;
+ addClickToOption( Configuration.color_subtree, _configuration.getClickToTitle( Configuration.color_subtree ) );
+ if ( default_option == Configuration.color_subtree ) {
+ selected_index = cb_index;
+ }
+ cb_index++;
+ }
if ( _configuration.doDisplayClickToOption( Configuration.open_seq_web ) ) {
_open_seq_web_item = cb_index;
addClickToOption( Configuration.open_seq_web, _configuration.getClickToTitle( Configuration.open_seq_web ) );
JMenuItem _move_node_names_to_seq_names_jmi;
JMenuItem _extract_tax_code_from_node_names_jmi;
JMenuItem _annotate_item;
+ JMenuItem _remove_branch_color_item;
+ JMenuItem _remove_visual_styles_item;
// font size menu:
JMenuItem _super_tiny_fonts_item;
JMenuItem _tiny_fonts_item;
Container _contentpane;
final LinkedList<TextFrame> _textframes = new LinkedList<TextFrame>(); ;
Configuration _configuration;
- JMenuItem _remove_branch_color_item;
Options _options;
private Phylogeny _species_tree;
InferenceManager _inference_manager;
}
removeBranchColors();
}
+ else if ( o == _remove_visual_styles_item ) {
+ if ( isSubtreeDisplayed() ) {
+ return;
+ }
+ removeVisualStyles();
+ }
else if ( o == _midpoint_root_item ) {
if ( isSubtreeDisplayed() ) {
return;
}
}
+ private void removeVisualStyles() {
+ if ( getMainPanel().getCurrentPhylogeny() != null ) {
+ AptxUtil.removeVisualStyles( getMainPanel().getCurrentPhylogeny() );
+ }
+ }
+
private void setPreviousNodeAnnotationReference( final String previous_node_annotation_ref ) {
_previous_node_annotation_ref = previous_node_annotation_ref;
}
static void setTextColorChooseMenuItem( final JMenuItem mi, final TreePanel tree_panel ) {
if ( ( tree_panel != null ) && ( tree_panel.getTreeColorSet() != null ) ) {
- mi.setText( "Select Colors... (current: " + tree_panel.getTreeColorSet().getCurrentColorSchemeName() + ")" );
+ mi.setText( "Select Color Scheme... (current: " + tree_panel.getTreeColorSet().getCurrentColorSchemeName()
+ + ")" );
}
else {
- mi.setText( "Select Colors..." );
+ mi.setText( "Select Color Scheme..." );
}
}
static void setTextForFontChooserMenuItem( final JMenuItem mi, final String font_desc ) {
- mi.setText( "Select Font... (current: " + font_desc + ")" );
+ mi.setText( "Select Default Font... (current: " + font_desc + ")" );
}
static void setTextMinSupportMenuItem( final JMenuItem mi, final Options options, final TreePanel current_tree_panel ) {
customizeJMenuItem( _confcolor_item );
_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" ) );
- _remove_branch_color_item.setToolTipText( "To delete branch color values from the current phylogeny." );
+ _tools_menu.addSeparator();
+ _tools_menu.add( _remove_visual_styles_item = new JMenuItem( "Delete All Visual Styles From Nodes" ) );
+ _remove_visual_styles_item
+ .setToolTipText( "To remove all node visual styles (fonts, colors) from the current phylogeny." );
+ customizeJMenuItem( _remove_visual_styles_item );
+ _tools_menu.add( _remove_branch_color_item = new JMenuItem( "Delete All Colors From Branches" ) );
+ _remove_branch_color_item.setToolTipText( "To remove all branch color values from the current phylogeny." );
customizeJMenuItem( _remove_branch_color_item );
_tools_menu.addSeparator();
_tools_menu.add( _midpoint_root_item = new JMenuItem( "Midpoint-Root" ) );
_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" ) );
- _remove_branch_color_item.setToolTipText( "To delete branch color values from the current phylogeny" );
+ _tools_menu.addSeparator();
+ _tools_menu.add( _remove_visual_styles_item = new JMenuItem( "Delete All Visual Styles From Nodes" ) );
+ _remove_visual_styles_item
+ .setToolTipText( "To remove all node visual styles (fonts, colors) from the current phylogeny." );
+ customizeJMenuItem( _remove_visual_styles_item );
+ _tools_menu.add( _remove_branch_color_item = new JMenuItem( "Delete All Colors From Branches" ) );
+ _remove_branch_color_item.setToolTipText( "To remove all branch color values from the current phylogeny." );
customizeJMenuItem( _remove_branch_color_item );
_tools_menu.addSeparator();
_tools_menu.add( _annotate_item = new JMenuItem( "Annotate Sequences of Selected Nodes" ) );
if ( node.isCollapse() ) {
continue;
}
- if ( getControlPanel().isShowNodeNames() ) {
- sum += getFontMetricsForLargeDefaultFont().stringWidth( node.getName() + " " );
- }
- if ( node.getNodeData().isHasSequence() ) {
- if ( getControlPanel().isShowSequenceAcc()
- && ( node.getNodeData().getSequence().getAccession() != null ) ) {
- sum += getFontMetricsForLargeDefaultFont().stringWidth( node.getNodeData().getSequence()
- .getAccession().getValue()
- + " " );
- }
- if ( getControlPanel().isShowSeqNames() && ( node.getNodeData().getSequence().getName().length() > 0 ) ) {
- sum += getFontMetricsForLargeDefaultFont().stringWidth( node.getNodeData().getSequence().getName()
- + " " );
- }
- if ( getControlPanel().isShowSeqSymbols()
- && ( node.getNodeData().getSequence().getSymbol().length() > 0 ) ) {
- sum += getFontMetricsForLargeDefaultFont().stringWidth( node.getNodeData().getSequence()
- .getSymbol()
- + " " );
- }
- if ( getControlPanel().isShowGeneNames()
- && ( node.getNodeData().getSequence().getGeneName().length() > 0 ) ) {
- sum += getFontMetricsForLargeDefaultFont().stringWidth( node.getNodeData().getSequence()
- .getGeneName()
- + " " );
- }
- if ( getControlPanel().isShowAnnotation()
- && ( node.getNodeData().getSequence().getAnnotations() != null )
- && !node.getNodeData().getSequence().getAnnotations().isEmpty() ) {
- sum += getFontMetricsForLargeDefaultFont().stringWidth( TreePanelUtil.createAnnotationString( node
- .getNodeData().getSequence().getAnnotations(), getOptions().isShowAnnotationRefSource() )
- + " " );
- }
- if ( getControlPanel().isShowDomainArchitectures()
- && ( node.getNodeData().getSequence().getDomainArchitecture() != null ) ) {
- sum += ( ( RenderableDomainArchitecture ) node.getNodeData().getSequence().getDomainArchitecture() )
- .getRenderingSize().getWidth();
- }
- }
+ final StringBuilder sb = new StringBuilder();
+ nodeDataAsSB( node, sb );
if ( node.getNodeData().isHasTaxonomy() ) {
- final Taxonomy tax = node.getNodeData().getTaxonomy();
- if ( getControlPanel().isShowTaxonomyCode() && !ForesterUtil.isEmpty( tax.getTaxonomyCode() ) ) {
- sum += getFontMetricsForLargeDefaultFont().stringWidth( tax.getTaxonomyCode() + " " );
- }
- if ( getControlPanel().isShowTaxonomyScientificNames()
- && !ForesterUtil.isEmpty( tax.getScientificName() ) ) {
- sum += getFontMetricsForLargeDefaultFont().stringWidth( tax.getScientificName() + " " );
- }
- if ( getControlPanel().isShowTaxonomyCommonNames() && !ForesterUtil.isEmpty( tax.getCommonName() ) ) {
- sum += getFontMetricsForLargeDefaultFont().stringWidth( tax.getCommonName() + " ()" );
- }
+ nodeTaxonomyDataAsSB( node.getNodeData().getTaxonomy(), sb );
+ }
+ boolean use_vis = false;
+ final Graphics2D g = ( Graphics2D ) getGraphics();
+ if ( getControlPanel().isUseVisualStyles() ) {
+ use_vis = setFont( g, node, false );
+ }
+ if ( !use_vis ) {
+ sum = getFontMetricsForLargeDefaultFont().stringWidth( sb.toString() );
}
- if ( getControlPanel().isShowProperties() && node.getNodeData().isHasProperties() ) {
- sum += getFontMetricsForLargeDefaultFont().stringWidth( propertiesToString( node ).toString() );
+ else {
+ sum = getFontMetrics( g.getFont() ).stringWidth( sb.toString() );
}
if ( getControlPanel().isShowBinaryCharacters() && node.getNodeData().isHasBinaryCharacters() ) {
sum += getFontMetricsForLargeDefaultFont().stringWidth( node.getNodeData().getBinaryCharacters()
}
}
- private void abbreviateScientificName( final String sn ) {
+ private void abbreviateScientificName( final String sn, final StringBuilder sb ) {
final String[] a = sn.split( "\\s+" );
- _sb.append( a[ 0 ].substring( 0, 1 ) );
- _sb.append( a[ 1 ].substring( 0, 2 ) );
+ sb.append( a[ 0 ].substring( 0, 1 ) );
+ sb.append( a[ 1 ].substring( 0, 2 ) );
if ( a.length > 2 ) {
for( int i = 2; i < a.length; i++ ) {
- _sb.append( " " );
- _sb.append( a[ i ] );
+ sb.append( " " );
+ sb.append( a[ i ] );
}
}
}
g.fill( _ellipse );
}
- final private void drawOvalGradient( final double x,
- final double y,
- final double width,
- final double heigth,
+ final private void drawOvalGradient( final float x,
+ final float y,
+ final float width,
+ final float heigth,
final Graphics2D g,
final Color color_1,
final Color color_2,
final Color color_border ) {
_ellipse.setFrame( x, y, width, heigth );
- g.setPaint( new GradientPaint( ( float ) x,
- ( float ) y,
- color_1,
- ( float ) ( x + width ),
- ( float ) ( y + heigth ),
- color_2,
- false ) );
+ g.setPaint( new GradientPaint( x, y, color_1, ( x + width ), ( y + heigth ), color_2, false ) );
g.fill( _ellipse );
if ( color_border != null ) {
g.setPaint( color_border );
g.fill( _rectangle );
}
- final private void drawRectGradient( final double x,
- final double y,
- final double width,
- final double heigth,
+ final private void drawRectGradient( final float x,
+ final float y,
+ final float width,
+ final float heigth,
final Graphics2D g,
final Color color_1,
final Color color_2,
final Color color_border ) {
_rectangle.setFrame( x, y, width, heigth );
- g.setPaint( new GradientPaint( ( float ) x,
- ( float ) y,
- color_1,
- ( float ) ( x + width ),
- ( float ) ( y + heigth ),
- color_2,
- false ) );
+ g.setPaint( new GradientPaint( x, y, color_1, ( x + width ), ( y + heigth ), color_2, false ) );
g.fill( _rectangle );
if ( color_border != null ) {
g.setPaint( color_border );
}
}
+ private final void nodeDataAsSB( final PhylogenyNode node, final StringBuilder sb ) {
+ if ( getControlPanel().isShowNodeNames() && ( node.getName().length() > 0 ) ) {
+ if ( sb.length() > 0 ) {
+ sb.append( " " );
+ }
+ sb.append( node.getName() );
+ }
+ if ( node.getNodeData().isHasSequence() ) {
+ if ( getControlPanel().isShowSeqSymbols() && ( node.getNodeData().getSequence().getSymbol().length() > 0 ) ) {
+ if ( sb.length() > 0 ) {
+ sb.append( " " );
+ }
+ sb.append( node.getNodeData().getSequence().getSymbol() );
+ }
+ if ( getControlPanel().isShowGeneNames() && ( node.getNodeData().getSequence().getGeneName().length() > 0 ) ) {
+ if ( sb.length() > 0 ) {
+ sb.append( " " );
+ }
+ sb.append( node.getNodeData().getSequence().getGeneName() );
+ }
+ if ( getControlPanel().isShowSeqNames() && ( node.getNodeData().getSequence().getName().length() > 0 ) ) {
+ if ( sb.length() > 0 ) {
+ sb.append( " " );
+ }
+ sb.append( node.getNodeData().getSequence().getName() );
+ }
+ if ( getControlPanel().isShowSequenceAcc() && ( node.getNodeData().getSequence().getAccession() != null ) ) {
+ if ( sb.length() > 0 ) {
+ sb.append( " " );
+ }
+ if ( !ForesterUtil.isEmpty( node.getNodeData().getSequence().getAccession().getSource() ) ) {
+ sb.append( node.getNodeData().getSequence().getAccession().getSource() );
+ sb.append( ":" );
+ }
+ sb.append( node.getNodeData().getSequence().getAccession().getValue() );
+ }
+ }
+ if ( getControlPanel().isShowProperties() && node.getNodeData().isHasProperties() ) {
+ if ( sb.length() > 0 ) {
+ sb.append( " " );
+ }
+ sb.append( propertiesToString( node ) );
+ }
+ }
+
+ private final void nodeTaxonomyDataAsSB( final Taxonomy taxonomy, final StringBuilder sb ) {
+ if ( _control_panel.isShowTaxonomyCode() && !ForesterUtil.isEmpty( taxonomy.getTaxonomyCode() ) ) {
+ sb.append( taxonomy.getTaxonomyCode() );
+ sb.append( " " );
+ }
+ if ( _control_panel.isShowTaxonomyScientificNames() && _control_panel.isShowTaxonomyCommonNames() ) {
+ if ( !ForesterUtil.isEmpty( taxonomy.getScientificName() )
+ && !ForesterUtil.isEmpty( taxonomy.getCommonName() ) ) {
+ if ( getOptions().isAbbreviateScientificTaxonNames()
+ && ( taxonomy.getScientificName().indexOf( ' ' ) > 0 ) ) {
+ abbreviateScientificName( taxonomy.getScientificName(), sb );
+ }
+ else {
+ sb.append( taxonomy.getScientificName() );
+ }
+ sb.append( " (" );
+ sb.append( taxonomy.getCommonName() );
+ sb.append( ") " );
+ }
+ else if ( !ForesterUtil.isEmpty( taxonomy.getScientificName() ) ) {
+ if ( getOptions().isAbbreviateScientificTaxonNames()
+ && ( taxonomy.getScientificName().indexOf( ' ' ) > 0 ) ) {
+ abbreviateScientificName( taxonomy.getScientificName(), sb );
+ }
+ else {
+ sb.append( taxonomy.getScientificName() );
+ }
+ sb.append( " " );
+ }
+ else if ( !ForesterUtil.isEmpty( taxonomy.getCommonName() ) ) {
+ sb.append( taxonomy.getCommonName() );
+ sb.append( " " );
+ }
+ }
+ else if ( _control_panel.isShowTaxonomyScientificNames() ) {
+ if ( !ForesterUtil.isEmpty( taxonomy.getScientificName() ) ) {
+ if ( getOptions().isAbbreviateScientificTaxonNames()
+ && ( taxonomy.getScientificName().indexOf( ' ' ) > 0 ) ) {
+ abbreviateScientificName( taxonomy.getScientificName(), sb );
+ }
+ else {
+ sb.append( taxonomy.getScientificName() );
+ }
+ sb.append( " " );
+ }
+ }
+ else if ( _control_panel.isShowTaxonomyCommonNames() ) {
+ if ( !ForesterUtil.isEmpty( taxonomy.getCommonName() ) ) {
+ sb.append( taxonomy.getCommonName() );
+ sb.append( " " );
+ }
+ }
+ }
+
private final String obtainTitleForExtDescNodeData() {
switch ( getOptions().getExtDescNodeDataToReturn() ) {
case NODE_NAME:
* @param node
* @param g
*/
- final private void paintNodeBox( final double x,
- final double y,
+ final private void paintNodeBox( final float x,
+ final float y,
final PhylogenyNode node,
final Graphics2D g,
final boolean to_pdf,
if ( ( isInFoundNodes( node ) || isInCurrentExternalNodes( node ) )
|| ( getOptions().isShowDefaultNodeShapesExternal() && node.isExternal() )
|| ( getOptions().isShowDefaultNodeShapesInternal() && node.isInternal() )
+ || ( getControlPanel().isUseVisualStyles() && ( ( node.getNodeData().getNodeVisualData() != null ) && ( ( node
+ .getNodeData().getNodeVisualData().getNodeColor() != null )
+ || ( node.getNodeData().getNodeVisualData().getSize() != NodeVisualData.DEFAULT_SIZE )
+ || ( node.getNodeData().getNodeVisualData().getFillType() != NodeFill.DEFAULT ) || ( node
+ .getNodeData().getNodeVisualData().getShape() != NodeShape.DEFAULT ) ) ) )
|| ( getControlPanel().isEvents() && node.isHasAssignedEvent() && ( node.getNodeData().getEvent()
.isDuplication()
|| node.getNodeData().getEvent().isSpeciation() || node.getNodeData().getEvent()
.isSpeciationOrDuplication() ) ) ) {
- final double box_size = getOptions().getDefaultNodeShapeSize();
- final double half_box_size = box_size / 2.0;
+ NodeVisualData vis = null;
+ if ( getControlPanel().isUseVisualStyles() && ( node.getNodeData().getNodeVisualData() != null )
+ && ( !node.getNodeData().getNodeVisualData().isEmpty() ) ) {
+ vis = node.getNodeData().getNodeVisualData();
+ }
+ float box_size = getOptions().getDefaultNodeShapeSize();
+ if ( ( vis != null ) && ( vis.getSize() != NodeVisualData.DEFAULT_SIZE ) ) {
+ box_size = vis.getSize();
+ }
+ final float half_box_size = box_size / 2.0f;
Color outline_color = null;
if ( ( to_pdf || to_graphics_file ) && getOptions().isPrintBlackAndWhite() ) {
outline_color = Color.BLACK;
else if ( isInFoundNodes( node ) || isInCurrentExternalNodes( node ) ) {
outline_color = getColorForFoundNode( node );
}
+ else if ( vis != null ) {
+ if ( vis.getNodeColor() != null ) {
+ outline_color = vis.getNodeColor();
+ }
+ else if ( vis.getFontColor() != null ) {
+ outline_color = vis.getFontColor();
+ }
+ }
else if ( getControlPanel().isEvents() && TreePanelUtil.isHasAssignedEvent( node ) ) {
final Event event = node.getNodeData().getEvent();
if ( event.isDuplication() ) {
outline_color = getTreeColorSet().getDuplicationOrSpeciationColor();
}
}
- else {
+ if ( outline_color == null ) {
outline_color = getGraphicsForNodeBoxWithColorForParentBranch( node );
if ( to_pdf && ( outline_color == getTreeColorSet().getBranchColor() ) ) {
outline_color = getTreeColorSet().getBranchColorForPdf();
}
}
- if ( getOptions().getDefaultNodeShape() == NodeShape.CIRCLE ) {
- if ( getOptions().getDefaultNodeFill() == NodeFill.GRADIENT ) {
+ NodeShape shape = null;
+ if ( vis != null ) {
+ if ( vis.getShape() == NodeShape.CIRCLE ) {
+ shape = NodeShape.CIRCLE;
+ }
+ else if ( vis.getShape() == NodeShape.RECTANGLE ) {
+ shape = NodeShape.RECTANGLE;
+ }
+ }
+ if ( shape == null ) {
+ if ( getOptions().getDefaultNodeShape() == NodeShape.CIRCLE ) {
+ shape = NodeShape.CIRCLE;
+ }
+ else if ( getOptions().getDefaultNodeShape() == NodeShape.RECTANGLE ) {
+ shape = NodeShape.RECTANGLE;
+ }
+ }
+ NodeFill fill = null;
+ if ( vis != null ) {
+ if ( vis.getFillType() == NodeFill.SOLID ) {
+ fill = NodeFill.SOLID;
+ }
+ else if ( vis.getFillType() == NodeFill.NONE ) {
+ fill = NodeFill.NONE;
+ }
+ else if ( vis.getFillType() == NodeFill.GRADIENT ) {
+ fill = NodeFill.GRADIENT;
+ }
+ }
+ if ( fill == null ) {
+ if ( getOptions().getDefaultNodeFill() == NodeFill.SOLID ) {
+ fill = NodeFill.SOLID;
+ }
+ else if ( getOptions().getDefaultNodeFill() == NodeFill.NONE ) {
+ fill = NodeFill.NONE;
+ }
+ else if ( getOptions().getDefaultNodeFill() == NodeFill.GRADIENT ) {
+ fill = NodeFill.GRADIENT;
+ }
+ }
+ Color vis_fill_color = null;
+ if ( ( vis != null ) && ( vis.getNodeColor() != null ) ) {
+ vis_fill_color = vis.getNodeColor();
+ }
+ if ( shape == NodeShape.CIRCLE ) {
+ if ( fill == NodeFill.GRADIENT ) {
drawOvalGradient( x - half_box_size, y - half_box_size, box_size, box_size, g, to_pdf ? Color.WHITE
: outline_color, to_pdf ? outline_color : getBackground(), outline_color );
}
- else if ( getOptions().getDefaultNodeFill() == NodeFill.NONE ) {
+ else if ( fill == NodeFill.NONE ) {
Color background = getBackground();
if ( to_pdf ) {
background = Color.WHITE;
background,
outline_color );
}
- else if ( getOptions().getDefaultNodeFill() == NodeVisualData.NodeFill.SOLID ) {
- g.setColor( outline_color );
+ else if ( fill == NodeVisualData.NodeFill.SOLID ) {
+ if ( vis_fill_color != null ) {
+ g.setColor( vis_fill_color );
+ }
+ else {
+ g.setColor( outline_color );
+ }
drawOvalFilled( x - half_box_size, y - half_box_size, box_size, box_size, g );
}
}
- else if ( getOptions().getDefaultNodeShape() == NodeVisualData.NodeShape.RECTANGLE ) {
- if ( getOptions().getDefaultNodeFill() == NodeVisualData.NodeFill.GRADIENT ) {
+ else if ( shape == NodeVisualData.NodeShape.RECTANGLE ) {
+ if ( fill == NodeVisualData.NodeFill.GRADIENT ) {
drawRectGradient( x - half_box_size, y - half_box_size, box_size, box_size, g, to_pdf ? Color.WHITE
: outline_color, to_pdf ? outline_color : getBackground(), outline_color );
}
- else if ( getOptions().getDefaultNodeFill() == NodeVisualData.NodeFill.NONE ) {
+ else if ( fill == NodeVisualData.NodeFill.NONE ) {
Color background = getBackground();
if ( to_pdf ) {
background = Color.WHITE;
background,
outline_color );
}
- else if ( getOptions().getDefaultNodeFill() == NodeVisualData.NodeFill.SOLID ) {
- g.setColor( outline_color );
+ else if ( fill == NodeVisualData.NodeFill.SOLID ) {
+ if ( vis_fill_color != null ) {
+ g.setColor( vis_fill_color );
+ }
+ else {
+ g.setColor( outline_color );
+ }
drawRectFilled( x - half_box_size, y - half_box_size, box_size, box_size, g );
}
}
else {
_sb.setLength( 0 );
}
- if ( getControlPanel().isShowNodeNames() && ( node.getName().length() > 0 ) ) {
- if ( _sb.length() > 0 ) {
- _sb.append( " " );
- }
- _sb.append( node.getName() );
- }
- if ( node.getNodeData().isHasSequence() ) {
- if ( getControlPanel().isShowSeqSymbols() && ( node.getNodeData().getSequence().getSymbol().length() > 0 ) ) {
- if ( _sb.length() > 0 ) {
- _sb.append( " " );
- }
- _sb.append( node.getNodeData().getSequence().getSymbol() );
- }
- if ( getControlPanel().isShowGeneNames() && ( node.getNodeData().getSequence().getGeneName().length() > 0 ) ) {
- if ( _sb.length() > 0 ) {
- _sb.append( " " );
- }
- _sb.append( node.getNodeData().getSequence().getGeneName() );
- }
- if ( getControlPanel().isShowSeqNames() && ( node.getNodeData().getSequence().getName().length() > 0 ) ) {
- if ( _sb.length() > 0 ) {
- _sb.append( " " );
- }
- _sb.append( node.getNodeData().getSequence().getName() );
- }
- if ( getControlPanel().isShowSequenceAcc() && ( node.getNodeData().getSequence().getAccession() != null ) ) {
- if ( _sb.length() > 0 ) {
- _sb.append( " " );
- }
- if ( !ForesterUtil.isEmpty( node.getNodeData().getSequence().getAccession().getSource() ) ) {
- _sb.append( node.getNodeData().getSequence().getAccession().getSource() );
- _sb.append( ":" );
- }
- _sb.append( node.getNodeData().getSequence().getAccession().getValue() );
- }
- }
- if ( getControlPanel().isShowProperties() && node.getNodeData().isHasProperties() ) {
- if ( _sb.length() > 0 ) {
- _sb.append( " " );
- }
- _sb.append( propertiesToString( node ) );
- }
+ nodeDataAsSB( node, _sb );
final boolean using_visual_font = setFont( g, node, is_in_found_nodes );
float down_shift_factor = 3.0f;
if ( !node.isExternal() && ( node.getNumberOfDescendants() == 1 ) ) {
+ ( getFontMetrics( g.getFont() ).getAscent() / ( node.getNumberOfDescendants() == 1 ? 1 : 3.0f ) );
}
_sb.setLength( 0 );
- if ( _control_panel.isShowTaxonomyCode() && !ForesterUtil.isEmpty( taxonomy.getTaxonomyCode() ) ) {
- _sb.append( taxonomy.getTaxonomyCode() );
- _sb.append( " " );
- }
- if ( _control_panel.isShowTaxonomyScientificNames() && _control_panel.isShowTaxonomyCommonNames() ) {
- if ( !ForesterUtil.isEmpty( taxonomy.getScientificName() )
- && !ForesterUtil.isEmpty( taxonomy.getCommonName() ) ) {
- if ( getOptions().isAbbreviateScientificTaxonNames()
- && ( taxonomy.getScientificName().indexOf( ' ' ) > 0 ) ) {
- abbreviateScientificName( taxonomy.getScientificName() );
- }
- else {
- _sb.append( taxonomy.getScientificName() );
- }
- _sb.append( " (" );
- _sb.append( taxonomy.getCommonName() );
- _sb.append( ") " );
- }
- else if ( !ForesterUtil.isEmpty( taxonomy.getScientificName() ) ) {
- if ( getOptions().isAbbreviateScientificTaxonNames()
- && ( taxonomy.getScientificName().indexOf( ' ' ) > 0 ) ) {
- abbreviateScientificName( taxonomy.getScientificName() );
- }
- else {
- _sb.append( taxonomy.getScientificName() );
- }
- _sb.append( " " );
- }
- else if ( !ForesterUtil.isEmpty( taxonomy.getCommonName() ) ) {
- _sb.append( taxonomy.getCommonName() );
- _sb.append( " " );
- }
- }
- else if ( _control_panel.isShowTaxonomyScientificNames() ) {
- if ( !ForesterUtil.isEmpty( taxonomy.getScientificName() ) ) {
- if ( getOptions().isAbbreviateScientificTaxonNames()
- && ( taxonomy.getScientificName().indexOf( ' ' ) > 0 ) ) {
- abbreviateScientificName( taxonomy.getScientificName() );
- }
- else {
- _sb.append( taxonomy.getScientificName() );
- }
- _sb.append( " " );
- }
- }
- else if ( _control_panel.isShowTaxonomyCommonNames() ) {
- if ( !ForesterUtil.isEmpty( taxonomy.getCommonName() ) ) {
- _sb.append( taxonomy.getCommonName() );
- _sb.append( " " );
- }
- }
+ nodeTaxonomyDataAsSB( taxonomy, _sb );
final String label = _sb.toString();
/* GUILHEM_BEG */
if ( _control_panel.isShowSequenceRelations() && ( label.length() > 0 )
public final class NodeVisualData implements PhylogenyData {\r
\r
public static final String APTX_VISUALIZATION_REF = "style:";\r
+ public static final int DEFAULT_SIZE = -1;\r
public static final String FONT_COLOR_REF = APTX_VISUALIZATION_REF + "font_color";\r
public static final String FONT_COLOR_TYPE = "xsd:token";\r
public static final String FONT_REF = APTX_VISUALIZATION_REF + "font";\r
public static final String FONT_STYLE_REF = APTX_VISUALIZATION_REF + "font_style";\r
public static final String FONT_STYLE_TYPE = "xsd:token";\r
public static final String FONT_TYPE = "xsd:token";\r
- public static final String NODE_BORDER_COLOR_REF = APTX_VISUALIZATION_REF + "node_border_color";\r
- public static final String NODE_BORDER_COLOR_TYPE = "xsd:token";\r
- public static final String NODE_FILL_COLOR_REF = APTX_VISUALIZATION_REF + "node_fill_color";\r
- public static final String NODE_FILL_COLOR_TYPE = "xsd:token";\r
+ public static final String NODE_COLOR_REF = APTX_VISUALIZATION_REF + "node_color";\r
+ public static final String NODE_COLOR_TYPE = "xsd:token";\r
public static final String NODE_FILL_GRADIENT = "gradient";\r
public static final String NODE_FILL_NONE = "none";\r
public static final String NODE_FILL_SOLID = "solid";\r
public static final String NODE_FILL_TYPE_REF = APTX_VISUALIZATION_REF + "node_fill_type";\r
public static final String NODE_FILL_TYPE_TYPE = "xsd:token";\r
- public static final String NODE_SHAPE_CIRCLE = "cicle";\r
+ public static final String NODE_SHAPE_CIRCLE = "circle";\r
public static final String NODE_SHAPE_RECTANGLE = "rectangle";\r
public static final String NODE_SHAPE_REF = APTX_VISUALIZATION_REF + "node_shape";\r
public static final String NODE_SHAPE_TYPE = "xsd:token";\r
public static final String NODE_TRANSPARENCY_REF = APTX_VISUALIZATION_REF + "node_transparency";\r
public static final String NODE_TRANSPARENCY_TYPE = "xsd:float";\r
private static final byte DEFAULT_FONT_SIZE = -1;\r
- private static final int DEFAULT_SIZE = -1;\r
private static final int DEFAULT_TRANSPARENCY = -1;\r
- private Color _border_color;\r
- private Color _fill_color;\r
private NodeFill _fill_type;\r
private Font _font;\r
private Color _font_color;\r
private String _font_name;\r
private byte _font_size;\r
private FontType _font_style;\r
+ private Color _node_color;\r
private NodeShape _shape;\r
private float _size;\r
private float _transparency;\r
final Color font_color,\r
final NodeShape shape,\r
final NodeFill fill_type,\r
- final Color border_color,\r
- final Color fill_color,\r
+ final Color node_color,\r
final float size,\r
final float transparency ) {\r
setFontName( font_name );\r
setFontColor( font_color );\r
setShape( shape );\r
setFillType( fill_type );\r
- setBorderColor( border_color );\r
- setFillColor( fill_color );\r
+ setNodeColor( node_color );\r
setSize( size );\r
setTransparency( transparency );\r
}\r
.getGreen(), getFontColor().getBlue() ) : null,\r
getShape(),\r
getFillType(),\r
- getBorderColor() != null ? new Color( getBorderColor().getRed(), getBorderColor()\r
- .getGreen(), getBorderColor().getBlue() ) : null,\r
- getFillColor() != null ? new Color( getFillColor().getRed(), getFillColor()\r
- .getGreen(), getFillColor().getBlue() ) : null,\r
+ getNodeColor() != null ? new Color( getNodeColor().getRed(), getNodeColor()\r
+ .getGreen(), getNodeColor().getBlue() ) : null,\r
getSize(),\r
getTransparency() );\r
}\r
\r
- public final Color getBorderColor() {\r
- return _border_color;\r
- }\r
-\r
- public final Color getFillColor() {\r
- return _fill_color;\r
- }\r
-\r
public final NodeFill getFillType() {\r
return _fill_type;\r
}\r
return Font.PLAIN;\r
}\r
\r
+ public final Color getNodeColor() {\r
+ return _node_color;\r
+ }\r
+\r
public final NodeShape getShape() {\r
return _shape;\r
}\r
return ( ForesterUtil.isEmpty( getFontName() ) && ( getFontStyle() == FontType.PLAIN )\r
&& ( getFontSize() == DEFAULT_FONT_SIZE ) && ( getFontColor() == null )\r
&& ( getShape() == NodeShape.DEFAULT ) && ( getFillType() == NodeFill.DEFAULT )\r
- && ( getBorderColor() == null ) && ( getFillColor() == null ) && ( getSize() == DEFAULT_SIZE ) && ( getTransparency() == DEFAULT_TRANSPARENCY ) );\r
+ && ( getNodeColor() == null ) && ( getSize() == DEFAULT_SIZE ) && ( getTransparency() == DEFAULT_TRANSPARENCY ) );\r
}\r
\r
@Override\r
return;\r
}\r
}\r
- //\r
else if ( prop.getRef().equals( NODE_SIZE_REF ) ) {\r
- int s = -1;\r
+ float s = -1.0f;\r
try {\r
- s = Integer.parseInt( prop.getValue() );\r
+ s = Float.parseFloat( prop.getValue() );\r
}\r
catch ( final NumberFormatException e ) {\r
return;\r
setSize( s );\r
}\r
}\r
- else if ( prop.getRef().equals( NODE_FILL_COLOR_REF ) ) {\r
- try {\r
- setFillColor( Color.decode( prop.getValue() ) );\r
- }\r
- catch ( final NumberFormatException e ) {\r
- return;\r
- }\r
- }\r
- else if ( prop.getRef().equals( NODE_BORDER_COLOR_REF ) ) {\r
+ else if ( prop.getRef().equals( NODE_COLOR_REF ) ) {\r
try {\r
- setBorderColor( Color.decode( prop.getValue() ) );\r
+ setNodeColor( Color.decode( prop.getValue() ) );\r
}\r
catch ( final NumberFormatException e ) {\r
return;\r
}\r
}\r
else if ( prop.getRef().equals( NODE_SHAPE_REF ) ) {\r
- try {\r
- setShape( prop.getValue() );\r
- }\r
- catch ( final NumberFormatException e ) {\r
- return;\r
- }\r
+ setShape( prop.getValue() );\r
+ }\r
+ else if ( prop.getRef().equals( NODE_FILL_TYPE_REF ) ) {\r
+ setFillType( prop.getValue() );\r
}\r
- }\r
-\r
- public final void setBorderColor( final Color border_color ) {\r
- _border_color = border_color;\r
- }\r
-\r
- public final void setFillColor( final Color fill_color ) {\r
- _fill_color = fill_color;\r
}\r
\r
public final void setFillType( final NodeFill fill_type ) {\r
_fill_type = fill_type;\r
}\r
\r
+ public final void setFillType( final String fill ) {\r
+ if ( fill.equalsIgnoreCase( NODE_FILL_NONE ) ) {\r
+ setFillType( NodeFill.NONE );\r
+ }\r
+ else if ( fill.equalsIgnoreCase( NODE_FILL_SOLID ) ) {\r
+ setFillType( NodeFill.SOLID );\r
+ }\r
+ else if ( fill.equalsIgnoreCase( NODE_FILL_GRADIENT ) ) {\r
+ setFillType( NodeFill.GRADIENT );\r
+ }\r
+ else {\r
+ setFillType( NodeFill.DEFAULT );\r
+ }\r
+ }\r
+\r
public final void setFontColor( final Color font_color ) {\r
_font_color = font_color;\r
}\r
}\r
}\r
\r
+ public final void setNodeColor( final Color node_color ) {\r
+ _node_color = node_color;\r
+ }\r
+\r
public final void setShape( final NodeShape shape ) {\r
_shape = shape;\r
}\r
setFontColor( null );\r
setShape( NodeShape.DEFAULT );\r
setFillType( NodeFill.DEFAULT );\r
- setBorderColor( null );\r
- setFillColor( null );\r
+ setNodeColor( null );\r
setSize( DEFAULT_SIZE );\r
setTransparency( DEFAULT_TRANSPARENCY );\r
_font = null;\r
NODE_SIZE_TYPE,\r
AppliesTo.NODE ) );\r
}\r
- if ( getFillColor() != null ) {\r
- properties.add( new Property( NODE_FILL_COLOR_REF,\r
- colorToHex( getFillColor() ),\r
- "",\r
- NODE_FILL_COLOR_TYPE,\r
- AppliesTo.NODE ) );\r
- }\r
- if ( getBorderColor() != null ) {\r
- properties.add( new Property( NODE_BORDER_COLOR_REF,\r
- colorToHex( getBorderColor() ),\r
+ if ( getNodeColor() != null ) {\r
+ properties.add( new Property( NODE_COLOR_REF,\r
+ colorToHex( getNodeColor() ),\r
"",\r
- NODE_BORDER_COLOR_TYPE,\r
+ NODE_COLOR_TYPE,\r
AppliesTo.NODE ) );\r
}\r
if ( getFillType() != NodeFill.DEFAULT ) {\r