- if ( getConfiguration().isEditable() ) {
- _file_jmenu.addSeparator();
- _file_jmenu.add( _new_item = new JMenuItem( "New" ) );
- _new_item.setToolTipText( "to create a new tree with one node, as source for manual tree construction" );
- }
- _file_jmenu.addSeparator();
- _file_jmenu.add( _save_item = new JMenuItem( "Save Tree As..." ) );
- _file_jmenu.add( _save_all_item = new JMenuItem( "Save All Trees As..." ) );
- _save_all_item.setToolTipText( "Write all phylogenies to one file." );
- _save_all_item.setEnabled( false );
- _file_jmenu.addSeparator();
- _file_jmenu.add( _write_to_pdf_item = new JMenuItem( "Export to PDF file ..." ) );
- if ( AptxUtil.canWriteFormat( "tif" ) || AptxUtil.canWriteFormat( "tiff" ) || AptxUtil.canWriteFormat( "TIF" ) ) {
- _file_jmenu.add( _write_to_tif_item = new JMenuItem( "Export to TIFF file..." ) );
- }
- _file_jmenu.add( _write_to_png_item = new JMenuItem( "Export to PNG file..." ) );
- _file_jmenu.add( _write_to_jpg_item = new JMenuItem( "Export to JPG file..." ) );
- if ( AptxUtil.canWriteFormat( "gif" ) ) {
- _file_jmenu.add( _write_to_gif_item = new JMenuItem( "Export to GIF file..." ) );
- }
- if ( AptxUtil.canWriteFormat( "bmp" ) ) {
- _file_jmenu.add( _write_to_bmp_item = new JMenuItem( "Export to BMP file..." ) );
- }
- _file_jmenu.addSeparator();
- _file_jmenu.add( _print_item = new JMenuItem( "Print..." ) );
- _file_jmenu.addSeparator();
- _file_jmenu.add( _close_item = new JMenuItem( "Close Tab" ) );
- _close_item.setToolTipText( "To close the current pane." );
- _close_item.setEnabled( true );
- _file_jmenu.addSeparator();
- _file_jmenu.add( _exit_item = new JMenuItem( "Exit" ) );
- // For print in color option item
- customizeJMenuItem( _open_item );
- _open_item
- .setFont( new Font( _open_item.getFont().getFontName(), Font.BOLD, _open_item.getFont().getSize() + 4 ) );
- customizeJMenuItem( _open_url_item );
- for( int i = 0; i < webservices_manager.getAvailablePhylogeniesWebserviceClients().size(); ++i ) {
- customizeJMenuItem( _load_phylogeny_from_webservice_menu_items[ i ] );
- }
- customizeJMenuItem( _save_item );
- if ( getConfiguration().isEditable() ) {
- customizeJMenuItem( _new_item );
- }
- customizeJMenuItem( _close_item );
- customizeJMenuItem( _save_all_item );
- customizeJMenuItem( _write_to_pdf_item );
- customizeJMenuItem( _write_to_png_item );
- customizeJMenuItem( _write_to_jpg_item );
- customizeJMenuItem( _write_to_gif_item );
- customizeJMenuItem( _write_to_tif_item );
- customizeJMenuItem( _write_to_bmp_item );
- customizeJMenuItem( _print_item );
- customizeJMenuItem( _exit_item );
- _jmenubar.add( _file_jmenu );
- }
-
- void buildOptionsMenu() {
- _options_jmenu = MainFrame.createMenu( OPTIONS_HEADER, getConfiguration() );
- _options_jmenu.addChangeListener( new ChangeListener() {
-
- @Override
- public void stateChanged( final ChangeEvent e ) {
- MainFrame.setOvPlacementColorChooseMenuItem( _overview_placment_mi, getOptions() );
- MainFrame.setTextColorChooseMenuItem( _switch_colors_mi, getCurrentTreePanel() );
- MainFrame
- .setTextMinSupportMenuItem( _choose_minimal_confidence_mi, getOptions(), getCurrentTreePanel() );
- MainFrame.setTextForFontChooserMenuItem( _choose_font_mi, MainFrame
- .createCurrentFontDesc( getMainPanel().getTreeFontSet() ) );
- setTextForGraphicsSizeChooserMenuItem( _print_size_mi, getOptions() );
- setTextForPdfLineWidthChooserMenuItem( _choose_pdf_width_mi, getOptions() );
- MainFrame.updateOptionsMenuDependingOnPhylogenyType( getMainPanel(),
- _show_scale_cbmi,
- _show_branch_length_values_cbmi,
- _non_lined_up_cladograms_rbmi,
- _uniform_cladograms_rbmi,
- _ext_node_dependent_cladogram_rbmi,
- _label_direction_cbmi );
- MainFrame.setCycleNodeFillMenuItem( _cycle_node_fill_mi, getOptions() );
- MainFrame.setCycleNodeShapeMenuItem( _cycle_node_shape_mi, getOptions() );
- MainFrame.setTextNodeSizeMenuItem( _choose_node_size_mi, getOptions() );
- }
- } );
- _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 );
- _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_branch_length_values_cbmi = new JCheckBoxMenuItem( DISPLAY_BRANCH_LENGTH_VALUES_LABEL ) );
- _options_jmenu.add( _show_confidence_stddev_cbmi = new JCheckBoxMenuItem( SHOW_CONF_STDDEV_LABEL ) );
- _options_jmenu.add( _show_default_node_shapes_cbmi = new JCheckBoxMenuItem( DISPLAY_NODE_BOXES_LABEL ) );
- _options_jmenu
- .add( _taxonomy_colorize_node_shapes_cbmi = new JCheckBoxMenuItem( MainFrame.TAXONOMY_COLORIZE_NODE_SHAPES_LABEL ) );
- _options_jmenu.add( _cycle_node_shape_mi = new JMenuItem( MainFrame.CYCLE_NODE_SHAPE_LABEL ) );
- _options_jmenu.add( _cycle_node_fill_mi = new JMenuItem( MainFrame.CYCLE_NODE_FILL_LABEL ) );
- _options_jmenu.add( _choose_node_size_mi = new JMenuItem( MainFrame.CHOOSE_NODE_SIZE_LABEL ) );
- _options_jmenu.add( _label_direction_cbmi = new JCheckBoxMenuItem( LABEL_DIRECTION_LABEL ) );
- _label_direction_cbmi.setToolTipText( LABEL_DIRECTION_TIP );
- _options_jmenu.add( _color_labels_same_as_parent_branch = new JCheckBoxMenuItem( COLOR_LABELS_LABEL ) );
- _color_labels_same_as_parent_branch.setToolTipText( MainFrame.COLOR_LABELS_TIP );
- _options_jmenu.add( _abbreviate_scientific_names = new JCheckBoxMenuItem( ABBREV_SN_LABEL ) );
- _options_jmenu.add( _screen_antialias_cbmi = new JCheckBoxMenuItem( SCREEN_ANTIALIAS_LABEL ) );
- _options_jmenu.add( _background_gradient_cbmi = new JCheckBoxMenuItem( BG_GRAD_LABEL ) );
- if ( getConfiguration().doDisplayOption( Configuration.show_domain_architectures ) ) {
- _options_jmenu.add( _show_domain_labels = new JCheckBoxMenuItem( SHOW_DOMAIN_LABELS_LABEL ) );
- }
- _options_jmenu.add( _choose_minimal_confidence_mi = new JMenuItem( "" ) );
- _options_jmenu.add( _overview_placment_mi = new JMenuItem( "" ) );
- _options_jmenu.add( _switch_colors_mi = new JMenuItem( "" ) );
- _options_jmenu.add( _choose_font_mi = new JMenuItem( "" ) );
- _options_jmenu.addSeparator();
- _options_jmenu.add( customizeMenuItemAsLabel( new JMenuItem( SEARCH_SUBHEADER ), getConfiguration() ) );
- _options_jmenu.add( _search_case_senstive_cbmi = new JCheckBoxMenuItem( SEARCH_CASE_SENSITIVE_LABEL ) );
- _options_jmenu.add( _search_whole_words_only_cbmi = new JCheckBoxMenuItem( SEARCH_TERMS_ONLY_LABEL ) );
- _options_jmenu.add( _inverse_search_result_cbmi = new JCheckBoxMenuItem( INVERSE_SEARCH_RESULT_LABEL ) );
- _options_jmenu.addSeparator();
- _options_jmenu.add( customizeMenuItemAsLabel( new JMenuItem( "Graphics Export & Printing:" ),
- getConfiguration() ) );
- _options_jmenu.add( _antialias_print_cbmi = new JCheckBoxMenuItem( "Antialias" ) );
- _options_jmenu.add( _print_black_and_white_cbmi = new JCheckBoxMenuItem( "Export in Black and White" ) );
- _options_jmenu
- .add( _print_using_actual_size_cbmi = new JCheckBoxMenuItem( "Use Current Image Size for PDF export and Printing" ) );
- _options_jmenu
- .add( _graphics_export_using_actual_size_cbmi = new JCheckBoxMenuItem( "Use Current Image Size for PNG, JPG, and GIF export" ) );
- _options_jmenu
- .add( _graphics_export_visible_only_cbmi = new JCheckBoxMenuItem( "Limit to Visible ('Screenshot') for PNG, JPG, and GIF export" ) );
- _options_jmenu.add( _print_size_mi = new JMenuItem( "" ) );
- _options_jmenu.add( _choose_pdf_width_mi = new JMenuItem( "" ) );
- _options_jmenu.addSeparator();
- _options_jmenu.add( customizeMenuItemAsLabel( new JMenuItem( "Newick/NHX/Nexus Input:" ), getConfiguration() ) );
- _options_jmenu
- .add( _internal_number_are_confidence_for_nh_parsing_cbmi = new JCheckBoxMenuItem( "Internal Node Names are Confidence Values" ) );
- _options_jmenu.add( _replace_underscores_cbmi = new JCheckBoxMenuItem( "Replace Underscores with Spaces" ) );
- _options_jmenu
- .add( _extract_pfam_style_tax_codes_cbmi = new JCheckBoxMenuItem( "Extract Taxonomy Codes from Pfam-style Labels" ) );
- _options_jmenu.add( customizeMenuItemAsLabel( new JMenuItem( "Newick/Nexus Output:" ), getConfiguration() ) );
- _options_jmenu
- .add( _use_brackets_for_conf_in_nh_export_cbmi = new JCheckBoxMenuItem( USE_BRACKETS_FOR_CONF_IN_NH_LABEL ) );
- _use_brackets_for_conf_in_nh_export_cbmi
- .setToolTipText( "e.g. \"0.1[90]\" for a branch with support 90 and a length of 0.1" );
- _options_jmenu
- .add( _use_internal_names_for_conf_in_nh_export_cbmi = new JCheckBoxMenuItem( USE_INTERNAL_NAMES_FOR_CONF_IN_NH_LABEL ) );
- customizeJMenuItem( _choose_font_mi );
- customizeJMenuItem( _choose_minimal_confidence_mi );
- customizeJMenuItem( _switch_colors_mi );
- customizeJMenuItem( _print_size_mi );
- customizeJMenuItem( _choose_pdf_width_mi );
- customizeJMenuItem( _overview_placment_mi );
- customizeCheckBoxMenuItem( _show_default_node_shapes_cbmi, getOptions().isShowDefaultNodeShapes() );
- customizeCheckBoxMenuItem( _taxonomy_colorize_node_shapes_cbmi, getOptions().isTaxonomyColorizeNodeShapes() );
- customizeJMenuItem( _cycle_node_shape_mi );
- customizeJMenuItem( _cycle_node_fill_mi );
- customizeJMenuItem( _choose_node_size_mi );
- customizeCheckBoxMenuItem( _color_labels_same_as_parent_branch, getOptions().isColorLabelsSameAsParentBranch() );
- customizeCheckBoxMenuItem( _screen_antialias_cbmi, getOptions().isAntialiasScreen() );
- customizeCheckBoxMenuItem( _background_gradient_cbmi, getOptions().isBackgroundColorGradient() );
- customizeCheckBoxMenuItem( _show_domain_labels, getOptions().isShowDomainLabels() );
- customizeCheckBoxMenuItem( _abbreviate_scientific_names, getOptions().isAbbreviateScientificTaxonNames() );
- customizeCheckBoxMenuItem( _search_case_senstive_cbmi, getOptions().isSearchCaseSensitive() );
- 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 );
- customizeCheckBoxMenuItem( _show_branch_length_values_cbmi, getOptions().isShowBranchLengthValues() );
- customizeCheckBoxMenuItem( _show_overview_cbmi, getOptions().isShowOverview() );
- customizeCheckBoxMenuItem( _label_direction_cbmi,
- getOptions().getNodeLabelDirection() == NODE_LABEL_DIRECTION.RADIAL );
- customizeCheckBoxMenuItem( _antialias_print_cbmi, getOptions().isAntialiasPrint() );
- customizeCheckBoxMenuItem( _print_black_and_white_cbmi, getOptions().isPrintBlackAndWhite() );
- customizeCheckBoxMenuItem( _internal_number_are_confidence_for_nh_parsing_cbmi, getOptions()
- .isInternalNumberAreConfidenceForNhParsing() );
- customizeCheckBoxMenuItem( _extract_pfam_style_tax_codes_cbmi, getOptions()
- .isExtractPfamTaxonomyCodesInNhParsing() );
- customizeCheckBoxMenuItem( _replace_underscores_cbmi, getOptions().isReplaceUnderscoresInNhParsing() );
- customizeCheckBoxMenuItem( _search_whole_words_only_cbmi, getOptions().isMatchWholeTermsOnly() );
- customizeCheckBoxMenuItem( _inverse_search_result_cbmi, getOptions().isInverseSearchResult() );
- customizeCheckBoxMenuItem( _graphics_export_visible_only_cbmi, getOptions().isGraphicsExportVisibleOnly() );
- customizeCheckBoxMenuItem( _print_using_actual_size_cbmi, getOptions().isPrintUsingActualSize() );
- customizeCheckBoxMenuItem( _graphics_export_using_actual_size_cbmi, getOptions()
- .isGraphicsExportUsingActualSize() );
- customizeCheckBoxMenuItem( _show_confidence_stddev_cbmi, getOptions().isShowConfidenceStddev() );
- customizeCheckBoxMenuItem( _use_brackets_for_conf_in_nh_export_cbmi, getOptions()
- .getNhConversionSupportValueStyle() == NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS );
- customizeCheckBoxMenuItem( _use_internal_names_for_conf_in_nh_export_cbmi, getOptions()
- .getNhConversionSupportValueStyle() == NH_CONVERSION_SUPPORT_VALUE_STYLE.AS_INTERNAL_NODE_NAMES );
- _jmenubar.add( _options_jmenu );
- }
-
- void buildToolsMenu() {
- _tools_menu = createMenu( "Tools", getConfiguration() );
- _tools_menu.add( _confcolor_item = new JMenuItem( "Colorize Branches Depending on Confidence" ) );
- customizeJMenuItem( _confcolor_item );
- _tools_menu.add( _color_rank_jmi = new JMenuItem( "Colorize Subtrees via Taxonomic Rank" ) );
- customizeJMenuItem( _color_rank_jmi );
- _color_rank_jmi.setToolTipText( "for example, at \"Class\" level, colorize mammal specific subtree red" );
- _tools_menu.add( _taxcolor_item = new JMenuItem( "Taxonomy Colorize Branches" ) );
- customizeJMenuItem( _taxcolor_item );
- _tools_menu.add( _remove_branch_color_item = new JMenuItem( "Delete Branch Colors" ) );
- _remove_branch_color_item.setToolTipText( "To delete branch color values from the current phylogeny" );
- customizeJMenuItem( _remove_branch_color_item );
- _tools_menu.addSeparator();
- _tools_menu.add( _annotate_item = new JMenuItem( "Annotate Sequences of Selected Nodes" ) );
- customizeJMenuItem( _annotate_item );
- _tools_menu.addSeparator();
- _tools_menu.add( _midpoint_root_item = new JMenuItem( "Midpoint-Root" ) );
- customizeJMenuItem( _midpoint_root_item );
- _tools_menu.addSeparator();
- _tools_menu.add( _collapse_species_specific_subtrees = new JMenuItem( "Collapse Species-Specific Subtrees" ) );
- customizeJMenuItem( _collapse_species_specific_subtrees );
- _tools_menu
- .add( _collapse_below_threshold = new JMenuItem( "Collapse Branches with Confidence Below Threshold into Multifurcations" ) );
- customizeJMenuItem( _collapse_below_threshold );
- _collapse_below_threshold
- .setToolTipText( "To collapse branches with confidence values below a threshold into multifurcations (in the case of multiple confidences per branch: without at least one confidence value above a threshold)" );
- _tools_menu.addSeparator();
- _tools_menu
- .add( _move_node_names_to_tax_sn_jmi = new JMenuItem( "Transfer Node Names to Taxonomic Scientific Names" ) );
- customizeJMenuItem( _move_node_names_to_tax_sn_jmi );
- _move_node_names_to_tax_sn_jmi.setToolTipText( "To interpret node names as taxonomic scientific names" );
- _tools_menu.add( _move_node_names_to_seq_names_jmi = new JMenuItem( "Transfer Node Names to Sequence Names" ) );
- customizeJMenuItem( _move_node_names_to_seq_names_jmi );
- _move_node_names_to_seq_names_jmi.setToolTipText( "To interpret node names as sequence (protein, gene) names" );
- _tools_menu
- .add( _extract_tax_code_from_node_names_jmi = new JMenuItem( "Extract Taxonomic Codes from Node Names" ) );
- customizeJMenuItem( _extract_tax_code_from_node_names_jmi );
- _extract_tax_code_from_node_names_jmi
- .setToolTipText( "To extract taxonomic codes (mnemonics) from nodes names in the form of 'xyz_ECOLI'" );
- _tools_menu.addSeparator();
- _tools_menu
- .add( _obtain_detailed_taxonomic_information_jmi = new JMenuItem( OBTAIN_DETAILED_TAXONOMIC_INFORMATION ) );
- customizeJMenuItem( _obtain_detailed_taxonomic_information_jmi );
- _obtain_detailed_taxonomic_information_jmi
- .setToolTipText( "To add additional taxonomic information (from UniProt Taxonomy)" );
- _tools_menu
- .add( _obtain_detailed_taxonomic_information_deleting_jmi = new JMenuItem( "Obtain Detailed Taxonomic Information (deletes nodes!)" ) );
- customizeJMenuItem( _obtain_detailed_taxonomic_information_deleting_jmi );
- _obtain_detailed_taxonomic_information_deleting_jmi
- .setToolTipText( "To add additional taxonomic information, deletes nodes for which taxonomy cannot found (from UniProt Taxonomy)" );
- _tools_menu.add( _obtain_seq_information_jmi = new JMenuItem( "Obtain Sequence Information" ) );
- customizeJMenuItem( _obtain_seq_information_jmi );
- _obtain_seq_information_jmi.setToolTipText( "To add additional sequence information" );
- _tools_menu.addSeparator();
- if ( !Constants.__RELEASE ) {
- _tools_menu.add( _function_analysis = new JMenuItem( "Add UniProtKB Annotations" ) );
- customizeJMenuItem( _function_analysis );
- _function_analysis
- .setToolTipText( "To add UniProtKB annotations for sequences with appropriate identifiers" );
- _tools_menu.addSeparator();
- }
- _tools_menu.add( _read_values_jmi = new JMenuItem( "Read Vector/Expression Values" ) );
- customizeJMenuItem( _read_values_jmi );
- _read_values_jmi.setToolTipText( "To add vector (e.g. gene expression) values (beta)" );
- _jmenubar.add( _tools_menu );
- }
-
- private void choosePdfWidth() {
- final String s = ( String ) JOptionPane.showInputDialog( this,
- "Please enter the default line width for PDF export.\n"
- + "[current value: "
- + getOptions().getPrintLineWidth() + "]\n",
- "Line Width for PDF Export",
- JOptionPane.QUESTION_MESSAGE,
- null,
- null,
- getOptions().getPrintLineWidth() );
- if ( !ForesterUtil.isEmpty( s ) ) {
- boolean success = true;
- float f = 0.0f;
- final String m_str = s.trim();
- if ( !ForesterUtil.isEmpty( m_str ) ) {
- try {
- f = Float.parseFloat( m_str );
- }
- catch ( final Exception ex ) {
- success = false;
- }
- }
- else {
- success = false;
- }
- if ( success && ( f > 0.0 ) ) {
- getOptions().setPrintLineWidth( f );
- }
- }
- }
-
- private void choosePrintSize() {
- final String s = ( String ) JOptionPane.showInputDialog( this,
- "Please enter values for width and height,\nseparated by a comma.\n"
- + "[current values: "
- + getOptions().getPrintSizeX() + ", "
- + getOptions().getPrintSizeY() + "]\n"
- + "[A4: " + Constants.A4_SIZE_X + ", "
- + Constants.A4_SIZE_Y + "]\n" + "[US Letter: "
- + Constants.US_LETTER_SIZE_X + ", "
- + Constants.US_LETTER_SIZE_Y + "]",
- "Default Size for Graphics Export",
- JOptionPane.QUESTION_MESSAGE,
- null,
- null,
- getOptions().getPrintSizeX() + ", "
- + getOptions().getPrintSizeY() );
- if ( !ForesterUtil.isEmpty( s ) && ( s.indexOf( ',' ) > 0 ) ) {
- boolean success = true;
- int x = 0;
- int y = 0;
- final String[] str_ary = s.split( "," );
- if ( str_ary.length == 2 ) {
- final String x_str = str_ary[ 0 ].trim();
- final String y_str = str_ary[ 1 ].trim();
- if ( !ForesterUtil.isEmpty( x_str ) && !ForesterUtil.isEmpty( y_str ) ) {
- try {
- x = Integer.parseInt( x_str );
- y = Integer.parseInt( y_str );
- }
- catch ( final Exception ex ) {
- success = false;
- }
- }
- else {
- success = false;
- }
- }
- else {
- success = false;
- }
- if ( success && ( x > 1 ) && ( y > 1 ) ) {
- getOptions().setPrintSizeX( x );
- getOptions().setPrintSizeY( y );
- }
- }
- }
-
- @Override
- void close() {
- if ( isUnsavedDataPresent() ) {
- final int r = JOptionPane.showConfirmDialog( this,
- "Exit despite potentially unsaved changes?",
- "Exit?",
- JOptionPane.YES_NO_OPTION );
- if ( r != JOptionPane.YES_OPTION ) {
- return;
- }
- }
- exit();
- }
-
- private void closeCurrentPane() {
- if ( getMainPanel().getCurrentTreePanel() != null ) {
- if ( getMainPanel().getCurrentTreePanel().isEdited() ) {
- final int r = JOptionPane.showConfirmDialog( this,
- "Close tab despite potentially unsaved changes?",
- "Close Tab?",
- JOptionPane.YES_NO_OPTION );
- if ( r != JOptionPane.YES_OPTION ) {
- return;
- }
- }
- getMainPanel().closeCurrentPane();
- activateSaveAllIfNeeded();
- }
- }
-
- private void collapse( final Phylogeny phy, final double m ) {
- final PhylogenyNodeIterator it = phy.iteratorPostorder();
- final List<PhylogenyNode> to_be_removed = new ArrayList<PhylogenyNode>();
- double min_support = Double.MAX_VALUE;
- boolean conf_present = false;
- while ( it.hasNext() ) {
- final PhylogenyNode n = it.next();
- if ( !n.isExternal() && !n.isRoot() ) {
- final List<Confidence> c = n.getBranchData().getConfidences();
- if ( ( c != null ) && ( c.size() > 0 ) ) {
- conf_present = true;
- double max = 0;
- for( final Confidence confidence : c ) {
- if ( confidence.getValue() > max ) {
- max = confidence.getValue();
- }
- }
- if ( max < getMinNotCollapseConfidenceValue() ) {
- to_be_removed.add( n );
- }
- if ( max < min_support ) {
- min_support = max;
- }
- }
- }
- }
- if ( conf_present ) {
- for( final PhylogenyNode node : to_be_removed ) {
- PhylogenyMethods.removeNode( node, phy );
- }
- if ( to_be_removed.size() > 0 ) {
- phy.externalNodesHaveChanged();
- phy.clearHashIdToNodeMap();
- phy.recalculateNumberOfExternalDescendants( true );
- getCurrentTreePanel().resetNodeIdToDistToLeafMap();
- getCurrentTreePanel().updateSetOfCollapsedExternalNodes();
- getCurrentTreePanel().calculateLongestExtNodeInfo();
- getCurrentTreePanel().setNodeInPreorderToNull();
- getCurrentTreePanel().recalculateMaxDistanceToRoot();
- getCurrentTreePanel().resetPreferredSize();
- getCurrentTreePanel().setEdited( true );
- getCurrentTreePanel().repaint();
- repaint();
- }
- if ( to_be_removed.size() > 0 ) {
- JOptionPane.showMessageDialog( this, "Collapsed " + to_be_removed.size()
- + " branches with\nconfidence values below " + getMinNotCollapseConfidenceValue(), "Collapsed "
- + to_be_removed.size() + " branches", JOptionPane.INFORMATION_MESSAGE );
- }
- else {
- JOptionPane.showMessageDialog( this, "No branch collapsed,\nminimum confidence value per branch is "
- + min_support, "No branch collapsed", JOptionPane.INFORMATION_MESSAGE );
- }
- }
- else {
- JOptionPane.showMessageDialog( this,
- "No branch collapsed because no confidence values present",
- "No confidence values present",
- JOptionPane.INFORMATION_MESSAGE );
- }
- }
-
- private void collapseBelowThreshold() {
- if ( getCurrentTreePanel() != null ) {
- final Phylogeny phy = getCurrentTreePanel().getPhylogeny();
- if ( ( phy != null ) && !phy.isEmpty() ) {
- final String s = ( String ) JOptionPane.showInputDialog( this,
- "Please enter the minimum confidence value\n",
- "Minimal Confidence Value",
- JOptionPane.QUESTION_MESSAGE,
- null,
- null,
- getMinNotCollapseConfidenceValue() );
- if ( !ForesterUtil.isEmpty( s ) ) {
- boolean success = true;
- double m = 0.0;
- final String m_str = s.trim();
- if ( !ForesterUtil.isEmpty( m_str ) ) {
- try {
- m = Double.parseDouble( m_str );
- }
- catch ( final Exception ex ) {
- success = false;
- }
- }
- else {
- success = false;
- }
- if ( success && ( m >= 0.0 ) ) {
- setMinNotCollapseConfidenceValue( m );
- collapse( phy, m );
- }
- }
- }
- }
- }
-
- private PhyloXmlParser createPhyloXmlParser() {
- PhyloXmlParser xml_parser = null;
- if ( getConfiguration().isValidatePhyloXmlAgainstSchema() ) {