X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=forester%2Fjava%2Fsrc%2Forg%2Fforester%2Farchaeopteryx%2FArchaeopteryxA.java;h=1ec5d96d3728d358a08e166c154f1345025b82d8;hb=226d82be9b70ce0c67b5b1055654d484073ea184;hp=bea6a7b44efc0e7f8db5cc1a25d2c48dd78dbdc6;hpb=ccf4c584032d16ed0ed8d0678f01305887724f96;p=jalview.git diff --git a/forester/java/src/org/forester/archaeopteryx/ArchaeopteryxA.java b/forester/java/src/org/forester/archaeopteryx/ArchaeopteryxA.java index bea6a7b..1ec5d96 100644 --- a/forester/java/src/org/forester/archaeopteryx/ArchaeopteryxA.java +++ b/forester/java/src/org/forester/archaeopteryx/ArchaeopteryxA.java @@ -5,7 +5,7 @@ // Copyright (C) 2008-2009 Christian M. Zmasek // Copyright (C) 2008-2009 Burnham Institute for Medical Research // All rights reserved -// +// // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either @@ -15,13 +15,13 @@ // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. -// +// // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software // 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,48 +40,75 @@ 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() { - Util.printAppletMessage( NAME, "going to be destroyed" ); + AptxUtil.printAppletMessage( NAME, "going to be destroyed" ); if ( getMainFrameApplet() != null ) { getMainFrameApplet().close(); } } - private MainFrameApplet getMainFrameApplet() { - return _mainframe_applet; + /** + * This method returns the current external node data which + * 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(); } - private String getMessage1() { - return _message_1; + public int getCurrentExternalNodesDataBufferChangeCounter() { + return getMainFrameApplet().getCurrentTreePanel().getCurrentExternalNodesDataBufferChangeCounter(); } - private String getMessage2() { - return _message_2; + public int getCurrentExternalNodesDataBufferLength() { + return getMainFrameApplet().getCurrentTreePanel().getCurrentExternalNodesDataBufferAsString().length(); + } + + public String getSpeciesTreeUrlStr() { + return _species_tree_url_str; } - public String getUrlString() { - return _url_string; + 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 ) ); - Util.printAppletMessage( NAME, "URL of phylogenies to load: \"" + getUrlString() + "\"" ); + setTreeUrlStr( getParameter( Constants.APPLET_PARAM_NAME_FOR_URL_OF_TREE_TO_LOAD ) ); + setSpeciesTreeUrlStr( getParameter( Constants.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 ); @@ -98,8 +125,8 @@ public class ArchaeopteryxA extends JApplet { repaint(); } final String config_filename = getParameter( Constants.APPLET_PARAM_NAME_FOR_CONFIG_FILE_URL ); - Util.printAppletMessage( NAME, "URL for configuration file is: " + config_filename ); - final Configuration configuration = new Configuration( config_filename, true, true ); + AptxUtil.printAppletMessage( NAME, "URL for configuration file is: " + config_filename ); + final Configuration configuration = new Configuration( config_filename, true, true, true ); try { if ( configuration.isUseNativeUI() ) { UIManager.setLookAndFeel( UIManager.getSystemLookAndFeelClassName() ); @@ -108,12 +135,28 @@ 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 = Util.readPhylogeniesFromUrl( url, configuration.isValidatePhyloXmlAgainstSchema() ); - Util.addPhylogeniesToTabs( phys, new File( url.getFile() ).getName(), getUrlString(), getMainFrameApplet() - .getConfiguration(), getMainFrameApplet().getMainPanel() ); + _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(), 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( tree_url.getFile() ).getName(), + getTreeUrlStr(), + getMainFrameApplet().getConfiguration(), + getMainFrameApplet().getMainPanel() ); getMainFrameApplet().getMainPanel().getControlPanel().showWholeAll(); getMainFrameApplet().getMainPanel().getControlPanel().showWhole(); setVisible( true ); @@ -130,7 +173,7 @@ public class ArchaeopteryxA extends JApplet { if ( !has_exception ) { setMessage1( NAME + " is now ready!" ); repaint(); - Util.printAppletMessage( NAME, "successfully initialized" ); + AptxUtil.printAppletMessage( NAME, "successfully initialized" ); } KeyboardFocusManager.getCurrentKeyboardFocusManager().clearGlobalFocusOwner(); getMainFrameApplet().requestFocus(); @@ -146,8 +189,8 @@ public class ArchaeopteryxA extends JApplet { if ( default_sequence != null ) { getMainFrameApplet().getMainPanel().getControlPanel().getSequenceRelationBox() .setSelectedItem( default_sequence ); - /* GUILHEM_END */ } + /* GUILHEM_END */ } /** @@ -165,6 +208,27 @@ public class ArchaeopteryxA extends JApplet { g.drawString( getMessage1(), 10, 40 ); } + @Override + public void start() { + getMainFrameApplet().getMainPanel().validate(); + getMainFrameApplet().requestFocus(); + getMainFrameApplet().requestFocusInWindow(); + getMainFrameApplet().requestFocus(); + AptxUtil.printAppletMessage( NAME, "started" ); + } + + private MainFrameApplet getMainFrameApplet() { + return _mainframe_applet; + } + + private String getMessage1() { + return _message_1; + } + + private String getMessage2() { + return _message_2; + } + private void setMessage1( final String message_1 ) { _message_1 = message_1; } @@ -173,16 +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; } - @Override - public void start() { - getMainFrameApplet().getMainPanel().validate(); - getMainFrameApplet().requestFocus(); - getMainFrameApplet().requestFocusInWindow(); - getMainFrameApplet().requestFocus(); - Util.printAppletMessage( NAME, "started" ); + private void setTreeUrlStr( final String url_string ) { + _tree_url_str = url_string; } }