X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=forester%2Fjava%2Fsrc%2Forg%2Fforester%2Farchaeopteryx%2FArchaeopteryxE.java;h=89e043ff0d19d3d0dffa6c952024ad4e9e16e7bc;hb=aec065f948a075773794133f102ea19eb1d59f64;hp=29a378b2aed21e6cfbdc1512f8e57e800327a74c;hpb=f4f236fff9a5f19dc9cf5dfb960f4a6d13ddb2fb;p=jalview.git diff --git a/forester/java/src/org/forester/archaeopteryx/ArchaeopteryxE.java b/forester/java/src/org/forester/archaeopteryx/ArchaeopteryxE.java index 29a378b..89e043f 100644 --- a/forester/java/src/org/forester/archaeopteryx/ArchaeopteryxE.java +++ b/forester/java/src/org/forester/archaeopteryx/ArchaeopteryxE.java @@ -13,7 +13,6 @@ 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; @@ -53,8 +52,8 @@ import org.forester.util.ForesterUtil; // public class ArchaeopteryxE extends JApplet implements ActionListener { - private final static String NAME = "ArchaeopteryxE"; - private static final long serialVersionUID = -1220055577935759443L; + private final static String NAME = "ArchaeopteryxE"; + private static final long serialVersionUID = -1220055577935759443L; private Configuration _configuration; private MainPanelApplets _main_panel; private JMenuBar _jmenubar; @@ -72,7 +71,6 @@ public class ArchaeopteryxE extends JApplet implements ActionListener { private JMenu _view_jmenu; private JMenuItem _view_as_XML_item; private JMenuItem _view_as_NH_item; - private JMenuItem _view_as_NHX_item; private JMenuItem _view_as_nexus_item; private JMenuItem _display_basic_information_item; private JMenu _type_menu; @@ -92,7 +90,6 @@ public class ArchaeopteryxE extends JApplet implements ActionListener { private JMenuItem _phyloxml_ref_item; private JMenuItem _aptx_ref_item; private JMenuItem _remove_branch_color_item; - private JMenuItem _infer_common_sn_names_item; private JCheckBoxMenuItem _show_domain_labels; private JCheckBoxMenuItem _color_labels_same_as_parent_branch; private JCheckBoxMenuItem _abbreviate_scientific_names; @@ -115,15 +112,17 @@ public class ArchaeopteryxE extends JApplet implements ActionListener { private JMenuItem _collapse_species_specific_subtrees; private JMenuItem _overview_placment_mi; private ButtonGroup _radio_group_1; - private JCheckBoxMenuItem _show_default_node_shapes_cbmi; + private JCheckBoxMenuItem _show_default_node_shapes_internal_cbmi; + private JCheckBoxMenuItem _show_default_node_shapes_external_cbmi; private JMenuItem _cycle_node_shape_mi; private JMenuItem _cycle_node_fill_mi; private JMenuItem _choose_node_size_mi; private JCheckBoxMenuItem _taxonomy_colorize_node_shapes_cbmi; private JCheckBoxMenuItem _show_confidence_stddev_cbmi; - private final LinkedList _textframes = new LinkedList(); - private String _ext_node_data_buffer = ""; + private final LinkedList _textframes = new LinkedList(); + // private String _ext_node_data_buffer = ""; + // private int _ext_node_data_buffer_change_counter = 0; @Override public void actionPerformed( final ActionEvent e ) { final Object o = e.getSource(); @@ -153,9 +152,6 @@ public class ArchaeopteryxE extends JApplet implements ActionListener { else if ( o == _view_as_NH_item ) { viewAsNH(); } - else if ( o == _view_as_NHX_item ) { - viewAsNHX(); - } else if ( o == _view_as_XML_item ) { viewAsXML(); } @@ -270,7 +266,10 @@ public class ArchaeopteryxE extends JApplet implements ActionListener { else if ( o == _color_labels_same_as_parent_branch ) { updateOptions( getOptions() ); } - else if ( o == _show_default_node_shapes_cbmi ) { + else if ( o == _show_default_node_shapes_internal_cbmi ) { + updateOptions( getOptions() ); + } + else if ( o == _show_default_node_shapes_external_cbmi ) { updateOptions( getOptions() ); } else if ( o == _taxonomy_colorize_node_shapes_cbmi ) { @@ -280,7 +279,7 @@ public class ArchaeopteryxE extends JApplet implements ActionListener { MainFrame.about(); } else if ( o == _help_item ) { - help( getConfiguration().getWebLinks() ); + help(); } else if ( o == _website_item ) { try { @@ -335,7 +334,15 @@ public class ArchaeopteryxE extends JApplet implements ActionListener { * @return current external node data as String */ public String getCurrentExternalNodesDataBuffer() { - return _ext_node_data_buffer; + return getCurrentTreePanel().getCurrentExternalNodesDataBufferAsString(); + } + + public int getCurrentExternalNodesDataBufferChangeCounter() { + return getCurrentTreePanel().getCurrentExternalNodesDataBufferChangeCounter(); + } + + public int getCurrentExternalNodesDataBufferLength() { + return getCurrentTreePanel().getCurrentExternalNodesDataBufferAsString().length(); } /** @@ -414,17 +421,17 @@ public class ArchaeopteryxE extends JApplet implements ActionListener { setupUI(); URL phys_url = null; Phylogeny[] phys = null; - final String phys_url_string = getParameter( Constants.APPLET_PARAM_NAME_FOR_URL_OF_TREE_TO_LOAD ); - AptxUtil.printAppletMessage( NAME, "URL for phylogenies is " + phys_url_string ); + final String tree_url_str = getParameter( Constants.APPLET_PARAM_NAME_FOR_URL_OF_TREE_TO_LOAD ); + AptxUtil.printAppletMessage( NAME, "URL for phylogenies is " + tree_url_str ); // Get URL to tree file - if ( phys_url_string != null ) { + if ( tree_url_str != null ) { try { - phys_url = new URL( phys_url_string ); + phys_url = new URL( tree_url_str ); } catch ( final Exception e ) { ForesterUtil.printErrorMessage( NAME, "error: " + e ); e.printStackTrace(); - JOptionPane.showMessageDialog( this, NAME + ": Could not create URL from: \"" + phys_url_string + JOptionPane.showMessageDialog( this, NAME + ": Could not create URL from: \"" + tree_url_str + "\"\nException: " + e, "Failed to create URL", JOptionPane.ERROR_MESSAGE ); } } @@ -480,11 +487,14 @@ public class ArchaeopteryxE extends JApplet implements ActionListener { @Override public void componentResized( final ComponentEvent e ) { if ( getMainPanel().getCurrentTreePanel() != null ) { - getMainPanel().getCurrentTreePanel().setParametersForPainting( getMainPanel().getCurrentTreePanel() - .getWidth(), - getMainPanel().getCurrentTreePanel() - .getHeight(), - false ); + getMainPanel().getCurrentTreePanel().calcParametersForPainting( getMainPanel() + .getCurrentTreePanel() + .getWidth(), + getMainPanel() + .getCurrentTreePanel() + .getHeight(), + getOptions() + .isAllowFontSizeChange() ); } } } ); @@ -616,7 +626,9 @@ public class ArchaeopteryxE extends JApplet implements ActionListener { .add( _show_branch_length_values_cbmi = new JCheckBoxMenuItem( MainFrame.DISPLAY_BRANCH_LENGTH_VALUES_LABEL ) ); _options_jmenu.add( _show_confidence_stddev_cbmi = new JCheckBoxMenuItem( MainFrame.SHOW_CONF_STDDEV_LABEL ) ); _options_jmenu - .add( _show_default_node_shapes_cbmi = new JCheckBoxMenuItem( MainFrame.DISPLAY_NODE_BOXES_LABEL ) ); + .add( _show_default_node_shapes_internal_cbmi = new JCheckBoxMenuItem( MainFrame.DISPLAY_NODE_BOXES_LABEL_INT ) ); + _options_jmenu + .add( _show_default_node_shapes_external_cbmi = new JCheckBoxMenuItem( MainFrame.DISPLAY_NODE_BOXES_LABEL_EXT ) ); _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 ) ); @@ -655,7 +667,10 @@ public class ArchaeopteryxE extends JApplet implements ActionListener { customizeCheckBoxMenuItem( _background_gradient_cbmi, getOptions().isBackgroundColorGradient() ); customizeCheckBoxMenuItem( _show_domain_labels, getOptions().isShowDomainLabels() ); customizeCheckBoxMenuItem( _abbreviate_scientific_names, getOptions().isAbbreviateScientificTaxonNames() ); - customizeCheckBoxMenuItem( _show_default_node_shapes_cbmi, getOptions().isShowDefaultNodeShapes() ); + customizeCheckBoxMenuItem( _show_default_node_shapes_external_cbmi, getOptions() + .isShowDefaultNodeShapesExternal() ); + customizeCheckBoxMenuItem( _show_default_node_shapes_internal_cbmi, getOptions() + .isShowDefaultNodeShapesInternal() ); customizeCheckBoxMenuItem( _taxonomy_colorize_node_shapes_cbmi, getOptions().isTaxonomyColorizeNodeShapes() ); customizeJMenuItem( _cycle_node_shape_mi ); customizeJMenuItem( _cycle_node_fill_mi ); @@ -690,9 +705,6 @@ public class ArchaeopteryxE extends JApplet implements ActionListener { _tools_menu.add( _midpoint_root_item = new JMenuItem( "Midpoint-Root" ) ); customizeJMenuItem( _midpoint_root_item ); _tools_menu.addSeparator(); - _tools_menu - .add( _infer_common_sn_names_item = new JMenuItem( "Infer Common Parts of Internal Scientific Names" ) ); - customizeJMenuItem( _infer_common_sn_names_item ); _tools_menu.add( _collapse_species_specific_subtrees = new JMenuItem( "Collapse Species-Specific Subtrees" ) ); customizeJMenuItem( _collapse_species_specific_subtrees ); _jmenubar.add( _tools_menu ); @@ -728,11 +740,9 @@ public class ArchaeopteryxE extends JApplet implements ActionListener { _view_jmenu.addSeparator(); _view_jmenu.add( _view_as_XML_item = new JMenuItem( "View as phyloXML" ) ); _view_jmenu.add( _view_as_NH_item = new JMenuItem( "View as Newick" ) ); - _view_jmenu.add( _view_as_NHX_item = new JMenuItem( "View as NHX" ) ); _view_jmenu.add( _view_as_nexus_item = new JMenuItem( "View as Nexus" ) ); customizeJMenuItem( _display_basic_information_item ); customizeJMenuItem( _view_as_NH_item ); - customizeJMenuItem( _view_as_NHX_item ); customizeJMenuItem( _view_as_XML_item ); customizeJMenuItem( _view_as_nexus_item ); _jmenubar.add( _view_jmenu ); @@ -754,6 +764,10 @@ public class ArchaeopteryxE extends JApplet implements ActionListener { } } + void clearCurrentExternalNodesDataBuffer() { + getCurrentTreePanel().clearCurrentExternalNodesDataBuffer(); + } + void customizeCheckBoxMenuItem( final JCheckBoxMenuItem item, final boolean is_selected ) { if ( item != null ) { item.setFont( MainFrame.menu_font ); @@ -801,7 +815,7 @@ public class ArchaeopteryxE extends JApplet implements ActionListener { return _options; } - void help( final Map weblinks ) { + void help() { final StringBuilder sb = new StringBuilder(); sb.append( "Display options\n" ); sb.append( "-------------------\n" ); @@ -839,15 +853,7 @@ public class ArchaeopteryxE extends JApplet implements ActionListener { 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( "java -Xmx1024m -cp path\\to\\forester.jar org.forester.archaeopteryx.Archaeopteryx\n\n" ); sb.append( "phyloXML\n" ); sb.append( "-------------------\n" ); sb.append( "Reference: " + Constants.PHYLOXML_REFERENCE + "\n" ); @@ -907,15 +913,6 @@ public class ArchaeopteryxE extends JApplet implements ActionListener { _configuration = configuration; } - void setCurrentExternalNodesDataBuffer( final String s ) { - if ( !ForesterUtil.isEmpty( s ) ) { - _ext_node_data_buffer = s.trim(); - } - else { - _ext_node_data_buffer = ""; - } - } - void setOptions( final Options options ) { _options = options; } @@ -1023,8 +1020,10 @@ public class ArchaeopteryxE extends JApplet implements ActionListener { && _abbreviate_scientific_names.isSelected() ); options.setColorLabelsSameAsParentBranch( ( _color_labels_same_as_parent_branch != null ) && _color_labels_same_as_parent_branch.isSelected() ); - options.setShowDefaultNodeShapes( ( _show_default_node_shapes_cbmi != null ) - && _show_default_node_shapes_cbmi.isSelected() ); + options.setShowDefaultNodeShapesInternal( ( _show_default_node_shapes_internal_cbmi != null ) + && _show_default_node_shapes_internal_cbmi.isSelected() ); + options.setShowDefaultNodeShapesExternal( ( _show_default_node_shapes_external_cbmi != null ) + && _show_default_node_shapes_external_cbmi.isSelected() ); options.setTaxonomyColorizeNodeShapes( ( _taxonomy_colorize_node_shapes_cbmi != null ) && _taxonomy_colorize_node_shapes_cbmi.isSelected() ); if ( ( _non_lined_up_cladograms_rbmi != null ) && ( _non_lined_up_cladograms_rbmi.isSelected() ) ) { @@ -1114,16 +1113,6 @@ public class ArchaeopteryxE extends JApplet implements ActionListener { } } - void viewAsNHX() { - if ( ( getMainPanel().getCurrentPhylogeny() != null ) && !getMainPanel().getCurrentPhylogeny().isEmpty() ) { - 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() ) { String title = "phyloXML";