final static short NUMBER_OF_DIGITS_AFTER_COMMA_FOR_BRANCH_LENGTH_VALUES_DEFAULT = 3;
final static short NUMBER_OF_DIGITS_AFTER_COMMA_FOR_CONFIDENCE_VALUES_DEFAULT = 2;
public static final boolean NH_PARSING_IGNORE_QUOTES_DEFAULT = false;
- static final CLADOGRAM_TYPE CLADOGRAM_TYPE_DEFAULT = CLADOGRAM_TYPE.EXT_NODE_SUM_DEP;
+ static final CLADOGRAM_TYPE CLADOGRAM_TYPE_DEFAULT = CLADOGRAM_TYPE.LINED_UP;
final static boolean VALIDATE_AGAINST_PHYLOXML_XSD_SCJEMA_DEFAULT = true;
final static String BACKUP_FILE_SUFFIX = ".BAK";
final static double MIN_NOT_COLLAPSE_DEFAULT = 50;
import org.forester.io.parsers.nexus.NexusPhylogeniesParser;
import org.forester.io.parsers.nhx.NHXParser;
import org.forester.io.parsers.nhx.NHXParser.TAXONOMY_EXTRACTION;
-import org.forester.io.parsers.phyloxml.PhyloXmlUtil;
import org.forester.io.parsers.tol.TolParser;
import org.forester.io.parsers.util.ParserUtils;
import org.forester.phylogeny.Phylogeny;
import org.forester.util.AsciiHistogram;
import org.forester.util.DescriptiveStatistics;
import org.forester.util.ForesterUtil;
+import org.forester.util.TaxonomyUtil;
public final class AptxUtil {
first = normalizeCharForRGB( first );
second = normalizeCharForRGB( second );
third = normalizeCharForRGB( third );
- if ( ( first > 235 ) && ( second > 235 ) && ( third > 235 ) ) {
+ if ( ( first > 200 ) && ( second > 200 ) && ( third > 200 ) ) {
first = 0;
}
else if ( ( first < 60 ) && ( second < 60 ) && ( third < 60 ) ) {
second = 255;
}
+ else if ( Math.abs( first - second ) < 40 && Math.abs( second - third ) < 40 ) {
+ third = 255;
+ }
return new Color( first, second, third );
}
}
final static String[] getAllPossibleRanks() {
- final String[] str_array = new String[ PhyloXmlUtil.TAXONOMY_RANKS_LIST.size() - 2 ];
+ final String[] str_array = new String[ TaxonomyUtil.TAXONOMY_RANKS_LIST.size() - 2 ];
int i = 0;
- for( final String e : PhyloXmlUtil.TAXONOMY_RANKS_LIST ) {
- if ( !e.equals( PhyloXmlUtil.UNKNOWN ) && !e.equals( PhyloXmlUtil.OTHER ) ) {
+ for( final String e : TaxonomyUtil.TAXONOMY_RANKS_LIST ) {
+ if ( !e.equals( TaxonomyUtil.UNKNOWN ) && !e.equals( TaxonomyUtil.OTHER ) ) {
str_array[ i++ ] = e;
}
}
}
final static String[] getAllPossibleRanks(final Map<String, Integer> present_ranks) {
- final String[] str_array = new String[ PhyloXmlUtil.TAXONOMY_RANKS_LIST.size() - 2 ];
+ final String[] str_array = new String[ TaxonomyUtil.TAXONOMY_RANKS_LIST.size() - 2 ];
int i = 0;
- for( final String e : PhyloXmlUtil.TAXONOMY_RANKS_LIST ) {
- if ( !e.equals( PhyloXmlUtil.UNKNOWN ) && !e.equals( PhyloXmlUtil.OTHER ) ) {
+ for( final String e : TaxonomyUtil.TAXONOMY_RANKS_LIST ) {
+ if ( !e.equals( TaxonomyUtil.UNKNOWN ) && !e.equals( TaxonomyUtil.OTHER ) ) {
if ( present_ranks != null && present_ranks.containsKey( e ) ) {
str_array[ i++ ] = e + " (" + present_ranks.get(e) + ")";
}
private JCheckBoxMenuItem _background_gradient_cbmi;
private JCheckBoxMenuItem _color_by_taxonomic_group_cbmi;
private JRadioButtonMenuItem _non_lined_up_cladograms_rbmi;
- private JRadioButtonMenuItem _uniform_cladograms_rbmi;
private JRadioButtonMenuItem _ext_node_dependent_cladogram_rbmi;
private Options _options;
private JMenuItem _choose_font_mi;
updateOptions( getOptions() );
_mainpanel.getControlPanel().showWhole();
}
- else if ( o == _uniform_cladograms_rbmi ) {
- updateOptions( getOptions() );
- _mainpanel.getControlPanel().showWhole();
- }
else if ( o == _ext_node_dependent_cladogram_rbmi ) {
updateOptions( getOptions() );
_mainpanel.getControlPanel().showWhole();
getConfiguration() ) );
_options_jmenu
.add( _ext_node_dependent_cladogram_rbmi = new JRadioButtonMenuItem( MainFrame.NONUNIFORM_CLADOGRAMS_LABEL ) );
- _options_jmenu.add( _uniform_cladograms_rbmi = new JRadioButtonMenuItem( MainFrame.UNIFORM_CLADOGRAMS_LABEL ) );
_options_jmenu
.add( _non_lined_up_cladograms_rbmi = new JRadioButtonMenuItem( MainFrame.NON_LINED_UP_CLADOGRAMS_LABEL ) );
_radio_group_1 = new ButtonGroup();
_radio_group_1.add( _ext_node_dependent_cladogram_rbmi );
- _radio_group_1.add( _uniform_cladograms_rbmi );
_radio_group_1.add( _non_lined_up_cladograms_rbmi );
_options_jmenu.add( _show_overview_cbmi = new JCheckBoxMenuItem( MainFrame.SHOW_OVERVIEW_LABEL ) );
_options_jmenu.add( _show_scale_cbmi = new JCheckBoxMenuItem( MainFrame.DISPLAY_SCALE_LABEL ) );
customizeCheckBoxMenuItem( _show_scale_cbmi, getOptions().isShowScale() );
customizeRadioButtonMenuItem( _non_lined_up_cladograms_rbmi,
getOptions().getCladogramType() == CLADOGRAM_TYPE.NON_LINED_UP );
- customizeRadioButtonMenuItem( _uniform_cladograms_rbmi,
- getOptions().getCladogramType() == CLADOGRAM_TYPE.TOTAL_NODE_SUM_DEP );
- customizeRadioButtonMenuItem( _ext_node_dependent_cladogram_rbmi,
- getOptions().getCladogramType() == CLADOGRAM_TYPE.EXT_NODE_SUM_DEP );
+ customizeRadioButtonMenuItem( _ext_node_dependent_cladogram_rbmi,
+ getOptions().getCladogramType() == CLADOGRAM_TYPE.LINED_UP );
customizeCheckBoxMenuItem( _show_overview_cbmi, getOptions().isShowOverview() );
customizeCheckBoxMenuItem( _search_with_regex_cbmi, getOptions().isSearchWithRegex() );
customizeCheckBoxMenuItem( _search_whole_words_only_cbmi, getOptions().isMatchWholeTermsOnly() );
if ( ( _non_lined_up_cladograms_rbmi != null ) && ( _non_lined_up_cladograms_rbmi.isSelected() ) ) {
options.setCladogramType( CLADOGRAM_TYPE.NON_LINED_UP );
}
- else if ( ( _uniform_cladograms_rbmi != null ) && ( _uniform_cladograms_rbmi.isSelected() ) ) {
- options.setCladogramType( CLADOGRAM_TYPE.TOTAL_NODE_SUM_DEP );
- }
+
else if ( ( _ext_node_dependent_cladogram_rbmi != null ) && ( _ext_node_dependent_cladogram_rbmi.isSelected() ) ) {
- options.setCladogramType( CLADOGRAM_TYPE.EXT_NODE_SUM_DEP );
+ options.setCladogramType( CLADOGRAM_TYPE.LINED_UP );
}
options.setSearchCaseSensitive( ( _search_case_senstive_cbmi != null )
&& _search_case_senstive_cbmi.isSelected() );
setMaxBaseFontSize( i );
}
}
- else if ( key.equals( "graphics_export_x" ) ) {
- // final String str = ( ( String ) st.nextElement() ).trim();
- // final int i = parseInt( str );
- // if ( i > 0 ) {
- // setGraphicsExportX( i );
- // }
- }
- else if ( key.equals( "graphics_export_y" ) ) {
- //final String str = ( ( String ) st.nextElement() ).trim();
- // final int i = parseInt( str );
- //if ( i > 0 ) {
- // setGraphicsExportY( i );
- //}
- }
else if ( key.equals( "pdf_export_line_width" ) ) {
final String str = ( ( String ) st.nextElement() ).trim();
final float f = parseFloat( str );
if ( type_str.equalsIgnoreCase( Options.CLADOGRAM_TYPE.NON_LINED_UP.toString() ) ) {
setCladogramType( Options.CLADOGRAM_TYPE.NON_LINED_UP );
}
- else if ( type_str.equalsIgnoreCase( Options.CLADOGRAM_TYPE.EXT_NODE_SUM_DEP.toString() ) ) {
- setCladogramType( Options.CLADOGRAM_TYPE.EXT_NODE_SUM_DEP );
- }
- else if ( type_str.equalsIgnoreCase( Options.CLADOGRAM_TYPE.TOTAL_NODE_SUM_DEP.toString() ) ) {
- setCladogramType( Options.CLADOGRAM_TYPE.TOTAL_NODE_SUM_DEP );
+ else if ( type_str.equalsIgnoreCase( Options.CLADOGRAM_TYPE.LINED_UP.toString() ) ) {
+ setCladogramType( Options.CLADOGRAM_TYPE.LINED_UP );
}
else {
ForesterUtil.printWarningMessage( AptxConstants.PRG_NAME, "unknown value [" + type_str
+ "] for [cladogram_type]" );
}
}
- else if ( key.equals( "non_lined_up_cladogram" ) ) {
- ForesterUtil
- .printWarningMessage( AptxConstants.PRG_NAME,
- "configuration key [non_lined_up_cladogram] is deprecated, use [cladogram_type] instead" );
- }
else if ( key.equals( "hide_controls_and_menus" ) ) {
_hide_controls_and_menus = parseBoolean( ( String ) st.nextElement() );
}
import org.forester.archaeopteryx.Options.CLADOGRAM_TYPE;
import org.forester.archaeopteryx.Options.PHYLOGENY_GRAPHICS_TYPE;
+import org.forester.archaeopteryx.util.TypomaticJButton;
import org.forester.phylogeny.Phylogeny;
import org.forester.phylogeny.PhylogenyMethods;
import org.forester.phylogeny.PhylogenyMethods.DESCENDANT_SORT_PRIORITY;
final class ControlPanel extends JPanel implements ActionListener {
enum NodeClickAction {
- ADD_NEW_NODE,
- BLAST,
- COLLAPSE,
- COLOR_SUBTREE,
- COPY_SUBTREE,
- CUT_SUBTREE,
- DELETE_NODE_OR_SUBTREE,
- EDIT_NODE_DATA,
- GET_EXT_DESC_DATA,
- OPEN_PDB_WEB,
- OPEN_SEQ_WEB,
- OPEN_TAX_WEB,
- PASTE_SUBTREE,
- REROOT,
- SELECT_NODES,
- SHOW_DATA,
- SORT_DESCENDENTS,
- SUBTREE,
- SWAP,
- CHANGE_NODE_FONT,
- COLOR_NODE_FONT,
- UNCOLLAPSE_ALL,
- ORDER_SUBTREE;
- }
- final static Font jcb_bold_font = new Font( Configuration.getDefaultFontFamilyName(),
- Font.BOLD,
- 9 );
- final static Font jcb_font = new Font( Configuration.getDefaultFontFamilyName(),
- Font.PLAIN,
- 9 );
- final static Font js_font = new Font( Configuration.getDefaultFontFamilyName(),
- Font.PLAIN,
- 9 );
+ ADD_NEW_NODE,
+ BLAST,
+ COLLAPSE,
+ COLOR_SUBTREE,
+ COPY_SUBTREE,
+ CUT_SUBTREE,
+ DELETE_NODE_OR_SUBTREE,
+ EDIT_NODE_DATA,
+ GET_EXT_DESC_DATA,
+ OPEN_PDB_WEB,
+ OPEN_SEQ_WEB,
+ OPEN_TAX_WEB,
+ PASTE_SUBTREE,
+ REROOT,
+ SELECT_NODES,
+ SHOW_DATA,
+ SORT_DESCENDENTS,
+ SUBTREE,
+ SWAP,
+ CHANGE_NODE_FONT,
+ COLOR_NODE_FONT,
+ UNCOLLAPSE_ALL,
+ ORDER_SUBTREE;
+ }
+ final static Font jcb_bold_font = new Font( Configuration
+ .getDefaultFontFamilyName(), Font.BOLD, 9 );
+ final static Font jcb_font = new Font( Configuration
+ .getDefaultFontFamilyName(), Font.PLAIN, 9 );
+ final static Font js_font = new Font( Configuration
+ .getDefaultFontFamilyName(), Font.PLAIN, 9 );
private static final String RETURN_TO_SUPER_TREE_TEXT = "Back to Super Tree";
private static final String SEARCH_TIP_TEXT = "Enter text to search for. Use ',' for logical OR and '+' for logical AND (not used in this manner for regular expression searches).";
private static final long serialVersionUID = -8463483932821545633L;
private int _collapse_cb_item;
private int _uncollapse_all_cb_item;
private int _order_subtree_cb_item;
-
-
private JCheckBox _color_acc_species;
private JCheckBox _color_acc_sequence;
private JCheckBox _color_according_to_annotation;
private JCheckBox _display_internal_data;
private JLabel _domain_display_label;
private JTextField _domain_structure_evalue_thr_tf;
+ private JTextField _depth_collapse_depth_tf;
+ private JTextField _rank_collapse_depth_tf;
private List<Boolean> _draw_phylogram;
private JCheckBox _dynamically_hide_data;
private int _edit_node_data_item;
private JButton _zoom_out_domain_structure;
private JButton _zoom_out_x;
private JButton _zoom_out_y;
+ private JButton _decr_depth_collapse_level;
+ private JButton _incr_depth_collapse_level;
+ private JLabel _depth_collapse_label;
+ private JButton _decr_rank_collapse_level;
+ private JButton _incr_rank_collapse_level;
+ private JLabel _rank_collapse_label;
ControlPanel( final MainPanel ap, final Configuration configuration ) {
init();
pri = DESCENDANT_SORT_PRIORITY.SEQUENCE;
}
PhylogenyMethods.orderAppearanceX( tp.getPhylogeny().getRoot(), true, pri );
-
tp.setNodeInPreorderToNull();
tp.getPhylogeny().externalNodesHaveChanged();
tp.getPhylogeny().clearHashIdToNodeMap();
setDynamicHidingIsOn( false );
displayedPhylogenyMightHaveChanged( true );
}
+ else if ( ( e.getSource() == _decr_depth_collapse_level )
+ || ( e.getSource() == _incr_depth_collapse_level ) ) {
+ if ( e.getSource() == _decr_depth_collapse_level ) {
+ _mainpanel.getCurrentTreePanel().decreaseDepthCollapseLevel();
+ }
+ else {
+ _mainpanel.getCurrentTreePanel().increaseDepthCollapseLevel();
+ }
+ search0();
+ search1();
+ _mainpanel.getCurrentTreePanel().updateSetOfCollapsedExternalNodes();
+ _mainpanel.getCurrentTreePanel().getPhylogeny().recalculateNumberOfExternalDescendants( true );
+ _mainpanel.getCurrentTreePanel().resetNodeIdToDistToLeafMap();
+ _mainpanel.getCurrentTreePanel().calculateLongestExtNodeInfo();
+ _mainpanel.getCurrentTreePanel().setNodeInPreorderToNull();
+ displayedPhylogenyMightHaveChanged( true );
+ _mainpanel.getCurrentTreePanel().resetPreferredSize();
+ _mainpanel.getCurrentTreePanel().updateOvSizes();
+ _mainpanel.adjustJScrollPane();
+ showWhole();
+ repaint();
+ }
+ else if ( ( e.getSource() == _decr_rank_collapse_level )
+ || ( e.getSource() == _incr_rank_collapse_level ) ) {
+ if ( e.getSource() == _decr_rank_collapse_level ) {
+ _mainpanel.getCurrentTreePanel().decreaseRankCollapseLevel();
+ }
+ else {
+ _mainpanel.getCurrentTreePanel().increaseRankCollapseLevel();
+ }
+ search0();
+ search1();
+ _mainpanel.getCurrentTreePanel().updateSetOfCollapsedExternalNodes();
+ _mainpanel.getCurrentTreePanel().getPhylogeny().recalculateNumberOfExternalDescendants( true );
+ _mainpanel.getCurrentTreePanel().resetNodeIdToDistToLeafMap();
+ _mainpanel.getCurrentTreePanel().calculateLongestExtNodeInfo();
+ _mainpanel.getCurrentTreePanel().setNodeInPreorderToNull();
+ displayedPhylogenyMightHaveChanged( true );
+ _mainpanel.getCurrentTreePanel().resetPreferredSize();
+ _mainpanel.getCurrentTreePanel().updateOvSizes();
+ _mainpanel.adjustJScrollPane();
+ showWhole();
+ repaint();
+ }
else {
displayedPhylogenyMightHaveChanged( true );
}
public JComboBox<SEQUENCE_RELATION_TYPE> getSequenceRelationTypeBox() {
if ( _sequence_relation_type_box == null ) {
_sequence_relation_type_box = new JComboBox<SEQUENCE_RELATION_TYPE>();
- for( final SequenceRelation.SEQUENCE_RELATION_TYPE type : SequenceRelation.SEQUENCE_RELATION_TYPE.values() ) {
+ for( final SequenceRelation.SEQUENCE_RELATION_TYPE type : SequenceRelation.SEQUENCE_RELATION_TYPE
+ .values() ) {
_sequence_relation_type_box.addItem( type );
}
_sequence_relation_type_box.addActionListener( new ActionListener() {
final int index,
final boolean isSelected,
final boolean cellHasFocus ) {
- final Component component = new DefaultListCellRenderer().getListCellRendererComponent( list,
- value,
- index,
- isSelected,
- cellHasFocus );
+ final Component component = new DefaultListCellRenderer()
+ .getListCellRendererComponent( list, value, index, isSelected, cellHasFocus );
if ( ( value != null ) && ( value instanceof SequenceRelation.SEQUENCE_RELATION_TYPE ) ) {
( ( DefaultListCellRenderer ) component ).setText( SequenceRelation
.getPrintableNameByType( ( SequenceRelation.SEQUENCE_RELATION_TYPE ) value ) );
}// addSequenceRelationBlock
/* GUILHEM_END */
-
private List<Boolean> getIsDrawPhylogramList() {
return _draw_phylogram;
}
getOptions().isSearchCaseSensitive(),
!getOptions().isMatchWholeTermsOnly(),
isShowDomainArchitectures(),
- tp != null ? Math.pow( 10,
- tp.getDomainStructureEvalueThresholdExp() )
- : 0 ) );
+ tp != null
+ ? Math.pow( 10,
+ tp.getDomainStructureEvalueThresholdExp() )
+ : 0 ) );
}
else {
- nodes.addAll( PhylogenyMethods.searchData( query,
- tree,
- getOptions().isSearchCaseSensitive(),
- !getOptions().isMatchWholeTermsOnly(),
- getOptions().isSearchWithRegex(),
- isShowDomainArchitectures(),
- tp != null ? Math.pow( 10, tp
- .getDomainStructureEvalueThresholdExp() ) : 0 ) );
+ nodes.addAll( PhylogenyMethods
+ .searchData( query,
+ tree,
+ getOptions().isSearchCaseSensitive(),
+ !getOptions().isMatchWholeTermsOnly(),
+ getOptions().isSearchWithRegex(),
+ isShowDomainArchitectures(),
+ tp != null ? Math.pow( 10, tp.getDomainStructureEvalueThresholdExp() ) : 0 ) );
}
}
if ( getOptions().isInverseSearchResult() ) {
final Set<Long> temp_nodes = nodes;
nodes = new HashSet<Long>();
for( final PhylogenyNode n : all ) {
- if ( (!temp_nodes.contains( n.getId() )) && n.isHasNodeData() ) {
+ if ( ( !temp_nodes.contains( n.getId() ) ) && n.isHasNodeData() ) {
nodes.add( n.getId() );
}
}
getOptions().isSearchCaseSensitive(),
!getOptions().isMatchWholeTermsOnly(),
isShowDomainArchitectures(),
- tp != null ? Math.pow( 10,
- tp.getDomainStructureEvalueThresholdExp() )
- : 0 ) );
+ tp != null
+ ? Math.pow( 10,
+ tp.getDomainStructureEvalueThresholdExp() )
+ : 0 ) );
}
else {
- nodes.addAll( PhylogenyMethods.searchData( query,
- tree,
- getOptions().isSearchCaseSensitive(),
- !getOptions().isMatchWholeTermsOnly(),
- getOptions().isSearchWithRegex(),
- isShowDomainArchitectures(),
- tp != null ? Math.pow( 10, tp
- .getDomainStructureEvalueThresholdExp() ) : 0 ) );
+ nodes.addAll( PhylogenyMethods
+ .searchData( query,
+ tree,
+ getOptions().isSearchCaseSensitive(),
+ !getOptions().isMatchWholeTermsOnly(),
+ getOptions().isSearchWithRegex(),
+ isShowDomainArchitectures(),
+ tp != null ? Math.pow( 10, tp.getDomainStructureEvalueThresholdExp() ) : 0 ) );
}
}
if ( getOptions().isInverseSearchResult() ) {
final Set<Long> temp_nodes = nodes;
nodes = new HashSet<Long>();
for( final PhylogenyNode n : all ) {
- if ( (!temp_nodes.contains( n.getId() )) && n.isHasNodeData() ) {
+ if ( ( !temp_nodes.contains( n.getId() ) ) && n.isHasNodeData() ) {
nodes.add( n.getId() );
}
}
searchReset1();
}
}
-
+
private void setDrawPhylogram( final int index, final boolean b ) {
getIsDrawPhylogramList().set( index, b );
}
}
cb_index++;
}
-if ( _configuration.doDisplayClickToOption( Configuration.uncollapse_all ) ) {
+ if ( _configuration.doDisplayClickToOption( Configuration.uncollapse_all ) ) {
_uncollapse_all_cb_item = cb_index;
addClickToOption( Configuration.uncollapse_all,
_configuration.getClickToTitle( Configuration.uncollapse_all ) );
selected_index = cb_index;
}
cb_index++;
-}
+ }
if ( _configuration.doDisplayClickToOption( Configuration.reroot ) ) {
_reroot_cb_item = cb_index;
addClickToOption( Configuration.reroot, _configuration.getClickToTitle( Configuration.reroot ) );
}
cb_index++;
}
-if ( _configuration.doDisplayClickToOption( Configuration.order_subtree ) ) {
+ if ( _configuration.doDisplayClickToOption( Configuration.order_subtree ) ) {
_order_subtree_cb_item = cb_index;
addClickToOption( Configuration.order_subtree,
_configuration.getClickToTitle( Configuration.order_subtree ) );
selected_index = cb_index;
}
cb_index++;
-}
-
+ }
if ( _configuration.doDisplayClickToOption( Configuration.sort_descendents ) ) {
_sort_descendents_item = cb_index;
addClickToOption( Configuration.sort_descendents,
}
if ( _configuration.doDisplayClickToOption( Configuration.color_subtree ) ) {
_color_subtree_cb_item = cb_index;
- addClickToOption( Configuration.color_subtree, _configuration.getClickToTitle( Configuration.color_subtree ) );
+ addClickToOption( Configuration.color_subtree,
+ _configuration.getClickToTitle( Configuration.color_subtree ) );
if ( default_option == Configuration.color_subtree ) {
selected_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 ) );
+ addClickToOption( Configuration.open_seq_web,
+ _configuration.getClickToTitle( Configuration.open_seq_web ) );
if ( default_option == Configuration.open_seq_web ) {
selected_index = cb_index;
}
}
if ( _configuration.doDisplayClickToOption( Configuration.open_pdb_web ) ) {
_open_pdb_item = cb_index;
- addClickToOption( Configuration.open_pdb_web, _configuration.getClickToTitle( Configuration.open_pdb_web ) );
+ addClickToOption( Configuration.open_pdb_web,
+ _configuration.getClickToTitle( Configuration.open_pdb_web ) );
if ( default_option == Configuration.open_pdb_web ) {
selected_index = cb_index;
}
}
if ( _configuration.doDisplayClickToOption( Configuration.open_tax_web ) ) {
_open_tax_web_item = cb_index;
- addClickToOption( Configuration.open_tax_web, _configuration.getClickToTitle( Configuration.open_tax_web ) );
+ addClickToOption( Configuration.open_tax_web,
+ _configuration.getClickToTitle( Configuration.open_tax_web ) );
if ( default_option == Configuration.open_tax_web ) {
selected_index = cb_index;
}
}
if ( _configuration.doDisplayClickToOption( Configuration.select_nodes ) ) {
_select_nodes_item = cb_index;
- addClickToOption( Configuration.select_nodes, _configuration.getClickToTitle( Configuration.select_nodes ) );
+ addClickToOption( Configuration.select_nodes,
+ _configuration.getClickToTitle( Configuration.select_nodes ) );
if ( default_option == Configuration.select_nodes ) {
selected_index = cb_index;
}
if ( _configuration.doDisplayClickToOption( Configuration.get_ext_desc_data ) ) {
_get_ext_desc_data = cb_index;
if ( !ForesterUtil.isEmpty( getConfiguration().getLabelForGetExtDescendentsData() ) ) {
- addClickToOption( Configuration.get_ext_desc_data, getConfiguration()
- .getLabelForGetExtDescendentsData() );
+ addClickToOption( Configuration.get_ext_desc_data,
+ getConfiguration().getLabelForGetExtDescendentsData() );
}
else {
addClickToOption( Configuration.get_ext_desc_data,
if ( getOptions().isEditable() ) {
if ( _configuration.doDisplayClickToOption( Configuration.cut_subtree ) ) {
_cut_subtree_item = cb_index;
- addClickToOption( Configuration.cut_subtree, _configuration.getClickToTitle( Configuration.cut_subtree ) );
+ addClickToOption( Configuration.cut_subtree,
+ _configuration.getClickToTitle( Configuration.cut_subtree ) );
if ( default_option == Configuration.cut_subtree ) {
selected_index = cb_index;
}
_configuration.doCheckOption( Configuration.dynamically_hide_data ) );
}
if ( _configuration.doDisplayOption( Configuration.node_data_popup ) ) {
- addCheckbox( Configuration.node_data_popup, _configuration.getDisplayTitle( Configuration.node_data_popup ) );
+ addCheckbox( Configuration.node_data_popup,
+ _configuration.getDisplayTitle( Configuration.node_data_popup ) );
setCheckbox( Configuration.node_data_popup, _configuration.doCheckOption( Configuration.node_data_popup ) );
}
if ( _configuration.doDisplayOption( Configuration.display_internal_data ) ) {
}
add( label );
if ( _configuration.doDisplayOption( Configuration.show_node_names ) ) {
- addCheckbox( Configuration.show_node_names, _configuration.getDisplayTitle( Configuration.show_node_names ) );
+ addCheckbox( Configuration.show_node_names,
+ _configuration.getDisplayTitle( Configuration.show_node_names ) );
setCheckbox( Configuration.show_node_names, _configuration.doCheckOption( Configuration.show_node_names ) );
}
if ( _configuration.doDisplayOption( Configuration.show_tax_code ) ) {
setCheckbox( Configuration.show_seq_names, _configuration.doCheckOption( Configuration.show_seq_names ) );
}
if ( _configuration.doDisplayOption( Configuration.show_gene_names ) ) {
- addCheckbox( Configuration.show_gene_names, _configuration.getDisplayTitle( Configuration.show_gene_names ) );
+ addCheckbox( Configuration.show_gene_names,
+ _configuration.getDisplayTitle( Configuration.show_gene_names ) );
setCheckbox( Configuration.show_gene_names, _configuration.doCheckOption( Configuration.show_gene_names ) );
}
if ( _configuration.doDisplayOption( Configuration.show_seq_symbols ) ) {
addCheckbox( Configuration.show_seq_symbols,
_configuration.getDisplayTitle( Configuration.show_seq_symbols ) );
- setCheckbox( Configuration.show_seq_symbols, _configuration.doCheckOption( Configuration.show_seq_symbols ) );
+ setCheckbox( Configuration.show_seq_symbols,
+ _configuration.doCheckOption( Configuration.show_seq_symbols ) );
}
if ( _configuration.doDisplayOption( Configuration.show_sequence_acc ) ) {
addCheckbox( Configuration.show_sequence_acc,
_configuration.doCheckOption( Configuration.show_sequence_acc ) );
}
if ( _configuration.doDisplayOption( Configuration.show_annotation ) ) {
- addCheckbox( Configuration.show_annotation, _configuration.getDisplayTitle( Configuration.show_annotation ) );
+ addCheckbox( Configuration.show_annotation,
+ _configuration.getDisplayTitle( Configuration.show_annotation ) );
setCheckbox( Configuration.show_annotation, _configuration.doCheckOption( Configuration.show_annotation ) );
}
if ( _configuration.doDisplayOption( Configuration.write_confidence_values ) ) {
if ( _configuration.doDisplayOption( Configuration.show_vector_data ) ) {
addCheckbox( Configuration.show_vector_data,
_configuration.getDisplayTitle( Configuration.show_vector_data ) );
- setCheckbox( Configuration.show_vector_data, _configuration.doCheckOption( Configuration.show_vector_data ) );
+ setCheckbox( Configuration.show_vector_data,
+ _configuration.doCheckOption( Configuration.show_vector_data ) );
}
if ( _configuration.doDisplayOption( Configuration.show_properties ) ) {
- addCheckbox( Configuration.show_properties, _configuration.getDisplayTitle( Configuration.show_properties ) );
+ addCheckbox( Configuration.show_properties,
+ _configuration.getDisplayTitle( Configuration.show_properties ) );
setCheckbox( Configuration.show_properties, _configuration.doCheckOption( Configuration.show_properties ) );
}
if ( _configuration.doDisplayOption( Configuration.show_taxonomy_images ) ) {
add( y_panel );
add( z_panel );
if ( getConfiguration().isUseNativeUI() ) {
- _zoom_in_x = new JButton( "+" );
- _zoom_out_x = new JButton( "-" );
+ _zoom_in_x = new TypomaticJButton( "+" );
+ _zoom_out_x = new TypomaticJButton( "-" );
}
else {
- _zoom_in_x = new JButton( "X+" );
- _zoom_out_x = new JButton( "X-" );
+ _zoom_in_x = new TypomaticJButton( "X+" );
+ _zoom_out_x = new TypomaticJButton( "X-" );
}
- _zoom_in_y = new JButton( "Y+" );
- _zoom_out_y = new JButton( "Y-" );
+ _zoom_in_y = new TypomaticJButton( "Y+" );
+ _zoom_out_y = new TypomaticJButton( "Y-" );
_show_whole = new JButton( "F" );
_show_whole.setToolTipText( "To fit the complete phylogeny to the current display size [F or Home]" );
_zoom_in_x.setToolTipText( "To zoom in horizontally [Shift+cursor-right]" );
_return_to_super_tree.setEnabled( false );
_order = new JButton( "Order Tree" );
_uncollapse_all = new JButton( "Uncollapse All" );
-
addJButton( _zoom_in_y, x_panel );
addJButton( _zoom_out_x, y_panel );
addJButton( _show_whole, y_panel );
if ( getConfiguration().doDisplayOption( Configuration.show_domain_architectures ) ) {
setUpControlsForDomainStrucures();
}
+ if ( true ) {
+ setUpControlsForDepthCollapse();
+ }
+ if ( true ) {
+ setUpControlsForRankCollapse();
+ }
final JLabel spacer2 = new JLabel( "" );
add( spacer2 );
addJButton( _return_to_super_tree, this );
_show_taxo_rank = new JCheckBox( title );
addJCheckBox( _show_taxo_rank, ch_panel );
add( ch_panel );
- break;
+ break;
case Configuration.show_taxonomy_images:
_show_taxo_images_cb = new JCheckBox( title );
addJCheckBox( _show_taxo_images_cb, ch_panel );
void displayedPhylogenyMightHaveChanged( final boolean recalc_longest_ext_node_info ) {
if ( ( _mainpanel != null )
&& ( ( _mainpanel.getCurrentPhylogeny() != null ) && !_mainpanel.getCurrentPhylogeny().isEmpty() ) ) {
-
if ( recalc_longest_ext_node_info ) {
_mainpanel.getCurrentTreePanel().initNodeData();
_mainpanel.getCurrentTreePanel().calculateLongestExtNodeInfo();
_mainpanel.getCurrentTreePanel().recalculateMaxDistanceToRoot();
setVisibilityOfDomainStrucureControls();
updateDomainStructureEvaluethresholdDisplay();
+ updateDepthCollapseDepthDisplay();
+ updateRankCollapseRankDisplay();
+ getMainPanel().getControlPanel();
_mainpanel.getCurrentTreePanel().calculateScaleDistance();
_mainpanel.getCurrentTreePanel().calcMaxDepth();
_mainpanel.adjustJScrollPane();
-
_mainpanel.getCurrentTreePanel().repaint();
// _mainpanel.getCurrentTreePanel().setUpUrtFactor();
}
boolean isShowTaxonomyCode() {
return ( ( _show_taxo_code != null ) && _show_taxo_code.isSelected() );
}
-
+
boolean isShowTaxonomyRank() {
return ( ( _show_taxo_rank != null ) && _show_taxo_rank.isSelected() );
}
}
boolean isUseVisualStyles() {
- return ( ( ( getUseVisualStylesCb() != null ) && getUseVisualStylesCb().isSelected() ) || ( ( getUseVisualStylesCb() == null ) && _color_branches ) );
+ return ( ( ( getUseVisualStylesCb() != null ) && getUseVisualStylesCb().isSelected() )
+ || ( ( getUseVisualStylesCb() == null ) && _color_branches ) );
}
boolean isWidthBranches() {
_domain_display_label = new JLabel( "Domain Architectures:" );
add( customizeLabel( _domain_display_label, getConfiguration() ) );
add( _domain_display_label );
- _zoom_in_domain_structure = new JButton( "d+" );
- _zoom_out_domain_structure = new JButton( "d-" );
+ _zoom_in_domain_structure = new TypomaticJButton( "d+" );
+ _zoom_out_domain_structure = new TypomaticJButton( "d-" );
_decr_domain_structure_evalue_thr = new JButton( "-" );
_incr_domain_structure_evalue_thr = new JButton( "+" );
_zoom_in_domain_structure.setPreferredSize( new Dimension( 10, 10 ) );
addJButton( _incr_domain_structure_evalue_thr, d2_panel );
}
+ void setUpControlsForDepthCollapse() {
+ _depth_collapse_label = new JLabel( "Collapse by Node Depth:" );
+ _depth_collapse_label
+ .setToolTipText( "to automaticall collapse nodes with a depth equal or larger than a threshold" );
+ add( customizeLabel( _depth_collapse_label, getConfiguration() ) );
+ add( _depth_collapse_label );
+ _decr_depth_collapse_level = new TypomaticJButton( "-" );
+ _incr_depth_collapse_level = new TypomaticJButton( "+" );
+ _decr_depth_collapse_level.setPreferredSize( new Dimension( 10, 10 ) );
+ _incr_depth_collapse_level.setPreferredSize( new Dimension( 10, 10 ) );
+ _decr_depth_collapse_level.setToolTipText( "to decrease the depth threshold (wraps around)" );
+ _incr_depth_collapse_level.setToolTipText( "to increase the depth threshold (wraps around)" );
+ _depth_collapse_depth_tf = new JTextField( 3 );
+ _depth_collapse_depth_tf.setToolTipText( "the current depth threshold" );
+ _depth_collapse_depth_tf.setEditable( false );
+ if ( !getConfiguration().isUseNativeUI() ) {
+ _depth_collapse_depth_tf.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
+ _depth_collapse_depth_tf.setBackground( getConfiguration().getGuiCheckboxTextColor() );
+ _depth_collapse_depth_tf.setBorder( null );
+ }
+ final JPanel panel = new JPanel( new GridLayout( 1, 3, 0, 0 ) );
+ if ( !_configuration.isUseNativeUI() ) {
+ panel.setBackground( getBackground() );
+ }
+ add( panel );
+ addJButton( _decr_depth_collapse_level, panel );
+ addJTextField( _depth_collapse_depth_tf, panel );
+ addJButton( _incr_depth_collapse_level, panel );
+ }
+
+ void setUpControlsForRankCollapse() {
+ _rank_collapse_label = new JLabel( "Collapse by Node Rank:" );
+ _rank_collapse_label
+ .setToolTipText( "to automatically collapse nodes with a taxonomic rank equal or lower than a threshold" );
+ add( customizeLabel( _rank_collapse_label, getConfiguration() ) );
+ add( _rank_collapse_label );
+ _decr_rank_collapse_level = new TypomaticJButton( "-" );
+ _incr_rank_collapse_level = new TypomaticJButton( "+" );
+ _decr_rank_collapse_level.setPreferredSize( new Dimension( 10, 10 ) );
+ _incr_rank_collapse_level.setPreferredSize( new Dimension( 10, 10 ) );
+ _decr_rank_collapse_level.setToolTipText( "to decrease the taxonomic rank threshold (wraps around)" );
+ _incr_rank_collapse_level.setToolTipText( "to increase the taxonomic rank threshold (wraps around)" );
+ _rank_collapse_depth_tf = new JTextField( 3 );
+ _rank_collapse_depth_tf.setToolTipText( "the current taxonomic rank threshold" );
+ _rank_collapse_depth_tf.setEditable( false );
+ if ( !getConfiguration().isUseNativeUI() ) {
+ _rank_collapse_depth_tf.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
+ _rank_collapse_depth_tf.setBackground( getConfiguration().getGuiCheckboxTextColor() );
+ _rank_collapse_depth_tf.setBorder( null );
+ }
+ final JPanel panel = new JPanel( new GridLayout( 1, 3, 0, 0 ) );
+ if ( !_configuration.isUseNativeUI() ) {
+ panel.setBackground( getBackground() );
+ }
+ add( panel );
+ addJButton( _decr_rank_collapse_level, panel );
+ addJTextField( _rank_collapse_depth_tf, panel );
+ addJButton( _incr_rank_collapse_level, panel );
+ }
+
void setupSearchTools0() {
final JLabel search_label = new JLabel( "Search (A):" );
search_label.setFont( ControlPanel.jcb_bold_font );
void setVisibilityOfDomainStrucureCB() {
try {
- if ( ( getCurrentTreePanel() != null )
- && ( ( getCurrentTreePanel().getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) || ( getCurrentTreePanel()
- .getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) ) ) {
+ if ( ( getCurrentTreePanel() != null ) && ( ( getCurrentTreePanel()
+ .getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
+ || ( getCurrentTreePanel().getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) ) ) {
if ( getMainPanel().getMainFrame()._right_line_up_domains_cbmi != null ) {
getMainPanel().getMainFrame()._right_line_up_domains_cbmi.setVisible( false );
}
}
}
}
- if ( isDrawPhylogram()
- || ( ( getCurrentTreePanel() != null ) && ( ( getCurrentTreePanel().getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) || ( getCurrentTreePanel()
- .getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) ) ) ) {
+ if ( isDrawPhylogram() || ( ( getCurrentTreePanel() != null ) && ( ( getCurrentTreePanel()
+ .getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
+ || ( getCurrentTreePanel().getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) ) ) ) {
if ( mf._non_lined_up_cladograms_rbmi != null ) {
mf._non_lined_up_cladograms_rbmi.setVisible( false );
}
- if ( mf._uniform_cladograms_rbmi != null ) {
- mf._uniform_cladograms_rbmi.setVisible( false );
- }
if ( mf._ext_node_dependent_cladogram_rbmi != null ) {
mf._ext_node_dependent_cladogram_rbmi.setVisible( false );
}
if ( mf._non_lined_up_cladograms_rbmi != null ) {
mf._non_lined_up_cladograms_rbmi.setVisible( true );
}
- if ( mf._uniform_cladograms_rbmi != null ) {
- mf._uniform_cladograms_rbmi.setVisible( true );
- }
if ( mf._ext_node_dependent_cladogram_rbmi != null ) {
mf._ext_node_dependent_cladogram_rbmi.setVisible( true );
}
* Fit entire tree into window.
*/
void showWhole() {
- if ( ( _mainpanel.getCurrentScrollPane() == null ) || _mainpanel.getCurrentTreePanel().getPhylogeny().isEmpty() ) {
+ if ( ( _mainpanel.getCurrentScrollPane() == null )
+ || _mainpanel.getCurrentTreePanel().getPhylogeny().isEmpty() ) {
return;
}
getCurrentTreePanel().updateSetOfCollapsedExternalNodes();
e.setSelectedTypeInTypeMenu( e.getCurrentTreePanel().getPhylogenyGraphicsType() );
}
else {
- getMainPanel().getMainFrame().setSelectedTypeInTypeMenu( getMainPanel().getCurrentTreePanel()
- .getPhylogenyGraphicsType() );
+ getMainPanel().getMainFrame()
+ .setSelectedTypeInTypeMenu( getMainPanel().getCurrentTreePanel().getPhylogenyGraphicsType() );
}
getMainPanel().getCurrentTreePanel().updateSubSuperTreeButton();
getMainPanel().getControlPanel().search0();
getMainPanel().getControlPanel().search1();
getMainPanel().getControlPanel().updateDomainStructureEvaluethresholdDisplay();
+ getMainPanel().getControlPanel().updateDepthCollapseDepthDisplay();
+ getMainPanel().getControlPanel().updateRankCollapseRankDisplay();
getSequenceRelationTypeBox().removeAllItems();
for( final SequenceRelation.SEQUENCE_RELATION_TYPE type : getMainPanel().getCurrentPhylogeny()
.getRelevantSequenceRelationTypes() ) {
/**
* Uncollapse all nodes.
*/
- void uncollapseAll( final TreePanel tp ) {
+ final void uncollapseAll( final TreePanel tp ) {
final Phylogeny t = tp.getPhylogeny();
if ( ( t != null ) && !t.isEmpty() ) {
for( final PhylogenyNodeIterator iter = t.iteratorPreorder(); iter.hasNext(); ) {
t.recalculateNumberOfExternalDescendants( false );
tp.setNodeInPreorderToNull();
t.clearHashIdToNodeMap();
+ tp.resetDepthCollapseDepthValue();
+ tp.resetRankCollapseRankValue();
showWhole();
}
}
- void updateDomainStructureEvaluethresholdDisplay() {
+ final void updateDomainStructureEvaluethresholdDisplay() {
if ( _domain_structure_evalue_thr_tf != null ) {
- _domain_structure_evalue_thr_tf.setText( "10^"
- + getMainPanel().getCurrentTreePanel().getDomainStructureEvalueThresholdExp() );
+ _domain_structure_evalue_thr_tf
+ .setText( "10^" + getMainPanel().getCurrentTreePanel().getDomainStructureEvalueThresholdExp() );
+ }
+ }
+
+ private final String obtainDepthCollapseDepthValue() {
+ if ( getMainPanel().getCurrentTreePanel() == null ) {
+ return "";
+ }
+ final TreePanel tp = getMainPanel().getCurrentTreePanel();
+ final Phylogeny p = tp.getPhylogeny();
+ if ( ( p == null ) || ( p.getNumberOfExternalNodes() < 3 ) ) {
+ return "off";
+ }
+ else if ( tp.getDepthCollapseDepthValue() < 0 ) {
+ tp.setDepthCollapseDepthValue( PhylogenyMethods.calculateMaxDepth( p ) );
+ return "off";
+ }
+ else if ( tp.getDepthCollapseDepthValue() == PhylogenyMethods.calculateMaxDepth( p ) ) {
+ return "off";
+ }
+ return String.valueOf( tp.getDepthCollapseDepthValue() );
+ }
+
+ private final String obtainRankCollapseDepthValue() {
+ if ( getMainPanel().getCurrentTreePanel() == null ) {
+ return "";
+ }
+ final TreePanel tp = getMainPanel().getCurrentTreePanel();
+ final Phylogeny p = tp.getPhylogeny();
+ if ( ( p == null ) || ( p.getNumberOfExternalNodes() < 3 ) ) {
+ return "off";
+ }
+ else {
+ final String ranks[] = PhylogenyMethods.obtainPresentRanksSorted( p );
+ if ( ranks.length < 1 ) {
+ return "off";
+ }
+ else if ( tp.getRankCollapseRankValue() < 0 ) {
+ tp.setRankCollapseRankValue( ranks.length - 1 );
+ return "off";
+ }
+ else if ( tp.getRankCollapseRankValue() == ( ranks.length - 1 ) ) {
+ return "off";
+ }
+ }
+ return String.valueOf( tp.getRankCollapseRankValue() );
+ }
+
+ final void updateDepthCollapseDepthDisplay() {
+ if ( _depth_collapse_depth_tf != null ) {
+ _depth_collapse_depth_tf.setText( " " + obtainDepthCollapseDepthValue() );
+ }
+ }
+
+ final void updateRankCollapseRankDisplay() {
+ if ( _rank_collapse_depth_tf != null ) {
+ final String r = obtainRankCollapseDepthValue();
+ if ( r.equals( "off" ) ) {
+ _rank_collapse_depth_tf.setText( " off" );
+ _rank_collapse_depth_tf.setToolTipText( "the current taxonomic rank threshold" );
+ }
+ else {
+ final String ranks[] = PhylogenyMethods
+ .obtainPresentRanksSorted( getMainPanel().getCurrentTreePanel().getPhylogeny() );
+ final int rr = Integer.parseInt( r );
+ _rank_collapse_depth_tf.setText( ranks[ rr ] );
+ _rank_collapse_depth_tf.setToolTipText( ( rr + 1 ) + "/" + ( ranks.length - 1 ) + ": "
+ + ranks[ Integer.parseInt( r ) ] );
+ }
}
}
- void zoomInX( final float factor, final float x_correction_factor ) {
+ final void zoomInX( final float factor, final float x_correction_factor ) {
final JScrollBar sb = getMainPanel().getCurrentScrollPane().getHorizontalScrollBar();
final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
treepanel.multiplyUrtFactor( 1f );
|| ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED )
|| isDrawPhylogram( getMainPanel().getCurrentTabIndex() )
|| ( getOptions().getCladogramType() == CLADOGRAM_TYPE.NON_LINED_UP ) ) {
- final double x = ( sb.getMaximum() - sb.getMinimum() ) / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
+ final double x = ( sb.getMaximum() - sb.getMinimum() )
+ / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
treepanel.setXdistance( ( treepanel.getXdistance() * factor ) );
treepanel.setXcorrectionFactor( ( treepanel.getXcorrectionFactor() * x_correction_factor ) );
getMainPanel().adjustJScrollPane();
treepanel.resetPreferredSize();
getMainPanel().getCurrentScrollPane().getViewport().validate();
- sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
- - ( sb.getVisibleAmount() / 2.0 ) ) );
+ sb.setValue( ForesterUtil
+ .roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x ) - ( sb.getVisibleAmount() / 2.0 ) ) );
}
else {
final int x = sb.getMaximum() - sb.getMinimum() - sb.getVisibleAmount() - sb.getValue();
treepanel.updateOvSizes();
}
- void zoomInY( final float factor ) {
+ final void zoomInY( final float factor ) {
final JScrollBar sb = getMainPanel().getCurrentScrollPane().getVerticalScrollBar();
final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
treepanel.multiplyUrtFactor( 1.1f );
getMainPanel().adjustJScrollPane();
treepanel.resetPreferredSize();
getMainPanel().getCurrentScrollPane().getViewport().validate();
- sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
- - ( sb.getVisibleAmount() / 2.0 ) ) );
+ sb.setValue( ForesterUtil
+ .roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x ) - ( sb.getVisibleAmount() / 2.0 ) ) );
treepanel.resetPreferredSize();
treepanel.updateOvSizes();
}
- void zoomOutX( final float factor, final float x_correction_factor ) {
+ final void zoomOutX( final float factor, final float x_correction_factor ) {
final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
treepanel.multiplyUrtFactor( 1f );
if ( ( treepanel.getXdistance() * factor ) > 0.0 ) {
}
}
- void zoomOutY( final float factor ) {
+ final void zoomOutY( final float factor ) {
final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
treepanel.multiplyUrtFactor( 0.9f );
if ( ( treepanel.getYdistance() * factor ) > 0.0 ) {
final JScrollBar sb = getMainPanel().getCurrentScrollPane().getVerticalScrollBar();
- final double x = ( sb.getMaximum() - sb.getMinimum() ) / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
+ final double x = ( sb.getMaximum() - sb.getMinimum() )
+ / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
treepanel.setYdistance( ( treepanel.getYdistance() * factor ) );
getMainPanel().adjustJScrollPane();
treepanel.resetPreferredSize();
getMainPanel().getCurrentScrollPane().getViewport().validate();
- sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
- - ( sb.getVisibleAmount() / 2.0 ) ) );
+ sb.setValue( ForesterUtil
+ .roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x ) - ( sb.getVisibleAmount() / 2.0 ) ) );
treepanel.resetPreferredSize();
treepanel.updateOvSizes();
}
}
- static JLabel customizeLabel( final JLabel label, final Configuration configuration ) {
+ final static JLabel customizeLabel( final JLabel label, final Configuration configuration ) {
label.setFont( ControlPanel.jcb_bold_font );
if ( !configuration.isUseNativeUI() ) {
label.setForeground( configuration.getGuiCheckboxTextColor() );
return label;
}
- public JCheckBox getUseBranchWidthsCb() {
+ final public JCheckBox getUseBranchWidthsCb() {
return _width_branches;
}
}
final static MsaFileFilter msafilter = new MsaFileFilter();
final static SequencesFileFilter seqsfilter = new SequencesFileFilter();
final static DefaultFilter defaultfilter = new DefaultFilter();
- static final String USE_MOUSEWHEEL_SHIFT_TO_ROTATE = "In this display type, use mousewheel + Shift to rotate [or A and S]";
+ static final String USE_MOUSEWHEEL_SHIFT_TO_ROTATE = "rotate with mousewheel + Shift (or A and S), D toggles between horizontal and radial labels";
static final String PHYLOXML_REF_TOOL_TIP = AptxConstants.PHYLOXML_REFERENCE; //TODO //FIXME
static final String APTX_REF_TOOL_TIP = AptxConstants.APTX_REFERENCE;
private static final long serialVersionUID = 3655000897845508358L;
static final String INVERSE_SEARCH_RESULT_LABEL = "Negate Result";
static final String COLOR_BY_TAXONOMIC_GROUP = "Colorize by Taxonomic Group";
static final String DISPLAY_SCALE_LABEL = "Scale";
- static final String NON_LINED_UP_CLADOGRAMS_LABEL = "Non-Lined Up Cladograms";
- static final String UNIFORM_CLADOGRAMS_LABEL = "Total Node Sum Dependent Cladograms";
+ static final String NON_LINED_UP_CLADOGRAMS_LABEL = "Non-Lined Up Cladogram";
static final String LABEL_DIRECTION_LABEL = "Radial Labels";
static final String LABEL_DIRECTION_TIP = "To use radial node labels in radial and unrooted display types";
static final String SEARCH_WITH_REGEX_TIP = "To search using regular expressions (~Java/Perl syntax). For example, use \"^B.+\\d{2,}$\" to search for everything starting with a B and ending with at least two digits.";
static final String DISPLAY_NODE_BOXES_LABEL_MARKED = "Shapes for Nodes with Visual Data";
static final String SHOW_OVERVIEW_LABEL = "Overview";
static final String FONT_SIZE_MENU_LABEL = "Font Size";
- static final String NONUNIFORM_CLADOGRAMS_LABEL = "External Node Sum Dependent Cladograms";
+ static final String NONUNIFORM_CLADOGRAMS_LABEL = "Lined Up Cladogram";
static final String SHOW_DOMAIN_LABELS_LABEL = "Domain Labels";
static final String SHOW_ANN_REF_SOURCE_LABEL = "Seq Annotation Ref Sources";
static final String COLOR_LABELS_TIP = "To use parent branch colors for node labels as well, need to turn off taxonomy dependent colorization and turn on branch colorization for this to become apparent";
JCheckBoxMenuItem _screen_antialias_cbmi;
JCheckBoxMenuItem _background_gradient_cbmi;
JRadioButtonMenuItem _non_lined_up_cladograms_rbmi;
- JRadioButtonMenuItem _uniform_cladograms_rbmi;
JRadioButtonMenuItem _ext_node_dependent_cladogram_rbmi;
JCheckBoxMenuItem _color_by_taxonomic_group_cbmi;
JCheckBoxMenuItem _show_scale_cbmi; //TODO fix me
JCheckBoxMenuItem _show_confidence_stddev_cbmi;
JCheckBoxMenuItem _right_line_up_domains_cbmi;
JCheckBoxMenuItem _line_up_renderable_data_cbmi;
+ JCheckBoxMenuItem _collapsed_with_average_height_cbmi;
// _ print
JCheckBoxMenuItem _graphics_export_visible_only_cbmi;
JCheckBoxMenuItem _antialias_print_cbmi;
updateOptions( getOptions() );
showWhole();
}
- else if ( o == _uniform_cladograms_rbmi ) {
- updateOptions( getOptions() );
- showWhole();
- }
else if ( o == _ext_node_dependent_cladogram_rbmi ) {
updateOptions( getOptions() );
showWhole();
}
updateOptions( getOptions() );
}
+
+ else if ( o == _collapsed_with_average_height_cbmi ) {
+ if ( _collapsed_with_average_height_cbmi.isSelected() ) {
+ _collapsed_with_average_height_cbmi.setSelected( true );
+ }
+ updateOptions( getOptions() );
+ }
else if ( o == _right_line_up_domains_cbmi ) {
if ( _right_line_up_domains_cbmi.isSelected() ) {
_line_up_renderable_data_cbmi.setSelected( true );
customizeCheckBoxMenuItem( _convex_type_cbmi, false );
customizeCheckBoxMenuItem( _unrooted_type_cbmi, false );
customizeCheckBoxMenuItem( _circular_type_cbmi, false );
+ _triangular_type_cbmi.setToolTipText( "not suitable for phylograms" );
+ _curved_type_cbmi.setToolTipText( "not suitable for phylograms" );
_unrooted_type_cbmi.setToolTipText( MainFrame.USE_MOUSEWHEEL_SHIFT_TO_ROTATE );
_circular_type_cbmi.setToolTipText( MainFrame.USE_MOUSEWHEEL_SHIFT_TO_ROTATE );
initializeTypeMenu( getOptions() );
if ( ( _non_lined_up_cladograms_rbmi != null ) && ( _non_lined_up_cladograms_rbmi.isSelected() ) ) {
options.setCladogramType( CLADOGRAM_TYPE.NON_LINED_UP );
}
- else if ( ( _uniform_cladograms_rbmi != null ) && ( _uniform_cladograms_rbmi.isSelected() ) ) {
- options.setCladogramType( CLADOGRAM_TYPE.TOTAL_NODE_SUM_DEP );
- }
else if ( ( _ext_node_dependent_cladogram_rbmi != null ) && ( _ext_node_dependent_cladogram_rbmi.isSelected() ) ) {
- options.setCladogramType( CLADOGRAM_TYPE.EXT_NODE_SUM_DEP );
+ options.setCladogramType( CLADOGRAM_TYPE.LINED_UP );
}
options.setSearchCaseSensitive( ( _search_case_senstive_cbmi != null )
&& _search_case_senstive_cbmi.isSelected() );
if ( ( _parse_beast_style_extended_nexus_tags_cbmi != null ) && _parse_beast_style_extended_nexus_tags_cbmi.isEnabled() ) {
options.setParseBeastStyleExtendedNexusTags(_parse_beast_style_extended_nexus_tags_cbmi.isSelected() );
}
+ if ( ( _collapsed_with_average_height_cbmi != null ) && _collapsed_with_average_height_cbmi.isEnabled() ) {
+ options.setCollapsedWithAverageHeigh(_collapsed_with_average_height_cbmi.isSelected() );
+ }
+
}
void updateTypeCheckboxes( final Options options, final Object o ) {
getConfiguration() ) );
_options_jmenu
.add( _ext_node_dependent_cladogram_rbmi = new JRadioButtonMenuItem( MainFrame.NONUNIFORM_CLADOGRAMS_LABEL ) );
- _options_jmenu.add( _uniform_cladograms_rbmi = new JRadioButtonMenuItem( MainFrame.UNIFORM_CLADOGRAMS_LABEL ) );
_options_jmenu.add( _non_lined_up_cladograms_rbmi = new JRadioButtonMenuItem( NON_LINED_UP_CLADOGRAMS_LABEL ) );
_radio_group_1 = new ButtonGroup();
_radio_group_1.add( _ext_node_dependent_cladogram_rbmi );
- _radio_group_1.add( _uniform_cladograms_rbmi );
- _radio_group_1.add( _non_lined_up_cladograms_rbmi );
+ _radio_group_1.add( _non_lined_up_cladograms_rbmi );
_options_jmenu.add( _show_overview_cbmi = new JCheckBoxMenuItem( MainFrame.SHOW_OVERVIEW_LABEL ) );
_options_jmenu.add( _show_scale_cbmi = new JCheckBoxMenuItem( MainFrame.DISPLAY_SCALE_LABEL ) );
_options_jmenu
customizeCheckBoxMenuItem( _show_scale_cbmi, getOptions().isShowScale() );
customizeRadioButtonMenuItem( _non_lined_up_cladograms_rbmi,
getOptions().getCladogramType() == CLADOGRAM_TYPE.NON_LINED_UP );
- customizeRadioButtonMenuItem( _uniform_cladograms_rbmi,
- getOptions().getCladogramType() == CLADOGRAM_TYPE.TOTAL_NODE_SUM_DEP );
- customizeRadioButtonMenuItem( _ext_node_dependent_cladogram_rbmi,
- getOptions().getCladogramType() == CLADOGRAM_TYPE.EXT_NODE_SUM_DEP );
+ customizeRadioButtonMenuItem( _ext_node_dependent_cladogram_rbmi,
+ getOptions().getCladogramType() == CLADOGRAM_TYPE.LINED_UP );
customizeCheckBoxMenuItem( _show_overview_cbmi, getOptions().isShowOverview() );
customizeCheckBoxMenuItem( _label_direction_cbmi,
getOptions().getNodeLabelDirection() == NODE_LABEL_DIRECTION.RADIAL );
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
-import java.util.Map;
import java.util.Set;
import javax.swing.ButtonGroup;
// Application-only print menu items
private JMenuItem _collapse_below_threshold;
private JMenuItem _collapse_below_branch_length;
- private JMenuItem _collapse_by_taxonomic_rank;
private ButtonGroup _radio_group_1;
private ButtonGroup _radio_group_2;
// Others:
}
collapseBelowThreshold();
}
- else if ( o == _collapse_by_taxonomic_rank ) {
- if ( isSubtreeDisplayed() ) {
- return;
- }
- collapseByTaxonomicRank();
- }
+
else if ( o == _collapse_below_branch_length ) {
if ( isSubtreeDisplayed() ) {
return;
}
}
- private void collapse( final Phylogeny phy ) {
+ private void collapseBelowThreshold( final Phylogeny phy ) {
final PhylogenyNodeIterator it = phy.iteratorPostorder();
final List<PhylogenyNode> to_be_removed = new ArrayList<PhylogenyNode>();
double min_support = Double.MAX_VALUE;
}
}
- private void collapseByTaxonomicRank() {
- if ( _mainpanel.getCurrentTreePanel() != null ) {
- final Map<String, Integer> present_ranks = AptxUtil.getRankCounts( _mainpanel.getCurrentTreePanel().getPhylogeny());
- final String[] ranks = AptxUtil.getAllPossibleRanks(present_ranks);
- String rank = ( String ) JOptionPane
- .showInputDialog( this,
- "What rank should the collapsing be based on",
- "Rank Selection",
- JOptionPane.QUESTION_MESSAGE,
- null,
- ranks,
- null );
- if ( !ForesterUtil.isEmpty( rank ) ) {
- if ( rank.indexOf( '(' ) > 0 ) {
- rank = rank.substring( 0, rank.indexOf( '(' ) ).trim();
- }
- _mainpanel.getCurrentTreePanel().collapseByTaxonomicRank( rank );
- }
- }
- }
-
private void collapseBelowBranchLengthThreshold() {
if ( getCurrentTreePanel() != null ) {
final Phylogeny phy = getCurrentTreePanel().getPhylogeny();
}
if ( success && ( m >= 0.0 ) ) {
setMinNotCollapseConfidenceValue( m );
- collapse( phy );
+ collapseBelowThreshold( phy );
}
}
}
_options_jmenu.add( customizeMenuItemAsLabel( new JMenuItem( DISPLAY_SUBHEADER ), getConfiguration() ) );
_options_jmenu
.add( _ext_node_dependent_cladogram_rbmi = new JRadioButtonMenuItem( MainFrame.NONUNIFORM_CLADOGRAMS_LABEL ) );
- _options_jmenu.add( _uniform_cladograms_rbmi = new JRadioButtonMenuItem( MainFrame.UNIFORM_CLADOGRAMS_LABEL ) );
_options_jmenu.add( _non_lined_up_cladograms_rbmi = new JRadioButtonMenuItem( NON_LINED_UP_CLADOGRAMS_LABEL ) );
_radio_group_1 = new ButtonGroup();
_radio_group_1.add( _ext_node_dependent_cladogram_rbmi );
- _radio_group_1.add( _uniform_cladograms_rbmi );
- _radio_group_1.add( _non_lined_up_cladograms_rbmi );
+ _radio_group_1.add( _non_lined_up_cladograms_rbmi );
_options_jmenu.add( _show_overview_cbmi = new JCheckBoxMenuItem( SHOW_OVERVIEW_LABEL ) );
_options_jmenu.add( _show_scale_cbmi = new JCheckBoxMenuItem( DISPLAY_SCALE_LABEL ) );
_options_jmenu
.add( _show_default_node_shapes_external_cbmi = new JCheckBoxMenuItem( DISPLAY_NODE_BOXES_LABEL_EXT ) );
_options_jmenu
.add( _show_default_node_shapes_for_marked_cbmi = new JCheckBoxMenuItem( MainFrame.DISPLAY_NODE_BOXES_LABEL_MARKED ) );
+
+ _options_jmenu
+ .add( _collapsed_with_average_height_cbmi = new JCheckBoxMenuItem( "Proportional Height of Collapsed Subtrees" ) );
+
+
_options_jmenu
.add( _line_up_renderable_data_cbmi = new JCheckBoxMenuItem( MainFrame.LINE_UP_RENDERABLE_DATA ) );
+
+
+
if ( getConfiguration().doDisplayOption( Configuration.show_domain_architectures ) ) {
_options_jmenu
.add( _right_line_up_domains_cbmi = new JCheckBoxMenuItem( MainFrame.RIGHT_LINE_UP_DOMAINS ) );
customizeCheckBoxMenuItem( _abbreviate_scientific_names, getOptions().isAbbreviateScientificTaxonNames() );
customizeCheckBoxMenuItem( _search_case_senstive_cbmi, getOptions().isSearchCaseSensitive() );
customizeCheckBoxMenuItem( _show_scale_cbmi, getOptions().isShowScale() );
+ customizeCheckBoxMenuItem( _collapsed_with_average_height_cbmi, getOptions().isCollapsedWithAverageHeigh() );
customizeRadioButtonMenuItem( _non_lined_up_cladograms_rbmi,
getOptions().getCladogramType() == CLADOGRAM_TYPE.NON_LINED_UP );
- customizeRadioButtonMenuItem( _uniform_cladograms_rbmi,
- getOptions().getCladogramType() == CLADOGRAM_TYPE.TOTAL_NODE_SUM_DEP );
customizeRadioButtonMenuItem( _ext_node_dependent_cladogram_rbmi,
- getOptions().getCladogramType() == CLADOGRAM_TYPE.EXT_NODE_SUM_DEP );
+ getOptions().getCladogramType() == CLADOGRAM_TYPE.LINED_UP );
customizeCheckBoxMenuItem( _show_overview_cbmi, getOptions().isShowOverview() );
customizeCheckBoxMenuItem( _label_direction_cbmi,
getOptions().getNodeLabelDirection() == NODE_LABEL_DIRECTION.RADIAL );
_delete_not_selected_nodes_item.setToolTipText( "To delete all not selected external nodes" );
customizeJMenuItem( _delete_not_selected_nodes_item );
_tools_menu.addSeparator();
- _tools_menu.add( _collapse_species_specific_subtrees = new JMenuItem( "Collapse Species-Specific Subtrees" ) );
+ _tools_menu.add( _collapse_species_specific_subtrees = new JMenuItem( "Collapse Single Taxonomy-Subtrees" ) );
customizeJMenuItem( _collapse_species_specific_subtrees );
- _collapse_species_specific_subtrees.setToolTipText( "To (reversibly) collapse species-specific subtrees" );
- _tools_menu.add( _collapse_by_taxonomic_rank = new JMenuItem( "Collapse By Taxonomic Rank" ) );
- customizeJMenuItem( _collapse_by_taxonomic_rank );
- _collapse_by_taxonomic_rank.setToolTipText( "To (reversibly) collapse subtrees by taxonomic rank" );
+ _collapse_species_specific_subtrees.setToolTipText( "To (reversibly) collapse subtrees associated with only one taxonomy (such as species specific subtrees)" );
_tools_menu
.add( _collapse_below_threshold = new JMenuItem( "Collapse Branches with Confidence Below Threshold into Multifurcations" ) );
customizeJMenuItem( _collapse_below_threshold );
final public class Options {
public static enum CLADOGRAM_TYPE {
- EXT_NODE_SUM_DEP, NON_LINED_UP, TOTAL_NODE_SUM_DEP;
+ LINED_UP, NON_LINED_UP;
}
public static enum NODE_LABEL_DIRECTION {
private boolean _right_align_domains;
private boolean _color_all_found_nodes_when_coloring_subtree;
private boolean _parse_beast_style_extended_nexus_tags;
-
+ private boolean _collapsed_with_average_height;
+
private Options() {
init();
}
_ext_desc_data_to_return = NodeDataField.UNKNOWN;
_line_up_renderable_node_data = true;
_right_align_domains = false;
+ _collapsed_with_average_height= true;
}
final private void setNumberOfDigitsAfterCommaForBranchLength( final short number_of_digits_after_comma_for_branch_length_values ) {
return _parse_beast_style_extended_nexus_tags;
}
- final void setParseBeastStyleExtendedNexusTags( boolean parse_beast_style_extended_nexus_tags ) {
+ final void setParseBeastStyleExtendedNexusTags( final boolean parse_beast_style_extended_nexus_tags ) {
_parse_beast_style_extended_nexus_tags = parse_beast_style_extended_nexus_tags;
}
+
+ final boolean isCollapsedWithAverageHeigh() {
+ return _collapsed_with_average_height;
+ }
+
+ final void setCollapsedWithAverageHeigh( final boolean collapsed_with_average_height ) {
+ _collapsed_with_average_height = collapsed_with_average_height;
+ }
+
+
}
}
}
}
- public final static boolean SPECIAL_DOMAIN_COLORING = true;
- final static Cursor ARROW_CURSOR = Cursor.getPredefinedCursor( Cursor.DEFAULT_CURSOR );
- final static Cursor CUT_CURSOR = Cursor.getPredefinedCursor( Cursor.CROSSHAIR_CURSOR );
- final static Cursor HAND_CURSOR = Cursor.getPredefinedCursor( Cursor.HAND_CURSOR );
- final static Cursor MOVE_CURSOR = Cursor.getPredefinedCursor( Cursor.MOVE_CURSOR );
- final static Cursor WAIT_CURSOR = Cursor.getPredefinedCursor( Cursor.WAIT_CURSOR );
- final private static double _180_OVER_PI = 180.0 / Math.PI;
- private static final float ANGLE_ROTATION_UNIT = ( float ) ( Math.PI / 32 );
- private final static int CONFIDENCE_LEFT_MARGIN = 4;
- private final static int EURO_D = 10;
- private final static NumberFormat FORMATTER_BRANCH_LENGTH;
- private final static NumberFormat FORMATTER_CONFIDENCE;
- private static final float HALF_PI = ( float ) ( Math.PI / 2.0 );
- private final static int LIMIT_FOR_HQ_RENDERING = 2000;
- private final static int MAX_NODE_FRAMES = 10;
- private final static int MAX_SUBTREES = 100;
- private final static int MIN_ROOT_LENGTH = 3;
- private final static int MOVE = 20;
- private final static String NODE_POPMENU_NODE_CLIENT_PROPERTY = "node";
- private static final float ONEHALF_PI = ( float ) ( 1.5 * Math.PI );
- private static final short OV_BORDER = 10;
- private final static double OVERVIEW_FOUND_NODE_BOX_SIZE = 2;
- private final static double OVERVIEW_FOUND_NODE_BOX_SIZE_HALF = 1;
- private static final float PI = ( float ) ( Math.PI );
- final private static Font POPUP_FONT = new Font( Configuration.getDefaultFontFamilyName(),
- Font.PLAIN,
- 12 );
- private static final float ROUNDED_D = 8;
- private final static long serialVersionUID = -978349745916505029L;
- private static final BasicStroke STROKE_0025 = new BasicStroke( 0.025f );
- private static final BasicStroke STROKE_005 = new BasicStroke( 0.05f );
- private static final BasicStroke STROKE_01 = new BasicStroke( 0.1f );
- private static final BasicStroke STROKE_025 = new BasicStroke( 0.25f );
- private static final BasicStroke STROKE_05 = new BasicStroke( 0.5f );
- private static final BasicStroke STROKE_075 = new BasicStroke( 0.75f );
- private static final BasicStroke STROKE_1 = new BasicStroke( 1f );
- private static final BasicStroke STROKE_2 = new BasicStroke( 2f );
- private static final double TWO_PI = 2 * Math.PI;
- private final static int WIGGLE = 2;
- private static final String SHOW_ONLY_THIS_CONF_TYPE = null; //TODO remove me
- HashMap<Long, Short> _nodeid_dist_to_leaf = new HashMap<Long, Short>();
- final private Arc2D _arc = new Arc2D.Double();
- private AffineTransform _at;
- private int _circ_max_depth;
- final private Set<Long> _collapsed_external_nodeid_set = new HashSet<Long>();
- private JColorChooser _color_chooser = null;
- private Configuration _configuration = null;
- private ControlPanel _control_panel = null;
- private final CubicCurve2D _cubic_curve = new CubicCurve2D.Float();
- private Set<Long> _current_external_nodes = null;
- private StringBuilder _current_external_nodes_data_buffer = new StringBuilder();
- private int _current_external_nodes_data_buffer_change_counter = 0;
- private int _domain_structure_e_value_thr_exp = AptxConstants.DOMAIN_STRUCTURE_E_VALUE_THR_DEFAULT_EXP;
- private double _domain_structure_width = AptxConstants.DOMAIN_STRUCTURE_DEFAULT_WIDTH;
- private int _dynamic_hiding_factor = 0;
- private boolean _edited = false;
- private final Ellipse2D _ellipse = new Ellipse2D.Float();
- private int _external_node_index = 0;
- private Set<Long> _found_nodes_0 = null;
- private Set<Long> _found_nodes_1 = null;
- private final FontRenderContext _frc = new FontRenderContext( null,
- false,
- false );
- private PHYLOGENY_GRAPHICS_TYPE _graphics_type = PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR;
- private PhylogenyNode _highlight_node = null;
- private boolean _in_ov = false;
- private boolean _in_ov_rect = false;
- private float _last_drag_point_x = 0;
- private float _last_drag_point_y = 0;
- private final Line2D _line = new Line2D.Float();
- private int _longest_ext_node_info = 0;
- private PhylogenyNode _ext_node_with_longest_txt_info = null;
- private MainPanel _main_panel = null;
- private double _max_distance_to_root = -1;
- private Popup _node_desc_popup;
- private int _node_frame_index = 0;
- private final NodeFrame[] _node_frames = new NodeFrame[ TreePanel.MAX_NODE_FRAMES ];
- private JPopupMenu _node_popup_menu = null;
- private JMenuItem _node_popup_menu_items[] = null;
- private PhylogenyNode[] _nodes_in_preorder = null;
- private Options _options = null;
- private float _ov_max_height = 0;
- private float _ov_max_width = 0;
- private boolean _ov_on = false;
- private final Rectangle2D _ov_rectangle = new Rectangle2D.Float();
- private final Rectangle _ov_virtual_rectangle = new Rectangle();
- private float _ov_x_correction_factor = 0.0f;
- private float _ov_x_distance = 0;
- private int _ov_x_position = 0;
- private float _ov_y_distance = 0;
- private int _ov_y_position = 0;
- private int _ov_y_start = 0;
- private final boolean _phy_has_branch_lengths;
- private Phylogeny _phylogeny = null;
- private final Path2D.Float _polygon = new Path2D.Float();
- private final StringBuffer _popup_buffer = new StringBuffer();
- private final QuadCurve2D _quad_curve = new QuadCurve2D.Float();
- private Sequence _query_sequence = null;
- private final Rectangle2D _rectangle = new Rectangle2D.Float();
- private final RenderingHints _rendering_hints = new RenderingHints( RenderingHints.KEY_RENDERING,
- RenderingHints.VALUE_RENDER_DEFAULT );
- private JTextArea _rollover_popup;
- private PhylogenyNode _root;
- private final StringBuilder _sb = new StringBuilder();
- private double _scale_distance = 0.0;
- private String _scale_label = null;
- private DescriptiveStatistics _statistics_for_vector_data;
- private final Phylogeny[] _sub_phylogenies = new Phylogeny[ TreePanel.MAX_SUBTREES ];
- private final PhylogenyNode[] _sub_phylogenies_temp_roots = new PhylogenyNode[ TreePanel.MAX_SUBTREES ];
- private int _subtree_index = 0;
- private File _treefile = null;
- private float _urt_factor = 1;
- private float _urt_factor_ov = 1;
- final private HashMap<Long, Double> _urt_nodeid_angle_map = new HashMap<Long, Double>();
- final private HashMap<Long, Integer> _urt_nodeid_index_map = new HashMap<Long, Integer>();
- private double _urt_starting_angle = ( float ) ( Math.PI / 2 );
- private float _x_correction_factor = 0.0f;
- private float _x_distance = 0.0f;
- private float _y_distance = 0.0f;
- private int _length_of_longest_text;
- private int _longest_domain;
- private Map<String, AttributedString> _attributed_string_map = null;
+ public final static boolean SPECIAL_DOMAIN_COLORING = true;
+ final static Cursor ARROW_CURSOR = Cursor
+ .getPredefinedCursor( Cursor.DEFAULT_CURSOR );
+ final static Cursor CUT_CURSOR = Cursor
+ .getPredefinedCursor( Cursor.CROSSHAIR_CURSOR );
+ final static Cursor HAND_CURSOR = Cursor
+ .getPredefinedCursor( Cursor.HAND_CURSOR );
+ final static Cursor MOVE_CURSOR = Cursor
+ .getPredefinedCursor( Cursor.MOVE_CURSOR );
+ final static Cursor WAIT_CURSOR = Cursor
+ .getPredefinedCursor( Cursor.WAIT_CURSOR );
+ final private static double _180_OVER_PI = 180.0 / Math.PI;
+ private static final float ANGLE_ROTATION_UNIT = ( float ) ( Math.PI
+ / 32 );
+ private final static int CONFIDENCE_LEFT_MARGIN = 4;
+ private final static int EURO_D = 10;
+ private final static NumberFormat FORMATTER_BRANCH_LENGTH;
+ private final static NumberFormat FORMATTER_CONFIDENCE;
+ private static final float HALF_PI = ( float ) ( Math.PI
+ / 2.0 );
+ private final static int LIMIT_FOR_HQ_RENDERING = 2000;
+ private final static int MAX_NODE_FRAMES = 10;
+ private final static int MAX_SUBTREES = 100;
+ private final static int MIN_ROOT_LENGTH = 3;
+ private final static int MOVE = 20;
+ private final static String NODE_POPMENU_NODE_CLIENT_PROPERTY = "node";
+ private static final float ONEHALF_PI = ( float ) ( 1.5
+ * Math.PI );
+ private static final short OV_BORDER = 10;
+ private final static double OVERVIEW_FOUND_NODE_BOX_SIZE = 2;
+ private final static double OVERVIEW_FOUND_NODE_BOX_SIZE_HALF = 1;
+ private static final float PI = ( float ) ( Math.PI );
+ final private static Font POPUP_FONT = new Font( Configuration
+ .getDefaultFontFamilyName(), Font.PLAIN, 12 );
+ private static final float ROUNDED_D = 8;
+ private final static long serialVersionUID = -978349745916505029L;
+ private static final BasicStroke STROKE_0025 = new BasicStroke( 0.025f );
+ private static final BasicStroke STROKE_005 = new BasicStroke( 0.05f );
+ private static final BasicStroke STROKE_01 = new BasicStroke( 0.1f );
+ private static final BasicStroke STROKE_025 = new BasicStroke( 0.25f );
+ private static final BasicStroke STROKE_05 = new BasicStroke( 0.5f );
+ private static final BasicStroke STROKE_075 = new BasicStroke( 0.75f );
+ private static final BasicStroke STROKE_1 = new BasicStroke( 1f );
+ private static final BasicStroke STROKE_2 = new BasicStroke( 2f );
+ private static final double TWO_PI = 2 * Math.PI;
+ private final static int WIGGLE = 2;
+ private static final String SHOW_ONLY_THIS_CONF_TYPE = null; //TODO remove me
+ HashMap<Long, Short> _nodeid_dist_to_leaf = new HashMap<Long, Short>();
+ final private Arc2D _arc = new Arc2D.Double();
+ private AffineTransform _at;
+ private int _circ_max_depth;
+ final private Set<Long> _collapsed_external_nodeid_set = new HashSet<Long>();
+ private JColorChooser _color_chooser = null;
+ private Configuration _configuration = null;
+ private ControlPanel _control_panel = null;
+ private final CubicCurve2D _cubic_curve = new CubicCurve2D.Float();
+ private Set<Long> _current_external_nodes = null;
+ private StringBuilder _current_external_nodes_data_buffer = new StringBuilder();
+ private int _current_external_nodes_data_buffer_change_counter = 0;
+ private int _domain_structure_e_value_thr_exp = AptxConstants.DOMAIN_STRUCTURE_E_VALUE_THR_DEFAULT_EXP;
+ private double _domain_structure_width = AptxConstants.DOMAIN_STRUCTURE_DEFAULT_WIDTH;
+ private int _dynamic_hiding_factor = 0;
+ private boolean _edited = false;
+ private final Ellipse2D _ellipse = new Ellipse2D.Float();
+ private int _external_node_index = 0;
+ private Set<Long> _found_nodes_0 = null;
+ private Set<Long> _found_nodes_1 = null;
+ private final FontRenderContext _frc = new FontRenderContext( null,
+ false,
+ false );
+ private PHYLOGENY_GRAPHICS_TYPE _graphics_type = PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR;
+ private PhylogenyNode _highlight_node = null;
+ private boolean _in_ov = false;
+ private boolean _in_ov_rect = false;
+ private float _last_drag_point_x = 0;
+ private float _last_drag_point_y = 0;
+ private final Line2D _line = new Line2D.Float();
+ private int _longest_ext_node_info = 0;
+ private PhylogenyNode _ext_node_with_longest_txt_info = null;
+ private MainPanel _main_panel = null;
+ private double _max_distance_to_root = -1;
+ private Popup _node_desc_popup;
+ private int _node_frame_index = 0;
+ private final NodeFrame[] _node_frames = new NodeFrame[ TreePanel.MAX_NODE_FRAMES ];
+ private JPopupMenu _node_popup_menu = null;
+ private JMenuItem _node_popup_menu_items[] = null;
+ private PhylogenyNode[] _nodes_in_preorder = null;
+ private Options _options = null;
+ private float _ov_max_height = 0;
+ private float _ov_max_width = 0;
+ private boolean _ov_on = false;
+ private final Rectangle2D _ov_rectangle = new Rectangle2D.Float();
+ private final Rectangle _ov_virtual_rectangle = new Rectangle();
+ private float _ov_x_correction_factor = 0.0f;
+ private float _ov_x_distance = 0;
+ private int _ov_x_position = 0;
+ private float _ov_y_distance = 0;
+ private int _ov_y_position = 0;
+ private int _ov_y_start = 0;
+ private final boolean _phy_has_branch_lengths;
+ private Phylogeny _phylogeny = null;
+ private final Path2D.Float _polygon = new Path2D.Float();
+ private final StringBuffer _popup_buffer = new StringBuffer();
+ private final QuadCurve2D _quad_curve = new QuadCurve2D.Float();
+ private Sequence _query_sequence = null;
+ private final Rectangle2D _rectangle = new Rectangle2D.Float();
+ private final RenderingHints _rendering_hints = new RenderingHints( RenderingHints.KEY_RENDERING,
+ RenderingHints.VALUE_RENDER_DEFAULT );
+ private JTextArea _rollover_popup;
+ private PhylogenyNode _root;
+ private final StringBuilder _sb = new StringBuilder();
+ private double _scale_distance = 0.0;
+ private String _scale_label = null;
+ private DescriptiveStatistics _statistics_for_vector_data;
+ private final Phylogeny[] _sub_phylogenies = new Phylogeny[ TreePanel.MAX_SUBTREES ];
+ private final PhylogenyNode[] _sub_phylogenies_temp_roots = new PhylogenyNode[ TreePanel.MAX_SUBTREES ];
+ private int _subtree_index = 0;
+ private File _treefile = null;
+ private float _urt_factor = 1;
+ private float _urt_factor_ov = 1;
+ final private HashMap<Long, Double> _urt_nodeid_angle_map = new HashMap<Long, Double>();
+ final private HashMap<Long, Integer> _urt_nodeid_index_map = new HashMap<Long, Integer>();
+ private double _urt_starting_angle = ( float ) ( Math.PI
+ / 2 );
+ private float _x_correction_factor = 0.0f;
+ private float _x_distance = 0.0f;
+ private float _y_distance = 0.0f;
+ private int _length_of_longest_text;
+ private int _longest_domain;
+ private Map<String, AttributedString> _attributed_string_map = null;
+ private int _depth_collapse_level = -1;
+ private int _rank_collapse_level = -1;
static {
final DecimalFormatSymbols dfs = new DecimalFormatSymbols();
dfs.setDecimalSeparator( '.' );
addMouseWheelListener( this );
calculateScaleDistance();
FORMATTER_CONFIDENCE.setMaximumFractionDigits( configuration.getNumberOfDigitsAfterCommaForConfidenceValues() );
- FORMATTER_BRANCH_LENGTH.setMaximumFractionDigits( configuration
- .getNumberOfDigitsAfterCommaForBranchLengthValues() );
+ FORMATTER_BRANCH_LENGTH
+ .setMaximumFractionDigits( configuration.getNumberOfDigitsAfterCommaForBranchLengthValues() );
}
@Override
g.setColor( Color.BLACK );
}
else if ( ( ( action == NodeClickAction.COPY_SUBTREE ) || ( action == NodeClickAction.CUT_SUBTREE )
- || ( action == NodeClickAction.DELETE_NODE_OR_SUBTREE ) || ( action == NodeClickAction.PASTE_SUBTREE ) || ( action == NodeClickAction.ADD_NEW_NODE ) )
- && ( getCutOrCopiedTree() != null )
- && ( getCopiedAndPastedNodes() != null )
- && !to_pdf
- && !to_graphics_file && getCopiedAndPastedNodes().contains( node.getId() ) ) {
+ || ( action == NodeClickAction.DELETE_NODE_OR_SUBTREE ) || ( action == NodeClickAction.PASTE_SUBTREE )
+ || ( action == NodeClickAction.ADD_NEW_NODE ) ) && ( getCutOrCopiedTree() != null )
+ && ( getCopiedAndPastedNodes() != null ) && !to_pdf && !to_graphics_file
+ && getCopiedAndPastedNodes().contains( node.getId() ) ) {
g.setColor( getTreeColorSet().getFoundColor0() );
}
else if ( getControlPanel().isUseVisualStyles() && ( PhylogenyMethods.getBranchColorValue( node ) != null ) ) {
}
}
else if ( !ForesterUtil.isEmpty( node.getNodeData().getSequence().getMolecularSequence() ) ) {
- if ( ForesterUtil.seqIsLikelyToBeAa( node.getNodeData().getSequence().getMolecularSequence() ) ) {
+ if ( ForesterUtil
+ .seqIsLikelyToBeAa( node.getNodeData().getSequence().getMolecularSequence() ) ) {
type = 'p';
}
else {
nodeTaxonomyDataAsSB( _ext_node_with_longest_txt_info.getNodeData().getTaxonomy(), sb );
}
}
-
return getFontMetricsForLargeDefaultFont().stringWidth( sb.toString() );
}
else {
al = new SubtreeColorizationActionListener( _color_chooser, node );
}
- final JDialog dialog = JColorChooser
- .createDialog( this, "Subtree colorization", true, _color_chooser, al, null );
+ final JDialog dialog = JColorChooser.createDialog( this,
+ "Subtree colorization",
+ true,
+ _color_chooser,
+ al,
+ null );
setEdited( true );
dialog.setVisible( true );
}
g.draw( _arc );
}
- final private void drawLine( final double x1, final double y1, final double x2, final double y2, final Graphics2D g ) {
+ final private void drawLine( final double x1,
+ final double y1,
+ final double x2,
+ final double y2,
+ final Graphics2D g ) {
if ( ( x1 == x2 ) && ( y1 == y2 ) ) {
return;
}
}
}
- final private void drawRect( final float x, final float y, final float width, final float heigth, final Graphics2D g ) {
+ final private void drawRect( final float x,
+ final float y,
+ final float width,
+ final float heigth,
+ final Graphics2D g ) {
_rectangle.setFrame( x, y, width, heigth );
g.draw( _rectangle );
}
}
final private void increaseOvSize() {
- if ( ( getOvMaxWidth() < ( getMainPanel().getCurrentScrollPane().getViewport().getVisibleRect().getWidth() / 2 ) )
+ if ( ( getOvMaxWidth() < ( getMainPanel().getCurrentScrollPane().getViewport().getVisibleRect().getWidth()
+ / 2 ) )
&& ( getOvMaxHeight() < ( getMainPanel().getCurrentScrollPane().getViewport().getVisibleRect()
.getHeight() / 2 ) ) ) {
setOvMaxWidth( getOvMaxWidth() + 5 );
setTreeFile( null );
setEdited( false );
initializeOvSettings();
+ resetDepthCollapseDepthValue();
+ resetRankCollapseRankValue();
setStartingAngle( ( TWO_PI * 3 ) / 4 );
final ImageLoader il = new ImageLoader( this );
new Thread( il ).start();
final private boolean inOvVirtualRectangle( final int x, final int y ) {
return ( ( x >= ( getOvVirtualRectangle().x - 1 ) )
&& ( x <= ( getOvVirtualRectangle().x + getOvVirtualRectangle().width + 1 ) )
- && ( y >= ( getOvVirtualRectangle().y - 1 ) ) && ( y <= ( getOvVirtualRectangle().y
- + getOvVirtualRectangle().height + 1 ) ) );
+ && ( y >= ( getOvVirtualRectangle().y - 1 ) )
+ && ( y <= ( getOvVirtualRectangle().y + getOvVirtualRectangle().height + 1 ) ) );
}
final private boolean inOvVirtualRectangle( final MouseEvent e ) {
}
final private boolean isCanOpenTaxWeb( final PhylogenyNode node ) {
- if ( node.getNodeData().isHasTaxonomy()
- && ( ( !ForesterUtil.isEmpty( node.getNodeData().getTaxonomy().getScientificName() ) )
- || ( !ForesterUtil.isEmpty( node.getNodeData().getTaxonomy().getTaxonomyCode() ) )
- || ( !ForesterUtil.isEmpty( node.getNodeData().getTaxonomy().getCommonName() ) ) || ( ( node
- .getNodeData().getTaxonomy().getIdentifier() != null ) && !ForesterUtil.isEmpty( node
- .getNodeData().getTaxonomy().getIdentifier().getValue() ) ) ) ) {
+ if ( node.getNodeData().isHasTaxonomy() && ( ( !ForesterUtil
+ .isEmpty( node.getNodeData().getTaxonomy().getScientificName() ) )
+ || ( !ForesterUtil.isEmpty( node.getNodeData().getTaxonomy().getTaxonomyCode() ) )
+ || ( !ForesterUtil.isEmpty( node.getNodeData().getTaxonomy().getCommonName() ) )
+ || ( ( node.getNodeData().getTaxonomy().getIdentifier() != null )
+ && !ForesterUtil.isEmpty( node.getNodeData().getTaxonomy().getIdentifier().getValue() ) ) ) ) {
return true;
}
else {
y_dist = 40 + ( int ) getYdistance();
}
return ( ( node.getYcoord() < ( getVisibleRect().getMinY() - y_dist ) )
- || ( node.getYcoord() > ( getVisibleRect().getMaxY() + y_dist ) ) || ( ( node.getParent() != null ) && ( node
- .getParent().getXcoord() > getVisibleRect().getMaxX() ) ) );
+ || ( node.getYcoord() > ( getVisibleRect().getMaxY() + y_dist ) )
+ || ( ( node.getParent() != null ) && ( node.getParent().getXcoord() > getVisibleRect().getMaxX() ) ) );
}
final private boolean isNodeDataInvisibleUnrootedCirc( final PhylogenyNode node ) {
return ( ( node.getYcoord() < ( getVisibleRect().getMinY() - 20 ) )
|| ( node.getYcoord() > ( getVisibleRect().getMaxY() + 20 ) )
- || ( node.getXcoord() < ( getVisibleRect().getMinX() - 20 ) ) || ( node.getXcoord() > ( getVisibleRect()
- .getMaxX() + 20 ) ) );
+ || ( node.getXcoord() < ( getVisibleRect().getMinX() - 20 ) )
+ || ( node.getXcoord() > ( getVisibleRect().getMaxX() + 20 ) ) );
}
final private boolean isNonLinedUpCladogram() {
return getOptions().getCladogramType() == CLADOGRAM_TYPE.NON_LINED_UP;
}
- final private boolean isUniformBranchLengthsForCladogram() {
- return getOptions().getCladogramType() == CLADOGRAM_TYPE.TOTAL_NODE_SUM_DEP;
- }
-
final private void keyPressedCalls( final KeyEvent e ) {
if ( isOvOn() && ( getMousePosition() != null ) && ( getMousePosition().getLocation() != null ) ) {
if ( inOvVirtualRectangle( getMousePosition().x, getMousePosition().y ) ) {
}
sb.append( node.getNodeData().getSequence().getGeneName() );
}
- if ( getControlPanel().isShowSeqNames() && ( node.getNodeData().getSequence().getName().length() > 0 ) ) {
+ if ( getControlPanel().isShowSeqNames()
+ && ( node.getNodeData().getSequence().getName().length() > 0 ) ) {
if ( sb.length() > 0 ) {
sb.append( " " );
}
AptxUtil.launchWebBrowser( new URI( uri_str ),
isApplet(),
isApplet() ? obtainApplet() : null,
- "_aptx_seq" );
+ "_aptx_seq" );
}
catch ( final IOException e ) {
AptxUtil.showErrorMessage( this, e.toString() );
AptxUtil.launchWebBrowser( new URI( uri_str ),
isApplet(),
isApplet() ? obtainApplet() : null,
- "_aptx_seq" );
+ "_aptx_seq" );
}
catch ( final IOException e ) {
AptxUtil.showErrorMessage( this, e.toString() );
e.printStackTrace();
}
}
- else if ( ( tax.getIdentifier() != null )
- && !ForesterUtil.isEmpty( tax.getIdentifier().getValue() )
+ else if ( ( tax.getIdentifier() != null ) && !ForesterUtil.isEmpty( tax.getIdentifier().getValue() )
&& !ForesterUtil.isEmpty( tax.getIdentifier().getProvider() )
- && ( tax.getIdentifier().getProvider().equalsIgnoreCase( "ncbi" ) || tax.getIdentifier().getProvider()
- .equalsIgnoreCase( "uniprot" ) ) ) {
+ && ( tax.getIdentifier().getProvider().equalsIgnoreCase( "ncbi" )
+ || tax.getIdentifier().getProvider().equalsIgnoreCase( "uniprot" ) ) ) {
try {
uri_str = "http://www.uniprot.org/taxonomy/"
+ URLEncoder.encode( tax.getIdentifier().getValue(), ForesterConstants.UTF_8 );
AptxUtil.launchWebBrowser( new URI( uri_str ),
isApplet(),
isApplet() ? obtainApplet() : null,
- "_aptx_tax" );
+ "_aptx_tax" );
}
catch ( final IOException e ) {
AptxUtil.showErrorMessage( this, e.toString() );
}
if ( !node.isRoot() ) {
if ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE ) {
- TreePanel.drawString( FORMATTER_BRANCH_LENGTH.format( node.getDistanceToParent() ), node.getParent()
- .getXcoord() + EURO_D, node.getYcoord() - getTreeFontSet().getSmallMaxDescent(), g );
+ TreePanel.drawString( FORMATTER_BRANCH_LENGTH.format( node.getDistanceToParent() ),
+ node.getParent().getXcoord() + EURO_D,
+ node.getYcoord() - getTreeFontSet().getSmallMaxDescent(),
+ g );
}
else if ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.ROUNDED ) {
- TreePanel.drawString( FORMATTER_BRANCH_LENGTH.format( node.getDistanceToParent() ), node.getParent()
- .getXcoord() + ROUNDED_D, node.getYcoord() - getTreeFontSet().getSmallMaxDescent(), g );
+ TreePanel.drawString( FORMATTER_BRANCH_LENGTH.format( node.getDistanceToParent() ),
+ node.getParent().getXcoord() + ROUNDED_D,
+ node.getYcoord() - getTreeFontSet().getSmallMaxDescent(),
+ g );
}
else {
- TreePanel.drawString( FORMATTER_BRANCH_LENGTH.format( node.getDistanceToParent() ), node.getParent()
- .getXcoord() + 3, node.getYcoord() - getTreeFontSet().getSmallMaxDescent(), g );
+ TreePanel.drawString( FORMATTER_BRANCH_LENGTH.format( node.getDistanceToParent() ),
+ node.getParent().getXcoord() + 3,
+ node.getYcoord() - getTreeFontSet().getSmallMaxDescent(),
+ g );
}
}
else {
- TreePanel.drawString( FORMATTER_BRANCH_LENGTH.format( node.getDistanceToParent() ), 3, node.getYcoord()
- - getTreeFontSet().getSmallMaxDescent(), g );
+ TreePanel.drawString( FORMATTER_BRANCH_LENGTH.format( node.getDistanceToParent() ),
+ 3,
+ node.getYcoord() - getTreeFontSet().getSmallMaxDescent(),
+ g );
}
}
else if ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CURVED ) {
final float dx = x2 - x1;
final float dy = y2 - y1;
- _cubic_curve.setCurve( x1, y1, x1 + ( dx * 0.4f ), y1 + ( dy * 0.2f ), x1 + ( dx * 0.6f ), y1
- + ( dy * 0.8f ), x2, y2 );
+ _cubic_curve.setCurve( x1,
+ y1,
+ x1 + ( dx * 0.4f ),
+ y1 + ( dy * 0.2f ),
+ x1 + ( dx * 0.6f ),
+ y1 + ( dy * 0.8f ),
+ x2,
+ y2 );
( g ).draw( _cubic_curve );
}
else {
else if ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CURVED ) {
final float dx = x2 - x1;
final float dy = y2 - y1;
- _cubic_curve.setCurve( x1, y1, x1 + ( dx * 0.4f ), y1 + ( dy * 0.2f ), x1 + ( dx * 0.6f ), y1
- + ( dy * 0.8f ), x2, y2 );
+ _cubic_curve.setCurve( x1,
+ y1,
+ x1 + ( dx * 0.4f ),
+ y1 + ( dy * 0.2f ),
+ x1 + ( dx * 0.6f ),
+ y1 + ( dy * 0.8f ),
+ x2,
+ y2 );
g.draw( _cubic_curve );
}
else {
if ( node.isFirstChildNode() || node.isLastChildNode()
|| ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE )
|| ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.ROUNDED ) ) {
- if ( !to_graphics_file
- && !to_pdf
- && ( ( ( y2 < ( getVisibleRect().getMinY() - 20 ) ) && ( y1 < ( getVisibleRect().getMinY() - 20 ) ) ) || ( ( y2 > ( getVisibleRect()
- .getMaxY() + 20 ) ) && ( y1 > ( getVisibleRect().getMaxY() + 20 ) ) ) ) ) {
+ if ( !to_graphics_file && !to_pdf
+ && ( ( ( y2 < ( getVisibleRect().getMinY() - 20 ) )
+ && ( y1 < ( getVisibleRect().getMinY() - 20 ) ) )
+ || ( ( y2 > ( getVisibleRect().getMaxY() + 20 ) )
+ && ( y1 > ( getVisibleRect().getMaxY() + 20 ) ) ) ) ) {
// Do nothing.
}
else {
}
}
// draw the horizontal line
- if ( !to_graphics_file && !to_pdf
- && ( ( y2 < ( getVisibleRect().getMinY() - 20 ) ) || ( y2 > ( getVisibleRect().getMaxY() + 20 ) ) ) ) {
+ if ( !to_graphics_file && !to_pdf && ( ( y2 < ( getVisibleRect().getMinY() - 20 ) )
+ || ( y2 > ( getVisibleRect().getMaxY() + 20 ) ) ) ) {
return;
}
float x1_r = 0;
c = getTreeColorSet().getCollapseFillColor();
}
double d = node.getAllExternalDescendants().size();
- if ( d > 1000 ) {
- d = ( 3 * _y_distance ) / 3;
+ float xxx;
+ double s = 0;
+ if ( getControlPanel().isDrawPhylogram() ) {
+ if ( d > 1000 ) {
+ d = 0.75 * _y_distance;
+ }
+ else {
+ d = 0.25 * Math.log10( d ) * _y_distance;
+ }
+ final float half_box_size = 0.5f * getOptions().getDefaultNodeShapeSize();
+ if ( d < half_box_size ) {
+ d = half_box_size;
+ }
+ _polygon.reset();
+ final float xx = node.getXcoord() - ( getOptions().getDefaultNodeShapeSize() );
+ xxx = xx > ( node.getParent().getXcoord() + 1 ) ? xx : node.getParent().getXcoord() + 1;
+ _polygon.moveTo( xxx, node.getYcoord() + 0.5 );
+ _polygon.lineTo( xxx, node.getYcoord() - 0.5 );
+ s = _options.isCollapsedWithAverageHeigh()
+ ? PhylogenyMethods.calculateAverageTreeHeight( node ) * _x_correction_factor : 1;
+ _polygon.lineTo( node.getXcoord() + s, node.getYcoord() - d );
+ _polygon.lineTo( node.getXcoord() + s, node.getYcoord() + d );
+ _polygon.closePath();
}
else {
- d = ( Math.log10( d ) * _y_distance ) / 2.5;
- }
- final int box_size = getOptions().getDefaultNodeShapeSize() + 1;
- if ( d < box_size ) {
- d = box_size;
- }
- final float xx = node.getXcoord() - ( 2 * box_size );
- final float xxx = xx > ( node.getParent().getXcoord() + 1 ) ? xx : node.getParent().getXcoord() + 1;
- _polygon.reset();
- _polygon.moveTo( xxx, node.getYcoord() );
- _polygon.lineTo( node.getXcoord() + 1, node.getYcoord() - d );
- _polygon.lineTo( node.getXcoord() + 1, node.getYcoord() + d );
- _polygon.closePath();
+ if ( d > 1000 ) {
+ d = _y_distance;
+ }
+ else {
+ d = ( Math.log10( d ) * _y_distance ) / 2.5;
+ }
+ final int box_size = getOptions().getDefaultNodeShapeSize() + 1;
+ if ( d < box_size ) {
+ d = box_size;
+ }
+ final float xx = node.getXcoord() - ( 2 * box_size );
+ xxx = xx > ( node.getParent().getXcoord() + 1 ) ? xx : node.getParent().getXcoord() + 1;
+ _polygon.reset();
+ _polygon.moveTo( xxx, node.getYcoord() );
+ _polygon.lineTo( node.getXcoord() + 1, node.getYcoord() - d );
+ _polygon.lineTo( node.getXcoord() + 1, node.getYcoord() + d );
+ _polygon.closePath();
+ }
if ( getOptions().getDefaultNodeFill() == NodeVisualData.NodeFill.SOLID ) {
g.setColor( c );
g.fill( _polygon );
g.draw( _polygon );
}
else if ( getOptions().getDefaultNodeFill() == NodeFill.GRADIENT ) {
- g.setPaint( new GradientPaint( xxx, node.getYcoord(), getBackground(), node.getXcoord(), ( float ) ( node
- .getYcoord() - d ), c, false ) );
+ g.setPaint( new GradientPaint( xxx,
+ node.getYcoord(),
+ getBackground(),
+ node.getXcoord(),
+ ( float ) ( node.getYcoord() - d ),
+ c,
+ false ) );
g.fill( _polygon );
g.setPaint( c );
g.draw( _polygon );
}
- paintNodeData( g, node, to_graphics_file, to_pdf, is_in_found_nodes );
+ paintNodeData( g, node, to_graphics_file, to_pdf, is_in_found_nodes, s );
}
final private void paintConfidenceValues( final Graphics2D g,
Collections.sort( confidences );
final StringBuilder sb = new StringBuilder();
for( final Confidence confidence : confidences ) {
- if ( ForesterUtil.isEmpty( SHOW_ONLY_THIS_CONF_TYPE )
- || ( !ForesterUtil.isEmpty( confidence.getType() ) && confidence.getType()
- .equalsIgnoreCase( SHOW_ONLY_THIS_CONF_TYPE ) ) ) {
+ if ( ForesterUtil.isEmpty( SHOW_ONLY_THIS_CONF_TYPE ) || ( !ForesterUtil.isEmpty( confidence.getType() )
+ && confidence.getType().equalsIgnoreCase( SHOW_ONLY_THIS_CONF_TYPE ) ) ) {
final double value = confidence.getValue();
if ( value != Confidence.CONFIDENCE_DEFAULT_VALUE ) {
if ( value < getOptions().getMinConfidenceValue() ) {
else {
not_first = true;
}
- sb.append( FORMATTER_CONFIDENCE.format( ForesterUtil.round( value, getOptions()
- .getNumberOfDigitsAfterCommaForConfidenceValues() ) ) );
+ sb.append( FORMATTER_CONFIDENCE.format( ForesterUtil
+ .round( value, getOptions().getNumberOfDigitsAfterCommaForConfidenceValues() ) ) );
if ( getOptions().isShowConfidenceStddev() ) {
if ( confidence.getStandardDeviation() != Confidence.CONFIDENCE_DEFAULT_VALUE ) {
sb.append( "(" );
- sb.append( FORMATTER_CONFIDENCE.format( ForesterUtil.round( confidence
- .getStandardDeviation(), getOptions()
- .getNumberOfDigitsAfterCommaForConfidenceValues() ) ) );
+ sb.append( FORMATTER_CONFIDENCE
+ .format( ForesterUtil.round( confidence.getStandardDeviation(),
+ getOptions()
+ .getNumberOfDigitsAfterCommaForConfidenceValues() ) ) );
sb.append( ")" );
}
}
}
final String conf_str = sb.toString();
TreePanel.drawString( conf_str,
- parent_x
- + ( ( x - parent_x - getTreeFontSet().getFontMetricsSmall()
- .stringWidth( conf_str ) ) / 2 ),
- ( node.getYcoord() + getTreeFontSet().getSmallMaxAscent() ) - 1,
- g );
+ parent_x + ( ( x - parent_x
+ - getTreeFontSet().getFontMetricsSmall().stringWidth( conf_str ) ) / 2 ),
+ ( node.getYcoord() + getTreeFontSet().getSmallMaxAscent() ) - 1,
+ g );
}
}
if ( AptxConstants.SPECIAL_CUSTOM ) {
g.setColor( Color.BLUE );
}
- TreePanel
- .drawString( gained,
- parent_x
- + ( ( x - parent_x - getFontMetricsForLargeDefaultFont().stringWidth( gained ) ) / 2 ),
- ( node.getYcoord() - getFontMetricsForLargeDefaultFont().getMaxDescent() ),
- g );
+ TreePanel.drawString( gained,
+ parent_x + ( ( x - parent_x
+ - getFontMetricsForLargeDefaultFont().stringWidth( gained ) ) / 2 ),
+ ( node.getYcoord() - getFontMetricsForLargeDefaultFont().getMaxDescent() ),
+ g );
g.setColor( getTreeColorSet().getLostCharactersColor() );
- TreePanel
- .drawString( lost,
- parent_x
- + ( ( x - parent_x - getFontMetricsForLargeDefaultFont().stringWidth( lost ) ) / 2 ),
- ( node.getYcoord() + getFontMetricsForLargeDefaultFont().getMaxAscent() ),
- g );
+ TreePanel.drawString( lost,
+ parent_x + ( ( x - parent_x
+ - getFontMetricsForLargeDefaultFont().stringWidth( lost ) ) / 2 ),
+ ( node.getYcoord() + getFontMetricsForLargeDefaultFont().getMaxAscent() ),
+ g );
}
}
private void paintMolecularSequences( final Graphics2D g, final PhylogenyNode node, final boolean to_pdf ) {
- final RenderableMsaSequence rs = RenderableMsaSequence.createInstance( node.getNodeData().getSequence()
- .getMolecularSequence(), node.getNodeData().getSequence().getType(), getConfiguration() );
+ final RenderableMsaSequence rs = RenderableMsaSequence
+ .createInstance( node.getNodeData().getSequence().getMolecularSequence(),
+ node.getNodeData().getSequence().getType(),
+ getConfiguration() );
if ( rs != null ) {
final int default_height = 8;
final float y = getYdistance();
|| ( getOptions().isShowDefaultNodeShapesExternal() && node.isExternal() )
|| ( getOptions().isShowDefaultNodeShapesInternal() && node.isInternal() )
|| ( getOptions().isShowDefaultNodeShapesForMarkedNodes()
- && ( node.getNodeData().getNodeVisualData() != null ) && ( !node.getNodeData()
- .getNodeVisualData().isEmpty() ) )
- || ( 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() ) ) ) {
+ && ( node.getNodeData().getNodeVisualData() != null )
+ && ( !node.getNodeData().getNodeVisualData().isEmpty() ) )
+ || ( 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() ) ) ) {
NodeVisualData vis = null;
if ( getControlPanel().isUseVisualStyles() && ( node.getNodeData().getNodeVisualData() != null )
&& ( !node.getNodeData().getNodeVisualData().isEmpty() ) ) {
}
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 );
+ 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 ( fill == NodeFill.NONE ) {
Color background = getBackground();
}
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 );
+ 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 ( fill == NodeVisualData.NodeFill.NONE ) {
Color background = getBackground();
final PhylogenyNode node,
final boolean to_graphics_file,
final boolean to_pdf,
- final boolean is_in_found_nodes ) {
+ final boolean is_in_found_nodes,
+ final double add ) {
if ( isNodeDataInvisible( node ) && !to_graphics_file && !to_pdf ) {
return 0;
}
if ( getControlPanel().isWriteBranchLengthValues()
&& ( ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR )
- || ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.ROUNDED ) || ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE ) )
- && ( !node.isRoot() ) && ( node.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) ) {
+ || ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.ROUNDED )
+ || ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE ) )
+ && ( !node.isRoot() ) && ( node.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) ) {
paintBranchLength( g, node, to_pdf, to_graphics_file );
}
if ( !getControlPanel().isShowInternalData() && !node.isExternal() && !node.isCollapse() ) {
}
_sb.setLength( 0 );
int x = 0;
+ if ( add > 0 ) {
+ x += add;
+ }
final int half_box_size = getOptions().getDefaultNodeShapeSize() / 2;
- if ( getControlPanel().isShowTaxonomyImages()
- && ( getImageMap() != null )
- && !getImageMap().isEmpty()
- && node.getNodeData().isHasTaxonomy()
- && ( ( node.getNodeData().getTaxonomy().getUris() != null ) && !node.getNodeData().getTaxonomy()
- .getUris().isEmpty() ) ) {
+ if ( getControlPanel().isShowTaxonomyImages() && ( getImageMap() != null ) && !getImageMap().isEmpty()
+ && node.getNodeData().isHasTaxonomy() && ( ( node.getNodeData().getTaxonomy().getUris() != null )
+ && !node.getNodeData().getTaxonomy().getUris().isEmpty() ) ) {
x += drawTaxonomyImage( node.getXcoord() + 2 + half_box_size, node.getYcoord(), node, g );
}
- if ( ( getControlPanel().isShowTaxonomyCode() || getControlPanel().isShowTaxonomyScientificNames() || getControlPanel()
- .isShowTaxonomyCommonNames() || getControlPanel().isShowTaxonomyRank() ) && node.getNodeData().isHasTaxonomy() ) {
+ if ( ( getControlPanel().isShowTaxonomyCode() || getControlPanel().isShowTaxonomyScientificNames()
+ || getControlPanel().isShowTaxonomyCommonNames() || getControlPanel().isShowTaxonomyRank() )
+ && node.getNodeData().isHasTaxonomy() ) {
x += paintTaxonomy( g, node, is_in_found_nodes, to_pdf, to_graphics_file, x );
}
setColor( g, node, to_graphics_file, to_pdf, is_in_found_nodes, getTreeColorSet().getSequenceColor() );
else {
final List<SequenceRelation> seqRelations = node.getNodeData().getSequence().getSequenceRelations();
for( final SequenceRelation seqRelation : seqRelations ) {
- final boolean fGotRelationWithQuery = ( seqRelation.getRef0().isEqual( _query_sequence ) || seqRelation
- .getRef1().isEqual( _query_sequence ) )
- && seqRelation.getType().equals( getControlPanel().getSequenceRelationTypeBox()
- .getSelectedItem() );
+ final boolean fGotRelationWithQuery = ( seqRelation.getRef0().isEqual( _query_sequence )
+ || seqRelation.getRef1().isEqual( _query_sequence ) )
+ && seqRelation.getType()
+ .equals( getControlPanel().getSequenceRelationTypeBox().getSelectedItem() );
if ( fGotRelationWithQuery ) { // we will underline the text to show that this sequence is ortholog to the query
final double linePosX = node.getXcoord() + 2 + half_box_size;
- final String sConfidence = ( !getControlPanel().isShowSequenceRelationConfidence() || ( seqRelation
- .getConfidence() == null ) ) ? null : " (" + seqRelation.getConfidence().getValue()
- + ")";
+ final String sConfidence = ( !getControlPanel().isShowSequenceRelationConfidence()
+ || ( seqRelation.getConfidence() == null ) ) ? null
+ : " (" + seqRelation.getConfidence().getValue() + ")";
if ( sConfidence != null ) {
float confidenceX = pos_x;
if ( sb_str.length() > 0 ) {
}
if ( confidenceX > linePosX ) { // let's only display confidence value if we are already displaying at least one of Prot/Gene Name and Taxonomy Code
final int confidenceWidth = ( int ) new TextLayout( sConfidence, g.getFont(), _frc )
- .getBounds().getWidth();
+ .getBounds().getWidth();
TreePanel.drawString( sConfidence, confidenceX, pos_y, g );
x += CONFIDENCE_LEFT_MARGIN + confidenceWidth;
}
else {
nodeTextBoundsWidth += 2;
}
- g.drawLine( ( int ) linePosX + 1, 3 + ( int ) pos_y, ( int ) linePosX + x
- + nodeTextBoundsWidth, 3 + ( int ) pos_y );
+ g.drawLine( ( int ) linePosX + 1,
+ 3 + ( int ) pos_y,
+ ( int ) linePosX + x + nodeTextBoundsWidth,
+ 3 + ( int ) pos_y );
break;
}
}
else if ( getControlPanel().isColorAccordingToAnnotation() ) {
g.setColor( calculateColorForAnnotation( ann ) );
}
- final String ann_str = TreePanelUtil.createAnnotationString( ann, getOptions().isShowAnnotationRefSource() );
- TreePanel.drawString( ann_str, node.getXcoord() + x + 3 + half_box_size, node.getYcoord()
- + ( getFontMetricsForLargeDefaultFont().getAscent() / down_shift_factor ), g );
+ final String ann_str = TreePanelUtil.createAnnotationString( ann,
+ getOptions().isShowAnnotationRefSource() );
+ TreePanel.drawString( ann_str,
+ node.getXcoord() + x + 3 + half_box_size,
+ node.getYcoord()
+ + ( getFontMetricsForLargeDefaultFont().getAscent() / down_shift_factor ),
+ g );
_sb.setLength( 0 );
_sb.append( ann_str );
if ( _sb.length() > 0 ) {
}
if ( getControlPanel().isShowBinaryCharacters() ) {
TreePanel.drawString( node.getNodeData().getBinaryCharacters().getPresentCharactersAsStringBuffer()
- .toString(), node.getXcoord() + x + 1 + half_box_size, node.getYcoord()
- + ( getFontMetricsForLargeDefaultFont().getAscent() / down_shift_factor ), g );
- paintGainedAndLostCharacters( g, node, node.getNodeData().getBinaryCharacters()
- .getGainedCharactersAsStringBuffer().toString(), node.getNodeData().getBinaryCharacters()
- .getLostCharactersAsStringBuffer().toString() );
+ .toString(),
+ node.getXcoord() + x + 1 + half_box_size,
+ node.getYcoord() + ( getFontMetricsForLargeDefaultFont().getAscent()
+ / down_shift_factor ),
+ g );
+ paintGainedAndLostCharacters( g,
+ node,
+ node.getNodeData().getBinaryCharacters()
+ .getGainedCharactersAsStringBuffer().toString(),
+ node.getNodeData().getBinaryCharacters()
+ .getLostCharactersAsStringBuffer().toString() );
}
else {
- TreePanel
- .drawString( " " + node.getNodeData().getBinaryCharacters().getPresentCount(),
- node.getXcoord() + x + 4 + half_box_size,
- node.getYcoord()
- + ( getFontMetricsForLargeDefaultFont().getAscent() / down_shift_factor ),
- g );
- paintGainedAndLostCharacters( g, node, "+"
- + node.getNodeData().getBinaryCharacters().getGainedCount(), "-"
- + node.getNodeData().getBinaryCharacters().getLostCount() );
+ TreePanel.drawString( " " + node.getNodeData().getBinaryCharacters().getPresentCount(),
+ node.getXcoord() + x + 4 + half_box_size,
+ node.getYcoord() + ( getFontMetricsForLargeDefaultFont().getAscent()
+ / down_shift_factor ),
+ g );
+ paintGainedAndLostCharacters( g,
+ node,
+ "+" + node.getNodeData().getBinaryCharacters().getGainedCount(),
+ "-" + node.getNodeData().getBinaryCharacters().getLostCount() );
}
}
}
_sb.setLength( 0 );
_sb.append( " " );
if ( node.getNodeData().isHasTaxonomy()
- && ( getControlPanel().isShowTaxonomyCode() || getControlPanel().isShowTaxonomyScientificNames() || getControlPanel()
- .isShowTaxonomyCommonNames() ) ) {
+ && ( getControlPanel().isShowTaxonomyCode() || getControlPanel().isShowTaxonomyScientificNames()
+ || getControlPanel().isShowTaxonomyCommonNames() ) ) {
final Taxonomy taxonomy = node.getNodeData().getTaxonomy();
if ( _control_panel.isShowTaxonomyCode() && !ForesterUtil.isEmpty( taxonomy.getTaxonomyCode() ) ) {
_sb.append( taxonomy.getTaxonomyCode() );
_sb.append( node.getName() );
}
if ( node.getNodeData().isHasSequence() ) {
- if ( getControlPanel().isShowSequenceAcc() && ( node.getNodeData().getSequence().getAccession() != null ) ) {
+ if ( getControlPanel().isShowSequenceAcc()
+ && ( node.getNodeData().getSequence().getAccession() != null ) ) {
if ( _sb.length() > 0 ) {
_sb.append( " " );
}
final private void paintNodeLite( final Graphics2D g, final PhylogenyNode node ) {
if ( node.isCollapse() ) {
- if ( !node.isRoot() && !node.getParent().isCollapse() ) {
- paintCollapsedNode( g, node, false, false, false );
- }
return;
}
if ( isInFoundNodes( node ) || isInCurrentExternalNodes( node ) ) {
g.setColor( getColorForFoundNode( node ) );
- drawRectFilled( node.getXSecondary() - OVERVIEW_FOUND_NODE_BOX_SIZE_HALF, node.getYSecondary()
- - OVERVIEW_FOUND_NODE_BOX_SIZE_HALF, OVERVIEW_FOUND_NODE_BOX_SIZE, OVERVIEW_FOUND_NODE_BOX_SIZE, g );
+ drawRectFilled( node.getXSecondary() - OVERVIEW_FOUND_NODE_BOX_SIZE_HALF,
+ node.getYSecondary() - OVERVIEW_FOUND_NODE_BOX_SIZE_HALF,
+ OVERVIEW_FOUND_NODE_BOX_SIZE,
+ OVERVIEW_FOUND_NODE_BOX_SIZE,
+ g );
}
float new_x = 0;
if ( !node.isExternal() && !node.isCollapse() ) {
final int parent_max_branch_to_leaf = getMaxBranchesToLeaf( node );
for( int i = 0; i < node.getNumberOfDescendants(); ++i ) {
final PhylogenyNode child_node = node.getChildNode( i );
- int factor_x;
- if ( !isUniformBranchLengthsForCladogram() ) {
- factor_x = node.getNumberOfExternalNodes() - child_node.getNumberOfExternalNodes();
- }
- else {
- factor_x = parent_max_branch_to_leaf - getMaxBranchesToLeaf( child_node );
- }
+ final int factor_x = node.getNumberOfExternalNodes() - child_node.getNumberOfExternalNodes();
if ( first_child ) {
first_child = false;
- y2 = node.getYSecondary()
- - ( getOvYDistance() * ( node.getNumberOfExternalNodes() - child_node
- .getNumberOfExternalNodes() ) );
+ y2 = node.getYSecondary() - ( getOvYDistance()
+ * ( node.getNumberOfExternalNodes() - child_node.getNumberOfExternalNodes() ) );
}
else {
y2 += getOvYDistance() * child_node.getNumberOfExternalNodes();
++_external_node_index;
}
// Confidence values
- if ( getControlPanel().isShowConfidenceValues()
- && !node.isExternal()
- && !node.isRoot()
+ if ( getControlPanel().isShowConfidenceValues() && !node.isExternal() && !node.isRoot()
&& ( ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.ROUNDED )
- || ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR ) || ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE ) )
- && node.getBranchData().isHasConfidences() ) {
+ || ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR )
+ || ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE ) )
+ && node.getBranchData().isHasConfidences() ) {
paintConfidenceValues( g, node, to_pdf, to_graphics_file );
}
// Draw a line to root:
if ( !node.isExternal() && !node.isCollapse() ) {
boolean first_child = true;
float y2 = 0.0f;
- final int parent_max_branch_to_leaf = getMaxBranchesToLeaf( node );
for( int i = 0; i < node.getNumberOfDescendants(); ++i ) {
final PhylogenyNode child_node = node.getChildNode( i );
- int factor_x;
- if ( !isUniformBranchLengthsForCladogram() ) {
- factor_x = node.getNumberOfExternalNodes() - child_node.getNumberOfExternalNodes();
- }
- else {
- factor_x = parent_max_branch_to_leaf - getMaxBranchesToLeaf( child_node );
- }
+ final int factor_x = node.getNumberOfExternalNodes() - child_node.getNumberOfExternalNodes();
if ( first_child ) {
first_child = false;
- y2 = node.getYcoord()
- - ( _y_distance * ( node.getNumberOfExternalNodes() - child_node.getNumberOfExternalNodes() ) );
+ y2 = node.getYcoord() - ( _y_distance
+ * ( node.getNumberOfExternalNodes() - child_node.getNumberOfExternalNodes() ) );
}
else {
y2 += _y_distance * child_node.getNumberOfExternalNodes();
&& ( !ForesterUtil.isEmpty( node.getNodeData().getSequence().getMolecularSequence() ) ) ) {
paintMolecularSequences( g, node, to_pdf );
}
- if ( dynamically_hide
- && !is_in_found_nodes
- && ( ( node.isExternal() && ( ( _external_node_index % dynamic_hiding_factor ) != 1 ) ) || ( !node
- .isExternal() && ( ( new_x_min < 20 ) || ( ( _y_distance * node.getNumberOfExternalNodes() ) < getFontMetricsForLargeDefaultFont()
+ if ( dynamically_hide && !is_in_found_nodes && ( ( node.isExternal()
+ && ( ( _external_node_index % dynamic_hiding_factor ) != 1 ) )
+ || ( !node.isExternal() && ( ( new_x_min < 20 )
+ || ( ( _y_distance * node.getNumberOfExternalNodes() ) < getFontMetricsForLargeDefaultFont()
.getHeight() ) ) ) ) ) {
return;
}
- final int x = paintNodeData( g, node, to_graphics_file, to_pdf, is_in_found_nodes );
+ final int x = paintNodeData( g, node, to_graphics_file, to_pdf, is_in_found_nodes, 0 );
paintNodeWithRenderableData( x, g, node, to_graphics_file, to_pdf );
}
return;
}
if ( getControlPanel().isShowDomainArchitectures() && node.getNodeData().isHasSequence()
- && ( node.getNodeData().getSequence().getDomainArchitecture() != null )
- && ( node.getNodeData().getSequence().getDomainArchitecture() instanceof RenderableDomainArchitecture ) ) {
+ && ( node.getNodeData().getSequence().getDomainArchitecture() != null ) && ( node.getNodeData()
+ .getSequence().getDomainArchitecture() instanceof RenderableDomainArchitecture ) ) {
RenderableDomainArchitecture rds = null;
try {
rds = ( RenderableDomainArchitecture ) node.getNodeData().getSequence().getDomainArchitecture();
if ( getOptions().isLineUpRendarableNodeData() ) {
if ( getOptions().isRightLineUpDomains() ) {
rds.render( ( float ) ( ( getMaxDistanceToRoot() * getXcorrectionFactor() )
- + _length_of_longest_text + ( ( _longest_domain - rds.getTotalLength() ) * rds
- .getRenderingFactorWidth() ) ), node.getYcoord() - ( h / 2.0f ), g, this, to_pdf );
- }
- else {
- rds.render( ( float ) ( ( getMaxDistanceToRoot() * getXcorrectionFactor() ) + _length_of_longest_text ),
+ + _length_of_longest_text
+ + ( ( _longest_domain - rds.getTotalLength() ) * rds.getRenderingFactorWidth() ) ),
node.getYcoord() - ( h / 2.0f ),
g,
this,
to_pdf );
}
+ else {
+ rds.render( ( float ) ( ( getMaxDistanceToRoot() * getXcorrectionFactor() )
+ + _length_of_longest_text ), node.getYcoord() - ( h / 2.0f ), g, this, to_pdf );
+ }
}
else {
rds.render( node.getXcoord() + x, node.getYcoord() - ( h / 2.0f ), g, this, to_pdf );
}
else {
if ( getOptions().isRightLineUpDomains() ) {
- rds.render( ( ( getPhylogeny().getFirstExternalNode().getXcoord() + _length_of_longest_text ) - 20 )
- + ( ( _longest_domain - rds.getTotalLength() ) * rds
- .getRenderingFactorWidth() ),
- node.getYcoord() - ( h / 2.0f ),
- g,
- this,
- to_pdf );
+ rds.render( ( ( getPhylogeny().getFirstExternalNode().getXcoord() + _length_of_longest_text )
+ - 20 ) + ( ( _longest_domain - rds.getTotalLength() ) * rds.getRenderingFactorWidth() ),
+ node.getYcoord() - ( h / 2.0f ),
+ g,
+ this,
+ to_pdf );
}
else {
rds.render( getPhylogeny().getFirstExternalNode().getXcoord() + _length_of_longest_text,
rv.render( ( float ) ( node.getXcoord() + x + domain_add ), node.getYcoord() - 3, g, this, to_pdf );
}
else {
- rv.render( ( float ) ( getPhylogeny().getFirstExternalNode().getXcoord() + _length_of_longest_text + domain_add ),
- node.getYcoord() - 3,
- g,
- this,
- to_pdf );
+ rv.render( ( float ) ( getPhylogeny().getFirstExternalNode().getXcoord() + _length_of_longest_text
+ + domain_add ), node.getYcoord() - 3, g, this, to_pdf );
}
}
}
}
final private void paintPhylogenyLite( final Graphics2D g ) {
- _phylogeny
- .getRoot()
- .setXSecondary( ( float ) ( getVisibleRect().x + getOvXPosition() + ( MOVE / ( getVisibleRect().width / getOvRectangle()
- .getWidth() ) ) ) );
+ _phylogeny.getRoot().setXSecondary( ( float ) ( getVisibleRect().x + getOvXPosition()
+ + ( MOVE / ( getVisibleRect().width / getOvRectangle().getWidth() ) ) ) );
_phylogeny.getRoot().setYSecondary( ( getVisibleRect().y + getOvYStart() ) );
final Stroke s = g.getStroke();
g.setStroke( STROKE_05 );
final float start_x = node.getXcoord() + 3 + ( getOptions().getDefaultNodeShapeSize() / 2 ) + x_shift;
float start_y;
if ( !using_visual_font ) {
- start_y = node.getYcoord()
- + ( getFontMetricsForLargeDefaultFont().getAscent() / ( node.getNumberOfDescendants() == 1 ? 1
- : 3.0f ) );
+ start_y = node.getYcoord() + ( getFontMetricsForLargeDefaultFont().getAscent()
+ / ( node.getNumberOfDescendants() == 1 ? 1 : 3.0f ) );
}
else {
start_y = node.getYcoord()
final String label = _sb.toString();
/* GUILHEM_BEG */
if ( _control_panel.isShowSequenceRelations() && ( label.length() > 0 )
- && ( node.getNodeData().isHasSequence() ) && node.getNodeData().getSequence().equals( _query_sequence ) ) {
+ && ( node.getNodeData().isHasSequence() )
+ && node.getNodeData().getSequence().equals( _query_sequence ) ) {
// invert font color and background color to show that this is the query sequence
- final Rectangle2D nodeTextBounds = new TextLayout( label, g.getFont(), new FontRenderContext( null,
- false,
- false ) )
- .getBounds();
+ final Rectangle2D nodeTextBounds = new TextLayout( label,
+ g.getFont(),
+ new FontRenderContext( null, false, false ) )
+ .getBounds();
g.fillRect( ( int ) start_x - 1, ( int ) start_y - 8, ( int ) nodeTextBounds.getWidth() + 4, 11 );
g.setColor( getTreeColorSet().getBackgroundColor() );
}
g.setColor( getTaxonomyBasedColor( node ) );
}
else if ( getControlPanel().isColorAccordingToAnnotation()
- && ( node.getNodeData().isHasSequence() && ( node.getNodeData().getSequence().getAnnotations() != null ) && ( !node
- .getNodeData().getSequence().getAnnotations().isEmpty() ) ) ) {
+ && ( node.getNodeData().isHasSequence() && ( node.getNodeData().getSequence().getAnnotations() != null )
+ && ( !node.getNodeData().getSequence().getAnnotations().isEmpty() ) ) ) {
g.setColor( calculateColorForAnnotation( node.getNodeData().getSequence().getAnnotations() ) );
}
else if ( getOptions().isColorLabelsSameAsParentBranch() && getControlPanel().isUseVisualStyles()
else {
ann_str = ann.toString();
}
- sb.append( SequenceWriter.toFasta( ann_str, n.getNodeData().getSequence()
- .getMolecularSequence(), 60 ) );
+ sb.append( SequenceWriter.toFasta( ann_str,
+ n.getNodeData().getSequence().getMolecularSequence(),
+ 60 ) );
data.add( sb.toString() );
}
break;
final String name = d.getName();
if ( !( s.contains( name ) ) ) {
data.add( name );
- if ( getOptions().getExtDescNodeDataToReturn() == NodeDataField.DOMAINS_COLLAPSED_PER_PROTEIN ) {
+ if ( getOptions()
+ .getExtDescNodeDataToReturn() == NodeDataField.DOMAINS_COLLAPSED_PER_PROTEIN ) {
s.add( name );
}
}
}
else if ( getConfiguration().getExtNodeDataReturnOn() == EXT_NODE_DATA_RETURN_ON.WINODW ) {
if ( sb.length() < 1 ) {
- TreePanelUtil.showInformationMessage( this, "No Appropriate Data (" + obtainTitleForExtDescNodeData()
- + ")", "Descendants of selected node do not contain selected data" );
+ TreePanelUtil.showInformationMessage( this,
+ "No Appropriate Data (" + obtainTitleForExtDescNodeData() + ")",
+ "Descendants of selected node do not contain selected data" );
clearCurrentExternalNodesDataBuffer();
}
else {
String title;
if ( ( getFoundNodes0() != null ) && !getFoundNodes0().isEmpty() ) {
title = ( getOptions().getExtDescNodeDataToReturn() == NodeDataField.UNKNOWN ? "Data"
- : obtainTitleForExtDescNodeData() )
- + " for "
- + data.size()
- + " nodes, unique entries: "
+ : obtainTitleForExtDescNodeData() ) + " for " + data.size() + " nodes, unique entries: "
+ size;
}
else {
title = ( getOptions().getExtDescNodeDataToReturn() == NodeDataField.UNKNOWN ? "Data"
- : obtainTitleForExtDescNodeData() )
- + " for "
- + data.size()
- + "/"
- + node.getNumberOfExternalNodes()
- + " external descendats of node "
- + node
+ : obtainTitleForExtDescNodeData() ) + " for " + data.size() + "/"
+ + node.getNumberOfExternalNodes() + " external descendats of node " + node
+ ", unique entries: " + size;
}
final String s = sb.toString().trim();
final private void showNodeDataPopup( final MouseEvent e, final PhylogenyNode node ) {
try {
if ( ( node.getName().length() > 0 )
- || ( node.getNodeData().isHasTaxonomy() && !TreePanelUtil.isTaxonomyEmpty( node.getNodeData()
- .getTaxonomy() ) )
- || ( node.getNodeData().isHasSequence() && !TreePanelUtil.isSequenceEmpty( node.getNodeData()
- .getSequence() ) ) || ( node.getNodeData().isHasDate() )
- || ( node.getNodeData().isHasDistribution() ) || node.getBranchData().isHasConfidences() ) {
+ || ( node.getNodeData().isHasTaxonomy()
+ && !TreePanelUtil.isTaxonomyEmpty( node.getNodeData().getTaxonomy() ) )
+ || ( node.getNodeData().isHasSequence()
+ && !TreePanelUtil.isSequenceEmpty( node.getNodeData().getSequence() ) )
+ || ( node.getNodeData().isHasDate() ) || ( node.getNodeData().isHasDistribution() )
+ || node.getBranchData().isHasConfidences() ) {
_popup_buffer.setLength( 0 );
short lines = 0;
if ( node.getName().length() > 0 ) {
_popup_buffer.append( "]" );
}
if ( !enc_data ) {
- if ( ( tax.getIdentifier() != null ) && !ForesterUtil.isEmpty( tax.getIdentifier().getValue() ) ) {
+ if ( ( tax.getIdentifier() != null )
+ && !ForesterUtil.isEmpty( tax.getIdentifier().getValue() ) ) {
if ( !ForesterUtil.isEmpty( tax.getIdentifier().getProvider() ) ) {
_popup_buffer.append( "[" );
_popup_buffer.append( tax.getIdentifier().getProvider() );
_popup_buffer.append( confidence.getType() );
_popup_buffer.append( "] " );
}
- _popup_buffer
- .append( FORMATTER_CONFIDENCE.format( ForesterUtil.round( confidence.getValue(),
- getOptions()
- .getNumberOfDigitsAfterCommaForConfidenceValues() ) ) );
+ _popup_buffer.append( FORMATTER_CONFIDENCE.format( ForesterUtil.round( confidence.getValue(),
+ getOptions()
+ .getNumberOfDigitsAfterCommaForConfidenceValues() ) ) );
if ( confidence.getStandardDeviation() != Confidence.CONFIDENCE_DEFAULT_VALUE ) {
_popup_buffer.append( " (sd=" );
- _popup_buffer.append( FORMATTER_CONFIDENCE.format( ForesterUtil.round( confidence
- .getStandardDeviation(), getOptions()
- .getNumberOfDigitsAfterCommaForConfidenceValues() ) ) );
+ _popup_buffer.append( FORMATTER_CONFIDENCE
+ .format( ForesterUtil.round( confidence.getStandardDeviation(),
+ getOptions()
+ .getNumberOfDigitsAfterCommaForConfidenceValues() ) ) );
_popup_buffer.append( ")" );
}
}
if ( _popup_buffer.length() > 0 ) {
if ( !getConfiguration().isUseNativeUI() ) {
_rollover_popup
- .setBorder( BorderFactory.createLineBorder( getTreeColorSet().getBranchColor() ) );
+ .setBorder( BorderFactory.createLineBorder( getTreeColorSet().getBranchColor() ) );
_rollover_popup.setBackground( getTreeColorSet().getBackgroundColor() );
if ( isInFoundNodes0( node ) && !isInFoundNodes1( node ) ) {
_rollover_popup.setForeground( getTreeColorSet().getFoundColor0() );
_rollover_popup.setBorder( BorderFactory.createLineBorder( Color.BLACK ) );
}
_rollover_popup.setText( _popup_buffer.toString() );
- _node_desc_popup = PopupFactory.getSharedInstance().getPopup( null,
- _rollover_popup,
- e.getLocationOnScreen().x + 10,
- e.getLocationOnScreen().y
- - ( lines * 20 ) );
+ _node_desc_popup = PopupFactory.getSharedInstance()
+ .getPopup( null,
+ _rollover_popup,
+ e.getLocationOnScreen().x + 10,
+ e.getLocationOnScreen().y - ( lines * 20 ) );
_node_desc_popup.show();
}
}
if ( getMainPanel().getMainFrame() == null ) {
// Must be "E" applet version.
( ( ArchaeopteryxE ) ( ( MainPanelApplets ) getMainPanel() ).getApplet() )
- .setSelectedTypeInTypeMenu( getPhylogenyGraphicsType() );
+ .setSelectedTypeInTypeMenu( getPhylogenyGraphicsType() );
}
else {
getMainPanel().getMainFrame().setSelectedTypeInTypeMenu( getPhylogenyGraphicsType() );
calculateLongestExtNodeInfo();
if ( ( getLongestExtNodeInfo() > ( x * 0.6 ) )
&& ( getTreeFontSet().getLargeFont().getSize() > ( 2 + TreeFontSet.FONT_SIZE_CHANGE_STEP ) ) ) {
- while ( ( getLongestExtNodeInfo() > ( x * 0.7 ) ) && ( getTreeFontSet().getLargeFont().getSize() > 2 ) ) {
+ while ( ( getLongestExtNodeInfo() > ( x * 0.7 ) )
+ && ( getTreeFontSet().getLargeFont().getSize() > 2 ) ) {
getMainPanel().getTreeFontSet().decreaseFontSize( getConfiguration().getMinBaseFontSize(), true );
calculateLongestExtNodeInfo();
}
}
else {
- while ( ( getLongestExtNodeInfo() < ( x * 0.6 ) )
- && ( getTreeFontSet().getLargeFont().getSize() <= ( getTreeFontSet().getLargeFontMemory()
- .getSize() - TreeFontSet.FONT_SIZE_CHANGE_STEP ) ) ) {
+ while ( ( getLongestExtNodeInfo() < ( x * 0.6 ) ) && ( getTreeFontSet().getLargeFont()
+ .getSize() <= ( getTreeFontSet().getLargeFontMemory().getSize()
+ - TreeFontSet.FONT_SIZE_CHANGE_STEP ) ) ) {
getMainPanel().getTreeFontSet().increaseFontSize();
calculateLongestExtNodeInfo();
}
}
//_length_of_longest_text = calcLengthOfLongestText();
int ext_nodes = _phylogeny.getRoot().getNumberOfExternalNodes();
- final int max_depth = PhylogenyMethods.calculateMaxDepth( _phylogeny );
+ final int max_depth = PhylogenyMethods.calculateMaxDepthConsiderCollapsed( _phylogeny ) + 1;
if ( ext_nodes == 1 ) {
ext_nodes = max_depth;
if ( ext_nodes < 1 ) {
updateOvSizes();
float xdist = 0;
float ov_xdist = 0;
- if ( !isNonLinedUpCladogram() && !isUniformBranchLengthsForCladogram() ) {
+ if ( !isNonLinedUpCladogram() ) {
xdist = ( float ) ( ( x - getLongestExtNodeInfo() - TreePanel.MOVE ) / ( ext_nodes + 3.0 ) );
ov_xdist = ( float ) ( getOvMaxWidth() / ( ext_nodes + 3.0 ) );
}
setXdistance( xdist );
setYdistance( ydist );
setOvXDistance( ov_xdist );
- final double height = _phylogeny.getHeight();
+ final double height = _phylogeny.calculateHeight( !_options.isCollapsedWithAverageHeigh() );
if ( height > 0 ) {
- final float corr = ( float ) ( ( x - ( 2.0 * TreePanel.MOVE ) - getLongestExtNodeInfo() - getXdistance() ) / height );
+ final float corr = ( float ) ( ( x - ( 2.0 * TreePanel.MOVE ) - getLongestExtNodeInfo()
+ - getXdistance() ) / height );
setXcorrectionFactor( corr > 0 ? corr : 0 );
final float ov_corr = ( float ) ( ( getOvMaxWidth() - getOvXDistance() ) / height );
setOvXcorrectionFactor( ov_corr > 0 ? ov_corr : 0 );
if ( ( _phylogeny == null ) || _phylogeny.isEmpty() ) {
return;
}
- int max_possible_length = ForesterUtil.roundToInt( ( getSize().getWidth() - 2 * MOVE )
- * AptxConstants.EXT_NODE_INFO_LENGTH_MAX_RATIO );
+ int max_possible_length = ForesterUtil
+ .roundToInt( ( getSize().getWidth() - ( 2 * MOVE ) ) * AptxConstants.EXT_NODE_INFO_LENGTH_MAX_RATIO );
if ( max_possible_length < 20 ) {
- max_possible_length = 20;
- }
+ max_possible_length = 20;
+ }
int longest = 30;
int longest_txt = 0;
_longest_domain = 0;
}
if ( getControlPanel().isShowBinaryCharacters() && node.getNodeData().isHasBinaryCharacters() ) {
sum += getFontMetricsForLargeDefaultFont().stringWidth( node.getNodeData().getBinaryCharacters()
- .getGainedCharactersAsStringBuffer().toString() );
+ .getGainedCharactersAsStringBuffer().toString() );
}
if ( getControlPanel().isShowVectorData() && ( node.getNodeData().getVector() != null )
&& ( node.getNodeData().getVector().size() > 0 ) ) {
// FIXME
// TODO this might need some clean up
final DomainArchitecture d = node.getNodeData().getSequence().getDomainArchitecture();
- sum += ( ( _domain_structure_width / ( ( RenderableDomainArchitecture ) d ).getOriginalSize()
- .getWidth() ) * d.getTotalLength() ) + 10;
+ sum += ( ( _domain_structure_width
+ / ( ( RenderableDomainArchitecture ) d ).getOriginalSize().getWidth() ) * d.getTotalLength() )
+ + 10;
if ( d.getTotalLength() > _longest_domain ) {
_longest_domain = d.getTotalLength();
}
}
}
_ext_node_with_longest_txt_info = longest_txt_node;
- if ( longest >= max_possible_length ) {
+ if ( longest >= max_possible_length ) {
_longest_ext_node_info = max_possible_length;
- }
- else {
- _longest_ext_node_info = longest;
- }
+ }
+ else {
+ _longest_ext_node_info = longest;
+ }
_length_of_longest_text = calcLengthOfLongestText();
}
if ( ref.startsWith( PhyloXmlUtil.VECTOR_PROPERTY_REF ) ) {
final Property p = pm.getProperty( ref );
final String value_str = p.getValue();
- final String index_str = ref
- .substring( PhyloXmlUtil.VECTOR_PROPERTY_REF.length(), ref.length() );
+ final String index_str = ref.substring( PhyloXmlUtil.VECTOR_PROPERTY_REF.length(),
+ ref.length() );
double d = -100;
try {
d = Double.parseDouble( value_str );
}
catch ( final NumberFormatException e ) {
- JOptionPane.showMessageDialog( this, "Could not parse \"" + value_str
- + "\" into a decimal value", "Problem with Vector Data", JOptionPane.ERROR_MESSAGE );
+ JOptionPane.showMessageDialog( this,
+ "Could not parse \"" + value_str + "\" into a decimal value",
+ "Problem with Vector Data",
+ JOptionPane.ERROR_MESSAGE );
return;
}
int i = -1;
catch ( final NumberFormatException e ) {
JOptionPane.showMessageDialog( this,
"Could not parse \"" + index_str
- + "\" into index for vector data",
+ + "\" into index for vector data",
"Problem with Vector Data",
JOptionPane.ERROR_MESSAGE );
return;
repaint();
}
}
-
+
final void uncollapseAll( final PhylogenyNode node ) {
if ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) {
JOptionPane.showMessageDialog( this,
return;
}
if ( !node.isExternal() ) {
- TreePanelUtil.uncollapseSubtree( node);
+ TreePanelUtil.uncollapseSubtree( node );
updateSetOfCollapsedExternalNodes();
_phylogeny.recalculateNumberOfExternalDescendants( true );
resetNodeIdToDistToLeafMap();
calculateLongestExtNodeInfo();
setNodeInPreorderToNull();
resetPreferredSize();
+ resetDepthCollapseDepthValue();
+ resetRankCollapseRankValue();
_main_panel.adjustJScrollPane();
+ getControlPanel().showWhole();
setArrowCursor();
- repaint();
}
- final void collapseByTaxonomicRank( final String rank ) {
- if ( ( _phylogeny == null ) || ( _phylogeny.getNumberOfExternalNodes() < 2 ) ) {
- return;
- }
- setWaitCursor();
-
- final int collapsed = TreePanelUtil.collapseByTaxonomicRank( _phylogeny, rank, this );
-
- setArrowCursor();
- repaint();
- if ( collapsed > 0 ) {
- String msg = "Collapsing via " + rank + " completed:\n";
- if ( collapsed > 1 ) {
- msg += "collapsed " + collapsed + " subtrees";
- }
- else {
- msg += "collapsed one subtree";
- }
- setEdited( true );
- JOptionPane.showMessageDialog( this,
- msg,
- "Taxonomy Rank-Collapsing Completed (" + rank + ")",
- JOptionPane.INFORMATION_MESSAGE );
- }
- else {
- String msg = "Could not taxonomy rank-collapse any subtree via " + rank + ".\n";
- msg += "Possible solutions (given that suitable taxonomic information is present):\n";
- msg += "select a different rank (e.g. phylum, genus, ...)\n";
- msg += " and/or\n";
- msg += "execute:\n";
- msg += "1. \"" + MainFrameApplication.OBTAIN_DETAILED_TAXONOMIC_INFORMATION + "\" (Tools)\n";
- msg += "2. \"" + MainFrameApplication.INFER_ANCESTOR_TAXONOMIES + "\" (Analysis)";
- JOptionPane.showMessageDialog( this, msg, "Taxonomy Rank-Collapsing Failed", JOptionPane.WARNING_MESSAGE );
- }
- }
-
-
-
+
+
final void colorRank( final String rank ) {
if ( ( _phylogeny == null ) || ( _phylogeny.getNumberOfExternalNodes() < 2 ) ) {
return;
msg += "select a different rank (e.g. phylum, genus, ...)\n";
msg += " and/or\n";
msg += "execute:\n";
- msg += "1. \"" + MainFrameApplication.OBTAIN_DETAILED_TAXONOMIC_INFORMATION + "\" (Tools)\n";
- msg += "2. \"" + MainFrameApplication.INFER_ANCESTOR_TAXONOMIES + "\" (Analysis)";
- JOptionPane.showMessageDialog( this, msg, "Taxonomy Rank-Colorization Failed", JOptionPane.WARNING_MESSAGE );
+ msg += "1. \"" + MainFrame.OBTAIN_DETAILED_TAXONOMIC_INFORMATION + "\" (Tools)\n";
+ msg += "2. \"" + MainFrame.INFER_ANCESTOR_TAXONOMIES + "\" (Analysis)";
+ JOptionPane.showMessageDialog( this,
+ msg,
+ "Taxonomy Rank-Colorization Failed",
+ JOptionPane.WARNING_MESSAGE );
}
}
if ( node.getNodeData().isHasSequence()
&& ( node.getNodeData().getSequence().getDomainArchitecture() != null ) ) {
RenderableDomainArchitecture rds = null;
- if ( !( node.getNodeData().getSequence().getDomainArchitecture() instanceof RenderableDomainArchitecture ) ) {
+ if ( !( node.getNodeData().getSequence()
+ .getDomainArchitecture() instanceof RenderableDomainArchitecture ) ) {
if ( SPECIAL_DOMAIN_COLORING ) {
rds = new RenderableDomainArchitecture( node.getNodeData().getSequence()
- .getDomainArchitecture(), node.getName() );
+ .getDomainArchitecture(), node.getName() );
}
else {
rds = new RenderableDomainArchitecture( node.getNodeData().getSequence()
- .getDomainArchitecture() );
+ .getDomainArchitecture() );
}
node.getNodeData().getSequence().setDomainArchitecture( rds );
}
final boolean inOv( final MouseEvent e ) {
return ( ( e.getX() > ( getVisibleRect().x + getOvXPosition() + 1 ) )
&& ( e.getX() < ( ( getVisibleRect().x + getOvXPosition() + getOvMaxWidth() ) - 1 ) )
- && ( e.getY() > ( getVisibleRect().y + getOvYPosition() + 1 ) ) && ( e.getY() < ( ( getVisibleRect().y
- + getOvYPosition() + getOvMaxHeight() ) - 1 ) ) );
+ && ( e.getY() > ( getVisibleRect().y + getOvYPosition() + 1 ) )
+ && ( e.getY() < ( ( getVisibleRect().y + getOvYPosition() + getOvMaxHeight() ) - 1 ) ) );
}
final boolean inOvRectangle( final MouseEvent e ) {
return ( ( e.getX() >= ( getOvRectangle().getX() - 1 ) )
&& ( e.getX() <= ( getOvRectangle().getX() + getOvRectangle().getWidth() + 1 ) )
- && ( e.getY() >= ( getOvRectangle().getY() - 1 ) ) && ( e.getY() <= ( getOvRectangle().getY()
- + getOvRectangle().getHeight() + 1 ) ) );
+ && ( e.getY() >= ( getOvRectangle().getY() - 1 ) )
+ && ( e.getY() <= ( getOvRectangle().getY() + getOvRectangle().getHeight() + 1 ) ) );
}
final boolean isApplet() {
final boolean isCanCollapse() {
return ( getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.UNROOTED );
}
-
+
final boolean isCanUncollapseAll( final PhylogenyNode node ) {
- if ( node.isExternal() || getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) {
+ if ( node.isExternal() || ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) ) {
return false;
}
if ( node.isCollapse() ) {
}
return false;
}
-
+
final boolean isCanColorSubtree() {
return ( getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.UNROOTED );
}
}
final boolean isCanCut( final PhylogenyNode node ) {
- return ( ( getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) && getOptions().isEditable() && !node
- .isRoot() );
+ return ( ( getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) && getOptions().isEditable()
+ && !node.isRoot() );
}
final boolean isCanDelete() {
}
final boolean isCanSubtree( final PhylogenyNode node ) {
- return ( ( getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) && !node.isExternal() && ( !node
- .isRoot() || ( _subtree_index > 0 ) ) );
+ return ( ( getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) && !node.isExternal()
+ && ( !node.isRoot() || ( _subtree_index > 0 ) ) );
}
final boolean isCurrentTreeIsSubtree() {
y = max_y;
}
getMainPanel().getCurrentScrollPane().getViewport()
- .setViewPosition( new Point( ForesterUtil.roundToInt( x ), ForesterUtil.roundToInt( y ) ) );
+ .setViewPosition( new Point( ForesterUtil.roundToInt( x ), ForesterUtil.roundToInt( y ) ) );
setInOvRect( true );
repaint();
}
g );
if ( isInFoundNodes( c ) || isInCurrentExternalNodes( c ) ) {
g.setColor( getColorForFoundNode( c ) );
- drawRectFilled( c.getXSecondary() - OVERVIEW_FOUND_NODE_BOX_SIZE_HALF, c.getYSecondary()
- - OVERVIEW_FOUND_NODE_BOX_SIZE_HALF, OVERVIEW_FOUND_NODE_BOX_SIZE, OVERVIEW_FOUND_NODE_BOX_SIZE, g );
+ drawRectFilled( c.getXSecondary() - OVERVIEW_FOUND_NODE_BOX_SIZE_HALF,
+ c.getYSecondary() - OVERVIEW_FOUND_NODE_BOX_SIZE_HALF,
+ OVERVIEW_FOUND_NODE_BOX_SIZE,
+ OVERVIEW_FOUND_NODE_BOX_SIZE,
+ g );
}
}
}
else {
if ( !to_graphics_file ) {
- g.setPaint( new GradientPaint( r.x, r.y, getTreeColorSet().getBackgroundColor(), r.x, r.y
- + r.height, getTreeColorSet().getBackgroundColorGradientBottom() ) );
+ g.setPaint( new GradientPaint( r.x,
+ r.y,
+ getTreeColorSet().getBackgroundColor(),
+ r.x,
+ r.y + r.height,
+ getTreeColorSet().getBackgroundColorGradientBottom() ) );
g.fill( r );
}
else {
&& ( getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) {
_external_node_index = 0;
// Position starting X of tree
- if ( !_phylogeny.isRooted() /*|| ( _subtree_index > 0 )*/) {
+ if ( !_phylogeny.isRooted() /*|| ( _subtree_index > 0 )*/ ) {
_phylogeny.getRoot().setXcoord( TreePanel.MOVE );
}
else if ( ( _phylogeny.getRoot().getDistanceToParent() > 0.0 ) && getControlPanel().isDrawPhylogram() ) {
- _phylogeny.getRoot().setXcoord( ( float ) ( TreePanel.MOVE + ( _phylogeny.getRoot()
- .getDistanceToParent() * getXcorrectionFactor() ) ) );
+ _phylogeny.getRoot().setXcoord( ( float ) ( TreePanel.MOVE
+ + ( _phylogeny.getRoot().getDistanceToParent() * getXcorrectionFactor() ) ) );
}
else {
_phylogeny.getRoot().setXcoord( TreePanel.MOVE + getXdistance() );
}
// Position starting Y of tree
_phylogeny.getRoot().setYcoord( ( getYdistance() * _phylogeny.getRoot().getNumberOfExternalNodes() )
- + ( TreePanel.MOVE / 2.0f ) );
+ + ( TreePanel.MOVE / 2.0f ) );
final int dynamic_hiding_factor = calcDynamicHidingFactor();
if ( getControlPanel().isDynamicallyHideData() ) {
if ( dynamic_hiding_factor > 1 ) {
final boolean radial_labels = getOptions().getNodeLabelDirection() == NODE_LABEL_DIRECTION.RADIAL;
_dynamic_hiding_factor = 0;
if ( getControlPanel().isDynamicallyHideData() ) {
- _dynamic_hiding_factor = ( int ) ( ( getFontMetricsForLargeDefaultFont().getHeight() * 1.5 * getPhylogeny()
- .getNumberOfExternalNodes() ) / ( TWO_PI * 10 ) );
+ _dynamic_hiding_factor = ( int ) ( ( getFontMetricsForLargeDefaultFont().getHeight() * 1.5
+ * getPhylogeny().getNumberOfExternalNodes() ) / ( TWO_PI * 10 ) );
}
if ( getControlPanel().getDynamicallyHideData() != null ) {
if ( _dynamic_hiding_factor > 1 ) {
}
}
else if ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) {
- final int radius = ( int ) ( ( Math.min( getPreferredSize().getWidth(), getPreferredSize().getHeight() ) / 2 ) - ( MOVE + getLongestExtNodeInfo() ) );
+ final int radius = ( int ) ( ( Math.min( getPreferredSize().getWidth(), getPreferredSize().getHeight() )
+ / 2 ) - ( MOVE + getLongestExtNodeInfo() ) );
final int d = radius + MOVE + getLongestExtNodeInfo();
_dynamic_hiding_factor = 0;
if ( getControlPanel().isDynamicallyHideData() && ( radius > 0 ) ) {
- _dynamic_hiding_factor = ( int ) ( ( getFontMetricsForLargeDefaultFont().getHeight() * 1.5 * getPhylogeny()
- .getNumberOfExternalNodes() ) / ( TWO_PI * radius ) );
+ _dynamic_hiding_factor = ( int ) ( ( getFontMetricsForLargeDefaultFont().getHeight() * 1.5
+ * getPhylogeny().getNumberOfExternalNodes() ) / ( TWO_PI * radius ) );
}
if ( getControlPanel().getDynamicallyHideData() != null ) {
if ( _dynamic_hiding_factor > 1 ) {
getStartingAngle(),
x_pos + radius_ov,
y_pos + radius_ov,
- ( int ) ( radius_ov - ( getLongestExtNodeInfo() / ( getVisibleRect().width / getOvRectangle()
- .getWidth() ) ) ),
- g );
+ ( int ) ( radius_ov - ( getLongestExtNodeInfo()
+ / ( getVisibleRect().width / getOvRectangle().getWidth() ) ) ),
+ g );
g.setTransform( _at );
paintOvRectangle( g );
}
y = TreePanel.MOVE
+ ForesterUtil.roundToInt( getYdistance() * getPhylogeny().getRoot().getNumberOfExternalNodes() * 2 );
if ( getControlPanel().isDrawPhylogram() ) {
- x = TreePanel.MOVE
- + getLongestExtNodeInfo()
- + ForesterUtil
- .roundToInt( ( getXcorrectionFactor() * getPhylogeny().getHeight() ) + getXdistance() );
-
+ x = TreePanel.MOVE + getLongestExtNodeInfo()
+ + ForesterUtil.roundToInt( ( getXcorrectionFactor()
+ * getPhylogeny().calculateHeight( !_options.isCollapsedWithAverageHeigh() ) )
+ + getXdistance() );
}
else {
- if ( !isNonLinedUpCladogram() && !isUniformBranchLengthsForCladogram() ) {
- x = TreePanel.MOVE
- + getLongestExtNodeInfo()
- + ForesterUtil.roundToInt( getXdistance()
- * ( getPhylogeny().getRoot().getNumberOfExternalNodes() + 2 ) );
+ if ( !isNonLinedUpCladogram() ) {
+ x = TreePanel.MOVE + getLongestExtNodeInfo() + ForesterUtil
+ .roundToInt( getXdistance() * ( getPhylogeny().getRoot().getNumberOfExternalNodes() + 2 ) );
}
else {
- x = TreePanel.MOVE
- + getLongestExtNodeInfo()
- + ForesterUtil.roundToInt( getXdistance()
- * ( PhylogenyMethods.calculateMaxDepth( getPhylogeny() ) + 1 ) );
+ x = TreePanel.MOVE + getLongestExtNodeInfo() + ForesterUtil
+ .roundToInt( getXdistance() * ( PhylogenyMethods.calculateMaxDepth( getPhylogeny() ) + 1 ) );
}
}
setPreferredSize( new Dimension( x, y ) );
if ( getControlPanel().isShowTaxonomyScientificNames() || getControlPanel().isShowTaxonomyCode() ) {
pri = DESCENDANT_SORT_PRIORITY.TAXONOMY;
}
- else if ( getControlPanel().isShowSeqNames() || getControlPanel().isShowSeqSymbols() || getControlPanel().isShowGeneNames() ) {
+ else if ( getControlPanel().isShowSeqNames() || getControlPanel().isShowSeqSymbols()
+ || getControlPanel().isShowGeneNames() ) {
pri = DESCENDANT_SORT_PRIORITY.SEQUENCE;
}
PhylogenyMethods.orderAppearanceX( node, true, pri );
-
setNodeInPreorderToNull();
getPhylogeny().externalNodesHaveChanged();
getPhylogeny().clearHashIdToNodeMap();
getControlPanel().displayedPhylogenyMightHaveChanged( true );
repaint();
}
-
+
final void swap( final PhylogenyNode node ) {
if ( node.isExternal() || ( node.getNumberOfDescendants() < 2 ) ) {
return;
}
final void updateOvSizes() {
- if ( ( getWidth() > ( 1.05 * getVisibleRect().width ) ) || ( getHeight() > ( 1.05 * getVisibleRect().height ) ) ) {
+ if ( ( getWidth() > ( 1.05 * getVisibleRect().width ) )
+ || ( getHeight() > ( 1.05 * getVisibleRect().height ) ) ) {
setOvOn( true );
float l = getLongestExtNodeInfo();
final float w_ratio = getOvMaxWidth() / getWidth();
final int ext_nodes = _phylogeny.getRoot().getNumberOfExternalNodes();
setOvYDistance( getOvMaxHeight() / ( 2 * ext_nodes ) );
float ov_xdist = 0;
- if ( !isNonLinedUpCladogram() && !isUniformBranchLengthsForCladogram() ) {
+ if ( !isNonLinedUpCladogram() ) {
ov_xdist = ( ( getOvMaxWidth() - l ) / ( ext_nodes ) );
}
else {
ydist = 0.0f;
}
setOvXDistance( ov_xdist );
- final double height = _phylogeny.getHeight();
+ final double height = _phylogeny.calculateHeight( !_options.isCollapsedWithAverageHeigh() );
if ( height > 0 ) {
final float ov_corr = ( float ) ( ( ( getOvMaxWidth() - l ) - getOvXDistance() ) / height );
setOvXcorrectionFactor( ov_corr > 0 ? ov_corr : 0 );
final private static void drawString( final String str, final float x, final float y, final Graphics2D g ) {
g.drawString( str, x, y );
}
-
-
+
final private void drawStringX( final String str, final float x, final float y, final Graphics2D g ) {
//TODO
//FIXME
if ( getAttributedStringMap() == null /*&& getAttributedStringMap().containsKey(str) */ ) {
- final AttributedString as = new AttributedString(str);
+ final AttributedString as = new AttributedString( str );
//Font plainFont = new Font("Times New Roman", Font.PLAIN, 24);
-
- as.addAttribute(TextAttribute.FONT, g.getFont());
- as.addAttribute(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON, 1, 3);
- as.addAttribute(TextAttribute.SUPERSCRIPT, TextAttribute.SUPERSCRIPT_SUPER, 3, 4);
-
- as.addAttribute(TextAttribute.FOREGROUND, Color.BLUE, 1, 2);
- as.addAttribute(TextAttribute.FOREGROUND, Color.PINK, 3, 5);
- as.addAttribute(TextAttribute.STRIKETHROUGH,
- TextAttribute.STRIKETHROUGH_ON, 2, 4);
- g.drawString(as.getIterator(), x, y);
+ as.addAttribute( TextAttribute.FONT, g.getFont() );
+ as.addAttribute( TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON, 1, 3 );
+ as.addAttribute( TextAttribute.SUPERSCRIPT, TextAttribute.SUPERSCRIPT_SUPER, 3, 4 );
+ as.addAttribute( TextAttribute.FOREGROUND, Color.BLUE, 1, 2 );
+ as.addAttribute( TextAttribute.FOREGROUND, Color.PINK, 3, 5 );
+ as.addAttribute( TextAttribute.STRIKETHROUGH, TextAttribute.STRIKETHROUGH_ON, 2, 4 );
+ g.drawString( as.getIterator(), x, y );
}
else {
g.drawString( str, x, y );
}
}
-
private final Map<String, AttributedString> getAttributedStringMap() {
- return _attributed_string_map ;
+ return _attributed_string_map;
}
-
+
private final void setAttributedStringMap( final Map<String, AttributedString> attributed_string_map ) {
_attributed_string_map = attributed_string_map;
}
final private static boolean plusPressed( final int key_code ) {
return ( ( key_code == KeyEvent.VK_ADD ) || ( key_code == KeyEvent.VK_PLUS )
- || ( key_code == KeyEvent.VK_EQUALS ) || ( key_code == KeyEvent.VK_SEMICOLON ) || ( key_code == KeyEvent.VK_1 ) );
+ || ( key_code == KeyEvent.VK_EQUALS ) || ( key_code == KeyEvent.VK_SEMICOLON )
+ || ( key_code == KeyEvent.VK_1 ) );
+ }
+
+ public void decreaseDepthCollapseLevel() {
+ if ( ( _phylogeny != null ) && ( _phylogeny.getNumberOfExternalNodes() > 2 ) ) {
+ if ( _depth_collapse_level <= 1 ) {
+ _depth_collapse_level = PhylogenyMethods.calculateMaxDepth( _phylogeny );
+ uncollapseAll();
+ }
+ else {
+ --_depth_collapse_level;
+ PhylogenyMethods.collapseToDepth( _phylogeny, _depth_collapse_level );
+ }
+
+ }
+ }
+
+ public void increaseDepthCollapseLevel() {
+ if ( ( _phylogeny != null ) && ( _phylogeny.getNumberOfExternalNodes() > 2 ) ) {
+ final int max = PhylogenyMethods.calculateMaxDepth( _phylogeny );
+ if ( _depth_collapse_level >= max ) {
+ _depth_collapse_level = 1;
+ }
+ else {
+ ++_depth_collapse_level;
+ }
+ PhylogenyMethods.collapseToDepth( _phylogeny, _depth_collapse_level );
+ }
+ }
+
+ public void decreaseRankCollapseLevel() {
+ if ( ( _phylogeny != null ) && ( _phylogeny.getNumberOfExternalNodes() > 2 ) ) {
+ final String ranks[] = PhylogenyMethods.obtainPresentRanksSorted( _phylogeny );
+ if ( ranks.length > 1 ) {
+ if ( _rank_collapse_level <= 0 ) {
+ _rank_collapse_level = ranks.length - 1;
+ uncollapseAll();
+ }
+ else {
+ --_rank_collapse_level;
+ PhylogenyMethods.collapseToRank( _phylogeny, mapToAbsoluteRankLevel( ranks, _rank_collapse_level ) );
+ }
+ }
+ }
+ }
+
+
+ public void increaseRankCollapseLevel() {
+ if ( ( _phylogeny != null ) && ( _phylogeny.getNumberOfExternalNodes() > 2 ) ) {
+ final String ranks[] = PhylogenyMethods.obtainPresentRanksSorted( _phylogeny );
+ if ( ranks.length > 1 ) {
+ if ( _rank_collapse_level >= (ranks.length - 1 ) ) {
+ _rank_collapse_level = 0;
+ PhylogenyMethods.collapseToRank( _phylogeny,mapToAbsoluteRankLevel( ranks, _rank_collapse_level ) );
+ }
+ else if ( _rank_collapse_level == (ranks.length - 2 ) ) {
+ ++_rank_collapse_level;
+ uncollapseAll();
+ }
+ else {
+ ++_rank_collapse_level;
+ PhylogenyMethods.collapseToRank( _phylogeny,mapToAbsoluteRankLevel( ranks, _rank_collapse_level ) );
+ }
+ }
+ }
+ }
+
+
+ private final static int mapToAbsoluteRankLevel( final String present_ranks_sorted[],
+ final int rank_collapse_level ) {
+ final String rank_str = present_ranks_sorted[ rank_collapse_level ];
+ if ( !TaxonomyUtil.RANK_TO_INT.containsKey( rank_str ) ) {
+ throw new IllegalStateException( "unexpected exception: cannot find rank " + rank_str );
+ }
+ return TaxonomyUtil.RANK_TO_INT.get( rank_str );
+ }
+
+ private final void uncollapseAll() {
+ final PhylogenyNodeIterator it = new PreorderTreeIterator(_phylogeny );
+ while ( it.hasNext() ) {
+ it.next().setCollapse( false );
+ }
+ }
+
+ final int resetDepthCollapseDepthValue() {
+ return _depth_collapse_level = -1;
+ }
+
+ final int getDepthCollapseDepthValue() {
+ return _depth_collapse_level;
+ }
+
+ final void setDepthCollapseDepthValue( final int depth_collapse_level ) {
+ _depth_collapse_level = depth_collapse_level;
+ }
+
+ final int resetRankCollapseRankValue() {
+ return _rank_collapse_level = -1;
+ }
+
+ final int getRankCollapseRankValue() {
+ return _rank_collapse_level;
+ }
+
+ final void setRankCollapseRankValue( final int rank_collapse_level ) {
+ _rank_collapse_level = rank_collapse_level;
}
}
final static void collapseSpeciesSpecificSubtrees( final Phylogeny phy ) {
boolean inferred = false;
+ for( final PhylogenyNodeIterator iter = phy.iteratorPreorder(); iter.hasNext(); ) {
+ iter.next().setCollapse( false );
+ }
for( final PhylogenyNodeIterator it = phy.iteratorPreorder(); it.hasNext(); ) {
final PhylogenyNode n = it.next();
if ( !n.isExternal() && !n.isCollapse() && ( n.getNumberOfDescendants() > 1 ) ) {
++collapsed;
if ( !ForesterUtil.isEmpty( n.getNodeData().getTaxonomy().getScientificName() ) ) {
true_lineage_set.add( n.getNodeData().getTaxonomy().getScientificName() );
- System.out.println( "1 true_lineage_set added " + n.getNodeData().getTaxonomy().getScientificName() );
}
}
}
if ( !true_lineage_set.isEmpty() ) {
for( final String lin : node.getNodeData().getTaxonomy().getLineage() ) {
if ( true_lineage_set.contains( lin ) ) {
- //TreePanelUtil
- // .colorizeSubtree( node, new BranchColor( true_lineage_to_color_map.get( lin ) ) );
TreePanelUtil.collapseSubtree( node, true );
++collapsed;
success = true;
if ( lineage_to_rank_map.containsKey( lin )
&& !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 );
- TreePanelUtil.collapseSubtree( node, true );
+ TreePanelUtil.collapseSubtree( node, true );
++collapsed;
true_lineage_set.add( lin );
- System.out.println( "2 true_lineage_set added " + lin );
break;
}
else {
lineage_to_rank_map.put( lin, up.getRank() );
System.out.println( lin + "->" + up.getRank() );
if ( up.getRank().equalsIgnoreCase( rank ) ) {
- // final BranchColor c = new BranchColor( tree_panel.calculateTaxonomyBasedColor( temp_tax ) );
- // TreePanelUtil.colorizeSubtree( node, c );
TreePanelUtil.collapseSubtree( node, true );
++collapsed;
true_lineage_set.add( lin );
- System.out.println( "3 true_lineage_set added " + lin );
break;
}
}
package org.forester.io.parsers.phyloxml;
-import java.util.ArrayList;
import java.util.HashSet;
-import java.util.List;
import java.util.Set;
import java.util.regex.Pattern;
public final class PhyloXmlUtil {
- public static final String OTHER = "other";
- public static final String UNKNOWN = "unknown";
public final static Pattern SEQUENCE_SYMBOL_PATTERN = Pattern.compile( "\\S{1,20}" );
public final static Pattern TAXOMONY_CODE_PATTERN = Pattern
.compile( ParserUtils.TAX_CODE );
public final static Pattern LIT_REF_DOI_PATTERN = Pattern
.compile( "[a-zA-Z0-9_\\.]+\\S+" );
public final static Set<String> SEQUENCE_TYPES = new HashSet<String>();
- public final static List<String> TAXONOMY_RANKS_LIST = new ArrayList<String>();
- public final static Set<String> TAXONOMY_RANKS_SET = new HashSet<String>();
public static final int ROUNDING_DIGITS_FOR_PHYLOXML_DOUBLE_OUTPUT = 9;
public static final String VECTOR_PROPERTY_REF = "vector:index=";
public static final String VECTOR_PROPERTY_TYPE = "xsd:decimal";
SEQUENCE_TYPES.add( SEQ_TYPE_RNA );
SEQUENCE_TYPES.add( SEQ_TYPE_PROTEIN );
SEQUENCE_TYPES.add( SEQ_TYPE_DNA );
- TAXONOMY_RANKS_LIST.add( "domain" );
- TAXONOMY_RANKS_LIST.add( "superkingdom" );
- TAXONOMY_RANKS_LIST.add( "kingdom" );
- TAXONOMY_RANKS_LIST.add( "subkingdom" );
- TAXONOMY_RANKS_LIST.add( "branch" );
- TAXONOMY_RANKS_LIST.add( "infrakingdom" );
- TAXONOMY_RANKS_LIST.add( "superphylum" );
- TAXONOMY_RANKS_LIST.add( "phylum" );
- TAXONOMY_RANKS_LIST.add( "subphylum" );
- TAXONOMY_RANKS_LIST.add( "infraphylum" );
- TAXONOMY_RANKS_LIST.add( "microphylum" );
- TAXONOMY_RANKS_LIST.add( "superdivision" );
- TAXONOMY_RANKS_LIST.add( "division" );
- TAXONOMY_RANKS_LIST.add( "subdivision" );
- TAXONOMY_RANKS_LIST.add( "infradivision" );
- TAXONOMY_RANKS_LIST.add( "superclass" );
- TAXONOMY_RANKS_LIST.add( "class" );
- TAXONOMY_RANKS_LIST.add( "subclass" );
- TAXONOMY_RANKS_LIST.add( "infraclass" );
- TAXONOMY_RANKS_LIST.add( "superlegion" );
- TAXONOMY_RANKS_LIST.add( "legion" );
- TAXONOMY_RANKS_LIST.add( "sublegion" );
- TAXONOMY_RANKS_LIST.add( "infralegion" );
- TAXONOMY_RANKS_LIST.add( "supercohort" );
- TAXONOMY_RANKS_LIST.add( "cohort" );
- TAXONOMY_RANKS_LIST.add( "subcohort" );
- TAXONOMY_RANKS_LIST.add( "infracohort" );
- TAXONOMY_RANKS_LIST.add( "superorder" );
- TAXONOMY_RANKS_LIST.add( "order" );
- TAXONOMY_RANKS_LIST.add( "suborder" );
- TAXONOMY_RANKS_LIST.add( "infraorder" );
- TAXONOMY_RANKS_LIST.add( "superfamily" );
- TAXONOMY_RANKS_LIST.add( "family" );
- TAXONOMY_RANKS_LIST.add( "subfamily" );
- TAXONOMY_RANKS_LIST.add( "supertribe" );
- TAXONOMY_RANKS_LIST.add( "tribe" );
- TAXONOMY_RANKS_LIST.add( "subtribe" );
- TAXONOMY_RANKS_LIST.add( "infratribe" );
- TAXONOMY_RANKS_LIST.add( "genus" );
- TAXONOMY_RANKS_LIST.add( "subgenus" );
- TAXONOMY_RANKS_LIST.add( "superspecies" );
- TAXONOMY_RANKS_LIST.add( "species" );
- TAXONOMY_RANKS_LIST.add( "subspecies" );
- TAXONOMY_RANKS_LIST.add( "variety" );
- TAXONOMY_RANKS_LIST.add( "varietas" );
- TAXONOMY_RANKS_LIST.add( "subvariety" );
- TAXONOMY_RANKS_LIST.add( "form" );
- TAXONOMY_RANKS_LIST.add( "subform" );
- TAXONOMY_RANKS_LIST.add( "cultivar" );
- TAXONOMY_RANKS_LIST.add( "strain" );
- TAXONOMY_RANKS_LIST.add( "section" );
- TAXONOMY_RANKS_LIST.add( "subsection" );
- TAXONOMY_RANKS_LIST.add( UNKNOWN );
- TAXONOMY_RANKS_LIST.add( OTHER );
- // same thing as set:
- TAXONOMY_RANKS_SET.add( "domain" );
- TAXONOMY_RANKS_SET.add( "superkingdom" );
- TAXONOMY_RANKS_SET.add( "kingdom" );
- TAXONOMY_RANKS_SET.add( "subkingdom" );
- TAXONOMY_RANKS_SET.add( "branch" );
- TAXONOMY_RANKS_SET.add( "infrakingdom" );
- TAXONOMY_RANKS_SET.add( "superphylum" );
- TAXONOMY_RANKS_SET.add( "phylum" );
- TAXONOMY_RANKS_SET.add( "subphylum" );
- TAXONOMY_RANKS_SET.add( "infraphylum" );
- TAXONOMY_RANKS_SET.add( "microphylum" );
- TAXONOMY_RANKS_SET.add( "superdivision" );
- TAXONOMY_RANKS_SET.add( "division" );
- TAXONOMY_RANKS_SET.add( "subdivision" );
- TAXONOMY_RANKS_SET.add( "infradivision" );
- TAXONOMY_RANKS_SET.add( "superclass" );
- TAXONOMY_RANKS_SET.add( "class" );
- TAXONOMY_RANKS_SET.add( "subclass" );
- TAXONOMY_RANKS_SET.add( "infraclass" );
- TAXONOMY_RANKS_SET.add( "superlegion" );
- TAXONOMY_RANKS_SET.add( "legion" );
- TAXONOMY_RANKS_SET.add( "sublegion" );
- TAXONOMY_RANKS_SET.add( "infralegion" );
- TAXONOMY_RANKS_SET.add( "supercohort" );
- TAXONOMY_RANKS_SET.add( "cohort" );
- TAXONOMY_RANKS_SET.add( "subcohort" );
- TAXONOMY_RANKS_SET.add( "infracohort" );
- TAXONOMY_RANKS_SET.add( "superorder" );
- TAXONOMY_RANKS_SET.add( "order" );
- TAXONOMY_RANKS_SET.add( "suborder" );
- TAXONOMY_RANKS_SET.add( "infraorder" );
- TAXONOMY_RANKS_SET.add( "superfamily" );
- TAXONOMY_RANKS_SET.add( "family" );
- TAXONOMY_RANKS_SET.add( "subfamily" );
- TAXONOMY_RANKS_SET.add( "supertribe" );
- TAXONOMY_RANKS_SET.add( "tribe" );
- TAXONOMY_RANKS_SET.add( "subtribe" );
- TAXONOMY_RANKS_SET.add( "infratribe" );
- TAXONOMY_RANKS_SET.add( "genus" );
- TAXONOMY_RANKS_SET.add( "subgenus" );
- TAXONOMY_RANKS_SET.add( "superspecies" );
- TAXONOMY_RANKS_SET.add( "species" );
- TAXONOMY_RANKS_SET.add( "subspecies" );
- TAXONOMY_RANKS_SET.add( "variety" );
- TAXONOMY_RANKS_SET.add( "varietas" );
- TAXONOMY_RANKS_SET.add( "subvariety" );
- TAXONOMY_RANKS_SET.add( "form" );
- TAXONOMY_RANKS_SET.add( "subform" );
- TAXONOMY_RANKS_SET.add( "cultivar" );
- TAXONOMY_RANKS_SET.add( "strain" );
- TAXONOMY_RANKS_SET.add( "section" );
- TAXONOMY_RANKS_SET.add( "subsection" );
- TAXONOMY_RANKS_SET.add( UNKNOWN );
- TAXONOMY_RANKS_SET.add( OTHER );
+
};
}
* the root-node of a subtree
* @return the height of the subtree emanating at n
*/
- public double calculateSubtreeHeight( final PhylogenyNode n ) {
- if ( n.isExternal() || n.isCollapse() ) {
- return ForesterUtil.isLargerOrEqualToZero( n.getDistanceToParent() );
+ public double calculateSubtreeHeight( final PhylogenyNode n, final boolean take_collapse_into_account ) {
+ if ( n.isExternal() || ( take_collapse_into_account && n.isCollapse() ) ) {
+ return n.getDistanceToParent() > 0 ? n.getDistanceToParent() : 0;
}
else {
double max = -Double.MAX_VALUE;
for( int i = 0; i < n.getNumberOfDescendants(); ++i ) {
- final double l = calculateSubtreeHeight( n.getChildNode( i ) );
+ final double l = calculateSubtreeHeight( n.getChildNode( i ), take_collapse_into_account );
if ( l > max ) {
max = l;
}
}
- return max + ForesterUtil.isLargerOrEqualToZero( n.getDistanceToParent() );
+ return max + ( n.getDistanceToParent() > 0 ? n.getDistanceToParent() : 0) ;
}
}
/**
* This calculates the height for rooted, tree-shaped phylogenies. The
- * height is the longest distance from the root to an external node. Please
- * note. Child nodes of collapsed nodes are ignored -- which is useful for
- * display purposes but might be misleading for other applications.
+ * height is the longest distance from the root to an external node.
*
* @return the height for rooted, tree-shaped phylogenies
*/
- public double getHeight() {
+ public double calculateHeight(final boolean take_collapse_into_account) {
if ( isEmpty() ) {
return 0.0;
}
- return calculateSubtreeHeight( getRoot() );
+ return calculateSubtreeHeight( getRoot(), take_collapse_into_account );
}
public Identifier getIdentifier() {
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
+import org.forester.archaeopteryx.TreePanelUtil;
import org.forester.io.parsers.FastaParser;
import org.forester.io.parsers.PhylogenyParser;
import org.forester.io.parsers.phyloxml.PhyloXmlDataFormatException;
import org.forester.phylogeny.factories.ParserBasedPhylogenyFactory;
import org.forester.phylogeny.factories.PhylogenyFactory;
import org.forester.phylogeny.iterators.PhylogenyNodeIterator;
+import org.forester.phylogeny.iterators.PreorderTreeIterator;
import org.forester.util.BasicDescriptiveStatistics;
import org.forester.util.DescriptiveStatistics;
import org.forester.util.ForesterUtil;
+import org.forester.util.TaxonomyUtil;
public class PhylogenyMethods {
}
return max;
}
+
+ public static String[] obtainPresentRanksSorted( final Phylogeny phy ) {
+ final Set<String> present_ranks = new HashSet<String>();
+ for( final PhylogenyNodeIterator iter = phy.iteratorPreorder(); iter.hasNext(); ) {
+ final PhylogenyNode node = iter.next();
+ if ( !node.isExternal() && !node.isRoot() && ( node.getNodeData().getTaxonomy() != null )
+ && !ForesterUtil.isEmpty( node.getNodeData().getTaxonomy().getRank() ) ) {
+ final String current_rank = node.getNodeData().getTaxonomy().getRank();
+ if ( TaxonomyUtil.RANK_TO_INT.containsKey( current_rank ) ) {
+ present_ranks.add( current_rank );
+ }
+ }
+ }
+ final String ordered_ranks[] = new String[present_ranks.size() + 1];
+ int c = 0;
+ for( final String rank : TaxonomyUtil.RANKS ) {
+ if ( present_ranks.contains( rank ) ) {
+ ordered_ranks[ c++ ] = rank;
+ }
+ }
+ ordered_ranks[ c ] = "off";
+ return ordered_ranks;
+ }
+
+ public static int calculateMaxDepthConsiderCollapsed( final Phylogeny phy ) {
+ int max = 0;
+ for( final PhylogenyNodeIterator iter = phy.iteratorExternalForward(); iter.hasNext(); ) {
+ PhylogenyNode n = iter.next();
+ int steps = 0;
+ while ( n.getParent() != null ) {
+ if ( !n.isCollapse() ) {
+ steps++;
+ }
+ n = n.getParent();
+ }
+ if ( steps > max ) {
+ max = steps;
+ }
+ }
+ return max;
+ }
public static double calculateMaxDistanceToRoot( final Phylogeny phy ) {
double max = 0.0;
return deleted;
}
- public static void deleteExternalNodesPositiveSelectionT( final List<Taxonomy> species_to_keep, final Phylogeny phy ) {
+ public static void deleteExternalNodesPositiveSelectionT( final List<Taxonomy> species_to_keep,
+ final Phylogeny phy ) {
final Set<Long> to_delete = new HashSet<Long>();
for( final PhylogenyNodeIterator it = phy.iteratorExternalForward(); it.hasNext(); ) {
final PhylogenyNode n = it.next();
else {
if ( ( n.getNumberOfDescendants() == 2 )
&& ( n.getChildNode1().getNumberOfExternalNodes() != n.getChildNode2().getNumberOfExternalNodes() )
- && ( ( n.getChildNode1().getNumberOfExternalNodes() < n.getChildNode2().getNumberOfExternalNodes() ) == order ) ) {
+ && ( ( n.getChildNode1().getNumberOfExternalNodes() < n.getChildNode2()
+ .getNumberOfExternalNodes() ) == order ) ) {
final PhylogenyNode temp = n.getChildNode1();
n.setChild1( n.getChildNode2() );
n.setChild2( temp );
}
}
}
-
+
public synchronized static void orderAppearanceX( final PhylogenyNode n,
final boolean order_ext_alphabetically,
final DESCENDANT_SORT_PRIORITY pri ) {
return;
}
else {
- _order_changed = false;
- orderAppearance( n,
- true,
- order_ext_alphabetically,
- pri );
- if (!_order_changed ) {
- orderAppearance( n,
- false,
- order_ext_alphabetically,
- pri );
- }
+ _order_changed = false;
+ orderAppearance( n, true, order_ext_alphabetically, pri );
+ if ( !_order_changed ) {
+ orderAppearance( n, false, order_ext_alphabetically, pri );
+ }
}
}
PhylogenyNode.setNodeCount( i );
}
- public final static Phylogeny[] readPhylogenies( final PhylogenyParser parser, final File file ) throws IOException {
+ 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 ) ) {
}
private static enum NDF {
- NodeName( "NN" ),
- TaxonomyCode( "TC" ),
- TaxonomyCommonName( "CN" ),
- TaxonomyScientificName( "TS" ),
- TaxonomyIdentifier( "TI" ),
- TaxonomySynonym( "SY" ),
- SequenceName( "SN" ),
- GeneName( "GN" ),
- SequenceSymbol( "SS" ),
- SequenceAccession( "SA" ),
- Domain( "DO" ),
- Annotation( "AN" ),
- CrossRef( "XR" ),
- BinaryCharacter( "BC" ),
- MolecularSequence( "MS" );
+ NodeName( "NN" ),
+ TaxonomyCode( "TC" ),
+ TaxonomyCommonName( "CN" ),
+ TaxonomyScientificName( "TS" ),
+ TaxonomyIdentifier( "TI" ),
+ TaxonomySynonym( "SY" ),
+ SequenceName( "SN" ),
+ GeneName( "GN" ),
+ SequenceSymbol( "SS" ),
+ SequenceAccession( "SA" ),
+ Domain( "DO" ),
+ Annotation( "AN" ),
+ CrossRef( "XR" ),
+ BinaryCharacter( "BC" ),
+ MolecularSequence( "MS" );
private final String _text;
}
public static List<Long> searchData( final String query,
- final Phylogeny phy,
- final boolean case_sensitive,
- final boolean partial,
- final boolean regex,
- final boolean search_domains,
- final double domains_confidence_threshold ) {
+ final Phylogeny phy,
+ final boolean case_sensitive,
+ final boolean partial,
+ final boolean regex,
+ final boolean search_domains,
+ final double domains_confidence_threshold ) {
final List<Long> nodes = new ArrayList<Long>();
if ( phy.isEmpty() || ( query == null ) ) {
return nodes;
&& match( node.getName(), my_query, case_sensitive, partial, regex ) ) {
match = true;
}
- else if ( ( ( ndf == null ) || ( ndf == NDF.TaxonomyCode ) )
- && node.getNodeData().isHasTaxonomy()
+ else if ( ( ( ndf == null ) || ( ndf == NDF.TaxonomyCode ) ) && node.getNodeData().isHasTaxonomy()
&& match( node.getNodeData().getTaxonomy().getTaxonomyCode(),
my_query,
case_sensitive,
regex ) ) {
match = true;
}
- else if ( ( ( ndf == null ) || ( ndf == NDF.TaxonomyCommonName ) )
- && node.getNodeData().isHasTaxonomy()
+ else if ( ( ( ndf == null ) || ( ndf == NDF.TaxonomyCommonName ) ) && node.getNodeData().isHasTaxonomy()
&& match( node.getNodeData().getTaxonomy().getCommonName(),
my_query,
case_sensitive,
regex ) ) {
match = true;
}
- else if ( ( ( ndf == null ) || ( ndf == NDF.TaxonomyScientificName ) )
- && node.getNodeData().isHasTaxonomy()
+ else if ( ( ( ndf == null ) || ( ndf == NDF.TaxonomyScientificName ) ) && node.getNodeData().isHasTaxonomy()
&& match( node.getNodeData().getTaxonomy().getScientificName(),
my_query,
case_sensitive,
regex ) ) {
match = true;
}
- else if ( ( ( ndf == null ) || ( ndf == NDF.TaxonomyIdentifier ) )
- && node.getNodeData().isHasTaxonomy()
+ else if ( ( ( ndf == null ) || ( ndf == NDF.TaxonomyIdentifier ) ) && node.getNodeData().isHasTaxonomy()
&& ( node.getNodeData().getTaxonomy().getIdentifier() != null )
&& match( node.getNodeData().getTaxonomy().getIdentifier().getValue(),
my_query,
match = true;
}
if ( !match && ( ( ndf == null ) || ( ndf == NDF.GeneName ) ) && node.getNodeData().isHasSequence()
- && match( node.getNodeData().getSequence().getGeneName(), my_query, case_sensitive, partial, regex ) ) {
+ && match( node.getNodeData().getSequence().getGeneName(),
+ my_query,
+ case_sensitive,
+ partial,
+ regex ) ) {
match = true;
}
if ( !match && ( ( ndf == null ) || ( ndf == NDF.SequenceSymbol ) ) && node.getNodeData().isHasSequence()
- && match( node.getNodeData().getSequence().getSymbol(), my_query, case_sensitive, partial, regex ) ) {
+ && match( node.getNodeData().getSequence().getSymbol(),
+ my_query,
+ case_sensitive,
+ partial,
+ regex ) ) {
match = true;
}
- if ( !match
- && ( ( ndf == null ) || ( ndf == NDF.SequenceAccession ) )
- && node.getNodeData().isHasSequence()
+ if ( !match && ( ( ndf == null ) || ( ndf == NDF.SequenceAccession ) ) && node.getNodeData().isHasSequence()
&& ( node.getNodeData().getSequence().getAccession() != null )
&& match( node.getNodeData().getSequence().getAccession().getValue(),
my_query,
}
}
}
- if ( !match
- && ( ndf == NDF.MolecularSequence )
- && node.getNodeData().isHasSequence()
+ if ( !match && ( ndf == NDF.MolecularSequence ) && node.getNodeData().isHasSequence()
&& match( node.getNodeData().getSequence().getMolecularSequence(),
my_query,
case_sensitive,
}
public static List<Long> searchDataLogicalAnd( final String[] queries,
- final Phylogeny phy,
- final boolean case_sensitive,
- final boolean partial,
- final boolean search_domains,
- final double domains_confidence_threshold ) {
+ final Phylogeny phy,
+ final boolean case_sensitive,
+ final boolean partial,
+ final boolean search_domains,
+ final double domains_confidence_threshold ) {
final List<Long> nodes = new ArrayList<Long>();
if ( phy.isEmpty() || ( queries == null ) || ( queries.length < 1 ) ) {
return nodes;
&& match( node.getName(), query, case_sensitive, partial, false ) ) {
match = true;
}
- else if ( ( ( ndf == null ) || ( ndf == NDF.TaxonomyCode ) )
- && node.getNodeData().isHasTaxonomy()
+ else if ( ( ( ndf == null ) || ( ndf == NDF.TaxonomyCode ) ) && node.getNodeData().isHasTaxonomy()
&& match( node.getNodeData().getTaxonomy().getTaxonomyCode(),
query,
case_sensitive,
false ) ) {
match = true;
}
- else if ( ( ( ndf == null ) || ( ndf == NDF.TaxonomyCommonName ) )
- && node.getNodeData().isHasTaxonomy()
+ else if ( ( ( ndf == null ) || ( ndf == NDF.TaxonomyCommonName ) ) && node.getNodeData().isHasTaxonomy()
&& match( node.getNodeData().getTaxonomy().getCommonName(),
query,
case_sensitive,
false ) ) {
match = true;
}
- else if ( ( ( ndf == null ) || ( ndf == NDF.TaxonomyIdentifier ) )
- && node.getNodeData().isHasTaxonomy()
+ else if ( ( ( ndf == null ) || ( ndf == NDF.TaxonomyIdentifier ) ) && node.getNodeData().isHasTaxonomy()
&& ( node.getNodeData().getTaxonomy().getIdentifier() != null )
&& match( node.getNodeData().getTaxonomy().getIdentifier().getValue(),
query,
}
}
if ( !match && ( ( ndf == null ) || ( ndf == NDF.SequenceName ) ) && node.getNodeData().isHasSequence()
- && match( node.getNodeData().getSequence().getName(), query, case_sensitive, partial, false ) ) {
+ && match( node.getNodeData().getSequence().getName(),
+ query,
+ case_sensitive,
+ partial,
+ false ) ) {
match = true;
}
- if ( !match
- && ( ( ndf == null ) || ( ndf == NDF.GeneName ) )
- && node.getNodeData().isHasSequence()
- && match( node.getNodeData().getSequence().getGeneName(), query, case_sensitive, partial, false ) ) {
+ if ( !match && ( ( ndf == null ) || ( ndf == NDF.GeneName ) ) && node.getNodeData().isHasSequence()
+ && match( node.getNodeData().getSequence().getGeneName(),
+ query,
+ case_sensitive,
+ partial,
+ false ) ) {
match = true;
}
if ( !match && ( ( ndf == null ) || ( ndf == NDF.SequenceSymbol ) )
- && node.getNodeData().isHasSequence()
- && match( node.getNodeData().getSequence().getSymbol(), query, case_sensitive, partial, false ) ) {
+ && node.getNodeData().isHasSequence() && match( node.getNodeData().getSequence().getSymbol(),
+ query,
+ case_sensitive,
+ partial,
+ false ) ) {
match = true;
}
- if ( !match
- && ( ( ndf == null ) || ( ndf == NDF.SequenceAccession ) )
+ if ( !match && ( ( ndf == null ) || ( ndf == NDF.SequenceAccession ) )
&& node.getNodeData().isHasSequence()
&& ( node.getNodeData().getSequence().getAccession() != null )
&& match( node.getNodeData().getSequence().getAccession().getValue(),
}
}
}
- if ( !match
- && ( ndf == NDF.MolecularSequence )
- && node.getNodeData().isHasSequence()
+ if ( !match && ( ndf == NDF.MolecularSequence ) && node.getNodeData().isHasSequence()
&& match( node.getNodeData().getSequence().getMolecularSequence(),
query,
case_sensitive,
}
else if ( !( ref_ext_taxo.contains( n.getNodeData().getTaxonomy().getScientificName() ) )
&& !( ref_ext_taxo.contains( n.getNodeData().getTaxonomy().getTaxonomyCode() ) )
- && !( ( n.getNodeData().getTaxonomy().getIdentifier() != null ) && ref_ext_taxo.contains( n
- .getNodeData().getTaxonomy().getIdentifier().getValuePlusProvider() ) ) ) {
+ && !( ( n.getNodeData().getTaxonomy().getIdentifier() != null ) && ref_ext_taxo
+ .contains( n.getNodeData().getTaxonomy().getIdentifier().getValuePlusProvider() ) ) ) {
nodes_to_delete.add( n );
}
}
return true;
}
- final static public void transferInternalNodeNamesToConfidence( final Phylogeny phy, final String confidence_type ) {
+ final static public void transferInternalNodeNamesToConfidence( final Phylogeny phy,
+ final String confidence_type ) {
final PhylogenyNodeIterator it = phy.iteratorPostorder();
while ( it.hasNext() ) {
transferInternalNodeNameToConfidence( confidence_type, it.next() );
final static public void transferNodeNameToField( final Phylogeny phy,
final PhylogenyNodeField field,
- final boolean external_only ) throws PhyloXmlDataFormatException {
+ final boolean external_only )
+ throws PhyloXmlDataFormatException {
final PhylogenyNodeIterator it = phy.iteratorPostorder();
while ( it.hasNext() ) {
final PhylogenyNode n = it.next();
return d;
}
+ public static double calculateAverageTreeHeight( final PhylogenyNode node ) {
+ final List<PhylogenyNode> ext = node.getAllExternalDescendants();
+ double s = 0;
+ for( PhylogenyNode n : ext ) {
+ while ( n != node ) {
+ if ( n.getDistanceToParent() > 0 ) {
+ s += n.getDistanceToParent();
+ }
+ n = n.getParent();
+ }
+ }
+ return s / ext.size();
+ }
+
/**
* Deep copies the phylogeny originating from this node.
*/
}
public static enum DESCENDANT_SORT_PRIORITY {
- NODE_NAME, SEQUENCE, TAXONOMY;
+ NODE_NAME,
+ SEQUENCE,
+ TAXONOMY;
}
public static enum PhylogenyNodeField {
- CLADE_NAME,
- SEQUENCE_NAME,
- SEQUENCE_SYMBOL,
- TAXONOMY_CODE,
- TAXONOMY_COMMON_NAME,
- TAXONOMY_ID,
- TAXONOMY_ID_UNIPROT_1,
- TAXONOMY_ID_UNIPROT_2,
- TAXONOMY_SCIENTIFIC_NAME;
+ CLADE_NAME,
+ SEQUENCE_NAME,
+ SEQUENCE_SYMBOL,
+ TAXONOMY_CODE,
+ TAXONOMY_COMMON_NAME,
+ TAXONOMY_ID,
+ TAXONOMY_ID_UNIPROT_1,
+ TAXONOMY_ID_UNIPROT_2,
+ TAXONOMY_SCIENTIFIC_NAME;
}
public static void addMolecularSeqsToTree( final Phylogeny phy, final Msa msa ) {
return 0;
}
}
+
+ public final static Map<Long, Integer> calculateDepths( final Phylogeny phy ) {
+ final Map<Long, Integer> depths = new HashMap<Long, Integer>();
+ calculateDepthsHelper( phy.getRoot(), 0, depths );
+ return depths;
+ }
+
+ private final static void calculateDepthsHelper( final PhylogenyNode n, int d, final Map<Long, Integer> depths ) {
+ depths.put( n.getId(), d );
+ ++d;
+ final List<PhylogenyNode> descs = n.getDescendants();
+ for( final PhylogenyNode desc : descs ) {
+ calculateDepthsHelper( desc, d, depths );
+ }
+ }
+
+ public final static void collapseToDepth( final Phylogeny phy, final int depth ) {
+ if ( phy.getNumberOfExternalNodes() < 3 ) {
+ return;
+ }
+ collapseToDepthHelper( phy.getRoot(), 0, depth );
+ }
+
+ private final static void collapseToDepthHelper( final PhylogenyNode n, int d, final int depth ) {
+ if ( n.isExternal() ) {
+ n.setCollapse( false );
+ return;
+ }
+ if ( d >= depth ) {
+ n.setCollapse( true );
+ final PhylogenyNodeIterator it = new PreorderTreeIterator( n );
+ while ( it.hasNext() ) {
+ it.next().setCollapse( true );
+ }
+ }
+ else {
+ n.setCollapse( false );
+ ++d;
+ final List<PhylogenyNode> descs = n.getDescendants();
+ for( final PhylogenyNode desc : descs ) {
+ collapseToDepthHelper( desc, d, depth );
+ }
+ }
+ }
+
+
+
+ public final static void collapseToRank( final Phylogeny phy, final int rank ) {
+ if ( phy.getNumberOfExternalNodes() < 3 ) {
+ return;
+ }
+ if ( rank < 0 || rank >= TaxonomyUtil.RANKS.length ) {
+ throw new IllegalArgumentException( "Rank " + rank + " is out of range" );
+ }
+ collapseToRankHelper( phy.getRoot(), rank );
+ }
+
+ private final static void collapseToRankHelper( final PhylogenyNode n, final int target_rank ) {
+ if ( n.isExternal() ) {
+ n.setCollapse( false );
+ return;
+ }
+ if ( ( n.getNodeData().getTaxonomy() != null )
+ && !ForesterUtil.isEmpty( n.getNodeData().getTaxonomy().getRank() ) ) {
+ final String current_rank = n.getNodeData().getTaxonomy().getRank();
+ if ( !TaxonomyUtil.RANK_TO_INT.containsKey( current_rank ) ) {
+ System.out.println( "Don't know rank \"" + current_rank + "\", ignoring." );
+ }
+ else {
+ if ( TaxonomyUtil.RANK_TO_INT.get( current_rank ) >= target_rank ) {
+ n.setCollapse( true );
+
+ final PhylogenyNodeIterator it = new PreorderTreeIterator( n );
+ while ( it.hasNext() ) {
+ it.next().setCollapse( true );
+ }
+ return;
+ }
+ }
+ }
+ n.setCollapse( false );
+ final List<PhylogenyNode> descs = n.getDescendants();
+ for( final PhylogenyNode desc : descs ) {
+ collapseToRankHelper( desc, target_rank );
+ }
+ }
+
+
+
}
}
/**
- * Inserts PhylogenyNode n at the specified position i into the list of
+ * Inserts PhylogenyNode node at the specified position i into the list of
* child nodes. This does not allow null slots in the list of child nodes:
- * If i is larger than the number of child nodes, n is just added to the
- * list, not place at index i.
+ * If i is larger than the number of child nodes, node is just added to the
+ * list, not placed at index i.
*
* @param i
* the index of position where to add the child
- * @param n
+ * @param node
* the PhylogenyNode to add
*/
final public void setChildNode( final int i, final PhylogenyNode node ) {
import org.forester.io.parsers.phyloxml.PhyloXmlMapping;
import org.forester.io.parsers.phyloxml.PhyloXmlUtil;
import org.forester.util.ForesterUtil;
+import org.forester.util.TaxonomyUtil;
public class Taxonomy implements PhylogenyData, MultipleUris, Comparable<Taxonomy> {
}
public void setRank( final String rank ) throws PhyloXmlDataFormatException {
- if ( !ForesterUtil.isEmpty( rank ) && !PhyloXmlUtil.TAXONOMY_RANKS_SET.contains( rank ) ) {
+ if ( !ForesterUtil.isEmpty( rank ) && !TaxonomyUtil.TAXONOMY_RANKS_SET.contains( rank ) ) {
throw new PhyloXmlDataFormatException( "illegal rank: [" + rank + "]" );
}
_rank = rank;
double diff = 0.0;
double height = 0.0;
final double[] height_diff = new double[ 2 ];
- final double l0 = t.calculateSubtreeHeight( t.getRoot().getChildNode( 0 ) );
- final double l1 = t.calculateSubtreeHeight( t.getRoot().getChildNode( 1 ) );
+ final double l0 = t.calculateSubtreeHeight( t.getRoot().getChildNode( 0 ), false );
+ final double l1 = t.calculateSubtreeHeight( t.getRoot().getChildNode( 1 ), false );
diff = l0 - l1;
- height = t.getHeight();
+ height = t.calculateHeight(false);
if ( d > 0.0 ) {
if ( ( 2 * d ) > Math.abs( diff ) ) {
child0.setDistanceToParent( d - ( diff / 2.0 ) );
if ( t2.getNumberOfExternalNodes() != 4 ) {
return false;
}
- if ( t2.getHeight() != 8.5 ) {
+ if ( t2.calculateHeight(false) != 8.5 ) {
return false;
}
if ( !t2.isCompletelyBinary() ) {
if ( t3.getNumberOfExternalNodes() != 5 ) {
return false;
}
- if ( t3.getHeight() != 11 ) {
+ if ( t3.calculateHeight(true) != 11 ) {
return false;
}
if ( t3.isCompletelyBinary() ) {
if ( t4.getNumberOfExternalNodes() != 9 ) {
return false;
}
- if ( t4.getHeight() != 11 ) {
+ if ( t4.calculateHeight(false) != 11 ) {
return false;
}
if ( t4.isCompletelyBinary() ) {
if ( t5.getNumberOfExternalNodes() != 8 ) {
return false;
}
- if ( t5.getHeight() != 15 ) {
+ if ( t5.calculateHeight(false) != 15 ) {
return false;
}
final StringBuffer sb6 = new StringBuffer( "(X,Y,Z,(((A111)A11:2)A1:2,(X,Y,Z,A21:1,A22:2,A23)A2:11,A3:2)A:2,B:10,C:3,D:8)" );
final Phylogeny t6 = factory.create( sb6.toString(), new NHXParser() )[ 0 ];
- if ( t6.getHeight() != 15 ) {
+ if ( t6.calculateHeight(true) != 15 ) {
return false;
}
final StringBuffer sb7 = new StringBuffer( "(((A11:2)A1:2,(A21:1,A22:2,A23)A2:11,A3:2)A:2,B:10,C:15,D:8)" );
final Phylogeny t7 = factory.create( sb7.toString(), new NHXParser() )[ 0 ];
- if ( t7.getHeight() != 15 ) {
+ if ( t7.calculateHeight(true) != 15 ) {
return false;
}
final StringBuffer sb8 = new StringBuffer( "(((A11:11)A1:2,(A21:2,A22:2,A23,A24,AA:)A2:11,A3:2)A:2,B:15,C:15,D:15)" );
if ( t8.getNumberOfExternalNodes() != 10 ) {
return false;
}
- if ( t8.getHeight() != 15 ) {
+ if ( t8.calculateHeight(true) != 15 ) {
return false;
}
final char[] a9 = new char[] { 'a' };
final Phylogeny t9 = factory.create( a9, new NHXParser() )[ 0 ];
- if ( t9.getHeight() != 0 ) {
+ if ( t9.calculateHeight(true) != 0 ) {
return false;
}
final char[] a10 = new char[] { 'a', ':', '6' };
final Phylogeny t10 = factory.create( a10, new NHXParser() )[ 0 ];
- if ( t10.getHeight() != 6 ) {
+ if ( t10.calculateHeight(true) != 6 ) {
return false;
}
}
package org.forester.util;
+import java.util.ArrayList;
import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
import java.util.Map;
+import java.util.Set;
public final class TaxonomyUtil {
}
_default_taxcode_taxgroup_map.put( code, group );
}
- private final static Map<String, String> _default_taxcode_taxgroup_map = new HashMap<String, String>();
+ private final static Map<String, String> _default_taxcode_taxgroup_map = new HashMap<String, String>();
static {
put( "BUFBU", "deuterostomia" );
put( "NOTVI", "deuterostomia" );
put( "HELPH", "bacteria" );
put( "AQUAE", "bacteria" );
}
- private final static Map<String, Integer> FAKE_CODE_TO_ID_MAP = new HashMap<String, Integer>();
+ private final static Map<String, Integer> FAKE_CODE_TO_ID_MAP = new HashMap<String, Integer>();
static {
FAKE_CODE_TO_ID_MAP.put( "CTEXX", 283909 );
FAKE_CODE_TO_ID_MAP.put( "HMAXX", 6085 );
FAKE_CODE_TO_ID_MAP.put( "ALIXX", 87102 );
FAKE_CODE_TO_ID_MAP.put( "TTRXX", 529818 );
}
+ public final static List<String> TAXONOMY_RANKS_LIST = new ArrayList<String>();
+ public final static Set<String> TAXONOMY_RANKS_SET = new HashSet<String>();
+ public static final String OTHER = "other";
+ public static final String UNKNOWN = "unknown";;
+ final public static HashMap<String, Integer> RANK_TO_INT = new HashMap<String, Integer>();
+ static {
+ TAXONOMY_RANKS_LIST.add( "domain" );
+ TAXONOMY_RANKS_LIST.add( "superkingdom" );
+ TAXONOMY_RANKS_LIST.add( "kingdom" );
+ TAXONOMY_RANKS_LIST.add( "subkingdom" );
+ TAXONOMY_RANKS_LIST.add( "branch" );
+ TAXONOMY_RANKS_LIST.add( "infrakingdom" );
+ TAXONOMY_RANKS_LIST.add( "superphylum" );
+ TAXONOMY_RANKS_LIST.add( "phylum" );
+ TAXONOMY_RANKS_LIST.add( "subphylum" );
+ TAXONOMY_RANKS_LIST.add( "infraphylum" );
+ TAXONOMY_RANKS_LIST.add( "microphylum" );
+ TAXONOMY_RANKS_LIST.add( "superdivision" );
+ TAXONOMY_RANKS_LIST.add( "division" );
+ TAXONOMY_RANKS_LIST.add( "subdivision" );
+ TAXONOMY_RANKS_LIST.add( "infradivision" );
+ TAXONOMY_RANKS_LIST.add( "superclass" );
+ TAXONOMY_RANKS_LIST.add( "class" );
+ TAXONOMY_RANKS_LIST.add( "subclass" );
+ TAXONOMY_RANKS_LIST.add( "infraclass" );
+ TAXONOMY_RANKS_LIST.add( "superlegion" );
+ TAXONOMY_RANKS_LIST.add( "legion" );
+ TAXONOMY_RANKS_LIST.add( "sublegion" );
+ TAXONOMY_RANKS_LIST.add( "infralegion" );
+ TAXONOMY_RANKS_LIST.add( "supercohort" );
+ TAXONOMY_RANKS_LIST.add( "cohort" );
+ TAXONOMY_RANKS_LIST.add( "subcohort" );
+ TAXONOMY_RANKS_LIST.add( "infracohort" );
+ TAXONOMY_RANKS_LIST.add( "superorder" );
+ TAXONOMY_RANKS_LIST.add( "order" );
+ TAXONOMY_RANKS_LIST.add( "suborder" );
+ TAXONOMY_RANKS_LIST.add( "infraorder" );
+ TAXONOMY_RANKS_LIST.add( "superfamily" );
+ TAXONOMY_RANKS_LIST.add( "family" );
+ TAXONOMY_RANKS_LIST.add( "subfamily" );
+ TAXONOMY_RANKS_LIST.add( "supertribe" );
+ TAXONOMY_RANKS_LIST.add( "tribe" );
+ TAXONOMY_RANKS_LIST.add( "subtribe" );
+ TAXONOMY_RANKS_LIST.add( "infratribe" );
+ TAXONOMY_RANKS_LIST.add( "genus" );
+ TAXONOMY_RANKS_LIST.add( "subgenus" );
+ TAXONOMY_RANKS_LIST.add( "superspecies" );
+ TAXONOMY_RANKS_LIST.add( "species" );
+ TAXONOMY_RANKS_LIST.add( "subspecies" );
+ TAXONOMY_RANKS_LIST.add( "variety" );
+ TAXONOMY_RANKS_LIST.add( "varietas" );
+ TAXONOMY_RANKS_LIST.add( "subvariety" );
+ TAXONOMY_RANKS_LIST.add( "form" );
+ TAXONOMY_RANKS_LIST.add( "subform" );
+ TAXONOMY_RANKS_LIST.add( "cultivar" );
+ TAXONOMY_RANKS_LIST.add( "strain" );
+ TAXONOMY_RANKS_LIST.add( "section" );
+ TAXONOMY_RANKS_LIST.add( "subsection" );
+ TAXONOMY_RANKS_LIST.add( UNKNOWN );
+ TAXONOMY_RANKS_LIST.add( OTHER );
+ }
+ final public static String RANKS[] = new String[ TAXONOMY_RANKS_LIST.size() - 2 ];
+ static {
+ // same thing as set:
+ for( final String rank : TAXONOMY_RANKS_LIST ) {
+ System.out.println( "=" + rank );
+ TAXONOMY_RANKS_SET.add( rank );
+ }
+ final int l = RANKS.length;
+ for( int i = 0; i < l; ++i ) {
+ System.out.println( "i=" + i );
+ RANKS[ i ] = TAXONOMY_RANKS_LIST.get( i );
+ RANK_TO_INT.put( RANKS[ i ], i );
+ }
+ }
}