clean up
authorcmzmasek@gmail.com <cmzmasek@gmail.com@ca865154-3058-d1c3-3e42-d8f55a55bdbd>
Wed, 20 Aug 2014 02:48:23 +0000 (02:48 +0000)
committercmzmasek@gmail.com <cmzmasek@gmail.com@ca865154-3058-d1c3-3e42-d8f55a55bdbd>
Wed, 20 Aug 2014 02:48:23 +0000 (02:48 +0000)
forester/java/src/org/forester/archaeopteryx/ArchaeopteryxE.java
forester/java/src/org/forester/archaeopteryx/TreePanel.java

index 71e58a5..77355ea 100644 (file)
@@ -608,12 +608,18 @@ public class ArchaeopteryxE extends JApplet implements ActionListener {
             }
         } );
         if ( getConfiguration().isUseTabbedDisplay() ) {
-            AptxUtil.printAppletMessage( NAME, "using tabbed display" );
-            AptxUtil.addPhylogeniesToTabs( phys,
-                                           new File( phys_url.getFile() ).getName(),
-                                           phys_url.toString(),
-                                           getConfiguration(),
-                                           getMainPanel() );
+            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" );
@@ -623,28 +629,34 @@ public class ArchaeopteryxE extends JApplet implements ActionListener {
             }
             AptxUtil.addPhylogenyToPanel( phys, getConfiguration(), getMainPanel() );
         }
-        validate();
-        setName( NAME );
-        getMainPanel().getControlPanel().showWholeAll();
-        getMainPanel().getControlPanel().showWhole();
-        /* 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 */
-        System.gc();
-        AptxUtil.printAppletMessage( NAME, "successfully initialized" );
-        setVisible( true );
+        try {
+            validate();
+            setName( NAME );
+            getMainPanel().getControlPanel().showWholeAll();
+            getMainPanel().getControlPanel().showWhole();
+            /* 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 */
+            System.gc();
+            AptxUtil.printAppletMessage( NAME, "successfully initialized" );
+            setVisible( true );
+        }
+        catch ( final Exception e ) {
+            ForesterUtil.printErrorMessage( NAME, e.toString() );
+            e.printStackTrace();
+        }
     }
 
     public void showTextFrame( final String s, final String title ) {
index b94b97b..341a8cb 100644 (file)
@@ -3426,47 +3426,52 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
     }
 
     private final void nodeDataAsSB( final PhylogenyNode node, final StringBuilder sb ) {
-        if ( getControlPanel().isShowNodeNames() && ( node.getName().length() > 0 ) ) {
-            if ( sb.length() > 0 ) {
-                sb.append( " " );
-            }
-            sb.append( node.getName() );
-        }
-        if ( node.getNodeData().isHasSequence() ) {
-            if ( getControlPanel().isShowSeqSymbols() && ( node.getNodeData().getSequence().getSymbol().length() > 0 ) ) {
+        if ( node != null ) {
+            if ( getControlPanel().isShowNodeNames() && ( !ForesterUtil.isEmpty( node.getName() ) ) ) {
                 if ( sb.length() > 0 ) {
                     sb.append( " " );
                 }
-                sb.append( node.getNodeData().getSequence().getSymbol() );
+                sb.append( node.getName() );
             }
-            if ( getControlPanel().isShowGeneNames() && ( node.getNodeData().getSequence().getGeneName().length() > 0 ) ) {
-                if ( sb.length() > 0 ) {
-                    sb.append( " " );
+            if ( node.getNodeData().isHasSequence() ) {
+                if ( getControlPanel().isShowSeqSymbols()
+                        && ( node.getNodeData().getSequence().getSymbol().length() > 0 ) ) {
+                    if ( sb.length() > 0 ) {
+                        sb.append( " " );
+                    }
+                    sb.append( node.getNodeData().getSequence().getSymbol() );
                 }
-                sb.append( node.getNodeData().getSequence().getGeneName() );
-            }
-            if ( getControlPanel().isShowSeqNames() && ( node.getNodeData().getSequence().getName().length() > 0 ) ) {
-                if ( sb.length() > 0 ) {
-                    sb.append( " " );
+                if ( getControlPanel().isShowGeneNames()
+                        && ( node.getNodeData().getSequence().getGeneName().length() > 0 ) ) {
+                    if ( sb.length() > 0 ) {
+                        sb.append( " " );
+                    }
+                    sb.append( node.getNodeData().getSequence().getGeneName() );
+                }
+                if ( getControlPanel().isShowSeqNames() && ( node.getNodeData().getSequence().getName().length() > 0 ) ) {
+                    if ( sb.length() > 0 ) {
+                        sb.append( " " );
+                    }
+                    sb.append( node.getNodeData().getSequence().getName() );
+                }
+                if ( getControlPanel().isShowSequenceAcc()
+                        && ( node.getNodeData().getSequence().getAccession() != null ) ) {
+                    if ( sb.length() > 0 ) {
+                        sb.append( " " );
+                    }
+                    if ( !ForesterUtil.isEmpty( node.getNodeData().getSequence().getAccession().getSource() ) ) {
+                        sb.append( node.getNodeData().getSequence().getAccession().getSource() );
+                        sb.append( ":" );
+                    }
+                    sb.append( node.getNodeData().getSequence().getAccession().getValue() );
                 }
-                sb.append( node.getNodeData().getSequence().getName() );
             }
-            if ( getControlPanel().isShowSequenceAcc() && ( node.getNodeData().getSequence().getAccession() != null ) ) {
+            if ( getControlPanel().isShowProperties() && node.getNodeData().isHasProperties() ) {
                 if ( sb.length() > 0 ) {
                     sb.append( " " );
                 }
-                if ( !ForesterUtil.isEmpty( node.getNodeData().getSequence().getAccession().getSource() ) ) {
-                    sb.append( node.getNodeData().getSequence().getAccession().getSource() );
-                    sb.append( ":" );
-                }
-                sb.append( node.getNodeData().getSequence().getAccession().getValue() );
-            }
-        }
-        if ( getControlPanel().isShowProperties() && node.getNodeData().isHasProperties() ) {
-            if ( sb.length() > 0 ) {
-                sb.append( " " );
+                sb.append( propertiesToString( node ) );
             }
-            sb.append( propertiesToString( node ) );
         }
     }