import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
+import java.awt.event.ComponentAdapter;
+import java.awt.event.ComponentListener;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.NoSuchElementException;
import javax.swing.Box;
-import javax.swing.JApplet;
import javax.swing.JCheckBoxMenuItem;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
+import javax.swing.JInternalFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import org.forester.util.ForesterUtil;
import org.forester.util.WindowsUtils;
-public abstract class MainFrame extends JFrame implements ActionListener {
-
- final static NHFilter nhfilter = new NHFilter();
- final static NHXFilter nhxfilter = new NHXFilter();
- final static XMLFilter xmlfilter = new XMLFilter();
- final static TolFilter tolfilter = new TolFilter();
- final static NexusFilter nexusfilter = new NexusFilter();
- final static PdfFilter pdffilter = new PdfFilter();
- final static GraphicsFileFilter graphicsfilefilter = new GraphicsFileFilter();
- final static MsaFileFilter msafilter = new MsaFileFilter();
- final static SequencesFileFilter seqsfilter = new SequencesFileFilter();
- final static DefaultFilter defaultfilter = new DefaultFilter();
+public abstract class MainFrame implements ActionListener {
+
+ public final static NHFilter nhfilter = new NHFilter();
+ public final static NHXFilter nhxfilter = new NHXFilter();
+ public final static XMLFilter xmlfilter = new XMLFilter();
+ public final static TolFilter tolfilter = new TolFilter();
+ public final static NexusFilter nexusfilter = new NexusFilter();
+ public final static PdfFilter pdffilter = new PdfFilter();
+ public final static GraphicsFileFilter graphicsfilefilter = new GraphicsFileFilter();
+ public final static MsaFileFilter msafilter = new MsaFileFilter();
+ public final static SequencesFileFilter seqsfilter = new SequencesFileFilter();
+ public final static DefaultFilter defaultfilter = new DefaultFilter();
static final String USE_MOUSEWHEEL_SHIFT_TO_ROTATE = "rotate with mousewheel + Shift (or A and S), D toggles between horizontal and radial labels";
static final String PHYLOXML_REF_TOOL_TIP = AptxConstants.PHYLOXML_REFERENCE; //TODO //FIXME
static final String APTX_REF_TOOL_TIP = AptxConstants.APTX_REFERENCE;
static final String OPTIONS_HEADER = "Options";
static final String SEARCH_SUBHEADER = "Search:";
static final String DISPLAY_SUBHEADER = "Display:";
- static final String SEARCH_TERMS_ONLY_LABEL = "Match Complete Terms Only";
- static final String SEARCH_REGEX_LABEL = "Search with Regular Expressions";
- static final String SEARCH_CASE_SENSITIVE_LABEL = "Case Sensitive";
- static final String INVERSE_SEARCH_RESULT_LABEL = "Negate Result";
+ static final String SEARCH_TERMS_ONLY_LABEL = "Words";
+ static final String SEARCH_REGEX_LABEL = "Regex";
+ static final String SEARCH_CASE_SENSITIVE_LABEL = "Match Case";
+ static final String INVERSE_SEARCH_RESULT_LABEL = "Inverse";
static final String COLOR_BY_TAXONOMIC_GROUP = "Colorize by Taxonomic Group";
static final String DISPLAY_SCALE_LABEL = "Scale";
static final String NON_LINED_UP_CLADOGRAMS_LABEL = "Non-Lined Up Cladogram";
static final String LINE_UP_RENDERABLE_DATA = "Line Up Diagrams (such as Domain Architectures)";
static final String INFER_ANCESTOR_TAXONOMIES = "Infer Ancestor Taxonomies";
static final String OBTAIN_DETAILED_TAXONOMIC_INFORMATION = "Obtain Detailed Taxonomic Information";
+
+ final AptxFrame _frame;
JMenuBar _jmenubar;
JMenu _file_jmenu;
JMenu _tools_menu;
JMenuItem _about_item;
JMenuItem _help_item;
JMenuItem _website_item;
+ JMenuItem _aptxjs_website_item;
JMenuItem _mailing_list_item;
JMenuItem _phyloxml_website_item;
JMenuItem _phyloxml_ref_item;
private String _previous_node_annotation_ref;
MainFrame() {
+ this(false);
+ }
+ MainFrame(boolean embedded){
+ if (embedded) {
+ _frame = new EmbeddedFrame();
+ }
+ else {
+ _frame = new StandaloneFrame();
+ }
_process_pool = ProcessPool.createInstance();
_writetopdf_filechooser = new JFileChooser();
_writetopdf_filechooser.setMultiSelectionEnabled( false );
// Do nothing. Not important.
}
}
-
+ public void addComponentListener( ComponentListener componentListener ) {
+ _frame.addComponentListener( componentListener );
+
+ }
+
+ public void dispose() {
+ _frame.dispose();
+ }
+ public Container getContentPane() {
+ return _frame.getContentPane();
+ }
+
+ public void repaint() {
+ _frame.repaint();
+ }
+
+
+ public void addFrameListener(FrameListener frameListener) {
+ _frame.addFrameListener(frameListener);
+ }
+
+ public void setSize(int x, int y) {
+ _frame.setSize(x,y);
+ }
+ public Container getJMenuBar() {
+ return _frame.getJMenuBar();
+ }
+ public void setDefaultCloseOperation( int doNothingOnClose ) {
+ _frame.setDefaultCloseOperation(doNothingOnClose);
+
+ }
+ public Container getParent() {
+ return _frame.getParent();
+ }
+ public void setVisible(boolean visible) {
+ _frame.setVisible(visible);
+ }
+ public void requestFocusInWindow() {
+ _frame.requestFocusInWindow();
+ }
+ public void setJMenuBar( JMenuBar jmenubar ) {
+ _frame.setJMenuBar(jmenubar);
+ }
+ public void setLocationRelativeTo( Component component ) {
+ _frame.setLocationRelativeTo(component);
+ }
+ public void setTitle(String title) {
+ _frame.setTitle(title);
+ }
+
+ public Container getThisFrame() {
+ return _frame.getThisFrame();
+ }
+
+ public void validate() {
+ _frame.validate();
+ }
+
+
+
+
+
+
/**
* Action performed.
*/
@Override
public void actionPerformed( final ActionEvent e ) {
final Object o = e.getSource();
- boolean is_applet = false;
- JApplet applet = null;
- if ( getCurrentTreePanel() != null ) {
- is_applet = getCurrentTreePanel().isApplet();
- if ( is_applet ) {
- applet = getCurrentTreePanel().obtainApplet();
- }
- }
+
if ( o == _exit_item ) {
close();
}
chooseMinimalConfidence();
}
else if ( o == _choose_node_size_mi ) {
- chooseNodeSize( getOptions(), this );
+ chooseNodeSize( getOptions(), _frame.getThisFrame() );
}
else if ( o == _overview_placment_mi ) {
MainFrame.cycleOverview( getOptions(), getCurrentTreePanel() );
showWhole();
}
else if ( o == _search_case_senstive_cbmi ) {
+ if ( ( _search_with_regex_cbmi != null ) && _search_case_senstive_cbmi.isSelected() ) {
+ _search_with_regex_cbmi.setSelected( false );
+ }
updateOptions( getOptions() );
getMainPanel().getControlPanel().search0();
getMainPanel().getControlPanel().search1();
_search_whole_words_only_cbmi.setSelected( false );
}
if ( ( _search_case_senstive_cbmi != null ) && _search_with_regex_cbmi.isSelected() ) {
- _search_case_senstive_cbmi.setSelected( true );
+ _search_case_senstive_cbmi.setSelected( false );
}
updateOptions( getOptions() );
getMainPanel().getControlPanel().search0();
}
else if ( o == _help_item ) {
try {
- AptxUtil.openWebsite( AptxConstants.APTX_DOC_SITE, is_applet, applet );
+ AptxUtil.openWebsite( AptxConstants.APTX_DOC_SITE );
}
catch ( final IOException e1 ) {
ForesterUtil.printErrorMessage( AptxConstants.PRG_NAME, e1.toString() );
}
else if ( o == _website_item ) {
try {
- AptxUtil.openWebsite( AptxConstants.APTX_WEB_SITE, is_applet, applet );
+ AptxUtil.openWebsite( AptxConstants.APTX_WEB_SITE);
+ }
+ catch ( final IOException e1 ) {
+ ForesterUtil.printErrorMessage( AptxConstants.PRG_NAME, e1.toString() );
+ }
+ }
+ else if ( o == _aptxjs_website_item ) {
+ try {
+ AptxUtil.openWebsite( AptxConstants.APTX_JS_WEB_SITE);;
}
catch ( final IOException e1 ) {
ForesterUtil.printErrorMessage( AptxConstants.PRG_NAME, e1.toString() );
}
else if ( o == _mailing_list_item ) {
try {
- AptxUtil.openWebsite( AptxConstants.APTX_MAILING_LIST, is_applet, applet );
+ AptxUtil.openWebsite( AptxConstants.APTX_MAILING_LIST );
}
catch ( final IOException e1 ) {
ForesterUtil.printErrorMessage( AptxConstants.PRG_NAME, e1.toString() );
}
else if ( o == _phyloxml_website_item ) {
try {
- AptxUtil.openWebsite( AptxConstants.PHYLOXML_WEB_SITE, is_applet, applet );
+ AptxUtil.openWebsite( AptxConstants.PHYLOXML_WEB_SITE );
}
catch ( final IOException e1 ) {
ForesterUtil.printErrorMessage( AptxConstants.PRG_NAME, e1.toString() );
}
else if ( o == _aptx_ref_item ) {
try {
- AptxUtil.openWebsite( AptxConstants.APTX_REFERENCE_URL, is_applet, applet );
+ AptxUtil.openWebsite( AptxConstants.APTX_REFERENCE_URL );
}
catch ( final IOException e1 ) {
ForesterUtil.printErrorMessage( AptxConstants.PRG_NAME, e1.toString() );
}
else if ( o == _phyloxml_ref_item ) {
try {
- AptxUtil.openWebsite( AptxConstants.PHYLOXML_REFERENCE_URL, is_applet, applet );
+ AptxUtil.openWebsite( AptxConstants.PHYLOXML_REFERENCE_URL );
}
catch ( final IOException e1 ) {
ForesterUtil.printErrorMessage( AptxConstants.PRG_NAME, e1.toString() );
_writetopdf_filechooser,
_current_dir,
getContentPane(),
- this );
+ getThisFrame() );
if ( curr_dir != null ) {
setCurrentDir( curr_dir );
}
GraphicsExportType.JPG,
_mainpanel,
_writetographics_filechooser,
- this,
+ getThisFrame(),
getContentPane(),
_current_dir );
if ( new_dir != null ) {
GraphicsExportType.GIF,
_mainpanel,
_writetographics_filechooser,
- this,
+ getThisFrame(),
getContentPane(),
_current_dir );
if ( new_dir != null ) {
GraphicsExportType.TIFF,
_mainpanel,
_writetographics_filechooser,
- this,
+ getThisFrame(),
getContentPane(),
_current_dir );
if ( new_dir != null ) {
GraphicsExportType.BMP,
_mainpanel,
_writetographics_filechooser,
- this,
+ getThisFrame(),
getContentPane(),
_current_dir );
if ( new_dir != null ) {
GraphicsExportType.PNG,
_mainpanel,
_writetographics_filechooser,
- this,
+ getThisFrame(),
getContentPane(),
_current_dir );
if ( new_dir != null ) {
}
}
else if ( o == _print_item ) {
- print( getCurrentTreePanel(), getOptions(), this );
+ print( getCurrentTreePanel(), getOptions(), _frame.getThisFrame() );
}
else if ( o == _save_item ) {
final File new_dir = writeToFile( _mainpanel.getCurrentPhylogeny(),
_save_filechooser,
_current_dir,
getContentPane(),
- this );
+ _frame.getThisFrame() );
if ( new_dir != null ) {
setCurrentDir( new_dir );
}
}
else if ( o == _lineage_inference ) {
if ( isSubtreeDisplayed() ) {
- JOptionPane.showMessageDialog( this,
+ JOptionPane.showMessageDialog( getThisFrame(),
"Subtree is shown.",
"Cannot infer ancestral taxonomies",
JOptionPane.ERROR_MESSAGE );
_contentpane.repaint();
}
+
public Configuration getConfiguration() {
return _configuration;
}
}
if ( ( nodes == null ) || nodes.isEmpty() ) {
JOptionPane
- .showMessageDialog( this,
+ .showMessageDialog( getThisFrame(),
"Need to select nodes, either via direct selection or via the \"Search\" function",
"No nodes selected for annotation",
JOptionPane.ERROR_MESSAGE );
ref = ref.replaceAll( "\\s+", " " );
if ( ( ref.indexOf( ':' ) < 1 ) || ( ref.indexOf( ':' ) > ( ref.length() - 2 ) )
|| ( ref.length() < 3 ) ) {
- JOptionPane.showMessageDialog( this,
+ JOptionPane.showMessageDialog( getThisFrame(),
"Reference needs to be in the form of \"GO:1234567\"",
"Illegal Format for Annotation Reference",
JOptionPane.ERROR_MESSAGE );
private void chooseFont() {
final FontChooser fc = new FontChooser();
fc.setFont( getMainPanel().getTreeFontSet().getLargeFont() );
- fc.showDialog( this, "Select the Base Font" );
+ fc.showDialog( getThisFrame(), "Select the Base Font" );
getMainPanel().getTreeFontSet().setBaseFont( fc.getFont() );
getControlPanel().displayedPhylogenyMightHaveChanged( true );
if ( getMainPanel().getCurrentTreePanel() != null ) {
private void chooseMinimalConfidence() {
final String s = ( String ) JOptionPane
- .showInputDialog( this,
+ .showInputDialog( getThisFrame(),
"Please enter the minimum for confidence values to be displayed.\n"
+ "[current value: " + getOptions().getMinConfidenceValue() + "]\n",
"Minimal Confidence Value",
}
if ( ( nodes == null ) || nodes.isEmpty() ) {
JOptionPane
- .showMessageDialog( this,
+ .showMessageDialog( getThisFrame(),
"Need to select external nodes, either via direct selection or via the \"Search\" function",
"No external nodes selected to " + function.toLowerCase(),
JOptionPane.ERROR_MESSAGE );
res = ext - todo;
}
if ( res < 1 ) {
- JOptionPane.showMessageDialog( this,
+ JOptionPane.showMessageDialog( getThisFrame(),
"Cannot delete all nodes",
"Attempt to delete all nodes ",
JOptionPane.ERROR_MESSAGE );
_process_menu.setForeground( Color.RED );
}
_process_menu.removeAll();
- final String text = "processes running: " + _process_pool.size();
+ final String text = "Processes Running: " + _process_pool.size();
_process_menu.setText( text );
_jmenubar.add( _process_menu );
for( int i = 0; i < _process_pool.size(); ++i ) {
setCurrentDir( _save_filechooser.getCurrentDirectory() );
if ( ( file != null ) && ( result == JFileChooser.APPROVE_OPTION ) ) {
if ( file.exists() ) {
- final int i = JOptionPane.showConfirmDialog( this,
+ final int i = JOptionPane.showConfirmDialog( getThisFrame(),
file + " already exists. Overwrite?",
"Warning",
JOptionPane.OK_CANCEL_OPTION,
file.delete();
}
catch ( final Exception e ) {
- JOptionPane.showMessageDialog( this,
+ JOptionPane.showMessageDialog( getThisFrame(),
"Failed to delete: " + file,
"Error",
JOptionPane.WARNING_MESSAGE );
writer.toPhyloXML( file, trees, 0, ForesterUtil.LINE_SEPARATOR );
}
catch ( final IOException e ) {
- JOptionPane.showMessageDialog( this,
+ JOptionPane.showMessageDialog( getThisFrame(),
"Failed to write to: " + file,
"Error",
JOptionPane.WARNING_MESSAGE );
}
}
- void activateSaveAllIfNeeded() {
+ public void activateSaveAllIfNeeded() {
if ( ( getMainPanel().getTabbedPane() != null ) && ( getMainPanel().getTabbedPane().getTabCount() > 1 ) ) {
_save_all_item.setEnabled( true );
}
_help_jmenu.add( _help_item = new JMenuItem( "Documentation" ) );
_help_jmenu.addSeparator();
_help_jmenu.add( _website_item = new JMenuItem( "Archaeopteryx Home" ) );
+ _help_jmenu.add( _aptxjs_website_item = new JMenuItem( "NEW! Archaeopteryx online version: Archaeopteryx.js" ) );
_help_jmenu.add( _mailing_list_item = new JMenuItem( "Mailing List" ) );
_aptx_ref_item = new JMenuItem( "Archaeopteryx Reference" ); //TODO need to add this...
_help_jmenu.add( _phyloxml_website_item = new JMenuItem( "phyloXML Home" ) );
_help_jmenu.add( _about_item = new JMenuItem( "About" ) );
customizeJMenuItem( _help_item );
customizeJMenuItem( _website_item );
+ customizeJMenuItem( _aptxjs_website_item );
customizeJMenuItem( _mailing_list_item );
customizeJMenuItem( _phyloxml_website_item );
customizeJMenuItem( _aptx_ref_item );
}
void choosePdfWidth() {
- final String s = ( String ) JOptionPane.showInputDialog( this,
+ final String s = ( String ) JOptionPane.showInputDialog( getThisFrame(),
"Please enter the default line width for PDF export.\n"
+ "[current value: "
+ getOptions().getPrintLineWidth() + "]\n",
final Map<String, Integer> present_ranks = AptxUtil.getRankCounts( _mainpanel.getCurrentTreePanel().getPhylogeny());
final String[] ranks = AptxUtil.getAllPossibleRanks(present_ranks);
String rank = ( String ) JOptionPane
- .showInputDialog( this,
+ .showInputDialog( getThisFrame(),
"What rank should the colorization be based on",
"Rank Selection",
JOptionPane.QUESTION_MESSAGE,
catch ( final Exception ex ) {
// Do nothing.
}
- JOptionPane.showMessageDialog( this,
+ JOptionPane.showMessageDialog( getThisFrame(),
ForesterUtil.wordWrap( e.getLocalizedMessage(), 80 ),
"Error during File|Open",
JOptionPane.ERROR_MESSAGE );
return;
}
if ( !_mainpanel.getCurrentPhylogeny().isRooted() ) {
- JOptionPane.showMessageDialog( this,
+ JOptionPane.showMessageDialog( getThisFrame(),
"Gene tree is not rooted.",
"Cannot execute GSDI",
JOptionPane.ERROR_MESSAGE );
gsdi = new GSDI( gene_tree, species_tree, false, true, true, true );
}
catch ( final SDIException e ) {
- JOptionPane.showMessageDialog( this,
+ JOptionPane.showMessageDialog( getThisFrame(),
e.getLocalizedMessage(),
"Error during GSDI",
JOptionPane.ERROR_MESSAGE );
_mainpanel.getCurrentTreePanel().setEdited( true );
final int poly = PhylogenyMethods.countNumberOfPolytomies( species_tree );
if ( gsdi.getStrippedExternalGeneTreeNodes().size() > 0 ) {
- JOptionPane.showMessageDialog( this,
+ JOptionPane.showMessageDialog( getThisFrame(),
"Duplications: " + gsdi.getDuplicationsSum() + "\n"
+ "Potential duplications: "
+ gsdi.getSpeciationOrDuplicationEventsSum() + "\n"
JOptionPane.WARNING_MESSAGE );
}
else {
- JOptionPane.showMessageDialog( this,
+ JOptionPane.showMessageDialog( getThisFrame(),
"Duplications: " + gsdi.getDuplicationsSum() + "\n"
+ "Potential duplications: "
+ gsdi.getSpeciationOrDuplicationEventsSum() + "\n"
final int p = PhylogenyMethods.countNumberOfPolytomies( _mainpanel.getCurrentPhylogeny() );
if ( ( p > 0 )
&& !( ( p == 1 ) && ( _mainpanel.getCurrentPhylogeny().getRoot().getNumberOfDescendants() == 3 ) ) ) {
- JOptionPane.showMessageDialog( this,
+ JOptionPane.showMessageDialog( getThisFrame(),
"Gene tree is not completely binary",
"Cannot execute GSDI",
JOptionPane.ERROR_MESSAGE );
gsdir = new GSDIR( gene_tree, species_tree, true, true, true );
}
catch ( final SDIException e ) {
- JOptionPane.showMessageDialog( this,
+ JOptionPane.showMessageDialog( getThisFrame(),
e.getLocalizedMessage(),
"Error during GSDIR",
JOptionPane.ERROR_MESSAGE );
_mainpanel.getCurrentTreePanel().setEdited( true );
final int poly = PhylogenyMethods.countNumberOfPolytomies( species_tree );
if ( gsdir.getStrippedExternalGeneTreeNodes().size() > 0 ) {
- JOptionPane.showMessageDialog( this,
+ JOptionPane.showMessageDialog( getThisFrame(),
"Minimal duplications: " + gsdir.getMinDuplicationsSum() + "\n"
+ "Speciations: " + gsdir.getSpeciationsSum() + "\n"
+ "Stripped gene tree nodes: "
JOptionPane.WARNING_MESSAGE );
}
else {
- JOptionPane.showMessageDialog( this,
+ JOptionPane.showMessageDialog( getThisFrame(),
"Minimal duplications: " + gsdir.getMinDuplicationsSum() + "\n"
+ "Speciations: " + gsdir.getSpeciationsSum() + "\n"
+ "Stripped gene tree nodes: "
return;
}
if ( !_mainpanel.getCurrentPhylogeny().isRooted() ) {
- JOptionPane.showMessageDialog( this,
+ JOptionPane.showMessageDialog( getThisFrame(),
"Phylogeny is not rooted.",
"Cannot infer ancestral taxonomies",
JOptionPane.ERROR_MESSAGE );
boolean GAndSDoHaveMoreThanOneSpeciesInComman( final Phylogeny gene_tree ) {
if ( ( gene_tree == null ) || gene_tree.isEmpty() ) {
- JOptionPane.showMessageDialog( this,
+ JOptionPane.showMessageDialog( getThisFrame(),
"Gene tree and species tree have no species in common.",
"Error during SDI",
JOptionPane.ERROR_MESSAGE );
return false;
}
else if ( gene_tree.getNumberOfExternalNodes() < 2 ) {
- JOptionPane.showMessageDialog( this,
+ JOptionPane.showMessageDialog( getThisFrame(),
"Gene tree and species tree have only one species in common.",
"Error during SDI",
JOptionPane.ERROR_MESSAGE );
return false;
}
else if ( ( getSpeciesTree() == null ) || getSpeciesTree().isEmpty() ) {
- JOptionPane.showMessageDialog( this,
+ JOptionPane.showMessageDialog( getThisFrame(),
"No species tree loaded",
"Cannot execute GSDI",
JOptionPane.ERROR_MESSAGE );
return false;
}
else if ( species_tree_has_to_binary && !getSpeciesTree().isCompletelyBinary() ) {
- JOptionPane.showMessageDialog( this,
+ JOptionPane.showMessageDialog( getThisFrame(),
"Species tree is not completely binary",
"Cannot execute GSDI",
JOptionPane.ERROR_MESSAGE );
return false;
}
else if ( gene_tree_has_to_binary && !_mainpanel.getCurrentPhylogeny().isCompletelyBinary() ) {
- JOptionPane.showMessageDialog( this,
+ JOptionPane.showMessageDialog( getThisFrame(),
"Gene tree is not completely binary",
"Cannot execute GSDI",
JOptionPane.ERROR_MESSAGE );
if ( getCurrentTreePanel() != null ) {
if ( getCurrentTreePanel().isCurrentTreeIsSubtree() ) {
JOptionPane
- .showMessageDialog( this,
+ .showMessageDialog( getThisFrame(),
"This operation can only be performed on a complete tree, not on the currently displayed sub-tree only.",
"Operation can not be exectuted on a sub-tree",
JOptionPane.WARNING_MESSAGE );
}
return new_current_dir;
}
+
+
}
class DefaultFilter extends FileFilter {