// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
//
// Contact: phylosoft @ gmail . com
-// WWW: www.phylosoft.org/forester
+// WWW: https://sites.google.com/site/cmzmasek/home/software/forester
package org.forester.archaeopteryx;
import java.awt.event.ComponentEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.net.MalformedURLException;
import java.net.URL;
import javax.swing.ButtonGroup;
import javax.swing.JCheckBoxMenuItem;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
-import javax.swing.JOptionPane;
import javax.swing.JRadioButtonMenuItem;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import org.forester.archaeopteryx.Options.CLADOGRAM_TYPE;
import org.forester.archaeopteryx.Options.NODE_LABEL_DIRECTION;
+import org.forester.io.parsers.nhx.NHXParser.TAXONOMY_EXTRACTION;
import org.forester.phylogeny.Phylogeny;
import org.forester.util.ForesterUtil;
public final class MainFrameApplet extends MainFrame {
- private static final long serialVersionUID = 1941019292746717053L;
- private final static int FRAME_X_SIZE = 640, FRAME_Y_SIZE = 580;
+ private static final long serialVersionUID = 1941019292746717053L;
+ private final static int DEFAULT_FRAME_X_SIZE = 640;
+ private final static int DEFAULT_FRAME_Y_SIZE = 580;
private final ArchaeopteryxA _applet;
private ButtonGroup _radio_group_1;
- MainFrameApplet( final ArchaeopteryxA parent_applet, final Configuration configuration ) {
+ MainFrameApplet( final ArchaeopteryxA parent_applet,
+ final Configuration configuration,
+ final String species_tree_url_str ) {
setTitle( ArchaeopteryxA.NAME );
_applet = parent_applet;
setConfiguration( configuration );
setOptions( Options.createInstance( configuration ) );
- _textframe = null;
- URL url = null;
- Phylogeny[] phys = null;
- // Get URL to tree file
- if ( _applet.getUrlString() != null ) {
- try {
- url = new URL( _applet.getUrlString() );
- }
- 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,
- "Failed to create URL",
- JOptionPane.ERROR_MESSAGE );
- close();
- }
- }
- // Load the tree from URL
- if ( url != null ) {
+ _mainpanel = new MainPanelApplets( _configuration, this );
+ if ( !ForesterUtil.isEmpty( species_tree_url_str ) ) {
try {
- phys = Util.readPhylogeniesFromUrl( url, getConfiguration().isValidatePhyloXmlAgainstSchema() );
+ readSpeciesTree( configuration, species_tree_url_str );
}
catch ( final Exception e ) {
+ ForesterUtil.printErrorMessage( ArchaeopteryxA.NAME, "failed to read species tree from "
+ + species_tree_url_str );
ForesterUtil.printErrorMessage( ArchaeopteryxA.NAME, e.toString() );
- e.printStackTrace();
- JOptionPane.showMessageDialog( this, ArchaeopteryxA.NAME + ": Failed to read phylogenies: "
- + "\nError: " + e, "Failed to read phylogenies", JOptionPane.ERROR_MESSAGE );
- close();
}
}
- if ( ( phys == null ) || ( phys.length < 1 ) ) {
- ForesterUtil.printErrorMessage( ArchaeopteryxA.NAME, "phylogenies from [" + url + "] are null or empty" );
- JOptionPane.showMessageDialog( this, ArchaeopteryxA.NAME + ": phylogenies from [" + url
- + "] are null or empty", "Failed to read phylogenies", JOptionPane.ERROR_MESSAGE );
- }
- else {
- Util.printAppletMessage( ArchaeopteryxA.NAME, "loaded " + phys.length + " phylogenies from: " + url );
- }
- _mainpanel = new MainPanelApplets( _configuration, this );
// build the menu bar
_jmenubar = new JMenuBar();
if ( !_configuration.isUseNativeUI() ) {
_jmenubar.setBackground( _configuration.getGuiMenuBackgroundColor() );
}
+ if ( getSpeciesTree() != null ) {
+ buildAnalysisMenu();
+ }
buildToolsMenu();
buildViewMenu();
buildFontSizeMenu();
_contentpane = getContentPane();
_contentpane.setLayout( new BorderLayout() );
_contentpane.add( _mainpanel, BorderLayout.CENTER );
- setSize( FRAME_X_SIZE, FRAME_Y_SIZE );
+ setSize( getConfiguration().getFrameXSize() > 40 ? getConfiguration().getFrameXSize() : DEFAULT_FRAME_X_SIZE,
+ getConfiguration().getFrameYSize() > 40 ? getConfiguration().getFrameYSize() : DEFAULT_FRAME_Y_SIZE );
addWindowListener( new WindowAdapter() {
@Override
@Override
public void componentResized( final ComponentEvent e ) {
if ( _mainpanel.getCurrentTreePanel() != null ) {
- _mainpanel.getCurrentTreePanel().setParametersForPainting( _mainpanel.getCurrentTreePanel()
- .getWidth(),
- _mainpanel.getCurrentTreePanel()
- .getHeight(),
- false );
+ _mainpanel.getCurrentTreePanel().calcParametersForPainting( _mainpanel.getCurrentTreePanel()
+ .getWidth(),
+ _mainpanel.getCurrentTreePanel()
+ .getHeight(),
+ getOptions().isAllowFontSizeChange() );
}
}
} );
setFocusable( true );
requestFocus();
requestFocusInWindow();
- // All done: hello, world!
setVisible( true );
System.gc();
}
+ private void readSpeciesTree( final Configuration configuration, final String species_tree_url_str )
+ throws MalformedURLException, FileNotFoundException, IOException {
+ final URL species_tree_url = new URL( species_tree_url_str );
+ final Phylogeny[] species_trees = AptxUtil.readPhylogeniesFromUrl( species_tree_url,
+ configuration
+ .isValidatePhyloXmlAgainstSchema(),
+ configuration
+ .isReplaceUnderscoresInNhParsing(),
+ false,
+ TAXONOMY_EXTRACTION.NO,
+ false );
+ if ( ( species_trees != null ) && ( species_trees.length > 0 ) ) {
+ AptxUtil.printAppletMessage( ArchaeopteryxA.NAME, "successfully read species tree" );
+ if ( species_trees[ 0 ].isEmpty() ) {
+ ForesterUtil.printErrorMessage( ArchaeopteryxA.NAME, "species tree is empty" );
+ }
+ else if ( !species_trees[ 0 ].isRooted() ) {
+ ForesterUtil.printErrorMessage( ArchaeopteryxA.NAME, "species tree is not rooted" );
+ }
+ else {
+ setSpeciesTree( species_trees[ 0 ] );
+ AptxUtil.printAppletMessage( ArchaeopteryxA.NAME, "species tree OK" );
+ }
+ }
+ else {
+ ForesterUtil.printErrorMessage( ArchaeopteryxA.NAME, "failed to read species tree from "
+ + species_tree_url_str );
+ }
+ }
+
+ @Override
+ public MainPanel getMainPanel() {
+ return _mainpanel;
+ }
+
+ 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() {
@Override
public void stateChanged( final ChangeEvent e ) {
- MainFrame.setOvPlacementColorChooseMenuItem( _overview_placment_mi, getCurrentTreePanel() );
+ MainFrame.setOvPlacementColorChooseMenuItem( _overview_placment_mi, getOptions() );
MainFrame.setTextColorChooseMenuItem( _switch_colors_mi, getCurrentTreePanel() );
MainFrame
.setTextMinSupportMenuItem( _choose_minimal_confidence_mi, getOptions(), getCurrentTreePanel() );
_uniform_cladograms_rbmi,
_ext_node_dependent_cladogram_rbmi,
_label_direction_cbmi );
+ MainFrame.setCycleNodeFillMenuItem( _cycle_node_fill_mi, getOptions() );
+ MainFrame.setCycleNodeShapeMenuItem( _cycle_node_shape_mi, getOptions() );
+ MainFrame.setTextNodeSizeMenuItem( _choose_node_size_mi, getOptions() );
}
} );
_options_jmenu.add( MainFrame.customizeMenuItemAsLabel( new JMenuItem( MainFrame.DISPLAY_SUBHEADER ),
_radio_group_1.add( _ext_node_dependent_cladogram_rbmi );
_radio_group_1.add( _uniform_cladograms_rbmi );
_radio_group_1.add( _non_lined_up_cladograms_rbmi );
- _options_jmenu.add( _show_node_boxes_cbmi = new JCheckBoxMenuItem( MainFrame.DISPLAY_NODE_BOXES_LABEL ) );
+ _options_jmenu.add( _show_overview_cbmi = new JCheckBoxMenuItem( MainFrame.SHOW_OVERVIEW_LABEL ) );
_options_jmenu.add( _show_scale_cbmi = new JCheckBoxMenuItem( MainFrame.DISPLAY_SCALE_LABEL ) );
_options_jmenu
.add( _show_branch_length_values_cbmi = new JCheckBoxMenuItem( MainFrame.DISPLAY_BRANCH_LENGTH_VALUES_LABEL ) );
- _options_jmenu.add( _show_overview_cbmi = new JCheckBoxMenuItem( MainFrame.SHOW_OVERVIEW_LABEL ) );
+ _options_jmenu.add( _show_confidence_stddev_cbmi = new JCheckBoxMenuItem( SHOW_CONF_STDDEV_LABEL ) );
+ _options_jmenu
+ .add( _show_default_node_shapes_internal_cbmi = new JCheckBoxMenuItem( DISPLAY_NODE_BOXES_LABEL_INT ) );
+ _options_jmenu
+ .add( _show_default_node_shapes_external_cbmi = new JCheckBoxMenuItem( DISPLAY_NODE_BOXES_LABEL_EXT ) );
+ _options_jmenu
+ .add( _taxonomy_colorize_node_shapes_cbmi = new JCheckBoxMenuItem( MainFrame.TAXONOMY_COLORIZE_NODE_SHAPES_LABEL ) );
+ _options_jmenu.add( _cycle_node_shape_mi = new JMenuItem( MainFrame.CYCLE_NODE_SHAPE_LABEL ) );
+ _options_jmenu.add( _cycle_node_fill_mi = new JMenuItem( MainFrame.CYCLE_NODE_FILL_LABEL ) );
+ _options_jmenu.add( _choose_node_size_mi = new JMenuItem( MainFrame.CHOOSE_NODE_SIZE_LABEL ) );
_options_jmenu.add( _label_direction_cbmi = new JCheckBoxMenuItem( LABEL_DIRECTION_LABEL ) );
_label_direction_cbmi.setToolTipText( LABEL_DIRECTION_TIP );
_options_jmenu.add( _color_labels_same_as_parent_branch = new JCheckBoxMenuItem( COLOR_LABELS_LABEL ) );
if ( getConfiguration().doDisplayOption( Configuration.show_domain_architectures ) ) {
_options_jmenu.add( _show_domain_labels = new JCheckBoxMenuItem( SHOW_DOMAIN_LABELS_LABEL ) );
}
+ _options_jmenu.add( _show_annotation_ref_source = new JCheckBoxMenuItem( SHOW_ANN_REF_SOURCE_LABEL ) );
_options_jmenu.add( _choose_minimal_confidence_mi = new JMenuItem( "" ) );
_options_jmenu.add( _overview_placment_mi = new JMenuItem( "" ) );
_options_jmenu.add( _switch_colors_mi = new JMenuItem( "" ) );
customizeJMenuItem( _switch_colors_mi );
customizeJMenuItem( _choose_minimal_confidence_mi );
customizeJMenuItem( _overview_placment_mi );
- customizeCheckBoxMenuItem( _show_node_boxes_cbmi, getOptions().isShowNodeBoxes() );
+ customizeCheckBoxMenuItem( _show_default_node_shapes_internal_cbmi, getOptions()
+ .isShowDefaultNodeShapesInternal() );
+ customizeCheckBoxMenuItem( _show_default_node_shapes_external_cbmi, getOptions()
+ .isShowDefaultNodeShapesExternal() );
+ customizeCheckBoxMenuItem( _taxonomy_colorize_node_shapes_cbmi, getOptions().isTaxonomyColorizeNodeShapes() );
+ customizeJMenuItem( _cycle_node_shape_mi );
+ customizeJMenuItem( _cycle_node_fill_mi );
+ customizeJMenuItem( _choose_node_size_mi );
customizeCheckBoxMenuItem( _color_labels_same_as_parent_branch, getOptions().isColorLabelsSameAsParentBranch() );
customizeCheckBoxMenuItem( _screen_antialias_cbmi, getOptions().isAntialiasScreen() );
customizeCheckBoxMenuItem( _background_gradient_cbmi, getOptions().isBackgroundColorGradient() );
customizeCheckBoxMenuItem( _show_domain_labels, getOptions().isShowDomainLabels() );
+ customizeCheckBoxMenuItem( _show_annotation_ref_source, getOptions().isShowAnnotationRefSource() );
customizeCheckBoxMenuItem( _abbreviate_scientific_names, getOptions().isAbbreviateScientificTaxonNames() );
customizeCheckBoxMenuItem( _search_case_senstive_cbmi, getOptions().isSearchCaseSensitive() );
customizeCheckBoxMenuItem( _show_scale_cbmi, getOptions().isShowScale() );
getOptions().getNodeLabelDirection() == NODE_LABEL_DIRECTION.RADIAL );
customizeCheckBoxMenuItem( _search_whole_words_only_cbmi, getOptions().isMatchWholeTermsOnly() );
customizeCheckBoxMenuItem( _inverse_search_result_cbmi, getOptions().isInverseSearchResult() );
+ customizeCheckBoxMenuItem( _show_confidence_stddev_cbmi, getOptions().isShowConfidenceStddev() );
_jmenubar.add( _options_jmenu );
}
_tools_menu.add( _midpoint_root_item = new JMenuItem( "Midpoint-Root" ) );
customizeJMenuItem( _midpoint_root_item );
_tools_menu.addSeparator();
- _tools_menu
- .add( _infer_common_sn_names_item = new JMenuItem( "Infer Common Parts of Internal Scientific Names" ) );
- customizeJMenuItem( _infer_common_sn_names_item );
_tools_menu.add( _collapse_species_specific_subtrees = new JMenuItem( "Collapse Species-Specific Subtrees" ) );
customizeJMenuItem( _collapse_species_specific_subtrees );
_jmenubar.add( _tools_menu );
}
@Override
- MainPanel getMainPanel() {
- return _mainpanel;
- }
-
- @Override
void readPhylogeniesFromURL() {
throw new NoSuchMethodError( "not implemented" );
}