+ public Configuration getConfiguration() {
+ return _configuration;
+ }
+
+ /**
+ * This method returns the current external node data which
+ * has been selected by the user by clicking the "Return ..."
+ * menu item. This method is expected to be called from Javascript or
+ * something like it.
+ *
+ * @return current external node data as String
+ */
+ public String getCurrentExternalNodesDataBuffer() {
+ return getCurrentTreePanel().getCurrentExternalNodesDataBufferAsString();
+ }
+
+ public int getCurrentExternalNodesDataBufferChangeCounter() {
+ return getCurrentTreePanel().getCurrentExternalNodesDataBufferChangeCounter();
+ }
+
+ public int getCurrentExternalNodesDataBufferLength() {
+ return getCurrentTreePanel().getCurrentExternalNodesDataBufferAsString().length();
+ }
+
+ public InferenceManager getInferenceManager() {
+ return _inference_manager;
+ }
+
+ public MainPanel getMainPanel() {
+ return _mainpanel;
+ }
+
+ public Options getOptions() {
+ return _options;
+ }
+
+ public ProcessPool getProcessPool() {
+ return _process_pool;
+ }
+
+ public void showTextFrame( final String s, final String title ) {
+ checkTextFrames();
+ _textframes.addLast( TextFrame.instantiate( s, title, _textframes ) );
+ }
+
+ public void showWhole() {
+ _mainpanel.getControlPanel().showWhole();
+ }
+
+ public void updateProcessMenu() {
+ // In general Swing is not thread safe.
+ // See "Swing's Threading Policy".
+ SwingUtilities.invokeLater( new Runnable() {
+
+ @Override
+ public void run() {
+ doUpdateProcessMenu();
+ }
+ } );
+ }
+
+ private void annotateSequences() {
+ if ( getCurrentTreePanel() != null ) {
+ List<PhylogenyNode> nodes = null;
+ if ( ( getCurrentTreePanel().getFoundNodes0() != null )
+ || ( getCurrentTreePanel().getFoundNodes1() != null ) ) {
+ nodes = getCurrentTreePanel().getFoundNodesAsListOfPhylogenyNodes();
+ }
+ if ( ( nodes == null ) || nodes.isEmpty() ) {
+ JOptionPane
+ .showMessageDialog( this,
+ "Need to select nodes, either via direct selection or via the \"Search\" function",
+ "No nodes selected for annotation",
+ JOptionPane.ERROR_MESSAGE );
+ return;
+ }
+ final Phylogeny phy = getMainPanel().getCurrentPhylogeny();
+ if ( ( phy != null ) && !phy.isEmpty() ) {
+ final JTextField ref_field = new JTextField( 10 );
+ final JTextField desc_filed = new JTextField( 20 );
+ ref_field.setText( ForesterUtil.isEmpty( getPreviousNodeAnnotationReference() ) ? ""
+ : getPreviousNodeAnnotationReference() );
+ final JPanel my_panel = new JPanel();
+ my_panel.add( new JLabel( "Reference " ) );
+ my_panel.add( ref_field );
+ my_panel.add( Box.createHorizontalStrut( 15 ) );
+ my_panel.add( new JLabel( "Description " ) );
+ my_panel.add( desc_filed );
+ final int result = JOptionPane.showConfirmDialog( null,
+ my_panel,
+ "Enter the sequence annotation(s) for the "
+ + nodes.size() + " selected nodes",
+ JOptionPane.OK_CANCEL_OPTION );
+ if ( result == JOptionPane.OK_OPTION ) {
+ String ref = ref_field.getText();
+ String desc = desc_filed.getText();
+ if ( !ForesterUtil.isEmpty( ref ) ) {
+ ref = ref.trim();
+ ref = ref.replaceAll( "\\s+", " " );
+ if ( ( ref.indexOf( ':' ) < 1 ) || ( ref.indexOf( ':' ) > ( ref.length() - 2 ) )
+ || ( ref.length() < 3 ) ) {
+ JOptionPane.showMessageDialog( this,
+ "Reference needs to be in the form of \"GO:1234567\"",
+ "Illegal Format for Annotation Reference",
+ JOptionPane.ERROR_MESSAGE );
+ return;
+ }
+ }
+ if ( ref != null ) {
+ setPreviousNodeAnnotationReference( ref );
+ }
+ if ( desc != null ) {
+ desc = desc.trim();
+ desc = desc.replaceAll( "\\s+", " " );
+ }
+ if ( !ForesterUtil.isEmpty( ref ) || !ForesterUtil.isEmpty( desc ) ) {
+ for( final PhylogenyNode n : nodes ) {
+ ForesterUtil.ensurePresenceOfSequence( n );
+ final Annotation ann = ForesterUtil.isEmpty( ref ) ? new Annotation()
+ : new Annotation( ref );
+ if ( !ForesterUtil.isEmpty( desc ) ) {
+ ann.setDesc( desc );
+ }
+ n.getNodeData().getSequence().addAnnotation( ann );
+ }
+ }
+ getMainPanel().getControlPanel().showAnnotations();
+ }
+ }
+ }
+ }
+
+ private void chooseFont() {
+ final FontChooser fc = new FontChooser();
+ fc.setFont( getMainPanel().getTreeFontSet().getLargeFont() );
+ fc.showDialog( this, "Select the Base Font" );
+ getMainPanel().getTreeFontSet().setBaseFont( fc.getFont() );
+ getControlPanel().displayedPhylogenyMightHaveChanged( true );
+ if ( getMainPanel().getCurrentTreePanel() != null ) {
+ getMainPanel().getCurrentTreePanel().resetPreferredSize();
+ getMainPanel().getCurrentTreePanel().updateOvSizes();
+ }
+
+ repaint();
+ }
+
+ private void chooseMinimalConfidence() {
+ final String s = ( String ) JOptionPane
+ .showInputDialog( this,
+ "Please enter the minimum for confidence values to be displayed.\n"
+ + "[current value: " + getOptions().getMinConfidenceValue() + "]\n",
+ "Minimal Confidence Value",
+ JOptionPane.QUESTION_MESSAGE,
+ null,
+ null,
+ getOptions().getMinConfidenceValue() );
+ if ( !ForesterUtil.isEmpty( s ) ) {
+ boolean success = true;
+ double m = 0.0;
+ final String m_str = s.trim();
+ if ( !ForesterUtil.isEmpty( m_str ) ) {
+ try {
+ m = Double.parseDouble( m_str );
+ }
+ catch ( final Exception ex ) {
+ success = false;
+ }
+ }
+ else {
+ success = false;
+ }
+ if ( success && ( m >= 0.0 ) ) {
+ getOptions().setMinConfidenceValue( m );
+ }
+ }
+ }
+
+ private void deleteSelectedNodes( final boolean delete ) {
+ final Phylogeny phy = getMainPanel().getCurrentPhylogeny();
+ if ( ( phy == null ) || ( phy.getNumberOfExternalNodes() < 2 ) ) {
+ return;
+ }
+ final List<PhylogenyNode> nodes = new ArrayList<PhylogenyNode>();
+ if ( ( getCurrentTreePanel().getFoundNodes0() != null ) || ( getCurrentTreePanel().getFoundNodes1() != null ) ) {
+ final List<PhylogenyNode> all_selected_nodes = getCurrentTreePanel().getFoundNodesAsListOfPhylogenyNodes();
+ for( final PhylogenyNode n : all_selected_nodes ) {
+ if ( n.isExternal() ) {
+ nodes.add( n );
+ }
+ }
+ }
+ String function = "Retain";
+ if ( delete ) {
+ function = "Delete";
+ }
+ if ( ( nodes == null ) || nodes.isEmpty() ) {