in progress
authorcmzmasek@gmail.com <cmzmasek@gmail.com@ca865154-3058-d1c3-3e42-d8f55a55bdbd>
Mon, 25 Aug 2014 20:34:07 +0000 (20:34 +0000)
committercmzmasek@gmail.com <cmzmasek@gmail.com@ca865154-3058-d1c3-3e42-d8f55a55bdbd>
Mon, 25 Aug 2014 20:34:07 +0000 (20:34 +0000)
forester/java/src/org/forester/archaeopteryx/ArchaeopteryxE.java
forester/java/src/org/forester/archaeopteryx/Constants.java
forester/java/src/org/forester/archaeopteryx/ControlPanel.java

index 7f22501..251a43c 100644 (file)
@@ -566,66 +566,62 @@ public class ArchaeopteryxE extends JApplet implements ActionListener {
             }
         }
         //
-        setVisible( false );
-        setMainPanel( new MainPanelApplets( getConfiguration(), this ) );
-        _jmenubar = new JMenuBar();
-        if ( !getConfiguration().isHideControlPanelAndMenubar() ) {
-            if ( !getConfiguration().isUseNativeUI() ) {
-                _jmenubar.setBackground( getConfiguration().getGuiMenuBackgroundColor() );
-            }
-            if ( getSpeciesTree() != null ) {
-                buildAnalysisMenu();
-            }
-            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().calcParametersForPainting( getMainPanel()
-                                                                                            .getCurrentTreePanel()
-                                                                                            .getWidth(),
-                                                                                    getMainPanel()
-                                                                                            .getCurrentTreePanel()
-                                                                                            .getHeight(),
-                                                                                    getOptions()
-                                                                                            .isAllowFontSizeChange() );
+        try {
+            setVisible( false );
+            setMainPanel( new MainPanelApplets( getConfiguration(), this ) );
+            _jmenubar = new JMenuBar();
+            if ( !getConfiguration().isHideControlPanelAndMenubar() ) {
+                if ( !getConfiguration().isUseNativeUI() ) {
+                    _jmenubar.setBackground( getConfiguration().getGuiMenuBackgroundColor() );
                 }
+                if ( getSpeciesTree() != null ) {
+                    buildAnalysisMenu();
+                }
+                buildToolsMenu();
+                buildViewMenu();
+                buildFontSizeMenu();
+                buildOptionsMenu();
+                buildTypeMenu();
+                buildHelpMenu();
+                setJMenuBar( _jmenubar );
             }
-        } );
-        if ( getConfiguration().isUseTabbedDisplay() ) {
-            try {
-                AptxUtil.printAppletMessage( NAME, "using tabbed display" );
-                AptxUtil.addPhylogeniesToTabs( phys,
-                                               new File( phys_url.getFile() ).getName(),
-                                               phys_url.toString(),
-                                               getConfiguration(),
-                                               getMainPanel() );
-            }
-            catch ( final Exception e ) {
-                ForesterUtil.printErrorMessage( NAME, e.toString() );
-                e.printStackTrace();
+            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()
+                                .calcParametersForPainting( getMainPanel().getCurrentTreePanel().getWidth(),
+                                                            getMainPanel().getCurrentTreePanel().getHeight(),
+                                                            getOptions().isAllowFontSizeChange() );
+                    }
+                }
+            } );
+            if ( getConfiguration().isUseTabbedDisplay() ) {
+                try {
+                    AptxUtil.printAppletMessage( NAME, "using tabbed display" );
+                    AptxUtil.addPhylogeniesToTabs( phys,
+                                                   new File( phys_url.getFile() ).getName(),
+                                                   phys_url.toString(),
+                                                   getConfiguration(),
+                                                   getMainPanel() );
+                }
+                catch ( final Exception e ) {
+                    ForesterUtil.printErrorMessage( NAME, e.toString() );
+                    e.printStackTrace();
+                }
             }
-        }
-        else {
-            AptxUtil.printAppletMessage( NAME, "not using tabbed display" );
-            if ( getSpeciesTree() != null ) {
-                AptxUtil.printAppletMessage( NAME,
-                                             "Warning: gsdi (gene duplication inference) only available tabbed display" );
+            else {
+                AptxUtil.printAppletMessage( NAME, "not using tabbed display" );
+                if ( getSpeciesTree() != null ) {
+                    AptxUtil.printAppletMessage( NAME,
+                                                 "Warning: gsdi (gene duplication inference) only available tabbed display" );
+                }
+                AptxUtil.addPhylogenyToPanel( phys, getConfiguration(), getMainPanel() );
             }
-            AptxUtil.addPhylogenyToPanel( phys, getConfiguration(), getMainPanel() );
-        }
-        try {
             validate();
             setName( NAME );
             getMainPanel().getControlPanel().showWholeAll();
@@ -1465,7 +1461,7 @@ public class ArchaeopteryxE extends JApplet implements ActionListener {
         }
     }
 
-    private MainPanel getMainPanel() {
+    MainPanel getMainPanel() {
         return _mainpanel;
     }
 
index e5564bc..502d883 100644 (file)
@@ -42,8 +42,8 @@ public final class Constants {
     public final static boolean __SYNTH_LF                                                    = false;                                                                             // TODO remove me
     public final static boolean ALLOW_DDBJ_BLAST                                              = false;
     public final static String  PRG_NAME                                                      = "Archaeopteryx";
-    final static String         VERSION                                                       = "0.9896 beta";
-    final static String         PRG_DATE                                                      = "140822";
+    final static String         VERSION                                                       = "0.9897 beta";
+    final static String         PRG_DATE                                                      = "140824";
     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"  };
index 789edcc..01adbb8 100644 (file)
@@ -2305,122 +2305,138 @@ final class ControlPanel extends JPanel implements ActionListener {
 
     private void setVisibilityOfDomainStrucureControls() {
         if ( _zoom_in_domain_structure != null ) {
-            if ( isShowDomainArchitectures() ) {
-                _domain_display_label.setVisible( true );
-                _zoom_in_domain_structure.setVisible( true );
-                _zoom_out_domain_structure.setVisible( true );
-                _decr_domain_structure_evalue_thr.setVisible( true );
-                _incr_domain_structure_evalue_thr.setVisible( true );
-                _domain_structure_evalue_thr_tf.setVisible( true );
-                if ( getMainPanel().getMainFrame()._right_line_up_domains_cbmi != null ) {
-                    getMainPanel().getMainFrame()._right_line_up_domains_cbmi.setVisible( true );
+            final MainFrame mf = getMainFrame();
+            if ( mf != null ) {
+                if ( isShowDomainArchitectures() ) {
+                    _domain_display_label.setVisible( true );
+                    _zoom_in_domain_structure.setVisible( true );
+                    _zoom_out_domain_structure.setVisible( true );
+                    _decr_domain_structure_evalue_thr.setVisible( true );
+                    _incr_domain_structure_evalue_thr.setVisible( true );
+                    _domain_structure_evalue_thr_tf.setVisible( true );
+                    if ( mf._right_line_up_domains_cbmi != null ) {
+                        mf._right_line_up_domains_cbmi.setVisible( true );
+                    }
+                    if ( mf._show_domain_labels != null ) {
+                        mf._show_domain_labels.setVisible( true );
+                    }
                 }
-                if ( getMainPanel().getMainFrame()._show_domain_labels != null ) {
-                    getMainPanel().getMainFrame()._show_domain_labels.setVisible( true );
+                else {
+                    _domain_display_label.setVisible( false );
+                    _zoom_in_domain_structure.setVisible( false );
+                    _zoom_out_domain_structure.setVisible( false );
+                    _decr_domain_structure_evalue_thr.setVisible( false );
+                    _incr_domain_structure_evalue_thr.setVisible( false );
+                    _domain_structure_evalue_thr_tf.setVisible( false );
+                    if ( mf._right_line_up_domains_cbmi != null ) {
+                        mf._right_line_up_domains_cbmi.setVisible( false );
+                    }
+                    if ( mf._show_domain_labels != null ) {
+                        mf._show_domain_labels.setVisible( false );
+                    }
                 }
             }
-            else {
-                _domain_display_label.setVisible( false );
-                _zoom_in_domain_structure.setVisible( false );
-                _zoom_out_domain_structure.setVisible( false );
-                _decr_domain_structure_evalue_thr.setVisible( false );
-                _incr_domain_structure_evalue_thr.setVisible( false );
-                _domain_structure_evalue_thr_tf.setVisible( false );
-                if ( getMainPanel().getMainFrame()._right_line_up_domains_cbmi != null ) {
-                    getMainPanel().getMainFrame()._right_line_up_domains_cbmi.setVisible( false );
-                }
-                if ( getMainPanel().getMainFrame()._show_domain_labels != null ) {
-                    getMainPanel().getMainFrame()._show_domain_labels.setVisible( false );
-                }
+        }
+    }
+
+    // This takes care of ArchaeopteryxE-issue.
+    // Can, and will, return null prior to  ArchaeopteryxE initialization completion.
+    final private MainFrame getMainFrame() {
+        MainFrame mf = getMainPanel().getMainFrame();
+        if ( mf == null ) {
+            // Must be "E" applet version.
+            final ArchaeopteryxE e = ( ArchaeopteryxE ) ( ( MainPanelApplets ) getMainPanel() ).getApplet();
+            if ( e.getMainPanel() == null ) {
+                return null;
             }
+            mf = e.getMainPanel().getMainFrame();
         }
+        return mf;
     }
 
     void setVisibilityOfX() {
-        try {
+        final MainFrame mf = getMainFrame();
+        if ( mf != null ) {
             if ( ( getCurrentTreePanel() != null ) && ( getCurrentTreePanel().getPhylogeny() != null ) ) {
                 if ( AptxUtil.isHasAtLeastOneBranchWithSupportSD( getCurrentTreePanel().getPhylogeny() ) ) {
-                    if ( getMainPanel().getMainFrame()._show_confidence_stddev_cbmi != null ) {
-                        getMainPanel().getMainFrame()._show_confidence_stddev_cbmi.setVisible( true );
+                    if ( mf._show_confidence_stddev_cbmi != null ) {
+                        mf._show_confidence_stddev_cbmi.setVisible( true );
                     }
                 }
                 else {
-                    if ( getMainPanel().getMainFrame()._show_confidence_stddev_cbmi != null ) {
-                        getMainPanel().getMainFrame()._show_confidence_stddev_cbmi.setVisible( false );
+                    if ( mf._show_confidence_stddev_cbmi != null ) {
+                        mf._show_confidence_stddev_cbmi.setVisible( false );
                     }
                 }
                 if ( AptxUtil.isHasAtLeastOneNodeWithScientificName( getCurrentTreePanel().getPhylogeny() ) ) {
-                    if ( getMainPanel().getMainFrame()._abbreviate_scientific_names != null ) {
-                        getMainPanel().getMainFrame()._abbreviate_scientific_names.setVisible( true );
+                    if ( mf._abbreviate_scientific_names != null ) {
+                        mf._abbreviate_scientific_names.setVisible( true );
                     }
                 }
                 else {
-                    if ( getMainPanel().getMainFrame()._abbreviate_scientific_names != null ) {
-                        getMainPanel().getMainFrame()._abbreviate_scientific_names.setVisible( false );
+                    if ( mf._abbreviate_scientific_names != null ) {
+                        mf._abbreviate_scientific_names.setVisible( false );
                     }
                 }
                 if ( AptxUtil.isHasAtLeastOneNodeWithSequenceAnnotation( getCurrentTreePanel().getPhylogeny() ) ) {
-                    if ( getMainPanel().getMainFrame()._show_annotation_ref_source != null ) {
-                        getMainPanel().getMainFrame()._show_annotation_ref_source.setVisible( true );
+                    if ( mf._show_annotation_ref_source != null ) {
+                        mf._show_annotation_ref_source.setVisible( true );
                     }
                 }
                 else {
-                    if ( getMainPanel().getMainFrame()._show_annotation_ref_source != null ) {
-                        getMainPanel().getMainFrame()._show_annotation_ref_source.setVisible( false );
+                    if ( mf._show_annotation_ref_source != null ) {
+                        mf._show_annotation_ref_source.setVisible( false );
                     }
                 }
             }
             if ( isDrawPhylogram()
                     || ( ( getCurrentTreePanel() != null ) && ( ( getCurrentTreePanel().getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) || ( getCurrentTreePanel()
                             .getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) ) ) ) {
-                if ( getMainPanel().getMainFrame()._non_lined_up_cladograms_rbmi != null ) {
-                    getMainPanel().getMainFrame()._non_lined_up_cladograms_rbmi.setVisible( false );
+                if ( mf._non_lined_up_cladograms_rbmi != null ) {
+                    mf._non_lined_up_cladograms_rbmi.setVisible( false );
                 }
-                if ( getMainPanel().getMainFrame()._uniform_cladograms_rbmi != null ) {
-                    getMainPanel().getMainFrame()._uniform_cladograms_rbmi.setVisible( false );
+                if ( mf._uniform_cladograms_rbmi != null ) {
+                    mf._uniform_cladograms_rbmi.setVisible( false );
                 }
-                if ( getMainPanel().getMainFrame()._ext_node_dependent_cladogram_rbmi != null ) {
-                    getMainPanel().getMainFrame()._ext_node_dependent_cladogram_rbmi.setVisible( false );
+                if ( mf._ext_node_dependent_cladogram_rbmi != null ) {
+                    mf._ext_node_dependent_cladogram_rbmi.setVisible( false );
                 }
             }
             else {
-                if ( getMainPanel().getMainFrame()._non_lined_up_cladograms_rbmi != null ) {
-                    getMainPanel().getMainFrame()._non_lined_up_cladograms_rbmi.setVisible( true );
+                if ( mf._non_lined_up_cladograms_rbmi != null ) {
+                    mf._non_lined_up_cladograms_rbmi.setVisible( true );
                 }
-                if ( getMainPanel().getMainFrame()._uniform_cladograms_rbmi != null ) {
-                    getMainPanel().getMainFrame()._uniform_cladograms_rbmi.setVisible( true );
+                if ( mf._uniform_cladograms_rbmi != null ) {
+                    mf._uniform_cladograms_rbmi.setVisible( true );
                 }
-                if ( getMainPanel().getMainFrame()._ext_node_dependent_cladogram_rbmi != null ) {
-                    getMainPanel().getMainFrame()._ext_node_dependent_cladogram_rbmi.setVisible( true );
+                if ( mf._ext_node_dependent_cladogram_rbmi != null ) {
+                    mf._ext_node_dependent_cladogram_rbmi.setVisible( true );
                 }
             }
             if ( isDrawPhylogram() ) {
-                if ( getMainPanel().getMainFrame()._show_scale_cbmi != null ) {
-                    getMainPanel().getMainFrame()._show_scale_cbmi.setVisible( true );
+                if ( mf._show_scale_cbmi != null ) {
+                    mf._show_scale_cbmi.setVisible( true );
                 }
             }
             else {
-                if ( getMainPanel().getMainFrame()._show_scale_cbmi != null ) {
-                    getMainPanel().getMainFrame()._show_scale_cbmi.setVisible( false );
+                if ( mf._show_scale_cbmi != null ) {
+                    mf._show_scale_cbmi.setVisible( false );
                 }
             }
             if ( getCurrentTreePanel() != null ) {
                 if ( ( getCurrentTreePanel().getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
                         || ( getCurrentTreePanel().getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) ) {
-                    if ( getMainPanel().getMainFrame()._label_direction_cbmi != null ) {
-                        getMainPanel().getMainFrame()._label_direction_cbmi.setVisible( true );
+                    if ( mf._label_direction_cbmi != null ) {
+                        mf._label_direction_cbmi.setVisible( true );
                     }
                 }
                 else {
-                    if ( getMainPanel().getMainFrame()._label_direction_cbmi != null ) {
-                        getMainPanel().getMainFrame()._label_direction_cbmi.setVisible( false );
+                    if ( mf._label_direction_cbmi != null ) {
+                        mf._label_direction_cbmi.setVisible( false );
                     }
                 }
             }
         }
-        catch ( final Exception ignore ) {
-            //not important...
-        }
     }
 
     void setVisibilityOfDomainStrucureCB() {