X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=forester%2Fjava%2Fsrc%2Forg%2Fforester%2Farchaeopteryx%2FArchaeopteryxA.java;h=6b4cdd749046037e037030926071dcaf8a575b25;hb=a9e626aa67ff9cb1649c371f9d705eb04498cc33;hp=d6f9f069762b463d247e81c8300cf5e365013f01;hpb=ceb6173a0256d06fffbe04756755bb18052622fc;p=jalview.git diff --git a/forester/java/src/org/forester/archaeopteryx/ArchaeopteryxA.java b/forester/java/src/org/forester/archaeopteryx/ArchaeopteryxA.java index d6f9f06..6b4cdd7 100644 --- a/forester/java/src/org/forester/archaeopteryx/ArchaeopteryxA.java +++ b/forester/java/src/org/forester/archaeopteryx/ArchaeopteryxA.java @@ -21,7 +21,7 @@ // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA // // Contact: phylosoft @ gmail . com -// WWW: www.phylosoft.org/forester +// WWW: https://sites.google.com/site/cmzmasek/home/software/forester package org.forester.archaeopteryx; @@ -40,17 +40,18 @@ import org.forester.util.ForesterUtil; public class ArchaeopteryxA extends JApplet { - private static final long serialVersionUID = 2314899014580484146L; - private final static Color background_color = new Color( 0, 0, 0 ); - private final static Color font_color = new Color( 0, 255, 0 ); - private final static Color ex_background_color = new Color( 0, 0, 0 ); - private final static Color ex_font_color = new Color( 255, 0, 0 ); - private final static Font font = new Font( Configuration.getDefaultFontFamilyName(), Font.BOLD, 9 ); + private static final long serialVersionUID = 2314899014580484146L; + private final static Color background_color = new Color( 0, 0, 0 ); + private final static Color font_color = new Color( 0, 255, 0 ); + private final static Color ex_background_color = new Color( 0, 0, 0 ); + private final static Color ex_font_color = new Color( 255, 0, 0 ); + private final static Font font = new Font( Configuration.getDefaultFontFamilyName(), Font.BOLD, 9 ); private MainFrameApplet _mainframe_applet; - private String _url_string = ""; - private String _message_1 = ""; - private String _message_2 = ""; - public final static String NAME = "ArchaeopteryxA"; + private String _tree_url_str = ""; + private String _species_tree_url_str = ""; + private String _message_1 = ""; + private String _message_2 = ""; + public final static String NAME = "ArchaeopteryxA"; @Override public void destroy() { @@ -65,14 +66,14 @@ public class ArchaeopteryxA extends JApplet { * has been selected by the user by clicking the "Return ..." * menu item. This method is expected to be called from Javascript or * something like it. - * + * * @return current external node data as String */ public String getCurrentExternalNodesDataBuffer() { return getMainFrameApplet().getCurrentTreePanel().getCurrentExternalNodesDataBufferAsString(); } - public int getCurrentExternalNodesDataBufferCounter() { + public int getCurrentExternalNodesDataBufferChangeCounter() { return getMainFrameApplet().getCurrentTreePanel().getCurrentExternalNodesDataBufferChangeCounter(); } @@ -80,16 +81,34 @@ public class ArchaeopteryxA extends JApplet { return getMainFrameApplet().getCurrentTreePanel().getCurrentExternalNodesDataBufferAsString().length(); } - public String getUrlString() { - return _url_string; + public String getSpeciesTreeUrlStr() { + return _species_tree_url_str; + } + + public String getTreeUrlStr() { + return _tree_url_str; } @Override public void init() { boolean has_exception = false; setName( NAME ); - setUrlString( getParameter( Constants.APPLET_PARAM_NAME_FOR_URL_OF_TREE_TO_LOAD ) ); - AptxUtil.printAppletMessage( NAME, "URL of phylogenies to load: \"" + getUrlString() + "\"" ); + setTreeUrlStr( getParameter( AptxConstants.APPLET_PARAM_NAME_FOR_URL_OF_TREE_TO_LOAD ) ); + setSpeciesTreeUrlStr( getParameter( AptxConstants.APPLET_PARAM_NAME_FOR_URL_OF_SPECIES_TREE_TO_LOAD ) ); + if ( !ForesterUtil.isEmpty( getTreeUrlStr() ) ) { + AptxUtil.printAppletMessage( NAME, "URL of tree(s) to load: " + getTreeUrlStr() ); + } + else { + ForesterUtil.printErrorMessage( NAME, "no URL for tree(s) to load!" ); + setBackground( ex_background_color ); + setForeground( ex_font_color ); + has_exception = true; + setMessage1( "no URL for tree(s) to load" ); + repaint(); + } + if ( !ForesterUtil.isEmpty( getSpeciesTreeUrlStr() ) ) { + AptxUtil.printAppletMessage( NAME, "URL of species tree to load: " + getSpeciesTreeUrlStr() ); + } setBackground( background_color ); setForeground( font_color ); setFont( font ); @@ -105,7 +124,7 @@ public class ArchaeopteryxA extends JApplet { setMessage2( "[Your Java version: " + s + "]" ); repaint(); } - final String config_filename = getParameter( Constants.APPLET_PARAM_NAME_FOR_CONFIG_FILE_URL ); + final String config_filename = getParameter( AptxConstants.APPLET_PARAM_NAME_FOR_CONFIG_FILE_URL ); AptxUtil.printAppletMessage( NAME, "URL for configuration file is: " + config_filename ); final Configuration configuration = new Configuration( config_filename, true, true, true ); try { @@ -116,15 +135,26 @@ public class ArchaeopteryxA extends JApplet { UIManager.setLookAndFeel( UIManager.getCrossPlatformLookAndFeelClassName() ); } setVisible( false ); - _mainframe_applet = new MainFrameApplet( this, configuration ); - URL url = null; - url = new URL( getUrlString() ); - final Phylogeny[] phys = AptxUtil.readPhylogeniesFromUrl( url, configuration + _mainframe_applet = new MainFrameApplet( this, configuration, getSpeciesTreeUrlStr() ); + final URL tree_url = new URL( getTreeUrlStr() ); + final Phylogeny[] phys = AptxUtil.readPhylogeniesFromUrl( tree_url, configuration .isValidatePhyloXmlAgainstSchema(), configuration.isReplaceUnderscoresInNhParsing(), configuration - .isInternalNumberAreConfidenceForNhParsing(), configuration.getTaxonomyExtraction() ); + .isInternalNumberAreConfidenceForNhParsing(), configuration.getTaxonomyExtraction(), configuration + .isMidpointReroot() ); + if ( phys == null ) { + ForesterUtil.printErrorMessage( NAME, "phylogenies from [" + tree_url + "] are null" ); + } + else if ( phys.length < 1 ) { + ForesterUtil.printErrorMessage( NAME, "phylogenies from [" + tree_url + "] are empty" ); + } + else { + AptxUtil.printAppletMessage( NAME, "loaded " + phys.length + " phylogenies from: " + tree_url ); + } + AptxUtil.printAppletMessage( ArchaeopteryxA.NAME, "loaded " + phys.length + " phylogenies from: " + + tree_url ); AptxUtil.addPhylogeniesToTabs( phys, - new File( url.getFile() ).getName(), - getUrlString(), + new File( tree_url.getFile() ).getName(), + getTreeUrlStr(), getMainFrameApplet().getConfiguration(), getMainFrameApplet().getMainPanel() ); getMainFrameApplet().getMainPanel().getControlPanel().showWholeAll(); @@ -150,22 +180,22 @@ public class ArchaeopteryxA extends JApplet { getMainFrameApplet().requestFocusInWindow(); getMainFrameApplet().requestFocus(); /* GUILHEM_BEG */ - final String default_relation = getParameter( Constants.APPLET_PARAM_NAME_FOR_DEFAULT_SEQUENCE_RELATION_TYPE ); + final String default_relation = getParameter( AptxConstants.APPLET_PARAM_NAME_FOR_DEFAULT_SEQUENCE_RELATION_TYPE ); if ( default_relation != null ) { getMainFrameApplet().getMainPanel().getControlPanel().getSequenceRelationTypeBox() .setSelectedItem( default_relation ); } - final String default_sequence = getParameter( Constants.APPLET_PARAM_NAME_FOR_DEFAULT_QUERY_SEQUENCE ); + final String default_sequence = getParameter( AptxConstants.APPLET_PARAM_NAME_FOR_DEFAULT_QUERY_SEQUENCE ); if ( default_sequence != null ) { getMainFrameApplet().getMainPanel().getControlPanel().getSequenceRelationBox() .setSelectedItem( default_sequence ); - /* GUILHEM_END */ } + /* GUILHEM_END */ } /** * Prints message when initialization is finished. Called automatically. - * + * * @param g * Graphics */ @@ -207,7 +237,11 @@ public class ArchaeopteryxA extends JApplet { _message_2 = message_2; } - private void setUrlString( final String url_string ) { - _url_string = url_string; + private void setSpeciesTreeUrlStr( final String url_string ) { + _species_tree_url_str = url_string; + } + + private void setTreeUrlStr( final String url_string ) { + _tree_url_str = url_string; } }