From 0fb29dd98e982b9a5121754b447bf19f982dbde3 Mon Sep 17 00:00:00 2001 From: "cmzmasek@gmail.com" Date: Mon, 8 Oct 2012 21:22:21 +0000 Subject: [PATCH] 1st fix of embedded applet null pointer "issue"... ^^ --- .../org/forester/archaeopteryx/ArchaeopteryxE.java | 49 +++++++++++--------- .../org/forester/archaeopteryx/Configuration.java | 2 +- .../src/org/forester/archaeopteryx/TreePanel.java | 9 +++- 3 files changed, 37 insertions(+), 23 deletions(-) diff --git a/forester/java/src/org/forester/archaeopteryx/ArchaeopteryxE.java b/forester/java/src/org/forester/archaeopteryx/ArchaeopteryxE.java index 7ba34f4..6b3f74f 100644 --- a/forester/java/src/org/forester/archaeopteryx/ArchaeopteryxE.java +++ b/forester/java/src/org/forester/archaeopteryx/ArchaeopteryxE.java @@ -72,6 +72,7 @@ public class ArchaeopteryxE extends JApplet implements ActionListener { private JMenuItem _view_as_NH_item; private JMenuItem _view_as_NHX_item; private JMenuItem _view_as_nexus_item; + private JMenuItem _display_basic_information_item; private JMenu _type_menu; private JCheckBoxMenuItem _rectangular_type_cbmi; private JCheckBoxMenuItem _triangular_type_cbmi; @@ -147,6 +148,9 @@ public class ArchaeopteryxE extends JApplet implements ActionListener { else if ( o == _switch_colors_mi ) { switchColors(); } + else if ( o == _display_basic_information_item ) { + displayBasicInformation(); + } else if ( o == _view_as_NH_item ) { viewAsNH(); } @@ -559,11 +563,14 @@ public class ArchaeopteryxE extends JApplet implements ActionListener { } void buildViewMenu() { - _view_jmenu = MainFrame.createMenu( "View as Text", getConfiguration() ); + _view_jmenu = MainFrame.createMenu( "View", getConfiguration() ); + _view_jmenu.add( _display_basic_information_item = new JMenuItem( "Display Basic Information" ) ); + _view_jmenu.addSeparator(); _view_jmenu.add( _view_as_XML_item = new JMenuItem( "View as phyloXML" ) ); _view_jmenu.add( _view_as_NH_item = new JMenuItem( "View as Newick" ) ); _view_jmenu.add( _view_as_NHX_item = new JMenuItem( "View as NHX" ) ); _view_jmenu.add( _view_as_nexus_item = new JMenuItem( "View as Nexus" ) ); + customizeJMenuItem( _display_basic_information_item ); customizeJMenuItem( _view_as_NH_item ); customizeJMenuItem( _view_as_NHX_item ); customizeJMenuItem( _view_as_XML_item ); @@ -1063,39 +1070,39 @@ public class ArchaeopteryxE extends JApplet implements ActionListener { } void viewAsNexus() { - removeTextFrame(); - if ( ( getMainPanel().getCurrentPhylogeny() == null ) || getMainPanel().getCurrentPhylogeny().isEmpty() - || ( getMainPanel().getCurrentPhylogeny().getNumberOfExternalNodes() > 10000 ) ) { - return; + if ( ( getMainPanel().getCurrentPhylogeny() != null ) && !getMainPanel().getCurrentPhylogeny().isEmpty() ) { + showTextFrame( getMainPanel().getCurrentPhylogeny().toNexus( getOptions() + .getNhConversionSupportValueStyle() ) ); } - _textframe = TextFrame.instantiate( getMainPanel().getCurrentPhylogeny().toNexus() ); } void viewAsNH() { - removeTextFrame(); - if ( ( getMainPanel().getCurrentPhylogeny() == null ) || getMainPanel().getCurrentPhylogeny().isEmpty() - || ( getMainPanel().getCurrentPhylogeny().getNumberOfExternalNodes() > 10000 ) ) { - return; + if ( ( getMainPanel().getCurrentPhylogeny() != null ) && !getMainPanel().getCurrentPhylogeny().isEmpty() ) { + showTextFrame( getMainPanel().getCurrentPhylogeny().toNewHampshire() ); } - _textframe = TextFrame.instantiate( getMainPanel().getCurrentPhylogeny().toNewHampshire() ); } void viewAsNHX() { - removeTextFrame(); - if ( ( getMainPanel().getCurrentPhylogeny() == null ) || getMainPanel().getCurrentPhylogeny().isEmpty() - || ( getMainPanel().getCurrentPhylogeny().getNumberOfExternalNodes() > 10000 ) ) { - return; + if ( ( getMainPanel().getCurrentPhylogeny() != null ) && !getMainPanel().getCurrentPhylogeny().isEmpty() ) { + showTextFrame( getMainPanel().getCurrentPhylogeny().toNewHampshireX() ); } - _textframe = TextFrame.instantiate( getMainPanel().getCurrentPhylogeny().toNewHampshireX() ); } void viewAsXML() { - removeTextFrame(); - if ( ( getMainPanel().getCurrentPhylogeny() == null ) || getMainPanel().getCurrentPhylogeny().isEmpty() - || ( getMainPanel().getCurrentPhylogeny().getNumberOfExternalNodes() > 10000 ) ) { - return; + if ( ( getMainPanel().getCurrentPhylogeny() != null ) && !getMainPanel().getCurrentPhylogeny().isEmpty() ) { + showTextFrame( getMainPanel().getCurrentPhylogeny().toPhyloXML( 0 ) ); } - _textframe = TextFrame.instantiate( getMainPanel().getCurrentPhylogeny().toPhyloXML( 0 ) ); + } + + void displayBasicInformation() { + if ( ( getMainPanel().getCurrentPhylogeny() != null ) && !getMainPanel().getCurrentPhylogeny().isEmpty() ) { + showTextFrame( AptxUtil.createBasicInformation( getMainPanel().getCurrentPhylogeny() ) ); + } + } + + public void showTextFrame( final String s ) { + removeTextFrame(); + _textframe = TextFrame.instantiate( s ); } static void setupScreenTextAntialias( final List treepanels, final boolean antialias ) { diff --git a/forester/java/src/org/forester/archaeopteryx/Configuration.java b/forester/java/src/org/forester/archaeopteryx/Configuration.java index 96299a3..1591e63 100644 --- a/forester/java/src/org/forester/archaeopteryx/Configuration.java +++ b/forester/java/src/org/forester/archaeopteryx/Configuration.java @@ -215,7 +215,7 @@ public final class Configuration { private Color _domain_structure_base_color = Constants.DOMAIN_STRUCTURE_BASE_COLOR_DEFAULT; private NODE_DATA _ext_desc_data_to_return = NODE_DATA.NODE_NAME; private String _label_for_get_ext_descendents_data = ""; - private EXT_NODE_DATA_RETURN_ON _ext_node_data_return_on = EXT_NODE_DATA_RETURN_ON.CONSOLE; + private EXT_NODE_DATA_RETURN_ON _ext_node_data_return_on = EXT_NODE_DATA_RETURN_ON.WINODW; private static String DEFAULT_FONT_FAMILY = ""; static { for( final String font_name : Constants.DEFAULT_FONT_CHOICES ) { diff --git a/forester/java/src/org/forester/archaeopteryx/TreePanel.java b/forester/java/src/org/forester/archaeopteryx/TreePanel.java index 7a643cc..1f237f7 100644 --- a/forester/java/src/org/forester/archaeopteryx/TreePanel.java +++ b/forester/java/src/org/forester/archaeopteryx/TreePanel.java @@ -1409,7 +1409,14 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee sb.append( d ); sb.append( "\n" ); } - getMainPanel().getMainFrame().showTextFrame( sb.toString() ); + if ( getMainPanel().getMainFrame() == null ) { + // Must be "E" applet version. + ( ( ArchaeopteryxE ) ( ( MainPanelApplets ) getMainPanel() ).getApplet() ).showTextFrame( sb + .toString() ); + } + else { + getMainPanel().getMainFrame().showTextFrame( sb.toString() ); + } } } } -- 1.7.10.2