From fea4064e24c6cb362b0e033cf7047afd20f5f53f Mon Sep 17 00:00:00 2001 From: cmzmasek Date: Wed, 22 Jun 2016 12:49:49 -0700 Subject: [PATCH] Fixed issue with reading from TreeBase --- .../{Constants.java => AptxConstants.java} | 12 +- .../src/org/forester/archaeopteryx/AptxUtil.java | 52 +++--- .../org/forester/archaeopteryx/Archaeopteryx.java | 4 +- .../org/forester/archaeopteryx/ArchaeopteryxA.java | 10 +- .../org/forester/archaeopteryx/ArchaeopteryxE.java | 44 ++--- .../org/forester/archaeopteryx/Configuration.java | 110 +++++------ .../org/forester/archaeopteryx/ControlPanel.java | 8 +- .../src/org/forester/archaeopteryx/MainFrame.java | 50 ++--- .../archaeopteryx/MainFrameApplication.java | 12 +- .../src/org/forester/archaeopteryx/MainPanel.java | 2 +- .../org/forester/archaeopteryx/NodeEditPanel.java | 6 +- .../src/org/forester/archaeopteryx/NodeFrame.java | 4 +- .../src/org/forester/archaeopteryx/NodePanel.java | 6 +- .../src/org/forester/archaeopteryx/Options.java | 18 +- .../org/forester/archaeopteryx/TreeColorSet.java | 4 +- .../src/org/forester/archaeopteryx/TreePanel.java | 48 ++--- .../org/forester/archaeopteryx/UrlTreeReader.java | 17 +- .../data/RenderableDomainArchitecture.java | 6 +- .../forester/archaeopteryx/tools/ImageLoader.java | 8 +- .../archaeopteryx/tools/RunnableProcess.java | 4 +- .../archaeopteryx/webservices/WebserviceUtil.java | 9 +- .../io/parsers/nexus/NexusPhylogeniesParser.java | 26 +-- forester/java/src/org/forester/test/Test.java | 194 ++++++++++++++------ .../src/org/forester/util/ForesterConstants.java | 2 +- .../java/src/org/forester/util/ForesterUtil.java | 49 ++++- .../java/src/org/forester/util/TrustManager.java | 4 +- 26 files changed, 413 insertions(+), 296 deletions(-) rename forester/java/src/org/forester/archaeopteryx/{Constants.java => AptxConstants.java} (96%) diff --git a/forester/java/src/org/forester/archaeopteryx/Constants.java b/forester/java/src/org/forester/archaeopteryx/AptxConstants.java similarity index 96% rename from forester/java/src/org/forester/archaeopteryx/Constants.java rename to forester/java/src/org/forester/archaeopteryx/AptxConstants.java index bf059cf..7d660f4 100644 --- a/forester/java/src/org/forester/archaeopteryx/Constants.java +++ b/forester/java/src/org/forester/archaeopteryx/AptxConstants.java @@ -34,7 +34,7 @@ import java.awt.Dimension; import org.forester.archaeopteryx.Options.CLADOGRAM_TYPE; import org.forester.util.ForesterConstants; -public final class Constants { +public final class AptxConstants { final static boolean __ALLOW_PHYLOGENETIC_INFERENCE = true; public final static boolean __RELEASE = false; // TODO remove me @@ -42,7 +42,7 @@ public final class Constants { public final static boolean __SYNTH_LF = false; // TODO remove me public final static String PRG_NAME = "Archaeopteryx"; final static String VERSION = "0.9909 experimental"; - final static String PRG_DATE = "150513"; + final static String PRG_DATE = "160622"; final static String DEFAULT_CONFIGURATION_FILE_NAME = "_aptx_configuration_file"; final static String[] DEFAULT_FONT_CHOICES = { "Arial", "Helvetica", "Verdana", "Tahoma", "Dialog", "Lucida Sans", "SansSerif", "Sans-serif", "Sans" }; @@ -51,13 +51,13 @@ public final class Constants { final static String AUTHOR_EMAIL = "phyloxml@gmail.com"; final static int DOMAIN_STRUCTURE_E_VALUE_THR_DEFAULT_EXP = -3; final static float BUTTON_ZOOM_IN_FACTOR = 1.25f; - final static float BUTTON_ZOOM_OUT_FACTOR = 1 / Constants.BUTTON_ZOOM_IN_FACTOR; + final static float BUTTON_ZOOM_OUT_FACTOR = 1 / AptxConstants.BUTTON_ZOOM_IN_FACTOR; final static float BUTTON_ZOOM_IN_X_CORRECTION_FACTOR = 1.2f; - final static float BUTTON_ZOOM_OUT_X_CORRECTION_FACTOR = 1 / Constants.BUTTON_ZOOM_IN_X_CORRECTION_FACTOR; + final static float BUTTON_ZOOM_OUT_X_CORRECTION_FACTOR = 1 / AptxConstants.BUTTON_ZOOM_IN_X_CORRECTION_FACTOR; final static float WHEEL_ZOOM_IN_FACTOR = 1.08f; - final static float WHEEL_ZOOM_OUT_FACTOR = 1 / Constants.WHEEL_ZOOM_IN_FACTOR; + final static float WHEEL_ZOOM_OUT_FACTOR = 1 / AptxConstants.WHEEL_ZOOM_IN_FACTOR; final static float WHEEL_ZOOM_IN_X_CORRECTION_FACTOR = 1.085f; - final static float WHEEL_ZOOM_OUT_X_CORRECTION_FACTOR = 1 / Constants.WHEEL_ZOOM_IN_X_CORRECTION_FACTOR; + final static float WHEEL_ZOOM_OUT_X_CORRECTION_FACTOR = 1 / AptxConstants.WHEEL_ZOOM_IN_X_CORRECTION_FACTOR; static final boolean SPECIAL_CUSTOM = false; //TODO remove me static final double EXT_NODE_INFO_LENGTH_MAX_RATIO = 0.95; static final Dimension NODE_PANEL_SPLIT_MINIMUM_SIZE = new Dimension( 100, 50 ); diff --git a/forester/java/src/org/forester/archaeopteryx/AptxUtil.java b/forester/java/src/org/forester/archaeopteryx/AptxUtil.java index 9f42b30..8f7963f 100644 --- a/forester/java/src/org/forester/archaeopteryx/AptxUtil.java +++ b/forester/java/src/org/forester/archaeopteryx/AptxUtil.java @@ -36,12 +36,12 @@ import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; -import java.io.InputStream; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.net.URI; import java.net.URL; -import java.net.URLConnection; +import java.security.KeyManagementException; +import java.security.NoSuchAlgorithmException; import java.text.ParseException; import java.util.Arrays; import java.util.HashSet; @@ -74,8 +74,6 @@ import org.forester.phylogeny.PhylogenyMethods.DESCENDANT_SORT_PRIORITY; import org.forester.phylogeny.PhylogenyNode; import org.forester.phylogeny.data.Confidence; import org.forester.phylogeny.data.Taxonomy; -import org.forester.phylogeny.factories.ParserBasedPhylogenyFactory; -import org.forester.phylogeny.factories.PhylogenyFactory; import org.forester.phylogeny.iterators.PhylogenyNodeIterator; import org.forester.util.AsciiHistogram; import org.forester.util.DescriptiveStatistics; @@ -291,7 +289,6 @@ public final class AptxUtil { final TAXONOMY_EXTRACTION taxonomy_extraction, final boolean midpoint_reroot ) throws FileNotFoundException, IOException { - final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance(); final PhylogenyParser parser; boolean nhx_or_nexus = false; if ( url.getHost().toLowerCase().indexOf( "tolweb" ) >= 0 ) { @@ -314,11 +311,16 @@ public final class AptxUtil { } } AptxUtil.printAppletMessage( "Archaeopteryx", "parser is " + parser.getName() ); - final URLConnection url_connection = url.openConnection(); - url_connection.setDefaultUseCaches( false ); - final InputStream i = url_connection.getInputStream(); - final Phylogeny[] phys = factory.create( i, parser ); - i.close(); + Phylogeny[] phys = null; + try { + phys = ForesterUtil.readPhylogeniesFromUrl( url, parser ); + } + catch ( final KeyManagementException e ) { + throw new IOException( e.getMessage() ); + } + catch ( final NoSuchAlgorithmException e ) { + throw new IOException( e.getMessage() ); + } if ( phys != null ) { if ( nhx_or_nexus && internal_numbers_are_confidences ) { for( final Phylogeny phy : phys ) { @@ -336,8 +338,8 @@ public final class AptxUtil { } final public static void showErrorMessage( final Component parent, final String error_msg ) { - printAppletMessage( Constants.PRG_NAME, error_msg ); - JOptionPane.showMessageDialog( parent, error_msg, "[" + Constants.PRG_NAME + " " + Constants.VERSION + printAppletMessage( AptxConstants.PRG_NAME, error_msg ); + JOptionPane.showMessageDialog( parent, error_msg, "[" + AptxConstants.PRG_NAME + " " + AptxConstants.VERSION + "] Error", JOptionPane.ERROR_MESSAGE ); } @@ -451,15 +453,15 @@ public final class AptxUtil { final String full_path, final Configuration configuration, final MainPanel main_panel ) { - if ( phys.length > Constants.MAX_TREES_TO_LOAD ) { + if ( phys.length > AptxConstants.MAX_TREES_TO_LOAD ) { JOptionPane.showMessageDialog( main_panel, "Attempt to load " + phys.length - + " phylogenies,\ngoing to load only the first " + Constants.MAX_TREES_TO_LOAD, Constants.PRG_NAME - + " more than " + Constants.MAX_TREES_TO_LOAD + " phylogenies", JOptionPane.WARNING_MESSAGE ); + + " phylogenies,\ngoing to load only the first " + AptxConstants.MAX_TREES_TO_LOAD, AptxConstants.PRG_NAME + + " more than " + AptxConstants.MAX_TREES_TO_LOAD + " phylogenies", JOptionPane.WARNING_MESSAGE ); } int i = 1; for( final Phylogeny phy : phys ) { if ( !phy.isEmpty() ) { - if ( i <= Constants.MAX_TREES_TO_LOAD ) { + if ( i <= AptxConstants.MAX_TREES_TO_LOAD ) { String my_name = ""; String my_name_for_file = ""; if ( phys.length > 1 ) { @@ -673,7 +675,7 @@ public final class AptxUtil { css = PhylogenyMethods.calculateConfidenceStatistics( phy ); } catch ( final IllegalArgumentException e ) { - ForesterUtil.printWarningMessage( Constants.PRG_NAME, e.getMessage() ); + ForesterUtil.printWarningMessage( AptxConstants.PRG_NAME, e.getMessage() ); } if ( ( css != null ) && ( css.size() > 0 ) ) { desc.append( "\n" ); @@ -720,9 +722,9 @@ public final class AptxUtil { */ final static void dieWithSystemError( final String message ) { System.out.println(); - System.out.println( Constants.PRG_NAME + " encountered the following system error: " + message ); + System.out.println( AptxConstants.PRG_NAME + " encountered the following system error: " + message ); System.out.println( "Please contact the authors." ); - System.out.println( Constants.PRG_NAME + " needs to close." ); + System.out.println( AptxConstants.PRG_NAME + " needs to close." ); System.out.println(); System.exit( -1 ); } @@ -809,7 +811,7 @@ public final class AptxUtil { final static void openWebsite( final String url, final boolean is_applet, final JApplet applet ) throws IOException { try { - AptxUtil.launchWebBrowser( new URI( url ), is_applet, applet, Constants.PRG_NAME ); + AptxUtil.launchWebBrowser( new URI( url ), is_applet, applet, AptxConstants.PRG_NAME ); } catch ( final Exception e ) { throw new IOException( e ); @@ -825,7 +827,7 @@ public final class AptxUtil { JOptionPane.showMessageDialog( null, "Java memory allocation might be too small, try \"-Xmx2048m\" java command line option" + "\n\nError: " + e.getLocalizedMessage(), - "Out of Memory Error [" + Constants.PRG_NAME + " " + Constants.VERSION + "]", + "Out of Memory Error [" + AptxConstants.PRG_NAME + " " + AptxConstants.VERSION + "]", JOptionPane.ERROR_MESSAGE ); System.exit( -1 ); } @@ -857,9 +859,9 @@ public final class AptxUtil { JOptionPane .showMessageDialog( null, "An unexpected (possibly severe) error has occured - terminating. \nPlease contact: " - + Constants.AUTHOR_EMAIL + " \nError: " + e.getLocalizedMessage() + "\n" + + AptxConstants.AUTHOR_EMAIL + " \nError: " + e.getLocalizedMessage() + "\n" + sb, - "Unexpected Severe Error [" + Constants.PRG_NAME + " " + Constants.VERSION + "]", + "Unexpected Severe Error [" + AptxConstants.PRG_NAME + " " + AptxConstants.VERSION + "]", JOptionPane.ERROR_MESSAGE ); System.exit( -1 ); } @@ -874,9 +876,9 @@ public final class AptxUtil { } JOptionPane.showMessageDialog( null, "An unexpected exception has occured. \nPlease contact: " - + Constants.AUTHOR_EMAIL + " \nException: " + e.getLocalizedMessage() + + AptxConstants.AUTHOR_EMAIL + " \nException: " + e.getLocalizedMessage() + "\n" + sb, - "Unexpected Exception [" + Constants.PRG_NAME + Constants.VERSION + "]", + "Unexpected Exception [" + AptxConstants.PRG_NAME + AptxConstants.VERSION + "]", JOptionPane.ERROR_MESSAGE ); } diff --git a/forester/java/src/org/forester/archaeopteryx/Archaeopteryx.java b/forester/java/src/org/forester/archaeopteryx/Archaeopteryx.java index e1a8a47..8cbf8ca 100644 --- a/forester/java/src/org/forester/archaeopteryx/Archaeopteryx.java +++ b/forester/java/src/org/forester/archaeopteryx/Archaeopteryx.java @@ -84,7 +84,7 @@ public final class Archaeopteryx { f = new File( args[ filename_index ] ); final String err = ForesterUtil.isReadableFile( f ); if ( !ForesterUtil.isEmpty( err ) ) { - ForesterUtil.fatalError( Constants.PRG_NAME, err ); + ForesterUtil.fatalError( AptxConstants.PRG_NAME, err ); } boolean nhx_or_nexus = false; final PhylogenyParser p = ParserUtils.createParserDependingOnFileType( f, conf @@ -115,7 +115,7 @@ public final class Archaeopteryx { } } catch ( final Exception e ) { - ForesterUtil.fatalError( Constants.PRG_NAME, "failed to start: " + e.getLocalizedMessage() ); + ForesterUtil.fatalError( AptxConstants.PRG_NAME, "failed to start: " + e.getLocalizedMessage() ); } String title = ""; if ( f != null ) { diff --git a/forester/java/src/org/forester/archaeopteryx/ArchaeopteryxA.java b/forester/java/src/org/forester/archaeopteryx/ArchaeopteryxA.java index c78bde4..6b4cdd7 100644 --- a/forester/java/src/org/forester/archaeopteryx/ArchaeopteryxA.java +++ b/forester/java/src/org/forester/archaeopteryx/ArchaeopteryxA.java @@ -93,8 +93,8 @@ public class ArchaeopteryxA extends JApplet { public void init() { boolean has_exception = false; setName( NAME ); - 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 ) ); + 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() ); } @@ -124,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 { @@ -180,12 +180,12 @@ 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 ); diff --git a/forester/java/src/org/forester/archaeopteryx/ArchaeopteryxE.java b/forester/java/src/org/forester/archaeopteryx/ArchaeopteryxE.java index 288cc14..6743505 100644 --- a/forester/java/src/org/forester/archaeopteryx/ArchaeopteryxE.java +++ b/forester/java/src/org/forester/archaeopteryx/ArchaeopteryxE.java @@ -345,42 +345,42 @@ public class ArchaeopteryxE extends JApplet implements ActionListener { } else if ( o == _help_item ) { try { - AptxUtil.openWebsite( Constants.APTX_DOC_SITE, true, this ); + AptxUtil.openWebsite( AptxConstants.APTX_DOC_SITE, true, this ); } catch ( final IOException e1 ) { - ForesterUtil.printErrorMessage( Constants.PRG_NAME, e1.toString() ); + ForesterUtil.printErrorMessage( AptxConstants.PRG_NAME, e1.toString() ); } } else if ( o == _website_item ) { try { - AptxUtil.openWebsite( Constants.APTX_WEB_SITE, true, this ); + AptxUtil.openWebsite( AptxConstants.APTX_WEB_SITE, true, this ); } catch ( final IOException e1 ) { - ForesterUtil.printErrorMessage( Constants.PRG_NAME, e1.toString() ); + ForesterUtil.printErrorMessage( AptxConstants.PRG_NAME, e1.toString() ); } } else if ( o == _phyloxml_website_item ) { try { - AptxUtil.openWebsite( Constants.PHYLOXML_WEB_SITE, true, this ); + AptxUtil.openWebsite( AptxConstants.PHYLOXML_WEB_SITE, true, this ); } catch ( final IOException e1 ) { - ForesterUtil.printErrorMessage( Constants.PRG_NAME, e1.toString() ); + ForesterUtil.printErrorMessage( AptxConstants.PRG_NAME, e1.toString() ); } } else if ( o == _aptx_ref_item ) { try { - AptxUtil.openWebsite( Constants.APTX_REFERENCE_URL, true, this ); + AptxUtil.openWebsite( AptxConstants.APTX_REFERENCE_URL, true, this ); } catch ( final IOException e1 ) { - ForesterUtil.printErrorMessage( Constants.PRG_NAME, e1.toString() ); + ForesterUtil.printErrorMessage( AptxConstants.PRG_NAME, e1.toString() ); } } else if ( o == _phyloxml_ref_item ) { try { - AptxUtil.openWebsite( Constants.PHYLOXML_REFERENCE_URL, true, this ); + AptxUtil.openWebsite( AptxConstants.PHYLOXML_REFERENCE_URL, true, this ); } catch ( final IOException e1 ) { - ForesterUtil.printErrorMessage( Constants.PRG_NAME, e1.toString() ); + ForesterUtil.printErrorMessage( AptxConstants.PRG_NAME, e1.toString() ); } } else if ( o == _color_by_taxonomic_group_cbmi ) { @@ -626,18 +626,18 @@ public class ArchaeopteryxE extends JApplet implements ActionListener { e.printStackTrace(); // Do nothing. Not important. } - 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 ); setConfiguration( configuration ); setOptions( Options.createInstance( configuration ) ); setupUI(); - final String tree_url_str = getParameter( Constants.APPLET_PARAM_NAME_FOR_URL_OF_TREE_TO_LOAD ); + final String tree_url_str = getParameter( AptxConstants.APPLET_PARAM_NAME_FOR_URL_OF_TREE_TO_LOAD ); if ( ForesterUtil.isEmpty( tree_url_str ) ) { ForesterUtil.printErrorMessage( NAME, "could not get tree URL from " - + Constants.APPLET_PARAM_NAME_FOR_URL_OF_TREE_TO_LOAD ); + + AptxConstants.APPLET_PARAM_NAME_FOR_URL_OF_TREE_TO_LOAD ); JOptionPane.showMessageDialog( this, NAME + ": could not get tree URL from " - + Constants.APPLET_PARAM_NAME_FOR_URL_OF_TREE_TO_LOAD, "Failed get URL", JOptionPane.ERROR_MESSAGE ); + + AptxConstants.APPLET_PARAM_NAME_FOR_URL_OF_TREE_TO_LOAD, "Failed get URL", JOptionPane.ERROR_MESSAGE ); return; } AptxUtil.printAppletMessage( NAME, "URL for phylogenies is " + tree_url_str ); @@ -654,7 +654,7 @@ public class ArchaeopteryxE extends JApplet implements ActionListener { } if ( phys_url == null ) { ForesterUtil.printErrorMessage( NAME, "failed to get tree URL from " - + Constants.APPLET_PARAM_NAME_FOR_URL_OF_TREE_TO_LOAD ); + + AptxConstants.APPLET_PARAM_NAME_FOR_URL_OF_TREE_TO_LOAD ); JOptionPane.showMessageDialog( this, NAME + ": Could not create URL from: \"" + tree_url_str, "Failed to create URL", @@ -699,7 +699,7 @@ public class ArchaeopteryxE extends JApplet implements ActionListener { AptxUtil.printAppletMessage( NAME, "loaded " + phys.length + " phylogenies from: " + phys_url ); } // - final String species_tree_url_str = getParameter( Constants.APPLET_PARAM_NAME_FOR_URL_OF_SPECIES_TREE_TO_LOAD ); + final String species_tree_url_str = getParameter( AptxConstants.APPLET_PARAM_NAME_FOR_URL_OF_SPECIES_TREE_TO_LOAD ); if ( !ForesterUtil.isEmpty( species_tree_url_str ) ) { AptxUtil.printAppletMessage( NAME, "URL of species tree to load: \"" + species_tree_url_str + "\"" ); Phylogeny[] species_trees = null; @@ -801,11 +801,11 @@ public class ArchaeopteryxE extends JApplet implements ActionListener { .getRelevantSequenceRelationTypes() ) { getCurrentTreePanel().getControlPanel().getSequenceRelationTypeBox().addItem( type ); } - 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 ) { getCurrentTreePanel().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 ) { getCurrentTreePanel().getControlPanel().getSequenceRelationBox().setSelectedItem( default_sequence ); } @@ -911,10 +911,10 @@ public class ArchaeopteryxE extends JApplet implements ActionListener { + "[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 + "]", + + "[A4: " + AptxConstants.A4_SIZE_X + ", " + + AptxConstants.A4_SIZE_Y + "]\n" + "[US Letter: " + + AptxConstants.US_LETTER_SIZE_X + ", " + + AptxConstants.US_LETTER_SIZE_Y + "]", "Default Size for Graphics Export", JOptionPane.QUESTION_MESSAGE, null, diff --git a/forester/java/src/org/forester/archaeopteryx/Configuration.java b/forester/java/src/org/forester/archaeopteryx/Configuration.java index 27e616a..3bb5d27 100644 --- a/forester/java/src/org/forester/archaeopteryx/Configuration.java +++ b/forester/java/src/org/forester/archaeopteryx/Configuration.java @@ -179,7 +179,7 @@ public final class Configuration { String config_filename; // This option is selected in the dropdown int default_clickto = Configuration.display_node_data; - String default_config_filename = Constants.DEFAULT_CONFIGURATION_FILE_NAME; + String default_config_filename = AptxConstants.DEFAULT_CONFIGURATION_FILE_NAME; // -------------- // Color set // -------------- @@ -188,18 +188,18 @@ public final class Configuration { // Fonts // ------- TreeFontSet tree_font_set; - boolean verbose = Constants.VERBOSE_DEFAULT; + boolean verbose = AptxConstants.VERBOSE_DEFAULT; private boolean _abbreviate_scientific_names = false; private boolean _antialias_screen = true; private boolean _background_color_gradient = false; private String _base_font_family_name = ""; private int _base_font_size = -1; - private CLADOGRAM_TYPE _cladogram_type = Constants.CLADOGRAM_TYPE_DEFAULT; + private CLADOGRAM_TYPE _cladogram_type = AptxConstants.CLADOGRAM_TYPE_DEFAULT; private boolean _color_labels_same_as_parent_branch = false; private int _default_bootstrap_samples = -1; private NodeFill _default_node_fill = NodeFill.SOLID; private NodeShape _default_node_shape = NodeShape.RECTANGLE; - private short _default_node_shape_size = Constants.DEFAULT_NODE_SHAPE_SIZE_DEFAULT; + private short _default_node_shape_size = AptxConstants.DEFAULT_NODE_SHAPE_SIZE_DEFAULT; private SortedMap _display_colors = null; private boolean _display_sequence_relations = false; private boolean _editable = true; @@ -209,14 +209,14 @@ public final class Configuration { private int _frame_y_size; private int _graphics_export_x = -1; private int _graphics_export_y = -1; - private Color _gui_background_color = Constants.GUI_BACKGROUND_DEFAULT; - private Color _gui_button_background_color = Constants.BUTTON_BACKGROUND_COLOR_DEFAULT; - private Color _gui_button_border_color = Constants.BUTTON_BORDER_COLOR_DEFAULT; - private Color _gui_button_text_color = Constants.BUTTON_TEXT_COLOR_DEFAULT; - private Color _gui_checkbox_and_button_active_color = Constants.CHECKBOX_AND_BUTTON_ACTIVE_COLOR_DEFAULT; - private Color _gui_checkbox_text_color = Constants.CHECKBOX_TEXT_COLOR_DEFAULT; - private Color _gui_menu_background_color = Constants.MENU_BACKGROUND_COLOR_DEFAULT; - private Color _gui_menu_text_color = Constants.MENU_TEXT_COLOR_DEFAULT; + private Color _gui_background_color = AptxConstants.GUI_BACKGROUND_DEFAULT; + private Color _gui_button_background_color = AptxConstants.BUTTON_BACKGROUND_COLOR_DEFAULT; + private Color _gui_button_border_color = AptxConstants.BUTTON_BORDER_COLOR_DEFAULT; + private Color _gui_button_text_color = AptxConstants.BUTTON_TEXT_COLOR_DEFAULT; + private Color _gui_checkbox_and_button_active_color = AptxConstants.CHECKBOX_AND_BUTTON_ACTIVE_COLOR_DEFAULT; + private Color _gui_checkbox_text_color = AptxConstants.CHECKBOX_TEXT_COLOR_DEFAULT; + private Color _gui_menu_background_color = AptxConstants.MENU_BACKGROUND_COLOR_DEFAULT; + private Color _gui_menu_text_color = AptxConstants.MENU_TEXT_COLOR_DEFAULT; private boolean _hide_controls_and_menus = false; private boolean _internal_number_are_confidence_for_nh_parsing = false; private String _label_for_get_ext_descendents_data = ""; @@ -226,8 +226,8 @@ public final class Configuration { private double _min_confidence_value = Options.MIN_CONFIDENCE_DEFAULT; private boolean _nh_parsing_replace_underscores = false; private NODE_LABEL_DIRECTION _node_label_direction = NODE_LABEL_DIRECTION.HORIZONTAL; - private short _number_of_digits_after_comma_for_branch_length_values = Constants.NUMBER_OF_DIGITS_AFTER_COMMA_FOR_BRANCH_LENGTH_VALUES_DEFAULT; - private short _number_of_digits_after_comma_for_confidence_values = Constants.NUMBER_OF_DIGITS_AFTER_COMMA_FOR_CONFIDENCE_VALUES_DEFAULT; + private short _number_of_digits_after_comma_for_branch_length_values = AptxConstants.NUMBER_OF_DIGITS_AFTER_COMMA_FOR_BRANCH_LENGTH_VALUES_DEFAULT; + private short _number_of_digits_after_comma_for_confidence_values = AptxConstants.NUMBER_OF_DIGITS_AFTER_COMMA_FOR_CONFIDENCE_VALUES_DEFAULT; private short _ov_max_height = 80; private short _ov_max_width = 80; private OVERVIEW_PLACEMENT_TYPE _ov_placement = OVERVIEW_PLACEMENT_TYPE.UPPER_LEFT; @@ -235,7 +235,7 @@ public final class Configuration { private File _path_to_local_mafft = null; private File _path_to_local_raxml = null; private PHYLOGENY_GRAPHICS_TYPE _phylogeny_graphics_type = PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR; - private float _print_line_width = Constants.PDF_LINE_WIDTH_DEFAULT; + private float _print_line_width = AptxConstants.PDF_LINE_WIDTH_DEFAULT; private boolean _show_annotation_ref_source = true; private boolean _show_default_node_shapes_external = false; private boolean _show_default_node_shapes_for_marked_nodes = false; @@ -246,7 +246,7 @@ public final class Configuration { private TAXONOMY_EXTRACTION _taxonomy_extraction = TAXONOMY_EXTRACTION.NO; private UI _ui = UI.UNKNOWN; private boolean _use_tabbed_display = false; - private boolean _validate_against_phyloxml_xsd_schema = Constants.VALIDATE_AGAINST_PHYLOXML_XSD_SCJEMA_DEFAULT; + private boolean _validate_against_phyloxml_xsd_schema = AptxConstants.VALIDATE_AGAINST_PHYLOXML_XSD_SCJEMA_DEFAULT; private Color _vector_data_min_color = Color.BLUE; private Color _vector_data_max_color = Color.YELLOW; private Color _vector_data_mean_color = Color.WHITE; @@ -256,14 +256,14 @@ public final class Configuration { private boolean _right_align_domains = false; private boolean _allow_thick_strokes = false; static { - for( final String font_name : Constants.DEFAULT_FONT_CHOICES ) { + for( final String font_name : AptxConstants.DEFAULT_FONT_CHOICES ) { if ( Arrays.binarySearch( AptxUtil.getAvailableFontFamiliesSorted(), font_name ) >= 0 ) { DEFAULT_FONT_FAMILY = font_name; break; } } if ( ForesterUtil.isEmpty( DEFAULT_FONT_FAMILY ) ) { - DEFAULT_FONT_FAMILY = Constants.DEFAULT_FONT_CHOICES[ Constants.DEFAULT_FONT_CHOICES.length - 1 ]; + DEFAULT_FONT_FAMILY = AptxConstants.DEFAULT_FONT_CHOICES[ AptxConstants.DEFAULT_FONT_CHOICES.length - 1 ]; } } @@ -290,16 +290,16 @@ public final class Configuration { final BufferedReader bf = new BufferedReader( isr ); readConfig( bf ); bf.close(); - ForesterUtil.programMessage( Constants.PRG_NAME, "successfully read from configuration url [" + ForesterUtil.programMessage( AptxConstants.PRG_NAME, "successfully read from configuration url [" + config_filename + "]" ); } catch ( final Exception e ) { - ForesterUtil.printWarningMessage( Constants.PRG_NAME, "failed to read configuration from [" + ForesterUtil.printWarningMessage( AptxConstants.PRG_NAME, "failed to read configuration from [" + config_filename + "]: " + e.getLocalizedMessage() ); } } catch ( final Exception e ) { - ForesterUtil.printWarningMessage( Constants.PRG_NAME, "cannot find or open configuration url [" + ForesterUtil.printWarningMessage( AptxConstants.PRG_NAME, "cannot find or open configuration url [" + config_filename + "]" ); } } @@ -317,14 +317,14 @@ public final class Configuration { } catch ( final Exception e ) { if ( verbose ) { - ForesterUtil.printWarningMessage( Constants.PRG_NAME, "failed to read configuration from [" + ForesterUtil.printWarningMessage( AptxConstants.PRG_NAME, "failed to read configuration from [" + config_filename + "]: " + e ); } } } else { if ( verbose ) { - ForesterUtil.printWarningMessage( Constants.PRG_NAME, "cannot find or open configuration file [" + ForesterUtil.printWarningMessage( AptxConstants.PRG_NAME, "cannot find or open configuration file [" + config_filename + "]" ); } } @@ -644,7 +644,7 @@ public final class Configuration { if ( name.equals( "edit_info" ) ) { index = Configuration.display_node_data; ForesterUtil - .printWarningMessage( Constants.PRG_NAME, + .printWarningMessage( AptxConstants.PRG_NAME, "configuration key [edit_info] is deprecated, use [display node data] instead" ); } else if ( name.equals( "display_node_data" ) ) { @@ -670,7 +670,7 @@ public final class Configuration { } else if ( name.equals( "display_sequences" ) ) { ForesterUtil - .printWarningMessage( Constants.PRG_NAME, "configuration key [display_sequences] is deprecated" ); + .printWarningMessage( AptxConstants.PRG_NAME, "configuration key [display_sequences] is deprecated" ); return DEPRECATED; } else if ( name.equals( "open_seq_web" ) ) { @@ -707,12 +707,12 @@ public final class Configuration { index = Configuration.select_nodes; } else if ( name.equals( "display_node_popup" ) ) { - ForesterUtil.printWarningMessage( Constants.PRG_NAME, + ForesterUtil.printWarningMessage( AptxConstants.PRG_NAME, "configuration key [display_node_popup] is deprecated" ); return DEPRECATED; } else if ( name.equals( "custom_option" ) ) { - ForesterUtil.printWarningMessage( Constants.PRG_NAME, "configuration key [custom_option] is deprecated" ); + ForesterUtil.printWarningMessage( AptxConstants.PRG_NAME, "configuration key [custom_option] is deprecated" ); return DEPRECATED; } else if ( name.equals( "color_subtree" ) ) { @@ -746,7 +746,7 @@ public final class Configuration { return false; } else { - ForesterUtil.printWarningMessage( Constants.PRG_NAME, "could not parse boolean value from [" + str + "]" ); + ForesterUtil.printWarningMessage( AptxConstants.PRG_NAME, "could not parse boolean value from [" + str + "]" ); return false; } } @@ -757,7 +757,7 @@ public final class Configuration { d = Double.parseDouble( str.trim() ); } catch ( final Exception e ) { - ForesterUtil.printWarningMessage( Constants.PRG_NAME, "could not parse double from [" + str + "]" ); + ForesterUtil.printWarningMessage( AptxConstants.PRG_NAME, "could not parse double from [" + str + "]" ); d = 0.0; } return d; @@ -769,7 +769,7 @@ public final class Configuration { f = Float.parseFloat( str.trim() ); } catch ( final Exception e ) { - ForesterUtil.printWarningMessage( Constants.PRG_NAME, "could not parse float from [" + str + "]" ); + ForesterUtil.printWarningMessage( AptxConstants.PRG_NAME, "could not parse float from [" + str + "]" ); f = 0.0f; } return f; @@ -781,7 +781,7 @@ public final class Configuration { i = Integer.parseInt( str.trim() ); } catch ( final Exception e ) { - ForesterUtil.printWarningMessage( Constants.PRG_NAME, "could not parse integer from [" + str + "]" ); + ForesterUtil.printWarningMessage( AptxConstants.PRG_NAME, "could not parse integer from [" + str + "]" ); i = -1; } return i; @@ -793,7 +793,7 @@ public final class Configuration { i = Short.parseShort( str.trim() ); } catch ( final Exception e ) { - ForesterUtil.printWarningMessage( Constants.PRG_NAME, "could not parse short from [" + str + "]" ); + ForesterUtil.printWarningMessage( AptxConstants.PRG_NAME, "could not parse short from [" + str + "]" ); i = -1; } return i; @@ -878,7 +878,7 @@ public final class Configuration { final String clickto_name = ( String ) st.nextElement(); default_clickto = getClickToIndex( clickto_name ); if ( default_clickto == -1 ) { - ForesterUtil.printWarningMessage( Constants.PRG_NAME, "invalid value [" + clickto_name + ForesterUtil.printWarningMessage( AptxConstants.PRG_NAME, "invalid value [" + clickto_name + "] for [default_click_to]" ); default_clickto = 0; } @@ -898,7 +898,7 @@ public final class Configuration { _ui = UI.UNKNOWN; } else { - ForesterUtil.printWarningMessage( Constants.PRG_NAME, "could not parse yes/no/? value from [" + my_str + ForesterUtil.printWarningMessage( AptxConstants.PRG_NAME, "could not parse yes/no/? value from [" + my_str + "]" ); _ui = UI.UNKNOWN; } @@ -937,7 +937,7 @@ public final class Configuration { } else { setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR ); - ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown value [" + type_str + ForesterUtil.printWarningMessage( AptxConstants.PRG_NAME, "unknown value [" + type_str + "] for [phylogeny_graphics_type]" ); } } @@ -991,7 +991,7 @@ public final class Configuration { setPrintLineWidth( f ); } else { - ForesterUtil.printWarningMessage( Constants.PRG_NAME, + ForesterUtil.printWarningMessage( AptxConstants.PRG_NAME, "value for [pdf_export_line_width] cannot be zero or negative" ); } } @@ -1017,7 +1017,7 @@ public final class Configuration { } else { ForesterUtil - .printWarningMessage( Constants.PRG_NAME, + .printWarningMessage( AptxConstants.PRG_NAME, "value for [default_number_of_bootstrap_resamples] cannot be negative" ); } } @@ -1072,13 +1072,13 @@ public final class Configuration { setCladogramType( Options.CLADOGRAM_TYPE.TOTAL_NODE_SUM_DEP ); } else { - ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown value [" + type_str + ForesterUtil.printWarningMessage( AptxConstants.PRG_NAME, "unknown value [" + type_str + "] for [cladogram_type]" ); } } else if ( key.equals( "non_lined_up_cladogram" ) ) { ForesterUtil - .printWarningMessage( Constants.PRG_NAME, + .printWarningMessage( AptxConstants.PRG_NAME, "configuration key [non_lined_up_cladogram] is deprecated, use [cladogram_type] instead" ); } else if ( key.equals( "hide_controls_and_menus" ) ) { @@ -1111,7 +1111,7 @@ public final class Configuration { } else { setOvPlacement( OVERVIEW_PLACEMENT_TYPE.UPPER_LEFT ); - ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown value [" + type_str + ForesterUtil.printWarningMessage( AptxConstants.PRG_NAME, "unknown value [" + type_str + "] for [overview_placement_type]" ); } } @@ -1125,7 +1125,7 @@ public final class Configuration { } else { setNodeLabelDirection( NODE_LABEL_DIRECTION.HORIZONTAL ); - ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown value [" + type_str + ForesterUtil.printWarningMessage( AptxConstants.PRG_NAME, "unknown value [" + type_str + "] for [node_label_direction]" ); } } @@ -1135,7 +1135,7 @@ public final class Configuration { setNumberOfDigitsAfterCommaForBranchLengthValue( i ); } else { - ForesterUtil.printWarningMessage( Constants.PRG_NAME, "illegal value [" + i + ForesterUtil.printWarningMessage( AptxConstants.PRG_NAME, "illegal value [" + i + "] for [branch_length_value_digits]" ); } } @@ -1145,7 +1145,7 @@ public final class Configuration { setNumberOfDigitsAfterCommaForConfidenceValues( i ); } else { - ForesterUtil.printWarningMessage( Constants.PRG_NAME, "illegal value [" + i + ForesterUtil.printWarningMessage( AptxConstants.PRG_NAME, "illegal value [" + i + "] for [confidence_value_digits]" ); } } @@ -1159,7 +1159,7 @@ public final class Configuration { final boolean r = parseBoolean( ( String ) st.nextElement() ); if ( r && ( getTaxonomyExtraction() != TAXONOMY_EXTRACTION.NO ) ) { ForesterUtil - .printWarningMessage( Constants.PRG_NAME, + .printWarningMessage( AptxConstants.PRG_NAME, "attempt to extract taxonomies and replace underscores at the same time" ); } else { @@ -1182,14 +1182,14 @@ public final class Configuration { } else { ForesterUtil - .printWarningMessage( Constants.PRG_NAME, + .printWarningMessage( AptxConstants.PRG_NAME, "unknown value for \"taxonomy_extraction_in_nh_parsing\": " + s + " (must be either: no, pfam_relaxed, pfam_strict, or aggressive)" ); } if ( ( getTaxonomyExtraction() != TAXONOMY_EXTRACTION.NO ) && isReplaceUnderscoresInNhParsing() ) { ForesterUtil - .printWarningMessage( Constants.PRG_NAME, + .printWarningMessage( AptxConstants.PRG_NAME, "attempt to extract taxonomies and replace underscores at the same time" ); } } @@ -1245,7 +1245,7 @@ public final class Configuration { setDefaultNodeFill( NodeFill.SOLID ); } else { - ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown value [" + fill_str + ForesterUtil.printWarningMessage( AptxConstants.PRG_NAME, "unknown value [" + fill_str + "] for [default_node_fill]" ); } } @@ -1258,7 +1258,7 @@ public final class Configuration { setDefaultNodeShape( NodeShape.RECTANGLE ); } else { - ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown value [" + shape_str + ForesterUtil.printWarningMessage( AptxConstants.PRG_NAME, "unknown value [" + shape_str + "] for [default_node_shape]" ); } } @@ -1307,7 +1307,7 @@ public final class Configuration { setExtDescNodeDataToReturn( NodeDataField.GO_TERM_IDS ); } else { - ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown value [" + s + ForesterUtil.printWarningMessage( AptxConstants.PRG_NAME, "unknown value [" + s + "] for [ext_descendents_data_to_return]" ); } } @@ -1329,7 +1329,7 @@ public final class Configuration { setExtNodeDataReturnOn( EXT_NODE_DATA_RETURN_ON.BUFFER_ONLY ); } else { - ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown value [" + s + ForesterUtil.printWarningMessage( AptxConstants.PRG_NAME, "unknown value [" + s + "] for [ext_descendents_data_to_return_on]" ); } } @@ -1399,7 +1399,7 @@ public final class Configuration { else if ( key.equals( "color_branches" ) ) { key_index = Configuration.use_style; ForesterUtil - .printWarningMessage( Constants.PRG_NAME, + .printWarningMessage( AptxConstants.PRG_NAME, "configuration key [color_branches] is deprecated, use [use_visual_styles] instead" ); } else if ( key.equals( "width_branches" ) ) { @@ -1479,7 +1479,7 @@ public final class Configuration { // Deprecated. } else { - ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown click-to option: " + ForesterUtil.printWarningMessage( AptxConstants.PRG_NAME, "unknown click-to option: " + click_to_name ); } } @@ -1499,20 +1499,20 @@ public final class Configuration { .put( ( String ) st.nextElement(), Color.decode( ( String ) st.nextElement() ) ); } else if ( key.equals( "function_color" ) ) { - ForesterUtil.printWarningMessage( Constants.PRG_NAME, + ForesterUtil.printWarningMessage( AptxConstants.PRG_NAME, "configuration key [function_color] is deprecated" ); } else if ( key.equals( DISPLAY_COLOR_KEY ) ) { putDisplayColors( ( String ) st.nextElement(), Color.decode( ( String ) st.nextElement() ) ); } else { - ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown configuration key [" + key + ForesterUtil.printWarningMessage( AptxConstants.PRG_NAME, "unknown configuration key [" + key + "] in: " + config_filename ); } } } else { - ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown configuration key [" + key + "] in: " + ForesterUtil.printWarningMessage( AptxConstants.PRG_NAME, "unknown configuration key [" + key + "] in: " + config_filename ); } } diff --git a/forester/java/src/org/forester/archaeopteryx/ControlPanel.java b/forester/java/src/org/forester/archaeopteryx/ControlPanel.java index 4cc4960..6d7c316 100644 --- a/forester/java/src/org/forester/archaeopteryx/ControlPanel.java +++ b/forester/java/src/org/forester/archaeopteryx/ControlPanel.java @@ -260,19 +260,19 @@ final class ControlPanel extends JPanel implements ActionListener { } // Zoom buttons else if ( e.getSource() == _zoom_in_x ) { - zoomInX( Constants.BUTTON_ZOOM_IN_FACTOR, Constants.BUTTON_ZOOM_IN_X_CORRECTION_FACTOR ); + zoomInX( AptxConstants.BUTTON_ZOOM_IN_FACTOR, AptxConstants.BUTTON_ZOOM_IN_X_CORRECTION_FACTOR ); displayedPhylogenyMightHaveChanged( false ); } else if ( e.getSource() == _zoom_in_y ) { - zoomInY( Constants.BUTTON_ZOOM_IN_FACTOR ); + zoomInY( AptxConstants.BUTTON_ZOOM_IN_FACTOR ); displayedPhylogenyMightHaveChanged( false ); } else if ( e.getSource() == _zoom_out_x ) { - zoomOutX( Constants.BUTTON_ZOOM_OUT_FACTOR, Constants.BUTTON_ZOOM_OUT_X_CORRECTION_FACTOR ); + zoomOutX( AptxConstants.BUTTON_ZOOM_OUT_FACTOR, AptxConstants.BUTTON_ZOOM_OUT_X_CORRECTION_FACTOR ); displayedPhylogenyMightHaveChanged( false ); } else if ( e.getSource() == _zoom_out_y ) { - zoomOutY( Constants.BUTTON_ZOOM_OUT_FACTOR ); + zoomOutY( AptxConstants.BUTTON_ZOOM_OUT_FACTOR ); displayedPhylogenyMightHaveChanged( false ); } else if ( e.getSource() == _show_whole ) { diff --git a/forester/java/src/org/forester/archaeopteryx/MainFrame.java b/forester/java/src/org/forester/archaeopteryx/MainFrame.java index 0f4ae3e..aa23df0 100644 --- a/forester/java/src/org/forester/archaeopteryx/MainFrame.java +++ b/forester/java/src/org/forester/archaeopteryx/MainFrame.java @@ -94,8 +94,8 @@ public abstract class MainFrame extends JFrame implements ActionListener { final static SequencesFileFilter seqsfilter = new SequencesFileFilter(); final static DefaultFilter defaultfilter = new DefaultFilter(); 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; + static final String PHYLOXML_REF_TOOL_TIP = AptxConstants.PHYLOXML_REFERENCE; //TODO //FIXME + static final String APTX_REF_TOOL_TIP = AptxConstants.APTX_REFERENCE; private static final long serialVersionUID = 3655000897845508358L; final static Font menu_font = new Font( Configuration.getDefaultFontFamilyName(), Font.PLAIN, @@ -586,42 +586,42 @@ public abstract class MainFrame extends JFrame implements ActionListener { } else if ( o == _help_item ) { try { - AptxUtil.openWebsite( Constants.APTX_DOC_SITE, is_applet, applet ); + AptxUtil.openWebsite( AptxConstants.APTX_DOC_SITE, is_applet, applet ); } catch ( final IOException e1 ) { - ForesterUtil.printErrorMessage( Constants.PRG_NAME, e1.toString() ); + ForesterUtil.printErrorMessage( AptxConstants.PRG_NAME, e1.toString() ); } } else if ( o == _website_item ) { try { - AptxUtil.openWebsite( Constants.APTX_WEB_SITE, is_applet, applet ); + AptxUtil.openWebsite( AptxConstants.APTX_WEB_SITE, is_applet, applet ); } catch ( final IOException e1 ) { - ForesterUtil.printErrorMessage( Constants.PRG_NAME, e1.toString() ); + ForesterUtil.printErrorMessage( AptxConstants.PRG_NAME, e1.toString() ); } } else if ( o == _phyloxml_website_item ) { try { - AptxUtil.openWebsite( Constants.PHYLOXML_WEB_SITE, is_applet, applet ); + AptxUtil.openWebsite( AptxConstants.PHYLOXML_WEB_SITE, is_applet, applet ); } catch ( final IOException e1 ) { - ForesterUtil.printErrorMessage( Constants.PRG_NAME, e1.toString() ); + ForesterUtil.printErrorMessage( AptxConstants.PRG_NAME, e1.toString() ); } } else if ( o == _aptx_ref_item ) { try { - AptxUtil.openWebsite( Constants.APTX_REFERENCE_URL, is_applet, applet ); + AptxUtil.openWebsite( AptxConstants.APTX_REFERENCE_URL, is_applet, applet ); } catch ( final IOException e1 ) { - ForesterUtil.printErrorMessage( Constants.PRG_NAME, e1.toString() ); + ForesterUtil.printErrorMessage( AptxConstants.PRG_NAME, e1.toString() ); } } else if ( o == _phyloxml_ref_item ) { try { - AptxUtil.openWebsite( Constants.PHYLOXML_REFERENCE_URL, is_applet, applet ); + AptxUtil.openWebsite( AptxConstants.PHYLOXML_REFERENCE_URL, is_applet, applet ); } catch ( final IOException e1 ) { - ForesterUtil.printErrorMessage( Constants.PRG_NAME, e1.toString() ); + ForesterUtil.printErrorMessage( AptxConstants.PRG_NAME, e1.toString() ); } } else if ( o == _write_to_pdf_item ) { @@ -1268,10 +1268,10 @@ public abstract class MainFrame extends JFrame implements ActionListener { + "[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 + "]", + + "[A4: " + AptxConstants.A4_SIZE_X + ", " + + AptxConstants.A4_SIZE_Y + "]\n" + "[US Letter: " + + AptxConstants.US_LETTER_SIZE_X + ", " + + AptxConstants.US_LETTER_SIZE_Y + "]", "Default Size for Graphics Export", JOptionPane.QUESTION_MESSAGE, null, @@ -2049,11 +2049,11 @@ public abstract class MainFrame extends JFrame implements ActionListener { * Display the about box. */ static void about() { - final StringBuffer about = new StringBuffer( "Archaeopteryx\nVersion " + Constants.VERSION + "\n" ); + final StringBuffer about = new StringBuffer( "Archaeopteryx\nVersion " + AptxConstants.VERSION + "\n" ); about.append( "Copyright (C) 2015 Christian M Zmasek\n" ); about.append( "All Rights Reserved\n" ); about.append( "License: GNU Lesser General Public License (LGPL)\n" ); - about.append( "Last modified: " + Constants.PRG_DATE + "\n" ); + about.append( "Last modified: " + AptxConstants.PRG_DATE + "\n" ); about.append( "Based on: " + ForesterUtil.getForesterLibraryInformation() + "\n" ); about.append( "phyloXML version : " + ForesterConstants.PHYLO_XML_VERSION + "\n" ); about.append( "phyloXML location: " + ForesterConstants.PHYLO_XML_LOCATION + "\n" ); @@ -2071,13 +2071,13 @@ public abstract class MainFrame extends JFrame implements ActionListener { about.append( "[free memory: " + free_memory + "MB, total memory: " + total_memory + "MB]\n" ); about.append( "[locale: " + Locale.getDefault() + "]\n" ); about.append( "References:\n" ); - about.append( Constants.PHYLOXML_REFERENCE_SHORT + "\n" ); + about.append( AptxConstants.PHYLOXML_REFERENCE_SHORT + "\n" ); about.append( "For more information & download:\n" ); - about.append( Constants.APTX_WEB_SITE + "\n" ); + about.append( AptxConstants.APTX_WEB_SITE + "\n" ); about.append( "Documentation:\n" ); - about.append( Constants.APTX_DOC_SITE + "\n" ); - about.append( "Comments: " + Constants.AUTHOR_EMAIL ); - JOptionPane.showMessageDialog( null, about, Constants.PRG_NAME, JOptionPane.PLAIN_MESSAGE ); + about.append( AptxConstants.APTX_DOC_SITE + "\n" ); + about.append( "Comments: " + AptxConstants.AUTHOR_EMAIL ); + JOptionPane.showMessageDialog( null, about, AptxConstants.PRG_NAME, JOptionPane.PLAIN_MESSAGE ); } static void chooseNodeSize( final Options options, final Component parent ) { @@ -2210,7 +2210,7 @@ public abstract class MainFrame extends JFrame implements ActionListener { tp.resetPreferredSize(); tp.repaint(); } - final String job_name = Constants.PRG_NAME; + final String job_name = AptxConstants.PRG_NAME; boolean error = false; String printer_name = null; try { @@ -2482,7 +2482,7 @@ public abstract class MainFrame extends JFrame implements ActionListener { return null; } else { - final File to = new File( file.getAbsoluteFile().toString() + Constants.BACKUP_FILE_SUFFIX ); + final File to = new File( file.getAbsoluteFile().toString() + AptxConstants.BACKUP_FILE_SUFFIX ); try { ForesterUtil.copyFile( file, to ); } diff --git a/forester/java/src/org/forester/archaeopteryx/MainFrameApplication.java b/forester/java/src/org/forester/archaeopteryx/MainFrameApplication.java index 8ede385..8b4fbdc 100644 --- a/forester/java/src/org/forester/archaeopteryx/MainFrameApplication.java +++ b/forester/java/src/org/forester/archaeopteryx/MainFrameApplication.java @@ -121,7 +121,7 @@ public final class MainFrameApplication extends MainFrame { private ButtonGroup _radio_group_1; private ButtonGroup _radio_group_2; // Others: - double _min_not_collapse = Constants.MIN_NOT_COLLAPSE_DEFAULT; + double _min_not_collapse = AptxConstants.MIN_NOT_COLLAPSE_DEFAULT; double _min_not_collapse_bl = 0.001; // Phylogeny Inference menu private JMenu _inference_menu; @@ -197,7 +197,7 @@ public final class MainFrameApplication extends MainFrame { } try { boolean synth_exception = false; - if ( Constants.__SYNTH_LF ) { + if ( AptxConstants.__SYNTH_LF ) { try { final SynthLookAndFeel synth = new SynthLookAndFeel(); synth.load( MainFrameApplication.class.getResourceAsStream( "/resources/synth_look_and_feel_1.xml" ), @@ -206,12 +206,12 @@ public final class MainFrameApplication extends MainFrame { } catch ( final Exception ex ) { synth_exception = true; - ForesterUtil.printWarningMessage( Constants.PRG_NAME, + ForesterUtil.printWarningMessage( AptxConstants.PRG_NAME, "could not create synth look and feel: " + ex.getLocalizedMessage() ); } } - if ( !Constants.__SYNTH_LF || synth_exception ) { + if ( !AptxConstants.__SYNTH_LF || synth_exception ) { if ( _configuration.isUseNativeUI() ) { UIManager.setLookAndFeel( UIManager.getSystemLookAndFeelClassName() ); } @@ -242,7 +242,7 @@ public final class MainFrameApplication extends MainFrame { setInferenceManager( InferenceManager.createInstance( _configuration ) ); setPhylogeneticInferenceOptions( PhylogeneticInferenceOptions.createInstance( _configuration ) ); // set title - setTitle( Constants.PRG_NAME + " " + Constants.VERSION + " (" + Constants.PRG_DATE + ")" ); + setTitle( AptxConstants.PRG_NAME + " " + AptxConstants.VERSION + " (" + AptxConstants.PRG_DATE + ")" ); _mainpanel = new MainPanel( _configuration, this ); // The file dialogs _open_filechooser = new JFileChooser(); @@ -296,7 +296,7 @@ public final class MainFrameApplication extends MainFrame { _jmenubar.setBackground( getConfiguration().getGuiMenuBackgroundColor() ); } buildFileMenu(); - if ( Constants.__ALLOW_PHYLOGENETIC_INFERENCE ) { + if ( AptxConstants.__ALLOW_PHYLOGENETIC_INFERENCE ) { buildPhylogeneticInferenceMenu(); } buildAnalysisMenu(); diff --git a/forester/java/src/org/forester/archaeopteryx/MainPanel.java b/forester/java/src/org/forester/archaeopteryx/MainPanel.java index cc03467..e94e035 100644 --- a/forester/java/src/org/forester/archaeopteryx/MainPanel.java +++ b/forester/java/src/org/forester/archaeopteryx/MainPanel.java @@ -375,7 +375,7 @@ public class MainPanel extends JPanel implements ComponentListener { if ( sel >= 0 ) { if ( !getConfiguration().isUseNativeUI() ) { if ( _tabbed_pane.getTabCount() > 0 ) { - _tabbed_pane.setForegroundAt( sel, Constants.TAB_LABEL_FOREGROUND_COLOR_SELECTED ); + _tabbed_pane.setForegroundAt( sel, AptxConstants.TAB_LABEL_FOREGROUND_COLOR_SELECTED ); for( int i = 0; i < _tabbed_pane.getTabCount(); ++i ) { if ( i != sel ) { _tabbed_pane.setBackgroundAt( i, getConfiguration().getGuiBackgroundColor() ); diff --git a/forester/java/src/org/forester/archaeopteryx/NodeEditPanel.java b/forester/java/src/org/forester/archaeopteryx/NodeEditPanel.java index 0917131..85476b1 100644 --- a/forester/java/src/org/forester/archaeopteryx/NodeEditPanel.java +++ b/forester/java/src/org/forester/archaeopteryx/NodeEditPanel.java @@ -165,10 +165,10 @@ class NodeEditPanel extends JPanel { final JSplitPane split_pane = new JSplitPane( JSplitPane.VERTICAL_SPLIT ); split_pane.setTopComponent( tree_view ); // split_pane.setBottomComponent( data_view ); - data_view.setMinimumSize( Constants.NODE_PANEL_SPLIT_MINIMUM_SIZE ); - tree_view.setMinimumSize( Constants.NODE_PANEL_SPLIT_MINIMUM_SIZE ); + data_view.setMinimumSize( AptxConstants.NODE_PANEL_SPLIT_MINIMUM_SIZE ); + tree_view.setMinimumSize( AptxConstants.NODE_PANEL_SPLIT_MINIMUM_SIZE ); // split_pane.setDividerLocation( 400 ); - split_pane.setPreferredSize( Constants.NODE_PANEL_SIZE ); + split_pane.setPreferredSize( AptxConstants.NODE_PANEL_SIZE ); add( split_pane ); getJTree().getSelectionModel().setSelectionMode( TreeSelectionModel.SINGLE_TREE_SELECTION ); getJTree().addKeyListener( new KeyListener() { diff --git a/forester/java/src/org/forester/archaeopteryx/NodeFrame.java b/forester/java/src/org/forester/archaeopteryx/NodeFrame.java index e929451..4c82bfe 100644 --- a/forester/java/src/org/forester/archaeopteryx/NodeFrame.java +++ b/forester/java/src/org/forester/archaeopteryx/NodeFrame.java @@ -46,7 +46,7 @@ final class NodeFrame extends javax.swing.JFrame { NodeFrame( final PhylogenyNode n, final Phylogeny tree, final TreePanel tp, final int x ) { super( "Node " + ( ForesterUtil.isEmpty( n.getName() ) ? n.getId() : n.getName() ) ); _reepanel = tp; - setSize( Constants.NODE_FRAME_SIZE ); + setSize( AptxConstants.NODE_FRAME_SIZE ); _index = x; final Container contentPane = getContentPane(); final NodePanel nodepanel = new NodePanel( n ); @@ -67,7 +67,7 @@ final class NodeFrame extends javax.swing.JFrame { NodeFrame( final PhylogenyNode n, final Phylogeny tree, final TreePanel tp, final int x, final String dummy ) { super( "Editable Node " + ( ForesterUtil.isEmpty( n.getName() ) ? n.getId() : n.getName() ) ); _reepanel = tp; - setSize( Constants.NODE_FRAME_SIZE ); + setSize( AptxConstants.NODE_FRAME_SIZE ); _index = x; final Container contentPane = getContentPane(); final NodeEditPanel nodepanel = new NodeEditPanel( n, tp ); diff --git a/forester/java/src/org/forester/archaeopteryx/NodePanel.java b/forester/java/src/org/forester/archaeopteryx/NodePanel.java index e39b580..e7427ca 100644 --- a/forester/java/src/org/forester/archaeopteryx/NodePanel.java +++ b/forester/java/src/org/forester/archaeopteryx/NodePanel.java @@ -137,10 +137,10 @@ class NodePanel extends JPanel implements TreeSelectionListener { final JSplitPane split_pane = new JSplitPane( JSplitPane.VERTICAL_SPLIT ); split_pane.setTopComponent( tree_view ); split_pane.setBottomComponent( data_view ); - data_view.setMinimumSize( Constants.NODE_PANEL_SPLIT_MINIMUM_SIZE ); - tree_view.setMinimumSize( Constants.NODE_PANEL_SPLIT_MINIMUM_SIZE ); + data_view.setMinimumSize( AptxConstants.NODE_PANEL_SPLIT_MINIMUM_SIZE ); + tree_view.setMinimumSize( AptxConstants.NODE_PANEL_SPLIT_MINIMUM_SIZE ); split_pane.setDividerLocation( 400 ); - split_pane.setPreferredSize( Constants.NODE_PANEL_SIZE ); + split_pane.setPreferredSize( AptxConstants.NODE_PANEL_SIZE ); add( split_pane ); } diff --git a/forester/java/src/org/forester/archaeopteryx/Options.java b/forester/java/src/org/forester/archaeopteryx/Options.java index dede12e..3eb403e 100644 --- a/forester/java/src/org/forester/archaeopteryx/Options.java +++ b/forester/java/src/org/forester/archaeopteryx/Options.java @@ -184,7 +184,7 @@ final public class Options { final private void init() { _default_node_shape = NodeShape.CIRCLE; _default_node_fill = NodeFill.GRADIENT; - _default_node_shape_size = Constants.DEFAULT_NODE_SHAPE_SIZE_DEFAULT; + _default_node_shape_size = AptxConstants.DEFAULT_NODE_SHAPE_SIZE_DEFAULT; _internal_number_are_confidence_for_nh_parsing = false; _show_scale = false; _antialias_screen = true; @@ -196,12 +196,12 @@ final public class Options { _show_default_node_shapes_external = false; _show_default_node_shapes_for_marked_nodes = false; if ( AptxUtil.isUsOrCanada() ) { - _print_size_x = Constants.US_LETTER_SIZE_X; - _print_size_y = Constants.US_LETTER_SIZE_Y; + _print_size_x = AptxConstants.US_LETTER_SIZE_X; + _print_size_y = AptxConstants.US_LETTER_SIZE_Y; } else { - _print_size_x = Constants.A4_SIZE_X; - _print_size_y = Constants.A4_SIZE_Y; + _print_size_x = AptxConstants.A4_SIZE_X; + _print_size_y = AptxConstants.A4_SIZE_Y; } _min_confidence_value = MIN_CONFIDENCE_DEFAULT; _print_black_and_white = false; @@ -212,17 +212,17 @@ final public class Options { _match_whole_terms_only = false; _search_with_regex = false; _search_case_sensitive = false; - _print_line_width = Constants.PDF_LINE_WIDTH_DEFAULT; + _print_line_width = AptxConstants.PDF_LINE_WIDTH_DEFAULT; _show_overview = true; _ov_placement = OVERVIEW_PLACEMENT_TYPE.UPPER_LEFT; _node_label_direction = NODE_LABEL_DIRECTION.HORIZONTAL; _inverse_search_result = false; _scale_bar_length = 0.0; - _number_of_digits_after_comma_for_branch_length_values = Constants.NUMBER_OF_DIGITS_AFTER_COMMA_FOR_BRANCH_LENGTH_VALUES_DEFAULT; - _number_of_digits_after_comma_for_confidence_values = Constants.NUMBER_OF_DIGITS_AFTER_COMMA_FOR_CONFIDENCE_VALUES_DEFAULT; + _number_of_digits_after_comma_for_branch_length_values = AptxConstants.NUMBER_OF_DIGITS_AFTER_COMMA_FOR_BRANCH_LENGTH_VALUES_DEFAULT; + _number_of_digits_after_comma_for_confidence_values = AptxConstants.NUMBER_OF_DIGITS_AFTER_COMMA_FOR_CONFIDENCE_VALUES_DEFAULT; _nh_parsing_replace_underscores = false; _taxonomy_extraction = TAXONOMY_EXTRACTION.NO; - _cladogram_type = Constants.CLADOGRAM_TYPE_DEFAULT; + _cladogram_type = AptxConstants.CLADOGRAM_TYPE_DEFAULT; _show_domain_labels = true; _show_annotation_ref_source = true; setAbbreviateScientificTaxonNames( false ); diff --git a/forester/java/src/org/forester/archaeopteryx/TreeColorSet.java b/forester/java/src/org/forester/archaeopteryx/TreeColorSet.java index 177eba8..f90ec22 100644 --- a/forester/java/src/org/forester/archaeopteryx/TreeColorSet.java +++ b/forester/java/src/org/forester/archaeopteryx/TreeColorSet.java @@ -341,7 +341,7 @@ public final class TreeColorSet { } Color getBinaryDomainCombinationsColor() { - if ( Constants.SPECIAL_CUSTOM ) { + if ( AptxConstants.SPECIAL_CUSTOM ) { return new Color( 50, 50, 50 ); } return binary_domain_combinations_color; @@ -492,7 +492,7 @@ public final class TreeColorSet { tcs.setColorforDefault( field, color ); } catch ( final IllegalArgumentException ex ) { - ForesterUtil.printWarningMessage( Constants.PRG_NAME, ex.getMessage() ); + ForesterUtil.printWarningMessage( AptxConstants.PRG_NAME, ex.getMessage() ); } } } diff --git a/forester/java/src/org/forester/archaeopteryx/TreePanel.java b/forester/java/src/org/forester/archaeopteryx/TreePanel.java index ae19727..b90c964 100644 --- a/forester/java/src/org/forester/archaeopteryx/TreePanel.java +++ b/forester/java/src/org/forester/archaeopteryx/TreePanel.java @@ -244,8 +244,8 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee private Set _current_external_nodes = null; private StringBuilder _current_external_nodes_data_buffer = new StringBuilder(); private int _current_external_nodes_data_buffer_change_counter = 0; - private int _domain_structure_e_value_thr_exp = Constants.DOMAIN_STRUCTURE_E_VALUE_THR_DEFAULT_EXP; - private double _domain_structure_width = Constants.DOMAIN_STRUCTURE_DEFAULT_WIDTH; + private int _domain_structure_e_value_thr_exp = AptxConstants.DOMAIN_STRUCTURE_E_VALUE_THR_DEFAULT_EXP; + private double _domain_structure_width = AptxConstants.DOMAIN_STRUCTURE_DEFAULT_WIDTH; private int _dynamic_hiding_factor = 0; private boolean _edited = false; private final Ellipse2D _ellipse = new Ellipse2D.Float(); @@ -452,13 +452,13 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee else { if ( notches < 0 ) { for( int i = 0; i < ( -notches ); ++i ) { - getControlPanel().zoomInY( Constants.WHEEL_ZOOM_IN_FACTOR ); + getControlPanel().zoomInY( AptxConstants.WHEEL_ZOOM_IN_FACTOR ); getControlPanel().displayedPhylogenyMightHaveChanged( false ); } } else { for( int i = 0; i < notches; ++i ) { - getControlPanel().zoomOutY( Constants.WHEEL_ZOOM_OUT_FACTOR ); + getControlPanel().zoomOutY( AptxConstants.WHEEL_ZOOM_OUT_FACTOR ); getControlPanel().displayedPhylogenyMightHaveChanged( false ); } } @@ -467,17 +467,17 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee else { if ( notches < 0 ) { for( int i = 0; i < ( -notches ); ++i ) { - getControlPanel().zoomInX( Constants.WHEEL_ZOOM_IN_FACTOR, - Constants.WHEEL_ZOOM_IN_X_CORRECTION_FACTOR ); - getControlPanel().zoomInY( Constants.WHEEL_ZOOM_IN_FACTOR ); + getControlPanel().zoomInX( AptxConstants.WHEEL_ZOOM_IN_FACTOR, + AptxConstants.WHEEL_ZOOM_IN_X_CORRECTION_FACTOR ); + getControlPanel().zoomInY( AptxConstants.WHEEL_ZOOM_IN_FACTOR ); getControlPanel().displayedPhylogenyMightHaveChanged( false ); } } else { for( int i = 0; i < notches; ++i ) { - getControlPanel().zoomOutY( Constants.WHEEL_ZOOM_OUT_FACTOR ); - getControlPanel().zoomOutX( Constants.WHEEL_ZOOM_OUT_FACTOR, - Constants.WHEEL_ZOOM_OUT_X_CORRECTION_FACTOR ); + getControlPanel().zoomOutY( AptxConstants.WHEEL_ZOOM_OUT_FACTOR ); + getControlPanel().zoomOutX( AptxConstants.WHEEL_ZOOM_OUT_FACTOR, + AptxConstants.WHEEL_ZOOM_OUT_X_CORRECTION_FACTOR ); getControlPanel().displayedPhylogenyMightHaveChanged( false ); } } @@ -1554,21 +1554,21 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee || ( e.getKeyCode() == KeyEvent.VK_LEFT ) || ( e.getKeyCode() == KeyEvent.VK_RIGHT ) ) { if ( e.getModifiersEx() == InputEvent.SHIFT_DOWN_MASK ) { if ( e.getKeyCode() == KeyEvent.VK_UP ) { - getMainPanel().getControlPanel().zoomInY( Constants.WHEEL_ZOOM_IN_FACTOR ); + getMainPanel().getControlPanel().zoomInY( AptxConstants.WHEEL_ZOOM_IN_FACTOR ); getMainPanel().getControlPanel().displayedPhylogenyMightHaveChanged( false ); } else if ( e.getKeyCode() == KeyEvent.VK_DOWN ) { - getMainPanel().getControlPanel().zoomOutY( Constants.WHEEL_ZOOM_OUT_FACTOR ); + getMainPanel().getControlPanel().zoomOutY( AptxConstants.WHEEL_ZOOM_OUT_FACTOR ); getMainPanel().getControlPanel().displayedPhylogenyMightHaveChanged( false ); } else if ( e.getKeyCode() == KeyEvent.VK_LEFT ) { - getMainPanel().getControlPanel().zoomOutX( Constants.WHEEL_ZOOM_OUT_FACTOR, - Constants.WHEEL_ZOOM_OUT_X_CORRECTION_FACTOR ); + getMainPanel().getControlPanel().zoomOutX( AptxConstants.WHEEL_ZOOM_OUT_FACTOR, + AptxConstants.WHEEL_ZOOM_OUT_X_CORRECTION_FACTOR ); getMainPanel().getControlPanel().displayedPhylogenyMightHaveChanged( false ); } else if ( e.getKeyCode() == KeyEvent.VK_RIGHT ) { - getMainPanel().getControlPanel().zoomInX( Constants.WHEEL_ZOOM_IN_FACTOR, - Constants.WHEEL_ZOOM_IN_FACTOR ); + getMainPanel().getControlPanel().zoomInX( AptxConstants.WHEEL_ZOOM_IN_FACTOR, + AptxConstants.WHEEL_ZOOM_IN_FACTOR ); getMainPanel().getControlPanel().displayedPhylogenyMightHaveChanged( false ); } } @@ -1615,15 +1615,15 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee } } else if ( ( e.getKeyCode() == KeyEvent.VK_SUBTRACT ) || ( e.getKeyCode() == KeyEvent.VK_MINUS ) ) { - getMainPanel().getControlPanel().zoomOutY( Constants.WHEEL_ZOOM_OUT_FACTOR ); - getMainPanel().getControlPanel().zoomOutX( Constants.WHEEL_ZOOM_OUT_FACTOR, - Constants.WHEEL_ZOOM_OUT_X_CORRECTION_FACTOR ); + getMainPanel().getControlPanel().zoomOutY( AptxConstants.WHEEL_ZOOM_OUT_FACTOR ); + getMainPanel().getControlPanel().zoomOutX( AptxConstants.WHEEL_ZOOM_OUT_FACTOR, + AptxConstants.WHEEL_ZOOM_OUT_X_CORRECTION_FACTOR ); getMainPanel().getControlPanel().displayedPhylogenyMightHaveChanged( false ); } else if ( plusPressed( e.getKeyCode() ) ) { - getMainPanel().getControlPanel().zoomInX( Constants.WHEEL_ZOOM_IN_FACTOR, - Constants.WHEEL_ZOOM_IN_FACTOR ); - getMainPanel().getControlPanel().zoomInY( Constants.WHEEL_ZOOM_IN_FACTOR ); + getMainPanel().getControlPanel().zoomInX( AptxConstants.WHEEL_ZOOM_IN_FACTOR, + AptxConstants.WHEEL_ZOOM_IN_FACTOR ); + getMainPanel().getControlPanel().zoomInY( AptxConstants.WHEEL_ZOOM_IN_FACTOR ); getMainPanel().getControlPanel().displayedPhylogenyMightHaveChanged( false ); } else if ( e.getKeyCode() == KeyEvent.VK_S ) { @@ -2452,7 +2452,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee final float x = node.getXcoord(); g.setFont( getTreeFontSet().getLargeFont() ); g.setColor( getTreeColorSet().getGainedCharactersColor() ); - if ( Constants.SPECIAL_CUSTOM ) { + if ( AptxConstants.SPECIAL_CUSTOM ) { g.setColor( Color.BLUE ); } TreePanel @@ -4427,7 +4427,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee return; } int max_length = ForesterUtil.roundToInt( ( getSize().getWidth() - MOVE ) - * Constants.EXT_NODE_INFO_LENGTH_MAX_RATIO ); + * AptxConstants.EXT_NODE_INFO_LENGTH_MAX_RATIO ); if ( max_length < 40 ) { max_length = 40; } diff --git a/forester/java/src/org/forester/archaeopteryx/UrlTreeReader.java b/forester/java/src/org/forester/archaeopteryx/UrlTreeReader.java index cb1d118..ce6f712 100644 --- a/forester/java/src/org/forester/archaeopteryx/UrlTreeReader.java +++ b/forester/java/src/org/forester/archaeopteryx/UrlTreeReader.java @@ -30,13 +30,11 @@ import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; -import javax.net.ssl.HttpsURLConnection; import javax.swing.JOptionPane; import org.forester.archaeopteryx.webservices.PhylogeniesWebserviceClient; import org.forester.archaeopteryx.webservices.WebserviceUtil; import org.forester.archaeopteryx.webservices.WebservicesManager; -import org.forester.archaeopteryx.webservices.WebservicesManager.WsPhylogenyFormat; import org.forester.io.parsers.PhylogenyParser; import org.forester.io.parsers.nexus.NexusPhylogeniesParser; import org.forester.io.parsers.nhx.NHXParser; @@ -46,10 +44,7 @@ import org.forester.io.parsers.tol.TolParser; import org.forester.phylogeny.Phylogeny; import org.forester.phylogeny.PhylogenyMethods; import org.forester.phylogeny.data.Identifier; -import org.forester.phylogeny.factories.ParserBasedPhylogenyFactory; -import org.forester.phylogeny.factories.PhylogenyFactory; import org.forester.util.ForesterUtil; -import org.forester.util.TrustManager; public class UrlTreeReader implements Runnable { @@ -155,17 +150,7 @@ public class UrlTreeReader implements Runnable { else { _main_frame.getMainPanel().setWaitCursor(); } - final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance(); - - if (client.getReturnFormat()== WebservicesManager.WsPhylogenyFormat.TREEBASE_TREE - || client.getReturnFormat()== WebservicesManager.WsPhylogenyFormat.TREEBASE_STUDY) { - - final HttpsURLConnection con = TrustManager.makeHttpsURLConnection( url ); - trees = factory.create( con.getInputStream(), parser ); - } - else { - trees = factory.create( url.openStream(), parser ); - } + trees = ForesterUtil.readPhylogeniesFromUrl( url, parser ); } catch ( final MalformedURLException e ) { exception = true; diff --git a/forester/java/src/org/forester/archaeopteryx/phylogeny/data/RenderableDomainArchitecture.java b/forester/java/src/org/forester/archaeopteryx/phylogeny/data/RenderableDomainArchitecture.java index 70b7a1c..bbc804e 100644 --- a/forester/java/src/org/forester/archaeopteryx/phylogeny/data/RenderableDomainArchitecture.java +++ b/forester/java/src/org/forester/archaeopteryx/phylogeny/data/RenderableDomainArchitecture.java @@ -39,7 +39,7 @@ import java.util.Map; import java.util.SortedMap; import org.forester.archaeopteryx.AptxUtil; -import org.forester.archaeopteryx.Constants; +import org.forester.archaeopteryx.AptxConstants; import org.forester.archaeopteryx.TreePanel; import org.forester.phylogeny.data.DomainArchitecture; import org.forester.phylogeny.data.PhylogenyData; @@ -211,7 +211,7 @@ public final class RenderableDomainArchitecture extends DomainArchitecture imple g.setColor( tree_panel.getTreeColorSet().getDomainBaseColor() ); } else { - g.setColor( Constants.DOMAIN_BASE_COLOR_FOR_PDF ); + g.setColor( AptxConstants.DOMAIN_BASE_COLOR_FOR_PDF ); } _rectangle.setFrame( start, y - 0.5, _domain_structure.getTotalLength() * f, 1 ); g.fill( _rectangle ); @@ -233,7 +233,7 @@ public final class RenderableDomainArchitecture extends DomainArchitecture imple g.setColor( tree_panel.getTreeColorSet().getDomainLabelColor() ); } else { - g.setColor( Constants.DOMAIN_LABEL_COLOR_FOR_PDF ); + g.setColor( AptxConstants.DOMAIN_LABEL_COLOR_FOR_PDF ); } g.drawString( d.getName(), xa, y1 + tree_panel.getMainPanel().getTreeFontSet().getFontMetricsSmall().getAscent() diff --git a/forester/java/src/org/forester/archaeopteryx/tools/ImageLoader.java b/forester/java/src/org/forester/archaeopteryx/tools/ImageLoader.java index b431697..9faee68 100644 --- a/forester/java/src/org/forester/archaeopteryx/tools/ImageLoader.java +++ b/forester/java/src/org/forester/archaeopteryx/tools/ImageLoader.java @@ -36,7 +36,7 @@ import java.util.List; import javax.imageio.ImageIO; import org.forester.archaeopteryx.AptxUtil; -import org.forester.archaeopteryx.Constants; +import org.forester.archaeopteryx.AptxConstants; import org.forester.archaeopteryx.TreePanel; import org.forester.phylogeny.PhylogenyNode; import org.forester.phylogeny.data.Taxonomy; @@ -96,18 +96,18 @@ public class ImageLoader implements Runnable { bi = ImageIO.read( uri.getValue().toURL() ); } catch ( final MalformedURLException e ) { - AptxUtil.printWarningMessage( Constants.PRG_NAME, + AptxUtil.printWarningMessage( AptxConstants.PRG_NAME, "could not load image from \"" + uri.getValue() + "\": Malformed URL Exception: " + e.getLocalizedMessage() ); } catch ( final IOException e ) { - AptxUtil.printWarningMessage( Constants.PRG_NAME, + AptxUtil.printWarningMessage( AptxConstants.PRG_NAME, "could not load image from \"" + uri.getValue() + "\": IO Exception: " + e.getLocalizedMessage() ); } catch ( final CMMException e ) { - AptxUtil.printWarningMessage( Constants.PRG_NAME, + AptxUtil.printWarningMessage( AptxConstants.PRG_NAME, "could not load image from \"" + uri.getValue() + "\": CMMException: " + e.getLocalizedMessage() ); } diff --git a/forester/java/src/org/forester/archaeopteryx/tools/RunnableProcess.java b/forester/java/src/org/forester/archaeopteryx/tools/RunnableProcess.java index 60ff4d4..6b9bb4b 100644 --- a/forester/java/src/org/forester/archaeopteryx/tools/RunnableProcess.java +++ b/forester/java/src/org/forester/archaeopteryx/tools/RunnableProcess.java @@ -1,7 +1,7 @@ package org.forester.archaeopteryx.tools; -import org.forester.archaeopteryx.Constants; +import org.forester.archaeopteryx.AptxConstants; import org.forester.archaeopteryx.MainFrame; import org.forester.util.ForesterUtil; @@ -25,7 +25,7 @@ public abstract class RunnableProcess implements Runnable { public void end( final MainFrame mf ) { final boolean removed = mf.getProcessPool().removeProcess( getProcessId() ); if ( !removed ) { - ForesterUtil.printWarningMessage( Constants.PRG_NAME, "could not remove process " + getProcessId() + ForesterUtil.printWarningMessage( AptxConstants.PRG_NAME, "could not remove process " + getProcessId() + " from process pool" ); } mf.updateProcessMenu(); diff --git a/forester/java/src/org/forester/archaeopteryx/webservices/WebserviceUtil.java b/forester/java/src/org/forester/archaeopteryx/webservices/WebserviceUtil.java index 4fcec49..6999f0d 100644 --- a/forester/java/src/org/forester/archaeopteryx/webservices/WebserviceUtil.java +++ b/forester/java/src/org/forester/archaeopteryx/webservices/WebserviceUtil.java @@ -56,8 +56,7 @@ public final class WebserviceUtil { public static final String TREE_FAM_INST = "tree_fam"; public static final String TREE_FAM_NAME = "TreeFam"; public static final String TREE_FAM_URL_BASE = "http://www.treefam.org/family/TF"; - public static final String TREEBASE_PHYLOWS_STUDY_URL_BASE = "http://purl.org/phylo/treebase/phylows/study/TB2:S"; - // public static final String TREEBASE_PHYLOWS_TREE_URL_BASE = "http://purl.org/phylo/treebase/phylows/tree/TB2:Tr"; + public static final String TREEBASE_PHYLOWS_STUDY_URL_BASE = "https://treebase.org/treebase-web/phylows/study/TB2:S"; public static final String TREEBASE_PHYLOWS_TREE_URL_BASE = "https://treebase.org/treebase-web/phylows/tree/TB2:Tr"; @@ -67,14 +66,14 @@ public final class WebserviceUtil { clients.add( new BasicPhylogeniesWebserviceClient( TREE_BASE_NAME, "Read Tree(s) from TreeBASE Study...", "Use TreeBASE to obtain evolutionary tree(s) from a study", - "Please enter a TreeBASE study (\"S\") identifier (without the \"S\")\n(Examples: 14909, 14525, 15613, 15632)", + "Please enter a TreeBASE study (\"S\") identifier (without the \"S\")\n(Examples: 13246, 11662, 562, 16424, 17878, 10190, 14909, 14525, 15613, 15632)", WsPhylogenyFormat.TREEBASE_STUDY, null, TREEBASE_PHYLOWS_STUDY_URL_BASE + PhylogeniesWebserviceClient.QUERY_PLACEHOLDER + "?format=nexus", true, - "http://www.treebase.org", + "https://treebase.org", TREE_BASE_INST ) ); clients.add( new BasicPhylogeniesWebserviceClient( TREE_BASE_NAME, "Read Tree from TreeBASE...", @@ -86,7 +85,7 @@ public final class WebserviceUtil { + PhylogeniesWebserviceClient.QUERY_PLACEHOLDER + "?format=nexus", true, - "http://www.treebase.org", + "https://treebase.org", TREE_BASE_INST ) ); clients.add( new BasicPhylogeniesWebserviceClient( PFAM_NAME, "Read Domain Tree from Pfam...", diff --git a/forester/java/src/org/forester/io/parsers/nexus/NexusPhylogeniesParser.java b/forester/java/src/org/forester/io/parsers/nexus/NexusPhylogeniesParser.java index 9df4b18..0f51cd7 100644 --- a/forester/java/src/org/forester/io/parsers/nexus/NexusPhylogeniesParser.java +++ b/forester/java/src/org/forester/io/parsers/nexus/NexusPhylogeniesParser.java @@ -35,7 +35,7 @@ import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.forester.archaeopteryx.Constants; +import org.forester.archaeopteryx.AptxConstants; import org.forester.io.parsers.IteratingPhylogenyParser; import org.forester.io.parsers.PhylogenyParser; import org.forester.io.parsers.nhx.NHXFormatException; @@ -53,7 +53,7 @@ import org.forester.util.ForesterUtil; public final class NexusPhylogeniesParser implements IteratingPhylogenyParser, PhylogenyParser { - final private static boolean DEBUG = true; + final private static boolean DEBUG = false; final private static String begin_trees = NexusConstants.BEGIN_TREES.toLowerCase(); final private static String end = NexusConstants.END.toLowerCase(); @@ -71,11 +71,11 @@ public final class NexusPhylogeniesParser implements IteratingPhylogenyParser, P final private static Pattern TRANSLATE_PATTERN = Pattern.compile( "([0-9A-Za-z]+)\\s+(.+)" ); final private static Pattern ALN_PATTERN = Pattern.compile( "(.+)\\s+([A-Za-z-_\\*\\?]+)" ); final private static Pattern DATATYPE_PATTERN = Pattern.compile( "datatype\\s?.\\s?([a-z]+)" ); - final private static Pattern LINK_TAXA_PATTERN = Pattern.compile( "link\\s+taxa\\s?.\\s?([^;]+)", - Pattern.CASE_INSENSITIVE ); + //final private static Pattern LINK_TAXA_PATTERN = Pattern.compile( "link\\s+taxa\\s?.\\s?([^;]+)", + // Pattern.CASE_INSENSITIVE ); final private static String utree = NexusConstants.UTREE.toLowerCase(); private BufferedReader _br; - private boolean _ignore_quotes_in_nh_data = Constants.NH_PARSING_IGNORE_QUOTES_DEFAULT; + private boolean _ignore_quotes_in_nh_data = AptxConstants.NH_PARSING_IGNORE_QUOTES_DEFAULT; private boolean _in_taxalabels; private boolean _in_translate; private boolean _in_tree; @@ -294,10 +294,10 @@ public final class NexusPhylogeniesParser implements IteratingPhylogenyParser, P } } else if ( line_lc.startsWith( "link" ) ) { - final Matcher link_m = LINK_TAXA_PATTERN.matcher( line ); - if ( link_m.lookingAt() ) { - final String link = link_m.group( 1 ); //TODO why? - } + //final Matcher link_m = LINK_TAXA_PATTERN.matcher( line ); + //if ( link_m.lookingAt() ) { + //final String link = link_m.group( 1 ); //TODO why? + // } } else if ( line_lc.startsWith( end ) || line_lc.startsWith( endblock ) ) { _in_trees_block = false; @@ -399,10 +399,10 @@ public final class NexusPhylogeniesParser implements IteratingPhylogenyParser, P _datatype = null; } else if ( line_lc.startsWith( "link" ) ) { - final Matcher link_m = LINK_TAXA_PATTERN.matcher( line ); - if ( link_m.lookingAt() ) { - final String link = link_m.group( 1 ); - } + // final Matcher link_m = LINK_TAXA_PATTERN.matcher( line ); + // if ( link_m.lookingAt() ) { + // final String link = link_m.group( 1 ); + // } } else { final Matcher datatype_matcher = DATATYPE_PATTERN.matcher( line_lc ); diff --git a/forester/java/src/org/forester/test/Test.java b/forester/java/src/org/forester/test/Test.java index bcda899..3efa354 100644 --- a/forester/java/src/org/forester/test/Test.java +++ b/forester/java/src/org/forester/test/Test.java @@ -125,7 +125,6 @@ import org.forester.util.ForesterConstants; import org.forester.util.ForesterUtil; import org.forester.util.GeneralTable; import org.forester.util.SequenceAccessionTools; -import org.forester.util.TrustManager; import org.forester.ws.seqdb.SequenceDatabaseEntry; import org.forester.ws.seqdb.SequenceDbWsTools; import org.forester.ws.seqdb.UniProtTaxonomy; @@ -183,22 +182,6 @@ public final class Test { } final long start_time = new Date().getTime(); - - - System.out.print( "TreeBase acccess: " ); - if ( Test.testTreeBaseReading() ) { - System.out.println( "OK." ); - succeeded++; - } - else { - System.out.println( "failed." ); - failed++; - } - System.exit( -1 ); - - - - System.out.print( "Basic node methods: " ); if ( Test.testBasicNodeMethods() ) { System.out.println( "OK." ); @@ -989,8 +972,8 @@ public final class Test { } } if ( PERFORM_WEB_TREE_ACCESS ) { - System.out.print( "NHX parsing from URL: " ); - if ( Test.testNHXparsingFromURL() ) { + System.out.print( "TreeBase acccess: " ); + if ( Test.testTreeBaseReading() ) { System.out.println( "OK." ); succeeded++; } @@ -998,8 +981,8 @@ public final class Test { System.out.println( "failed." ); failed++; } - System.out.print( "NHX parsing from URL 2: " ); - if ( Test.testNHXparsingFromURL2() ) { + System.out.print( "ToL access: " ); + if ( Test.testToLReading() ) { System.out.println( "OK." ); succeeded++; } @@ -1007,8 +990,8 @@ public final class Test { System.out.println( "failed." ); failed++; } - System.out.print( "phyloXML parsing from URL: " ); - if ( Test.testPhyloXMLparsingFromURL() ) { + System.out.print( "NHX parsing from URL: " ); + if ( Test.testNHXparsingFromURL() ) { System.out.println( "OK." ); succeeded++; } @@ -1016,8 +999,8 @@ public final class Test { System.out.println( "failed." ); failed++; } - System.out.print( "TreeBase acccess: " ); - if ( Test.testTreeBaseReading() ) { + System.out.print( "NHX parsing from URL 2: " ); + if ( Test.testNHXparsingFromURL2() ) { System.out.println( "OK." ); succeeded++; } @@ -1025,8 +1008,8 @@ public final class Test { System.out.println( "failed." ); failed++; } - System.out.print( "ToL access: " ); - if ( Test.testToLReading() ) { + System.out.print( "phyloXML parsing from URL: " ); + if ( Test.testPhyloXMLparsingFromURL() ) { System.out.println( "OK." ); succeeded++; } @@ -1034,7 +1017,6 @@ public final class Test { System.out.println( "failed." ); failed++; } - // System.out.print( "TreeFam access: " ); if ( Test.testTreeFamReading() ) { System.out.println( "OK." ); @@ -1044,8 +1026,6 @@ public final class Test { System.out.println( "failed." ); failed++; } - // - // System.out.print( "Pfam tree access: " ); if ( Test.testPfamTreeReading() ) { System.out.println( "OK." ); @@ -1469,17 +1449,24 @@ public final class Test { parser.setTaxonomyExtraction( NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT ); parser.setReplaceUnderscores( false ); parser.setGuessRootedness( true ); - final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance(); - final Phylogeny[] phys = factory.create( u.openStream(), parser ); + final Phylogeny[] phys = ForesterUtil.readPhylogeniesFromUrl( u, parser); if ( ( phys == null ) || ( phys.length != 1 ) ) { return false; } if ( phys[ 0 ].getNumberOfExternalNodes() < 10 ) { return false; } + final Phylogeny[] phys2 = ForesterUtil.readPhylogeniesFromUrl( u, parser); + if ( ( phys2 == null ) || ( phys2.length != 1 ) ) { + return false; + } + if ( phys2[ 0 ].getNumberOfExternalNodes() != phys[ 0 ].getNumberOfExternalNodes() ) { + return false; + } } catch ( final Exception e ) { e.printStackTrace(); + return false; } return true; } @@ -1488,14 +1475,20 @@ public final class Test { try { final String s = "https://sites.google.com/site/cmzmasek/home/software/archaeopteryx/examples/archaeopteryx_a/apaf_bcl2.xml"; final URL u = new URL( s ); - final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance(); - final Phylogeny[] phys = factory.create( u.openStream(), PhyloXmlParser.createPhyloXmlParser() ); + final Phylogeny[] phys = ForesterUtil.readPhylogeniesFromUrl( u, PhyloXmlParser.createPhyloXmlParser() ); + if ( ( phys == null ) || ( phys.length != 2 ) ) { return false; } + final Phylogeny[] phys2 = ForesterUtil.readPhylogeniesFromUrl( u, PhyloXmlParser.createPhyloXmlParser() ); + + if ( ( phys2 == null ) || ( phys2.length != 2 ) ) { + return false; + } } catch ( final Exception e ) { e.printStackTrace(); + return false; } return true; } @@ -1503,8 +1496,7 @@ public final class Test { private static final boolean testToLReading() { try { final URL u = new URL( WebserviceUtil.TOL_URL_BASE + "15079" ); - final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance(); - final Phylogeny[] phys = factory.create( u.openStream(), new TolParser() ); + final Phylogeny[] phys = ForesterUtil.readPhylogeniesFromUrl( u, new TolParser() ); if ( ( phys == null ) || ( phys.length != 1 ) ) { return false; } @@ -1517,40 +1509,126 @@ public final class Test { if ( phys[ 0 ].getNumberOfExternalNodes() < 5 ) { return false; } + // + final URL u2 = new URL( WebserviceUtil.TOL_URL_BASE + "17706" ); + final Phylogeny[] phys2 = ForesterUtil.readPhylogeniesFromUrl( u2, new TolParser() ); + if ( ( phys2 == null ) || ( phys2.length != 1 ) ) { + return false; + } + if ( !phys2[ 0 ].getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "17706" ) ) { + return false; + } + if ( phys2[ 0 ].getNumberOfExternalNodes() < 5 ) { + return false; + } } catch ( final Exception e ) { e.printStackTrace(); + return false; } return true; } private static final boolean testTreeBaseReading() { try { - final URL u = new URL( WebserviceUtil.TREEBASE_PHYLOWS_TREE_URL_BASE + "72557?format=nexus" ); - System.out.println( u.toString() ); - - final HttpsURLConnection con = TrustManager.makeHttpsURLConnection( u ); - + final URL u = new URL( WebserviceUtil.TREEBASE_PHYLOWS_TREE_URL_BASE + "72557?format=nexus" ); final NexusPhylogeniesParser parser = new NexusPhylogeniesParser(); parser.setReplaceUnderscores( true ); - final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance(); - - - final Phylogeny[] phys = factory.create( con.getInputStream(), parser ); - if ( ( phys == null ) || ( phys.length < 1 ) ) { + final Phylogeny[] phys = ForesterUtil.readPhylogeniesFromUrl( u, parser ); + if ( ( phys == null ) || ( phys.length != 1 ) ) { + return false; + } + final URL u_1 = new URL( WebserviceUtil.TREEBASE_PHYLOWS_TREE_URL_BASE + "2406?format=nexus" ); + final NexusPhylogeniesParser parser_1 = new NexusPhylogeniesParser(); + final Phylogeny[] phys_1 = ForesterUtil.readPhylogeniesFromUrl( u_1, parser_1 ); + if ( ( phys_1 == null ) || ( phys_1.length != 1 ) ) { + return false; + } + final URL u_2 = new URL( WebserviceUtil.TREEBASE_PHYLOWS_TREE_URL_BASE + "422?format=nexus" ); + final NexusPhylogeniesParser parser_2 = new NexusPhylogeniesParser(); + final Phylogeny[] phys_2 = ForesterUtil.readPhylogeniesFromUrl( u_2, parser_2 ); + if ( ( phys_2 == null ) || ( phys_2.length != 1 ) ) { + return false; + } + final URL u_3 = new URL( WebserviceUtil.TREEBASE_PHYLOWS_TREE_URL_BASE + "2654?format=nexus" ); + final NexusPhylogeniesParser parser_3 = new NexusPhylogeniesParser(); + final Phylogeny[] phys_3 = ForesterUtil.readPhylogeniesFromUrl( u_3, parser_3 ); + if ( ( phys_3 == null ) || ( phys_3.length != 1 ) ) { + return false; + } + final URL u_4 = new URL( WebserviceUtil.TREEBASE_PHYLOWS_TREE_URL_BASE + "825?format=nexus" ); + final NexusPhylogeniesParser parser_4 = new NexusPhylogeniesParser(); + final Phylogeny[] phys_4 = ForesterUtil.readPhylogeniesFromUrl( u_4, parser_4 ); + if ( ( phys_4 == null ) || ( phys_4.length != 1 ) ) { return false; } final URL u2 = new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE + "15613?format=nexus" ); final NexusPhylogeniesParser parser2 = new NexusPhylogeniesParser(); parser2.setReplaceUnderscores( true ); - final PhylogenyFactory factory2 = ParserBasedPhylogenyFactory.getInstance(); - final Phylogeny[] phys2 = factory2.create( u2.openStream(), parser2 ); + final Phylogeny[] phys2 = ForesterUtil.readPhylogeniesFromUrl( u2, parser2 ); if ( ( phys2 == null ) || ( phys2.length != 9 ) ) { - //return false; + return false; + } + final URL u3 = new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE + "14909?format=nexus" ); + final NexusPhylogeniesParser parser3 = new NexusPhylogeniesParser(); + final Phylogeny[] phys3 = ForesterUtil.readPhylogeniesFromUrl( u3, parser3 ); + if ( ( phys3 == null ) || ( phys3.length != 2 ) ) { + return false; + } + final Phylogeny[] phys4 = ForesterUtil.readPhylogeniesFromUrl( new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE + "14525?format=nexus" ), + new NexusPhylogeniesParser() ); + if ( ( phys4 == null ) || ( phys4.length != 1 ) ) { + return false; + } + final Phylogeny[] phys5 = ForesterUtil.readPhylogeniesFromUrl( new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE + "15632?format=nexus" ) , + new NexusPhylogeniesParser() ); + if ( ( phys5 == null ) || ( phys5.length != 1 ) ) { + return false; + } + final Phylogeny[] phys6 = ForesterUtil.readPhylogeniesFromUrl( new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE + "10190?format=nexus" ) , + new NexusPhylogeniesParser() ); + if ( ( phys6 == null ) || ( phys6.length != 1 ) ) { + return false; + } + final Phylogeny[] phys7 = ForesterUtil.readPhylogeniesFromUrl( new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE + "13246?format=nexus" ) , + new NexusPhylogeniesParser() ); + if ( ( phys7 == null ) || ( phys7.length != 2 ) ) { + return false; + } + final Phylogeny[] phys8 = ForesterUtil.readPhylogeniesFromUrl( new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE + "11662?format=nexus" ) , + new NexusPhylogeniesParser() ); + if ( ( phys8 == null ) || ( phys8.length != 2 ) ) { + return false; + } + final Phylogeny[] phys9 = ForesterUtil.readPhylogeniesFromUrl( new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE + "562?format=nexus" ) , + new NexusPhylogeniesParser() ); + if ( ( phys9 == null ) || ( phys9.length != 4 ) ) { + return false; + } + final Phylogeny[] phys16424 = ForesterUtil.readPhylogeniesFromUrl( new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE + "16424?format=nexus" ) , + new NexusPhylogeniesParser() ); + if ( ( phys16424 == null ) || ( phys16424.length != 1 ) ) { + return false; + } + final Phylogeny[] phys17878 = ForesterUtil.readPhylogeniesFromUrl( new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE + "17878?format=nexus" ) , + new NexusPhylogeniesParser() ); + if ( ( phys17878 == null ) || ( phys17878.length != 17 ) ) { + return false; + } + final Phylogeny[] phys18804 = ForesterUtil.readPhylogeniesFromUrl( new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE + "18804?format=nexus" ) , + new NexusPhylogeniesParser() ); + if ( ( phys18804 == null ) || ( phys18804.length != 2 ) ) { + return false; + } + final Phylogeny[] phys346 = ForesterUtil.readPhylogeniesFromUrl( new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE + "346?format=nexus" ) , + new NexusPhylogeniesParser() ); + if ( ( phys346 == null ) || ( phys346.length != 1 ) ) { + return false; } } catch ( final Exception e ) { e.printStackTrace(); + return false; } return true; } @@ -1562,8 +1640,7 @@ public final class Test { parser.setTaxonomyExtraction( NHXParser.TAXONOMY_EXTRACTION.NO ); parser.setReplaceUnderscores( false ); parser.setGuessRootedness( true ); - final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance(); - final Phylogeny[] phys = factory.create( u.openStream(), parser ); + final Phylogeny[] phys = ForesterUtil.readPhylogeniesFromUrl( u, parser ); if ( ( phys == null ) || ( phys.length != 1 ) ) { return false; } @@ -1573,6 +1650,7 @@ public final class Test { } catch ( final Exception e ) { e.printStackTrace(); + return false; } return true; } @@ -4917,12 +4995,22 @@ public final class Test { private static boolean testFastaParser() { try { - if ( !FastaParser.isLikelyFasta( new FileInputStream( PATH_TO_TEST_DATA + "fasta_0.fasta" ) ) ) { + FileInputStream fis1 = new FileInputStream( PATH_TO_TEST_DATA + "fasta_0.fasta" ); + if ( !FastaParser.isLikelyFasta( fis1 ) ) { + fis1.close(); return false; } - if ( FastaParser.isLikelyFasta( new FileInputStream( PATH_TO_TEST_DATA + "msa_3.txt" ) ) ) { + else { + fis1.close(); + } + FileInputStream fis2 = new FileInputStream( PATH_TO_TEST_DATA + "msa_3.txt" ); + if ( FastaParser.isLikelyFasta( fis2 ) ) { + fis2.close(); return false; } + else { + fis2.close(); + } final Msa msa_0 = FastaParser.parseMsa( new FileInputStream( PATH_TO_TEST_DATA + "fasta_0.fasta" ) ); if ( !msa_0.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "ACGTGKXFMFDMXEXXXSFMFMF" ) ) { return false; diff --git a/forester/java/src/org/forester/util/ForesterConstants.java b/forester/java/src/org/forester/util/ForesterConstants.java index fa65992..a39dd73 100644 --- a/forester/java/src/org/forester/util/ForesterConstants.java +++ b/forester/java/src/org/forester/util/ForesterConstants.java @@ -28,7 +28,7 @@ package org.forester.util; public final class ForesterConstants { public final static String FORESTER_VERSION = "1.039"; - public final static String FORESTER_DATE = "150513"; + public final static String FORESTER_DATE = "160622"; public final static String PHYLO_XML_VERSION = "1.10"; public final static String PHYLO_XML_LOCATION = "http://www.phyloxml.org"; public final static String PHYLO_XML_XSD = "phyloxml.xsd"; diff --git a/forester/java/src/org/forester/util/ForesterUtil.java b/forester/java/src/org/forester/util/ForesterUtil.java index b3eb0f2..48d973b 100644 --- a/forester/java/src/org/forester/util/ForesterUtil.java +++ b/forester/java/src/org/forester/util/ForesterUtil.java @@ -42,6 +42,8 @@ import java.io.Writer; import java.math.BigDecimal; import java.net.URL; import java.net.URLConnection; +import java.security.KeyManagementException; +import java.security.NoSuchAlgorithmException; import java.text.DateFormat; import java.text.DecimalFormat; import java.text.DecimalFormatSymbols; @@ -62,11 +64,14 @@ import java.util.TreeSet; import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.forester.archaeopteryx.Constants; +import org.forester.archaeopteryx.AptxConstants; +import org.forester.io.parsers.PhylogenyParser; +import org.forester.phylogeny.Phylogeny; import org.forester.phylogeny.PhylogenyNode; import org.forester.phylogeny.data.Distribution; import org.forester.phylogeny.data.Sequence; import org.forester.phylogeny.data.Taxonomy; +import org.forester.phylogeny.factories.ParserBasedPhylogenyFactory; import org.forester.protein.BasicProtein; import org.forester.protein.Domain; import org.forester.protein.Protein; @@ -646,7 +651,7 @@ public final class ForesterUtil { return OS_NAME.toLowerCase().startsWith( "mac" ); } catch ( final Exception e ) { - ForesterUtil.printWarningMessage( Constants.PRG_NAME, "minor error: " + e ); + ForesterUtil.printWarningMessage( AptxConstants.PRG_NAME, "minor error: " + e ); return false; } } @@ -683,7 +688,7 @@ public final class ForesterUtil { return OS_NAME.toLowerCase().indexOf( "win" ) > -1; } catch ( final Exception e ) { - ForesterUtil.printWarningMessage( Constants.PRG_NAME, "minor error: " + e ); + ForesterUtil.printWarningMessage( AptxConstants.PRG_NAME, "minor error: " + e ); return false; } } @@ -1413,6 +1418,44 @@ public final class ForesterUtil { return sb.toString(); } + + public final static Phylogeny[] readPhylogeniesFromUrl( final URL url, + final PhylogenyParser parser ) + throws NoSuchAlgorithmException, IOException, KeyManagementException { + if ( url == null ) { + throw new IllegalArgumentException( "URL to read from must not be null" ); + } + else if ( parser == null ) { + throw new IllegalArgumentException( "parser to use to read from URL must not be null" ); + } + final URLConnection con; + if ( url.toString().startsWith( "https:" ) ) { + con = TrustManager.makeHttpsURLConnection( url ); + } + else if ( url.toString().startsWith( "http:" ) ) { + con = url.openConnection(); + } + else { + throw new IllegalArgumentException( "Cannot deal with URL: " + url ); + } + if ( con == null ) { + throw new IOException( "could not create connection from " + url ); + } + con.setDefaultUseCaches( false ); + final InputStream is = con.getInputStream(); + if ( is == null ) { + throw new IOException( "could not create input stream from " + url ); + } + final Phylogeny[] trees = ParserBasedPhylogenyFactory.getInstance().create( is, parser ); + try { + is.close(); + } + catch ( final Exception e ) { + // ignore + } + return trees; + } + private ForesterUtil() { } } diff --git a/forester/java/src/org/forester/util/TrustManager.java b/forester/java/src/org/forester/util/TrustManager.java index e907295..92de72b 100644 --- a/forester/java/src/org/forester/util/TrustManager.java +++ b/forester/java/src/org/forester/util/TrustManager.java @@ -11,7 +11,7 @@ import javax.net.ssl.HttpsURLConnection; import javax.net.ssl.SSLContext; import javax.net.ssl.X509TrustManager; -public class TrustManager implements X509TrustManager { +final class TrustManager implements X509TrustManager { @Override public X509Certificate[] getAcceptedIssuers() { @@ -28,7 +28,7 @@ public class TrustManager implements X509TrustManager { throws CertificateException { } - public final static HttpsURLConnection makeHttpsURLConnection( final URL url ) throws NoSuchAlgorithmException, + final static HttpsURLConnection makeHttpsURLConnection( final URL url ) throws NoSuchAlgorithmException, IOException, KeyManagementException { -- 1.7.10.2