+ public Options getOptions() {
+ return _options;
+ }
+
+ @Override
+ public void init() {
+ final String config_filename = getParameter( Constants.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();
+ URL phys_url = null;
+ Phylogeny[] phys = null;
+ final String phys_url_string = getParameter( Constants.APPLET_PARAM_NAME_FOR_URL_OF_TREE_TO_LOAD );
+ AptxUtil.printAppletMessage( NAME, "URL for phylogenies is " + phys_url_string );
+ // Get URL to tree file
+ if ( phys_url_string != null ) {
+ try {
+ phys_url = new URL( phys_url_string );
+ }
+ catch ( final Exception e ) {
+ ForesterUtil.printErrorMessage( NAME, "error: " + e );
+ e.printStackTrace();
+ JOptionPane.showMessageDialog( this, NAME + ": Could not create URL from: \"" + phys_url_string
+ + "\"\nException: " + e, "Failed to create URL", JOptionPane.ERROR_MESSAGE );
+ }
+ }
+ // Load the tree from URL
+ if ( phys_url != null ) {
+ try {
+ phys = AptxUtil.readPhylogeniesFromUrl( phys_url,
+ getConfiguration().isValidatePhyloXmlAgainstSchema(),
+ getConfiguration().isReplaceUnderscoresInNhParsing(),
+ getConfiguration().isInternalNumberAreConfidenceForNhParsing(),
+ getConfiguration().getTaxonomyExtraction() );
+ }
+ catch ( final Exception e ) {
+ ForesterUtil.printErrorMessage( NAME, e.toString() );
+ e.printStackTrace();
+ JOptionPane.showMessageDialog( this,
+ NAME + ": Failed to read phylogenies: " + "\nException: " + e,
+ "Failed to read phylogenies",
+ JOptionPane.ERROR_MESSAGE );
+ }
+ }
+ if ( ( phys == null ) || ( phys.length < 1 ) ) {
+ ForesterUtil.printErrorMessage( NAME, "phylogenies from [" + phys_url + "] are null or empty" );
+ JOptionPane.showMessageDialog( this,
+ NAME + ": phylogenies from [" + phys_url + "] are null or empty",
+ "Failed to read phylogenies",
+ JOptionPane.ERROR_MESSAGE );
+ return;
+ }
+ else {
+ AptxUtil.printAppletMessage( NAME, "loaded " + phys.length + " phylogenies from: " + phys_url );
+ }
+ setVisible( false );
+ setMainPanel( new MainPanelApplets( getConfiguration(), this ) );
+ _jmenubar = new JMenuBar();
+ if ( !getConfiguration().isHideControlPanelAndMenubar() ) {
+ if ( !getConfiguration().isUseNativeUI() ) {
+ _jmenubar.setBackground( getConfiguration().getGuiMenuBackgroundColor() );
+ }
+ buildToolsMenu();
+ buildViewMenu();
+ buildFontSizeMenu();
+ buildOptionsMenu();
+ buildTypeMenu();
+ buildHelpMenu();
+ setJMenuBar( _jmenubar );
+ }
+ final Container contentpane = getContentPane();
+ contentpane.setLayout( new BorderLayout() );
+ contentpane.add( getMainPanel(), BorderLayout.CENTER );
+ addComponentListener( new ComponentAdapter() {
+
+ @Override
+ public void componentResized( final ComponentEvent e ) {
+ if ( getMainPanel().getCurrentTreePanel() != null ) {
+ getMainPanel().getCurrentTreePanel().setParametersForPainting( getMainPanel().getCurrentTreePanel()
+ .getWidth(),
+ getMainPanel().getCurrentTreePanel()
+ .getHeight(),
+ false );
+ }
+ }
+ } );
+ if ( getConfiguration().isUseTabbedDisplay() ) {
+ AptxUtil.printAppletMessage( NAME, "using tabbed display" );
+ AptxUtil.addPhylogeniesToTabs( phys,
+ new File( phys_url.getFile() ).getName(),
+ phys_url.toString(),
+ getConfiguration(),
+ getMainPanel() );
+ }
+ else {
+ AptxUtil.printAppletMessage( NAME, "not using tabbed display" );
+ AptxUtil.addPhylogenyToPanel( phys, getConfiguration(), getMainPanel() );
+ }
+ validate();
+ setName( NAME );
+ getMainPanel().getControlPanel().showWholeAll();
+ getMainPanel().getControlPanel().showWhole();
+ System.gc();
+ AptxUtil.printAppletMessage( NAME, "successfully initialized" );
+ /* GUILHEM_BEG */
+ getCurrentTreePanel().getControlPanel().getSequenceRelationTypeBox().removeAllItems();
+ for( final SequenceRelation.SEQUENCE_RELATION_TYPE type : getMainPanel().getCurrentPhylogeny()
+ .getRelevantSequenceRelationTypes() ) {
+ getCurrentTreePanel().getControlPanel().getSequenceRelationTypeBox().addItem( type );
+ }
+ final String default_relation = getParameter( Constants.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 );
+ if ( default_sequence != null ) {
+ getCurrentTreePanel().getControlPanel().getSequenceRelationBox().setSelectedItem( default_sequence );
+ /* GUILHEM_END */
+ }
+ setVisible( true );
+ }
+
+ public void showTextFrame( final String s, final String title ) {
+ checkTextFrames();
+ _textframes.addLast( TextFrame.instantiate( s, title, _textframes ) );
+ }
+
+ @Override
+ public void start() {
+ if ( getMainPanel() != null ) {
+ getMainPanel().validate();
+ }
+ requestFocus();
+ requestFocusInWindow();
+ requestFocus();
+ AptxUtil.printAppletMessage( NAME, "started" );
+ }
+