import java.io.File;
import java.io.IOException;
import java.net.URL;
+import java.util.LinkedList;
import java.util.List;
+import java.util.Map;
+import java.util.NoSuchElementException;
import javax.swing.ButtonGroup;
import javax.swing.JApplet;
private JMenuItem _small_fonts_mi;
private JMenuItem _medium_fonts_mi;
private JMenuItem _large_fonts_mi;
- private TextFrame _textframe;
private JMenu _tools_menu;
private JMenuItem _taxcolor_item;
private JMenuItem _confcolor_item;
private JMenuItem _choose_node_size_mi;
private JCheckBoxMenuItem _taxonomy_colorize_node_shapes_cbmi;
private JCheckBoxMenuItem _show_confidence_stddev_cbmi;
+ final LinkedList<TextFrame> _textframes = new LinkedList<TextFrame>(); ;
@Override
public void actionPerformed( final ActionEvent e ) {
MainFrame.about();
}
else if ( o == _help_item ) {
- MainFrame.help( getConfiguration().getWebLinks() );
+ help( getConfiguration().getWebLinks() );
}
else if ( o == _website_item ) {
try {
repaint();
}
+ void help( final Map<String, WebLink> weblinks ) {
+ final StringBuilder sb = new StringBuilder();
+ sb.append( "Display options\n" );
+ sb.append( "-------------------\n" );
+ sb.append( "Use the checkboxes to select types of information to display on the tree.\n\n" );
+ sb.append( "Clickable tree nodes\n" );
+ sb.append( "--------------------\n" );
+ sb.append( "Tree nodes can be clicked, the action is determined by the 'click on node to' menu\n" );
+ sb.append( "or by right clicking:\n" );
+ sb.append( "o Display Node Data -- display information for a node\n" );
+ sb.append( "o Collapse/Uncollapse -- collapse and uncollapse subtree from clicked node\n" );
+ sb.append( "o Root/Reroot -- change tree root to clicked node\n" );
+ sb.append( "o Sub/Super Tree -- toggle between subtree from clicked node and whole tree\n" );
+ sb.append( "o Swap Descendants -- switch descendant on either side of clicked node\n" );
+ sb.append( "o Colorize Subtree -- color a subtree\n" );
+ sb.append( "o Open Sequence Web -- launch a web browser to display sequence information\n" );
+ sb.append( "o Open Taxonomy Web -- launch a web browser to display taxonomy information\n" );
+ sb.append( "- there may be additional choices depending on this particular setup\n\n" );
+ sb.append( "Right clicking on a node always displays the information of a node.\n\n" );
+ sb.append( "Zooming\n" );
+ sb.append( "---------\n" );
+ sb.append( "The mouse wheel and the plus and minus keys control zooming.\n" );
+ sb.append( "Mouse wheel+Ctrl changes the text size.\n" );
+ sb.append( "Mouse wheel+Shift controls zooming in vertical direction only.\n" );
+ sb.append( "Use the buttons on the control panel to zoom the tree in and out, horizontally or vertically.\n" );
+ sb.append( "The entire tree can be fitted into the window by clicking the \"F\" button, or by pressing F, Delete, or Home.\n" );
+ sb.append( "The up, down, left, and right keys can be used to move the visible part (if zoomed in).\n" );
+ sb.append( "Up, down, left, and right+Shift can be used to control zooming horizontally and vertically.\n" );
+ sb.append( "Plus and minus keys+Ctrl change the text size; F+Ctrl, Delete+Ctrl, or Home+Ctrl resets it.\n\n" );
+ sb.append( "Quick tree manipulation:\n" );
+ sb.append( "------------------------\n" );
+ sb.append( "Order Subtrees -- order the tree by branch length\n" );
+ sb.append( "Uncollapse All -- uncollapse any and all collapsed branches\n\n" );
+ sb.append( "Memory problems (Java heap space error)\n" );
+ sb.append( "---------------------------------------\n" );
+ sb.append( "Since the Java default memory allocation is quite small, it might by necessary (for trees\n" );
+ sb.append( "with more than approximately 5000 external nodes) to increase the memory which Java can use, with\n" );
+ sb.append( "the '-Xmx' Java command line option. For example:\n" );
+ sb.append( "java -Xms32m -Xmx256m -cp path\\to\\forester.jar org.forester.archaeopteryx.Archaeopteryx\n\n" );
+ if ( ( weblinks != null ) && ( weblinks.size() > 0 ) ) {
+ sb.append( "Active web links\n" );
+ sb.append( "--------------------\n" );
+ for( final String key : weblinks.keySet() ) {
+ sb.append( " " + weblinks.get( key ).toString() + "\n" );
+ }
+ }
+ sb.append( "\n" );
+ sb.append( "phyloXML\n" );
+ sb.append( "-------------------\n" );
+ sb.append( "Reference: " + Constants.PHYLOXML_REFERENCE + "\n" );
+ sb.append( "Website: " + Constants.PHYLOXML_WEB_SITE + "\n" );
+ sb.append( "Version: " + ForesterConstants.PHYLO_XML_VERSION + "\n" );
+ sb.append( "\n" );
+ sb.append( "For more information: http://www.phylosoft.org/archaeopteryx/\n" );
+ sb.append( "Email: " + Constants.AUTHOR_EMAIL + "\n\n" );
+ TextFrame.instantiate( sb.toString(), "Help", _textframes );
+ }
+
/**
* This method returns the current phylogeny as a string in the chosen format
*
* @author Herve Menager
*/
public String getCurrentPhylogeny( final String format ) {
- removeTextFrame();
+ removeAllTextFrames();
if ( ( getMainPanel().getCurrentPhylogeny() == null ) || getMainPanel().getCurrentPhylogeny().isEmpty()
|| ( getMainPanel().getCurrentPhylogeny().getNumberOfExternalNodes() > 10000 ) ) {
return new String();
@Override
public void destroy() {
AptxUtil.printAppletMessage( NAME, "going to be destroyed " );
- removeTextFrame();
+ removeAllTextFrames();
if ( getMainPanel() != null ) {
getMainPanel().terminate();
}
}
}
- void removeTextFrame() {
- if ( _textframe != null ) {
- _textframe.close();
- _textframe = null;
- }
- }
-
void setConfiguration( final Configuration configuration ) {
_configuration = configuration;
}
( ( JCheckBoxMenuItem ) o ).setSelected( true );
}
+ void displayBasicInformation() {
+ if ( ( getMainPanel().getCurrentPhylogeny() != null ) && !getMainPanel().getCurrentPhylogeny().isEmpty() ) {
+ String title = "Basic Information";
+ if ( !ForesterUtil.isEmpty( getMainPanel().getCurrentPhylogeny().getName() ) ) {
+ title = getMainPanel().getCurrentPhylogeny().getName() + " " + title;
+ }
+ showTextFrame( AptxUtil.createBasicInformation( getMainPanel().getCurrentPhylogeny() ), title );
+ }
+ }
+
void viewAsNexus() {
if ( ( getMainPanel().getCurrentPhylogeny() != null ) && !getMainPanel().getCurrentPhylogeny().isEmpty() ) {
+ String title = "Nexus";
+ if ( !ForesterUtil.isEmpty( getMainPanel().getCurrentPhylogeny().getName() ) ) {
+ title = getMainPanel().getCurrentPhylogeny().getName() + " " + title;
+ }
showTextFrame( getMainPanel().getCurrentPhylogeny().toNexus( getOptions()
- .getNhConversionSupportValueStyle() ) );
+ .getNhConversionSupportValueStyle() ),
+ title );
}
}
void viewAsNH() {
if ( ( getMainPanel().getCurrentPhylogeny() != null ) && !getMainPanel().getCurrentPhylogeny().isEmpty() ) {
- showTextFrame( getMainPanel().getCurrentPhylogeny().toNewHampshire() );
+ String title = "New Hampshire";
+ if ( !ForesterUtil.isEmpty( getMainPanel().getCurrentPhylogeny().getName() ) ) {
+ title = getMainPanel().getCurrentPhylogeny().getName() + " " + title;
+ }
+ showTextFrame( getMainPanel().getCurrentPhylogeny()
+ .toNewHampshire( false, getOptions().getNhConversionSupportValueStyle() ),
+ title );
}
}
void viewAsNHX() {
if ( ( getMainPanel().getCurrentPhylogeny() != null ) && !getMainPanel().getCurrentPhylogeny().isEmpty() ) {
- showTextFrame( getMainPanel().getCurrentPhylogeny().toNewHampshireX() );
+ String title = "NHX";
+ if ( !ForesterUtil.isEmpty( getMainPanel().getCurrentPhylogeny().getName() ) ) {
+ title = getMainPanel().getCurrentPhylogeny().getName() + " " + title;
+ }
+ showTextFrame( getMainPanel().getCurrentPhylogeny().toNewHampshireX(), title );
}
}
void viewAsXML() {
if ( ( getMainPanel().getCurrentPhylogeny() != null ) && !getMainPanel().getCurrentPhylogeny().isEmpty() ) {
- showTextFrame( getMainPanel().getCurrentPhylogeny().toPhyloXML( 0 ) );
+ String title = "phyloXML";
+ if ( !ForesterUtil.isEmpty( getMainPanel().getCurrentPhylogeny().getName() ) ) {
+ title = getMainPanel().getCurrentPhylogeny().getName() + " " + title;
+ }
+ showTextFrame( getMainPanel().getCurrentPhylogeny().toPhyloXML( 0 ), title );
}
}
- void displayBasicInformation() {
- if ( ( getMainPanel().getCurrentPhylogeny() != null ) && !getMainPanel().getCurrentPhylogeny().isEmpty() ) {
- showTextFrame( AptxUtil.createBasicInformation( getMainPanel().getCurrentPhylogeny() ) );
+ public void showTextFrame( final String s, final String title ) {
+ checkTextFrames();
+ _textframes.addLast( TextFrame.instantiate( s, title, _textframes ) );
+ }
+
+ void checkTextFrames() {
+ if ( _textframes.size() > 5 ) {
+ try {
+ if ( _textframes.getFirst() != null ) {
+ _textframes.getFirst().removeMe();
+ }
+ else {
+ _textframes.removeFirst();
+ }
+ }
+ catch ( final NoSuchElementException e ) {
+ // Ignore.
+ }
}
}
- public void showTextFrame( final String s ) {
- removeTextFrame();
- _textframe = TextFrame.instantiate( s );
+ void removeAllTextFrames() {
+ for( final TextFrame tf : _textframes ) {
+ if ( tf != null ) {
+ tf.close();
+ }
+ }
+ _textframes.clear();
}
static void setupScreenTextAntialias( final List<TreePanel> treepanels, final boolean antialias ) {
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;
+import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
+import java.util.NoSuchElementException;
import javax.swing.JApplet;
import javax.swing.JCheckBoxMenuItem;
public abstract class MainFrame extends JFrame implements ActionListener {
- static final String USE_MOUSEWHEEL_SHIFT_TO_ROTATE = "In this display type, use mousewheel + Shift to rotate [or A and S]";
- static final String PHYLOXML_REF_TOOL_TIP = Constants.PHYLOXML_REFERENCE; //TODO //FIXME
- static final String APTX_REF_TOOL_TIP = Constants.APTX_REFERENCE;
- private static final long serialVersionUID = 3655000897845508358L;
- final static Font menu_font = new Font( Configuration.getDefaultFontFamilyName(),
- Font.PLAIN,
- 10 );
- static final String TYPE_MENU_HEADER = "Type";
- static final String RECTANGULAR_TYPE_CBMI_LABEL = "Rectangular";
- static final String EURO_TYPE_CBMI_LABEL = "Euro Type";
- static final String CURVED_TYPE_CBMI_LABEL = "Curved";
- static final String TRIANGULAR_TYPE_CBMI_LABEL = "Triangular";
- static final String CONVEX_TYPE_CBMI_LABEL = "Convex";
- static final String ROUNDED_TYPE_CBMI_LABEL = "Rounded";
- static final String UNROOTED_TYPE_CBMI_LABEL = "Unrooted (alpha)"; //TODO
- static final String CIRCULAR_TYPE_CBMI_LABEL = "Circular (alpha)"; //TODO
- static final String OPTIONS_HEADER = "Options";
- static final String SEARCH_SUBHEADER = "Search:";
- static final String DISPLAY_SUBHEADER = "Display:";
- static final String SEARCH_TERMS_ONLY_LABEL = "Match Complete Terms Only";
- static final String SEARCH_CASE_SENSITIVE_LABEL = "Case Sensitive";
- static final String INVERSE_SEARCH_RESULT_LABEL = "Negate Result";
- static final String DISPLAY_BRANCH_LENGTH_VALUES_LABEL = "Display Branch Length Values";
- static final String DISPLAY_SCALE_LABEL = "Display 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 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 SCREEN_ANTIALIAS_LABEL = "Antialias";
- static final String COLOR_LABELS_LABEL = "Colorize Labels Same as Parent Branch";
- static final String BG_GRAD_LABEL = "Background Color Gradient";
- static final String DISPLAY_NODE_BOXES_LABEL = "Show Node Shapes";
- static final String SHOW_OVERVIEW_LABEL = "Show Overview";
- static final String FONT_SIZE_MENU_LABEL = "Font Size";
- static final String NONUNIFORM_CLADOGRAMS_LABEL = "External Node Sum Dependent Cladograms";
- static final String SHOW_DOMAIN_LABELS_LABEL = "Show Domain Labels";
- 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";
- static final String ABBREV_SN_LABEL = "Abbreviate Scientific Taxonomic Names";
- static final String TAXONOMY_COLORIZE_NODE_SHAPES_LABEL = "Colorize Node Shapes According to Taxonomy";
- static final String CYCLE_NODE_SHAPE_LABEL = "Cycle Node Shapes";
- static final String CYCLE_NODE_FILL_LABEL = "Cycle Node Fill Type";
- static final String CHOOSE_NODE_SIZE_LABEL = "Choose Node Shape Size";
- static final String SHOW_CONF_STDDEV_LABEL = "Show Confidence Standard Deviations";
- static final String USE_BRACKETS_FOR_CONF_IN_NH_LABEL = "Use Brackets for Confidence Values";
- static final String USE_INTERNAL_NAMES_FOR_CONF_IN_NH_LABEL = "Use Internal Node Names for Confidence Values";
- JMenuBar _jmenubar;
- JMenu _file_jmenu;
- JMenu _tools_menu;
- JMenu _view_jmenu;
- JMenu _options_jmenu;
- JMenu _font_size_menu;
- JMenu _help_jmenu;
- JMenuItem[] _load_phylogeny_from_webservice_menu_items;
+ static final String USE_MOUSEWHEEL_SHIFT_TO_ROTATE = "In this display type, use mousewheel + Shift to rotate [or A and S]";
+ static final String PHYLOXML_REF_TOOL_TIP = Constants.PHYLOXML_REFERENCE; //TODO //FIXME
+ static final String APTX_REF_TOOL_TIP = Constants.APTX_REFERENCE;
+ private static final long serialVersionUID = 3655000897845508358L;
+ final static Font menu_font = new Font( Configuration.getDefaultFontFamilyName(),
+ Font.PLAIN,
+ 10 );
+ static final String TYPE_MENU_HEADER = "Type";
+ static final String RECTANGULAR_TYPE_CBMI_LABEL = "Rectangular";
+ static final String EURO_TYPE_CBMI_LABEL = "Euro Type";
+ static final String CURVED_TYPE_CBMI_LABEL = "Curved";
+ static final String TRIANGULAR_TYPE_CBMI_LABEL = "Triangular";
+ static final String CONVEX_TYPE_CBMI_LABEL = "Convex";
+ static final String ROUNDED_TYPE_CBMI_LABEL = "Rounded";
+ static final String UNROOTED_TYPE_CBMI_LABEL = "Unrooted (alpha)"; //TODO
+ static final String CIRCULAR_TYPE_CBMI_LABEL = "Circular (alpha)"; //TODO
+ static final String OPTIONS_HEADER = "Options";
+ static final String SEARCH_SUBHEADER = "Search:";
+ static final String DISPLAY_SUBHEADER = "Display:";
+ static final String SEARCH_TERMS_ONLY_LABEL = "Match Complete Terms Only";
+ static final String SEARCH_CASE_SENSITIVE_LABEL = "Case Sensitive";
+ static final String INVERSE_SEARCH_RESULT_LABEL = "Negate Result";
+ static final String DISPLAY_BRANCH_LENGTH_VALUES_LABEL = "Display Branch Length Values";
+ static final String DISPLAY_SCALE_LABEL = "Display 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 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 SCREEN_ANTIALIAS_LABEL = "Antialias";
+ static final String COLOR_LABELS_LABEL = "Colorize Labels Same as Parent Branch";
+ static final String BG_GRAD_LABEL = "Background Color Gradient";
+ static final String DISPLAY_NODE_BOXES_LABEL = "Show Node Shapes";
+ static final String SHOW_OVERVIEW_LABEL = "Show Overview";
+ static final String FONT_SIZE_MENU_LABEL = "Font Size";
+ static final String NONUNIFORM_CLADOGRAMS_LABEL = "External Node Sum Dependent Cladograms";
+ static final String SHOW_DOMAIN_LABELS_LABEL = "Show Domain Labels";
+ 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";
+ static final String ABBREV_SN_LABEL = "Abbreviate Scientific Taxonomic Names";
+ static final String TAXONOMY_COLORIZE_NODE_SHAPES_LABEL = "Colorize Node Shapes According to Taxonomy";
+ static final String CYCLE_NODE_SHAPE_LABEL = "Cycle Node Shapes";
+ static final String CYCLE_NODE_FILL_LABEL = "Cycle Node Fill Type";
+ static final String CHOOSE_NODE_SIZE_LABEL = "Choose Node Shape Size";
+ static final String SHOW_CONF_STDDEV_LABEL = "Show Confidence Standard Deviations";
+ static final String USE_BRACKETS_FOR_CONF_IN_NH_LABEL = "Use Brackets for Confidence Values";
+ static final String USE_INTERNAL_NAMES_FOR_CONF_IN_NH_LABEL = "Use Internal Node Names for Confidence Values";
+ JMenuBar _jmenubar;
+ JMenu _file_jmenu;
+ JMenu _tools_menu;
+ JMenu _view_jmenu;
+ JMenu _options_jmenu;
+ JMenu _font_size_menu;
+ JMenu _help_jmenu;
+ JMenuItem[] _load_phylogeny_from_webservice_menu_items;
// file menu:
- JMenuItem _open_item;
- JMenuItem _open_url_item;
- JMenuItem _save_item;
- JMenuItem _save_all_item;
- JMenuItem _close_item;
- JMenuItem _exit_item;
- JMenuItem _new_item;
+ JMenuItem _open_item;
+ JMenuItem _open_url_item;
+ JMenuItem _save_item;
+ JMenuItem _save_all_item;
+ JMenuItem _close_item;
+ JMenuItem _exit_item;
+ JMenuItem _new_item;
// tools menu:
- JMenuItem _midpoint_root_item;
- JMenuItem _taxcolor_item;
- JMenuItem _confcolor_item;
- JMenuItem _color_rank_jmi;
- JMenuItem _infer_common_sn_names_item;
- JMenuItem _collapse_species_specific_subtrees;
- JMenuItem _collapse_below_threshold; //TODO implememt me
- JMenuItem _obtain_detailed_taxonomic_information_jmi;
- JMenuItem _obtain_detailed_taxonomic_information_deleting_jmi;
- JMenuItem _obtain_uniprot_seq_information_jmi;
- JMenuItem _move_node_names_to_tax_sn_jmi;
- JMenuItem _move_node_names_to_seq_names_jmi;
- JMenuItem _extract_tax_code_from_node_names_jmi;
+ JMenuItem _midpoint_root_item;
+ JMenuItem _taxcolor_item;
+ JMenuItem _confcolor_item;
+ JMenuItem _color_rank_jmi;
+ JMenuItem _infer_common_sn_names_item;
+ JMenuItem _collapse_species_specific_subtrees;
+ JMenuItem _collapse_below_threshold; //TODO implememt me
+ JMenuItem _obtain_detailed_taxonomic_information_jmi;
+ JMenuItem _obtain_detailed_taxonomic_information_deleting_jmi;
+ JMenuItem _obtain_uniprot_seq_information_jmi;
+ JMenuItem _move_node_names_to_tax_sn_jmi;
+ JMenuItem _move_node_names_to_seq_names_jmi;
+ JMenuItem _extract_tax_code_from_node_names_jmi;
// font size menu:
- JMenuItem _super_tiny_fonts_item;
- JMenuItem _tiny_fonts_item;
- JMenuItem _small_fonts_item;
- JMenuItem _medium_fonts_item;
- JMenuItem _large_fonts_item;
+ JMenuItem _super_tiny_fonts_item;
+ JMenuItem _tiny_fonts_item;
+ JMenuItem _small_fonts_item;
+ JMenuItem _medium_fonts_item;
+ JMenuItem _large_fonts_item;
// options menu:
// _ screen and print
- JMenuItem _choose_font_mi;
- JMenuItem _switch_colors_mi;
- JCheckBoxMenuItem _label_direction_cbmi;
+ JMenuItem _choose_font_mi;
+ JMenuItem _switch_colors_mi;
+ JCheckBoxMenuItem _label_direction_cbmi;
// _ screen display
- 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 _show_branch_length_values_cbmi;
- JCheckBoxMenuItem _show_scale_cbmi; //TODO fix me
- JCheckBoxMenuItem _show_overview_cbmi;
- JCheckBoxMenuItem _show_domain_labels;
- JCheckBoxMenuItem _abbreviate_scientific_names;
- JCheckBoxMenuItem _color_labels_same_as_parent_branch;
- JMenuItem _overview_placment_mi;
- JMenuItem _choose_minimal_confidence_mi;
- JCheckBoxMenuItem _show_default_node_shapes_cbmi;
- JMenuItem _cycle_node_shape_mi;
- JMenuItem _cycle_node_fill_mi;
- JMenuItem _choose_node_size_mi;
- JCheckBoxMenuItem _taxonomy_colorize_node_shapes_cbmi;
- JCheckBoxMenuItem _show_confidence_stddev_cbmi;
+ 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 _show_branch_length_values_cbmi;
+ JCheckBoxMenuItem _show_scale_cbmi; //TODO fix me
+ JCheckBoxMenuItem _show_overview_cbmi;
+ JCheckBoxMenuItem _show_domain_labels;
+ JCheckBoxMenuItem _abbreviate_scientific_names;
+ JCheckBoxMenuItem _color_labels_same_as_parent_branch;
+ JMenuItem _overview_placment_mi;
+ JMenuItem _choose_minimal_confidence_mi;
+ JCheckBoxMenuItem _show_default_node_shapes_cbmi;
+ JMenuItem _cycle_node_shape_mi;
+ JMenuItem _cycle_node_fill_mi;
+ JMenuItem _choose_node_size_mi;
+ JCheckBoxMenuItem _taxonomy_colorize_node_shapes_cbmi;
+ JCheckBoxMenuItem _show_confidence_stddev_cbmi;
// _ print
- JCheckBoxMenuItem _graphics_export_visible_only_cbmi;
- JCheckBoxMenuItem _antialias_print_cbmi;
- JCheckBoxMenuItem _print_black_and_white_cbmi;
- JCheckBoxMenuItem _print_using_actual_size_cbmi;
- JCheckBoxMenuItem _graphics_export_using_actual_size_cbmi;
- JMenuItem _print_size_mi;
- JMenuItem _choose_pdf_width_mi;
+ JCheckBoxMenuItem _graphics_export_visible_only_cbmi;
+ JCheckBoxMenuItem _antialias_print_cbmi;
+ JCheckBoxMenuItem _print_black_and_white_cbmi;
+ JCheckBoxMenuItem _print_using_actual_size_cbmi;
+ JCheckBoxMenuItem _graphics_export_using_actual_size_cbmi;
+ JMenuItem _print_size_mi;
+ JMenuItem _choose_pdf_width_mi;
// _ parsing
- JCheckBoxMenuItem _internal_number_are_confidence_for_nh_parsing_cbmi;
- JCheckBoxMenuItem _extract_pfam_style_tax_codes_cbmi;
- JCheckBoxMenuItem _replace_underscores_cbmi;
- JCheckBoxMenuItem _use_brackets_for_conf_in_nh_export_cbmi;
- JCheckBoxMenuItem _use_internal_names_for_conf_in_nh_export_cbmi;
+ JCheckBoxMenuItem _internal_number_are_confidence_for_nh_parsing_cbmi;
+ JCheckBoxMenuItem _extract_pfam_style_tax_codes_cbmi;
+ JCheckBoxMenuItem _replace_underscores_cbmi;
+ JCheckBoxMenuItem _use_brackets_for_conf_in_nh_export_cbmi;
+ JCheckBoxMenuItem _use_internal_names_for_conf_in_nh_export_cbmi;
// _ search
- JCheckBoxMenuItem _search_case_senstive_cbmi;
- JCheckBoxMenuItem _search_whole_words_only_cbmi;
- JCheckBoxMenuItem _inverse_search_result_cbmi;
+ JCheckBoxMenuItem _search_case_senstive_cbmi;
+ JCheckBoxMenuItem _search_whole_words_only_cbmi;
+ JCheckBoxMenuItem _inverse_search_result_cbmi;
// type menu:
- JMenu _type_menu;
- JCheckBoxMenuItem _rectangular_type_cbmi;
- JCheckBoxMenuItem _triangular_type_cbmi;
- JCheckBoxMenuItem _curved_type_cbmi;
- JCheckBoxMenuItem _convex_type_cbmi;
- JCheckBoxMenuItem _euro_type_cbmi;
- JCheckBoxMenuItem _rounded_type_cbmi;
- JCheckBoxMenuItem _unrooted_type_cbmi;
- JCheckBoxMenuItem _circular_type_cbmi;
+ JMenu _type_menu;
+ JCheckBoxMenuItem _rectangular_type_cbmi;
+ JCheckBoxMenuItem _triangular_type_cbmi;
+ JCheckBoxMenuItem _curved_type_cbmi;
+ JCheckBoxMenuItem _convex_type_cbmi;
+ JCheckBoxMenuItem _euro_type_cbmi;
+ JCheckBoxMenuItem _rounded_type_cbmi;
+ JCheckBoxMenuItem _unrooted_type_cbmi;
+ JCheckBoxMenuItem _circular_type_cbmi;
// view as text menu:
- JMenuItem _view_as_NH_item;
- JMenuItem _view_as_NHX_item;
- JMenuItem _view_as_XML_item;
- JMenuItem _view_as_nexus_item;
- JMenuItem _display_basic_information_item;
+ JMenuItem _view_as_NH_item;
+ JMenuItem _view_as_NHX_item;
+ JMenuItem _view_as_XML_item;
+ JMenuItem _view_as_nexus_item;
+ JMenuItem _display_basic_information_item;
// help menu:
- JMenuItem _about_item;
- JMenuItem _help_item;
- JMenuItem _website_item;
- JMenuItem _phyloxml_website_item;
- JMenuItem _phyloxml_ref_item;
- JMenuItem _aptx_ref_item;
+ JMenuItem _about_item;
+ JMenuItem _help_item;
+ JMenuItem _website_item;
+ JMenuItem _phyloxml_website_item;
+ JMenuItem _phyloxml_ref_item;
+ JMenuItem _aptx_ref_item;
// process menu:
- JMenu _process_menu;
+ JMenu _process_menu;
// Handy pointers to child components:
- MainPanel _mainpanel;
- Container _contentpane;
- TextFrame _textframe;
- Configuration _configuration;
- JMenuItem _remove_branch_color_item;
- Options _options;
- InferenceManager _inference_manager;
- final ProcessPool _process_pool;
+ MainPanel _mainpanel;
+ Container _contentpane;
+ final LinkedList<TextFrame> _textframes = new LinkedList<TextFrame>(); ;
+ Configuration _configuration;
+ JMenuItem _remove_branch_color_item;
+ Options _options;
+ InferenceManager _inference_manager;
+ final ProcessPool _process_pool;
MainFrame() {
_process_pool = ProcessPool.createInstance();
}
void close() {
- removeTextFrame();
+ removeAllTextFrames();
if ( _mainpanel != null ) {
_mainpanel.terminate();
}
}
}
- void removeTextFrame() {
- if ( _textframe != null ) {
- _textframe.close();
- _textframe = null;
+ void checkTextFrames() {
+ if ( _textframes.size() > 5 ) {
+ try {
+ if ( _textframes.getFirst() != null ) {
+ _textframes.getFirst().removeMe();
+ }
+ else {
+ _textframes.removeFirst();
+ }
+ }
+ catch ( final NoSuchElementException e ) {
+ // Ignore.
+ }
}
}
+ void removeAllTextFrames() {
+ for( final TextFrame tf : _textframes ) {
+ if ( tf != null ) {
+ tf.close();
+ }
+ }
+ _textframes.clear();
+ }
+
void setConfiguration( final Configuration configuration ) {
_configuration = configuration;
}
void displayBasicInformation() {
if ( ( _mainpanel.getCurrentPhylogeny() != null ) && !_mainpanel.getCurrentPhylogeny().isEmpty() ) {
- showTextFrame( AptxUtil.createBasicInformation( _mainpanel.getCurrentPhylogeny() ) );
+ String title = "Basic Information";
+ if ( !ForesterUtil.isEmpty( _mainpanel.getCurrentPhylogeny().getName() ) ) {
+ title = _mainpanel.getCurrentPhylogeny().getName() + " " + title;
+ }
+ showTextFrame( AptxUtil.createBasicInformation( _mainpanel.getCurrentPhylogeny() ), title );
}
}
void viewAsNexus() {
if ( ( _mainpanel.getCurrentPhylogeny() != null ) && !_mainpanel.getCurrentPhylogeny().isEmpty() ) {
- showTextFrame( _mainpanel.getCurrentPhylogeny().toNexus( getOptions().getNhConversionSupportValueStyle() ) );
+ String title = "Nexus";
+ if ( !ForesterUtil.isEmpty( _mainpanel.getCurrentPhylogeny().getName() ) ) {
+ title = _mainpanel.getCurrentPhylogeny().getName() + " " + title;
+ }
+ showTextFrame( _mainpanel.getCurrentPhylogeny().toNexus( getOptions().getNhConversionSupportValueStyle() ),
+ title );
}
}
void viewAsNH() {
if ( ( _mainpanel.getCurrentPhylogeny() != null ) && !_mainpanel.getCurrentPhylogeny().isEmpty() ) {
+ String title = "New Hampshire";
+ if ( !ForesterUtil.isEmpty( _mainpanel.getCurrentPhylogeny().getName() ) ) {
+ title = _mainpanel.getCurrentPhylogeny().getName() + " " + title;
+ }
showTextFrame( _mainpanel.getCurrentPhylogeny()
- .toNewHampshire( false, getOptions().getNhConversionSupportValueStyle() ) );
+ .toNewHampshire( false, getOptions().getNhConversionSupportValueStyle() ),
+ title );
}
}
void viewAsNHX() {
if ( ( _mainpanel.getCurrentPhylogeny() != null ) && !_mainpanel.getCurrentPhylogeny().isEmpty() ) {
- showTextFrame( _mainpanel.getCurrentPhylogeny().toNewHampshireX() );
+ String title = "NHX";
+ if ( !ForesterUtil.isEmpty( _mainpanel.getCurrentPhylogeny().getName() ) ) {
+ title = _mainpanel.getCurrentPhylogeny().getName() + " " + title;
+ }
+ showTextFrame( _mainpanel.getCurrentPhylogeny().toNewHampshireX(), title );
}
}
void viewAsXML() {
if ( ( _mainpanel.getCurrentPhylogeny() != null ) && !_mainpanel.getCurrentPhylogeny().isEmpty() ) {
- showTextFrame( _mainpanel.getCurrentPhylogeny().toPhyloXML( 0 ) );
+ String title = "phyloXML";
+ if ( !ForesterUtil.isEmpty( _mainpanel.getCurrentPhylogeny().getName() ) ) {
+ title = _mainpanel.getCurrentPhylogeny().getName() + " " + title;
+ }
+ showTextFrame( _mainpanel.getCurrentPhylogeny().toPhyloXML( 0 ), title );
}
}
- public void showTextFrame( final String s ) {
- removeTextFrame();
- _textframe = TextFrame.instantiate( s );
+ public void showTextFrame( final String s, final String title ) {
+ checkTextFrames();
+ _textframes.addLast( TextFrame.instantiate( s, title, _textframes ) );
}
/**
}
}
- static void help( final Map<String, WebLink> weblinks ) {
+ void help( final Map<String, WebLink> weblinks ) {
final StringBuilder sb = new StringBuilder();
sb.append( "Display options\n" );
sb.append( "-------------------\n" );
sb.append( "\n" );
sb.append( "For more information: http://www.phylosoft.org/archaeopteryx/\n" );
sb.append( "Email: " + Constants.AUTHOR_EMAIL + "\n\n" );
- TextFrame.instantiate( sb.toString() );
+ TextFrame.instantiate( sb.toString(), "Help", _textframes );
}
static void setOvPlacementColorChooseMenuItem( final JMenuItem mi, final Options options ) {
errorMessageNoCutCopyPasteInUnrootedDisplay();
return;
}
- final String label = getASimpleTextRepresentationOfANode( node );
+ final String label = createASimpleTextRepresentationOfANode( node );
String msg = "";
if ( ForesterUtil.isEmpty( label ) ) {
msg = "How to add the new, empty node?";
JOptionPane.ERROR_MESSAGE );
return;
}
- final String label = getASimpleTextRepresentationOfANode( node );
+ final String label = createASimpleTextRepresentationOfANode( node );
final int r = JOptionPane.showConfirmDialog( null,
"Cut subtree" + label + "?",
"Confirm Cutting of Subtree",
JOptionPane.ERROR_MESSAGE );
return;
}
- final String label = getASimpleTextRepresentationOfANode( node );
+ final String label = createASimpleTextRepresentationOfANode( node );
final Object[] options = { "Node only", "Entire subtree", "Cancel" };
final int r = JOptionPane.showOptionDialog( this,
"Delete" + label + "?",
return null;
}
- final private String getASimpleTextRepresentationOfANode( final PhylogenyNode node ) {
+ final private String createASimpleTextRepresentationOfANode( final PhylogenyNode node ) {
final String tax = PhylogenyMethods.getSpecies( node );
String label = node.getName();
if ( !ForesterUtil.isEmpty( label ) && !ForesterUtil.isEmpty( tax ) ) {
throw new IllegalArgumentException( "unknown data element: "
+ getOptions().getExtDescNodeDataToReturn() );
}
- if ( getConfiguration().getExtNodeDataReturnOn() == EXT_NODE_DATA_RETURN_ON.CONSOLE ) {
- for( final String d : data ) {
- System.out.println( d );
- }
+ } // for loop
+ if ( getConfiguration().getExtNodeDataReturnOn() == EXT_NODE_DATA_RETURN_ON.CONSOLE ) {
+ for( final String d : data ) {
+ System.out.println( d );
}
- else if ( getConfiguration().getExtNodeDataReturnOn() == EXT_NODE_DATA_RETURN_ON.WINODW ) {
- final StringBuilder sb = new StringBuilder();
- for( final String d : data ) {
- sb.append( d );
- sb.append( "\n" );
- }
- if ( getMainPanel().getMainFrame() == null ) {
- // Must be "E" applet version.
- ( ( ArchaeopteryxE ) ( ( MainPanelApplets ) getMainPanel() ).getApplet() ).showTextFrame( sb
- .toString() );
- }
- else {
- getMainPanel().getMainFrame().showTextFrame( sb.toString() );
- }
+ }
+ else if ( getConfiguration().getExtNodeDataReturnOn() == EXT_NODE_DATA_RETURN_ON.WINODW ) {
+ final StringBuilder sb = new StringBuilder();
+ for( final String d : data ) {
+ sb.append( d );
+ sb.append( "\n" );
+ }
+ if ( getMainPanel().getMainFrame() == null ) {
+ // Must be "E" applet version.
+ ( ( ArchaeopteryxE ) ( ( MainPanelApplets ) getMainPanel() ).getApplet() )
+ .showTextFrame( sb.toString(), node + " " + obtainTitleForExtDescNodeData() );
}
+ else {
+ getMainPanel().getMainFrame().showTextFrame( sb.toString(),
+ node + " " + obtainTitleForExtDescNodeData() );
+ }
+ }
+ }
+
+ private final String obtainTitleForExtDescNodeData() {
+ switch ( getOptions().getExtDescNodeDataToReturn() ) {
+ case NODE_NAME:
+ return "Node Names";
+ case SEQUENCE_NAME:
+ return "Sequence Names";
+ case SEQUENCE_SYMBOL:
+ return "Sequence Symbols";
+ case SEQUENCE_MOL_SEQ:
+ return "Molecular Sequences";
+ case SEQUENCE_ACC:
+ return "Sequence Accessors";
+ case TAXONOMY_SCIENTIFIC_NAME:
+ return "Scientific Names";
+ case TAXONOMY_CODE:
+ return "Taxonomy Codes";
+ default:
+ throw new IllegalArgumentException( "unknown data element: "
+ + getOptions().getExtDescNodeDataToReturn() );
}
}
JOptionPane.ERROR_MESSAGE );
return;
}
- final String label = getASimpleTextRepresentationOfANode( getCutOrCopiedTree().getRoot() );
+ final String label = createASimpleTextRepresentationOfANode( getCutOrCopiedTree().getRoot() );
final Object[] options = { "As sibling", "As descendant", "Cancel" };
final int r = JOptionPane.showOptionDialog( this,
"How to paste subtree" + label + "?",