import javax.swing.JApplet;
import javax.swing.UIManager;
+import org.forester.io.parsers.nhx.NHXParser.TAXONOMY_EXTRACTION;
import org.forester.phylogeny.Phylogeny;
import org.forester.util.ForesterUtil;
public class ArchaeopteryxA extends JApplet {
- private static final long serialVersionUID = 2314899014580484146L;
- private final static Color background_color = new Color( 0, 0, 0 );
- private final static Color font_color = new Color( 0, 255, 0 );
- private final static Color ex_background_color = new Color( 0, 0, 0 );
- private final static Color ex_font_color = new Color( 255, 0, 0 );
- private final static Font font = new Font( Configuration.getDefaultFontFamilyName(), Font.BOLD, 9 );
+ private static final long serialVersionUID = 2314899014580484146L;
+ private final static Color background_color = new Color( 0, 0, 0 );
+ private final static Color font_color = new Color( 0, 255, 0 );
+ private final static Color ex_background_color = new Color( 0, 0, 0 );
+ private final static Color ex_font_color = new Color( 255, 0, 0 );
+ private final static Font font = new Font( Configuration.getDefaultFontFamilyName(), Font.BOLD, 9 );
private MainFrameApplet _mainframe_applet;
- private String _url_string = "";
- private String _message_1 = "";
- private String _message_2 = "";
- public final static String NAME = "ArchaeopteryxA";
+ private String _tree_url_str = "";
+ private String _species_tree_url_str = "";
+ private String _message_1 = "";
+ private String _message_2 = "";
+ public final static String NAME = "ArchaeopteryxA";
@Override
public void destroy() {
return getMainFrameApplet().getCurrentTreePanel().getCurrentExternalNodesDataBufferAsString().length();
}
- public String getUrlString() {
- return _url_string;
+ public String getTreeUrlStr() {
+ return _tree_url_str;
+ }
+
+ public String getSpeciesTreeUrlStr() {
+ return _species_tree_url_str;
}
@Override
public void init() {
boolean has_exception = false;
setName( NAME );
- setUrlString( getParameter( Constants.APPLET_PARAM_NAME_FOR_URL_OF_TREE_TO_LOAD ) );
- AptxUtil.printAppletMessage( NAME, "URL of phylogenies to load: \"" + getUrlString() + "\"" );
+ 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 ) );
+ if ( !ForesterUtil.isEmpty( getTreeUrlStr() ) ) {
+ AptxUtil.printAppletMessage( NAME, "URL of tree(s) to load: \"" + getTreeUrlStr() + "\"" );
+ }
+ else {
+ ForesterUtil.printErrorMessage( NAME, "no URL for tree(s) to load!" );
+ setBackground( ex_background_color );
+ setForeground( ex_font_color );
+ has_exception = true;
+ setMessage1( "no URL for tree(s) to load" );
+ repaint();
+ }
+ if ( !ForesterUtil.isEmpty( getSpeciesTreeUrlStr() ) ) {
+ AptxUtil.printAppletMessage( NAME, "URL of species tree to load: \"" + getSpeciesTreeUrlStr() + "\"" );
+ }
setBackground( background_color );
setForeground( font_color );
setFont( font );
}
setVisible( false );
_mainframe_applet = new MainFrameApplet( this, configuration );
- URL url = null;
- url = new URL( getUrlString() );
- final Phylogeny[] phys = AptxUtil.readPhylogeniesFromUrl( url, configuration
+ final URL tree_url = new URL( getTreeUrlStr() );
+ final Phylogeny[] phys = AptxUtil.readPhylogeniesFromUrl( tree_url, configuration
.isValidatePhyloXmlAgainstSchema(), configuration.isReplaceUnderscoresInNhParsing(), configuration
.isInternalNumberAreConfidenceForNhParsing(), configuration.getTaxonomyExtraction() );
AptxUtil.addPhylogeniesToTabs( phys,
- new File( url.getFile() ).getName(),
- getUrlString(),
+ new File( tree_url.getFile() ).getName(),
+ getTreeUrlStr(),
getMainFrameApplet().getConfiguration(),
getMainFrameApplet().getMainPanel() );
+ if ( !ForesterUtil.isEmpty( getSpeciesTreeUrlStr() ) ) {
+ final URL species_tree_url = new URL( getSpeciesTreeUrlStr() );
+ final Phylogeny[] species_trees = AptxUtil
+ .readPhylogeniesFromUrl( species_tree_url,
+ configuration.isValidatePhyloXmlAgainstSchema(),
+ configuration.isReplaceUnderscoresInNhParsing(),
+ false,
+ TAXONOMY_EXTRACTION.NO );
+ if ( ( species_trees != null ) && ( species_trees.length > 0 ) ) {
+ AptxUtil.printAppletMessage( NAME, "successfully read species tree" );
+ getMainFrameApplet().setSpeciesTree( species_trees[ 0 ] );
+ }
+ }
getMainFrameApplet().getMainPanel().getControlPanel().showWholeAll();
getMainFrameApplet().getMainPanel().getControlPanel().showWhole();
setVisible( true );
_message_2 = message_2;
}
- private void setUrlString( final String url_string ) {
- _url_string = url_string;
+ private void setTreeUrlStr( final String url_string ) {
+ _tree_url_str = url_string;
+ }
+
+ private void setSpeciesTreeUrlStr( final String url_string ) {
+ _species_tree_url_str = url_string;
}
}
URL url = null;
Phylogeny[] phys = null;
// Get URL to tree file
- if ( _applet.getUrlString() != null ) {
+ if ( _applet.getTreeUrlStr() != null ) {
try {
- url = new URL( _applet.getUrlString() );
+ url = new URL( _applet.getTreeUrlStr() );
}
catch ( final Exception e ) {
ForesterUtil.printErrorMessage( ArchaeopteryxA.NAME, e.toString() );
e.printStackTrace();
JOptionPane.showMessageDialog( this,
ArchaeopteryxA.NAME + ": Could not create URL from: \""
- + _applet.getUrlString() + "\"\nError: " + e,
+ + _applet.getTreeUrlStr() + "\"\nError: " + e,
"Failed to create URL",
JOptionPane.ERROR_MESSAGE );
close();
if ( !_configuration.isUseNativeUI() ) {
_jmenubar.setBackground( _configuration.getGuiMenuBackgroundColor() );
}
+ //TODO if species tree...
+ buildAnalysisMenu();
buildToolsMenu();
buildViewMenu();
buildFontSizeMenu();
System.gc();
}
+ void buildAnalysisMenu() {
+ _analysis_menu = MainFrame.createMenu( "Analysis", getConfiguration() );
+ _analysis_menu.add( _gsdi_item = new JMenuItem( "GSDI (Generalized Speciation Duplication Inference)" ) );
+ _analysis_menu.add( _gsdir_item = new JMenuItem( "GSDIR (GSDI with re-rooting)" ) );
+ customizeJMenuItem( _gsdi_item );
+ customizeJMenuItem( _gsdir_item );
+ // _analysis_menu.addSeparator();
+ // _analysis_menu.add( _lineage_inference = new JMenuItem( INFER_ANCESTOR_TAXONOMIES ) );
+ // customizeJMenuItem( _lineage_inference );
+ // _lineage_inference.setToolTipText( "Inference of ancestor taxonomies/lineages" );
+ _jmenubar.add( _analysis_menu );
+ }
+
void buildOptionsMenu() {
_options_jmenu = MainFrame.createMenu( MainFrame.OPTIONS_HEADER, getConfiguration() );
_options_jmenu.addChangeListener( new ChangeListener() {
void readPhylogeniesFromURL() {
throw new NoSuchMethodError( "not implemented" );
}
+
+ void setSpeciesTree( final Phylogeny species_tree ) {
+ _species_tree = species_tree;
+ }
}