+ final JPanel d1_panel = new JPanel( new GridLayout( 1, 2, 0, 0 ) );
+ final JPanel d2_panel = new JPanel( new GridLayout( 1, 3, 0, 0 ) );
+ if ( !_configuration.isUseNativeUI() ) {
+ d1_panel.setBackground( getBackground() );
+ d2_panel.setBackground( getBackground() );
+ }
+ add( d1_panel );
+ add( d2_panel );
+ addJButton( _zoom_out_domain_structure, d1_panel );
+ addJButton( _zoom_in_domain_structure, d1_panel );
+ addJButton( _decr_domain_structure_evalue_thr, d2_panel );
+ addJTextField( _domain_structure_evalue_thr_tf, d2_panel );
+ addJButton( _incr_domain_structure_evalue_thr, d2_panel );
+ }
+
+ void setupSearchTools() {
+ final String tip = "Enter text to search for. Use ',' for multiple searches (logical OR) and '+' for logical AND.";
+ final JLabel search_label = new JLabel( "Search:" );
+ search_label.setFont( ControlPanel.jcb_bold_font );
+ if ( !getConfiguration().isUseNativeUI() ) {
+ search_label.setForeground( getConfiguration().getGuiCheckboxTextColor() );
+ }
+ add( search_label );
+ search_label.setToolTipText( tip );
+ _search_found_label = new JLabel();
+ getSearchFoundCountsLabel().setVisible( false );
+ _search_found_label.setFont( ControlPanel.jcb_bold_font );
+ if ( !getConfiguration().isUseNativeUI() ) {
+ _search_found_label.setForeground( getConfiguration().getGuiCheckboxTextColor() );
+ }
+ _search_tf = new JTextField( 3 );
+ _search_tf.setToolTipText( tip );
+ _search_tf.setEditable( true );
+ if ( !getConfiguration().isUseNativeUI() ) {
+ _search_tf.setForeground( getConfiguration().getGuiMenuBackgroundColor() );
+ _search_tf.setBackground( getConfiguration().getGuiCheckboxTextColor() );
+ _search_tf.setBorder( null );
+ }
+ _search_reset_button = new JButton();
+ getSearchResetButton().setText( "Reset" );
+ getSearchResetButton().setEnabled( false );
+ getSearchResetButton().setVisible( false );
+ final JPanel s_panel_1 = new JPanel( new BorderLayout() );
+ final JPanel s_panel_2 = new JPanel( new GridLayout( 1, 2, 0, 0 ) );
+ s_panel_1.setBackground( getBackground() );
+ add( s_panel_1 );
+ s_panel_2.setBackground( getBackground() );
+ add( s_panel_2 );
+ final KeyAdapter key_adapter = new KeyAdapter() {
+
+ @Override
+ public void keyReleased( final KeyEvent key_event ) {
+ search();
+ displayedPhylogenyMightHaveChanged( true );
+ }
+ };
+ final ActionListener action_listener = new ActionListener() {
+
+ @Override
+ public void actionPerformed( final ActionEvent e ) {
+ searchReset();
+ setSearchFoundCountsOnLabel( 0 );
+ getSearchFoundCountsLabel().setVisible( false );
+ getSearchTextField().setText( "" );
+ getSearchResetButton().setEnabled( false );
+ getSearchResetButton().setVisible( false );
+ displayedPhylogenyMightHaveChanged( true );
+ }
+ };
+ _search_reset_button.addActionListener( action_listener );
+ _search_tf.addKeyListener( key_adapter );
+ addJTextField( _search_tf, s_panel_1 );
+ s_panel_2.add( _search_found_label );
+ addJButton( _search_reset_button, s_panel_2 );
+ }
+
+ /**
+ * Fit entire tree into window.
+ */
+ void showWhole() {
+ if ( ( _mainpanel.getCurrentScrollPane() == null ) || _mainpanel.getCurrentTreePanel().getPhylogeny().isEmpty() ) {
+ return;
+ }
+ getCurrentTreePanel().updateSetOfCollapsedExternalNodes();
+ displayedPhylogenyMightHaveChanged( true );
+ _mainpanel.getCurrentTreePanel().updateOvSettings();
+ _mainpanel.getCurrentTreePanel().validate();
+ _mainpanel.validate();
+ _mainpanel.getCurrentTreePanel().setParametersForPainting( _mainpanel.getSizeOfViewport().width,
+ _mainpanel.getSizeOfViewport().height,
+ true );
+ _mainpanel.getCurrentTreePanel().resetPreferredSize();
+ _mainpanel.adjustJScrollPane();
+ _mainpanel.getCurrentTreePanel().repaint();
+ _mainpanel.getCurrentTreePanel().validate();
+ _mainpanel.validate();
+ _mainpanel.getCurrentTreePanel().setParametersForPainting( _mainpanel.getSizeOfViewport().width,
+ _mainpanel.getSizeOfViewport().height,
+ true );
+ _mainpanel.getCurrentTreePanel().resetPreferredSize();
+ _mainpanel.adjustJScrollPane();
+ _mainpanel.getCurrentTreePanel().repaint();
+ _mainpanel.getCurrentTreePanel().updateOvSizes();
+ }
+
+ void showWholeAll() {
+ for( final TreePanel tree_panel : _mainpanel.getTreePanels() ) {
+ if ( tree_panel != null ) {
+ tree_panel.validate();
+ tree_panel.setParametersForPainting( _mainpanel.getSizeOfViewport().width,
+ _mainpanel.getSizeOfViewport().height,
+ true );
+ tree_panel.resetPreferredSize();
+ tree_panel.repaint();
+ }
+ }
+ }
+
+ // Create header for click-to combo box.
+ void startClickToOptions() {
+ final JLabel spacer = new JLabel( "" );
+ spacer.setFont( ControlPanel.jcb_font );
+ add( spacer );
+ _click_to_label = new JLabel( "Click on Node to:" );
+ add( customizeLabel( _click_to_label, getConfiguration() ) );
+ _click_to_combobox = new JComboBox();
+ _click_to_combobox.setFocusable( false );
+ _click_to_combobox.setMaximumRowCount( 14 );
+ _click_to_combobox.setFont( ControlPanel.js_font );
+ if ( !_configuration.isUseNativeUI() ) {
+ _click_to_combobox.setBackground( getConfiguration().getGuiBackgroundColor() );
+ }
+ // don't add listener until all items are set (or each one will trigger
+ // an event)
+ // click_to_list.addActionListener(this);
+ add( _click_to_combobox );
+ // Correlates option names to titles
+ _all_click_to_names = new HashMap<Integer, String>();
+ _click_to_names = new ArrayList<String>();
+ }
+
+ void tabChanged() {
+ if ( getMainPanel().getTabbedPane().getTabCount() > 0 ) {
+ if ( getCurrentTreePanel().isPhyHasBranchLengths()
+ && ( getCurrentTreePanel().getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) {
+ setDrawPhylogramEnabled( true );
+ setDrawPhylogram( isDrawPhylogram() );
+ }
+ else {
+ setDrawPhylogramEnabled( false );
+ setDrawPhylogram( false );
+ }
+ if ( getMainPanel().getMainFrame() == null ) {
+ // Must be "E" applet version.
+ final ArchaeopteryxE e = ( ArchaeopteryxE ) ( ( MainPanelApplets ) getMainPanel() ).getApplet();
+ e.setSelectedTypeInTypeMenu( e.getCurrentTreePanel().getPhylogenyGraphicsType() );
+ }
+ else {
+ getMainPanel().getMainFrame().setSelectedTypeInTypeMenu( getMainPanel().getCurrentTreePanel()
+ .getPhylogenyGraphicsType() );
+ }
+ getMainPanel().getCurrentTreePanel().updateSubSuperTreeButton();
+ getMainPanel().getControlPanel().search();
+ getSequenceRelationTypeBox().removeAllItems();
+ for( final SequenceRelation.SEQUENCE_RELATION_TYPE type : getMainPanel().getCurrentPhylogeny()
+ .getRelevantSequenceRelationTypes() ) {
+ _sequence_relation_type_box.addItem( type );
+ }
+ //setSequenceRelationQueries( getMainPanel().getCurrentPhylogeny().getSequenceRelationQueries() );
+ // according to GUILHEM the line above can be removed.
+ }
+ }
+
+ /**
+ * Uncollapse all nodes.
+ */
+ void uncollapseAll( final TreePanel tp ) {
+ final Phylogeny t = tp.getPhylogeny();
+ if ( ( t != null ) && !t.isEmpty() ) {
+ for( final PhylogenyNodeIterator iter = t.iteratorPreorder(); iter.hasNext(); ) {
+ final PhylogenyNode node = iter.next();
+ node.setCollapse( false );
+ }
+ tp.resetNodeIdToDistToLeafMap();
+ tp.updateSetOfCollapsedExternalNodes();
+ t.recalculateNumberOfExternalDescendants( false );
+ tp.setNodeInPreorderToNull();
+ t.clearHashIdToNodeMap();
+ showWhole();
+ }
+ }
+
+ void updateDomainStructureEvaluethresholdDisplay() {
+ if ( _domain_structure_evalue_thr_tf != null ) {
+ _domain_structure_evalue_thr_tf.setText( "10^"
+ + getMainPanel().getCurrentTreePanel().getDomainStructureEvalueThreshold() );
+ }
+ }
+
+ void zoomInX( final float factor, final float x_correction_factor ) {
+ final JScrollBar sb = getMainPanel().getCurrentScrollPane().getHorizontalScrollBar();
+ final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
+ treepanel.multiplyUrtFactor( 1f );
+ if ( ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
+ || ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED )
+ || isDrawPhylogram( getMainPanel().getCurrentTabIndex() )
+ || ( getOptions().getCladogramType() == CLADOGRAM_TYPE.NON_LINED_UP ) ) {
+ final double x = ( sb.getMaximum() - sb.getMinimum() ) / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
+ treepanel.setXdistance( ( treepanel.getXdistance() * factor ) );
+ treepanel.setXcorrectionFactor( ( treepanel.getXcorrectionFactor() * x_correction_factor ) );
+ getMainPanel().adjustJScrollPane();
+ treepanel.resetPreferredSize();
+ getMainPanel().getCurrentScrollPane().getViewport().validate();
+ sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
+ - ( sb.getVisibleAmount() / 2.0 ) ) );
+ }
+ else {
+ final int x = sb.getMaximum() - sb.getMinimum() - sb.getVisibleAmount() - sb.getValue();
+ treepanel.setXdistance( ( treepanel.getXdistance() * factor ) );
+ treepanel.setXcorrectionFactor( ( treepanel.getXcorrectionFactor() * x_correction_factor ) );
+ getMainPanel().adjustJScrollPane();
+ treepanel.resetPreferredSize();
+ getMainPanel().getCurrentScrollPane().getViewport().validate();
+ sb.setValue( sb.getMaximum() - sb.getMinimum() - x - sb.getVisibleAmount() );
+ }
+ treepanel.resetPreferredSize();
+ treepanel.updateOvSizes();
+ }
+
+ void zoomInY( final float factor ) {
+ final JScrollBar sb = getMainPanel().getCurrentScrollPane().getVerticalScrollBar();
+ final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
+ treepanel.multiplyUrtFactor( 1.1f );
+ final double x = ( sb.getMaximum() - sb.getMinimum() ) / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
+ treepanel.setYdistance( ( treepanel.getYdistance() * factor ) );
+ getMainPanel().adjustJScrollPane();
+ treepanel.resetPreferredSize();
+ getMainPanel().getCurrentScrollPane().getViewport().validate();
+ sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
+ - ( sb.getVisibleAmount() / 2.0 ) ) );
+ treepanel.resetPreferredSize();
+ treepanel.updateOvSizes();
+ }
+
+ void zoomOutX( final float factor, final float x_correction_factor ) {
+ final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
+ treepanel.multiplyUrtFactor( 1f );
+ if ( ( treepanel.getXdistance() * factor ) > 0.0 ) {
+ final JScrollBar sb = getMainPanel().getCurrentScrollPane().getHorizontalScrollBar();
+ if ( ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR )
+ || ( treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED )
+ || isDrawPhylogram( getMainPanel().getCurrentTabIndex() )
+ || ( getOptions().getCladogramType() == CLADOGRAM_TYPE.NON_LINED_UP ) ) {
+ getMainPanel().adjustJScrollPane();
+ treepanel.resetPreferredSize();
+ getMainPanel().getCurrentScrollPane().getViewport().validate();
+ final double x = ( sb.getMaximum() - sb.getMinimum() )
+ / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
+ treepanel.setXdistance( ( treepanel.getXdistance() * factor ) );
+ treepanel.setXcorrectionFactor( ( treepanel.getXcorrectionFactor() * x_correction_factor ) );
+ getMainPanel().adjustJScrollPane();
+ treepanel.resetPreferredSize();
+ getMainPanel().getCurrentScrollPane().getViewport().validate();
+ sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
+ - ( sb.getVisibleAmount() / 2.0 ) ) );
+ }
+ else {
+ final int x = sb.getMaximum() - sb.getMinimum() - sb.getVisibleAmount() - sb.getValue();
+ treepanel.setXdistance( treepanel.getXdistance() * factor );
+ treepanel.setXcorrectionFactor( treepanel.getXcorrectionFactor() * x_correction_factor );
+ if ( x > 0 ) {
+ getMainPanel().adjustJScrollPane();
+ treepanel.resetPreferredSize();
+ getMainPanel().getCurrentScrollPane().getViewport().validate();
+ sb.setValue( sb.getMaximum() - sb.getMinimum() - x - sb.getVisibleAmount() );
+ }
+ }
+ treepanel.resetPreferredSize();
+ treepanel.updateOvSizes();
+ }
+ }
+
+ void zoomOutY( final float factor ) {
+ final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
+ treepanel.multiplyUrtFactor( 0.9f );
+ if ( ( treepanel.getYdistance() * factor ) > 0.0 ) {
+ final JScrollBar sb = getMainPanel().getCurrentScrollPane().getVerticalScrollBar();
+ final double x = ( sb.getMaximum() - sb.getMinimum() ) / ( sb.getValue() + ( sb.getVisibleAmount() / 2.0 ) );
+ treepanel.setYdistance( ( treepanel.getYdistance() * factor ) );
+ getMainPanel().adjustJScrollPane();
+ treepanel.resetPreferredSize();
+ getMainPanel().getCurrentScrollPane().getViewport().validate();
+ sb.setValue( ForesterUtil.roundToInt( ( ( sb.getMaximum() - sb.getMinimum() ) / x )
+ - ( sb.getVisibleAmount() / 2.0 ) ) );
+ treepanel.resetPreferredSize();
+ treepanel.updateOvSizes();
+ }
+ }
+
+ private void addClickToOption( final int which, final String title ) {
+ _click_to_combobox.addItem( title );
+ _click_to_names.add( title );
+ _all_click_to_names.put( new Integer( which ), title );
+ if ( !_configuration.isUseNativeUI() ) {
+ _click_to_combobox.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
+ _click_to_combobox.setForeground( getConfiguration().getGuiButtonTextColor() );
+ }
+ }
+
+ /* GUILHEM_BEG */
+ private void addSequenceRelationBlock() {
+ final JLabel spacer = new JLabel( "" );
+ spacer.setSize( 1, 1 );
+ add( spacer );
+ final JLabel mainLabel = new JLabel( "Sequence relations to display" );
+ final JLabel typeLabel = customizeLabel( new JLabel( "(type) " ), getConfiguration() );
+ typeLabel.setFont( ControlPanel.js_font.deriveFont( 7 ) );
+ getSequenceRelationTypeBox().setFocusable( false );
+ _sequence_relation_type_box.setFont( ControlPanel.js_font );
+ if ( !_configuration.isUseNativeUI() ) {
+ _sequence_relation_type_box.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
+ _sequence_relation_type_box.setForeground( getConfiguration().getGuiButtonTextColor() );
+ }
+ _sequence_relation_type_box.setRenderer( new ListCellRenderer() {
+
+ @Override
+ public Component getListCellRendererComponent( final JList list,
+ final Object value,
+ final int index,
+ final boolean isSelected,
+ final boolean cellHasFocus ) {
+ final Component component = new DefaultListCellRenderer().getListCellRendererComponent( list,
+ value,
+ index,
+ isSelected,
+ cellHasFocus );
+ if ( ( value != null ) && ( value instanceof SequenceRelation.SEQUENCE_RELATION_TYPE ) ) {
+ ( ( DefaultListCellRenderer ) component ).setText( SequenceRelation
+ .getPrintableNameByType( ( SequenceRelation.SEQUENCE_RELATION_TYPE ) value ) );
+ }
+ return component;
+ }
+ } );
+ final GridBagLayout gbl = new GridBagLayout();
+ _sequence_relation_type_box.setMinimumSize( new Dimension( 115, 17 ) );
+ _sequence_relation_type_box.setPreferredSize( new Dimension( 115, 20 ) );
+ final JPanel horizGrid = new JPanel( gbl );
+ horizGrid.setBackground( getBackground() );
+ horizGrid.add( typeLabel );
+ horizGrid.add( _sequence_relation_type_box );
+ add( customizeLabel( mainLabel, getConfiguration() ) );
+ add( horizGrid );
+ add( getSequenceRelationBox() );
+ if ( _configuration.doDisplayOption( Configuration.show_relation_confidence ) ) {
+ addCheckbox( Configuration.show_relation_confidence,
+ _configuration.getDisplayTitle( Configuration.show_relation_confidence ) );
+ setCheckbox( Configuration.show_relation_confidence,
+ _configuration.doCheckOption( Configuration.show_relation_confidence ) );
+ }
+ }// addSequenceRelationBlock
+
+ /* GUILHEM_END */
+ private List<Boolean> getIsDrawPhylogramList() {
+ return _draw_phylogram;
+ }
+
+ JLabel getSearchFoundCountsLabel() {
+ return _search_found_label;
+ }
+
+ JButton getSearchResetButton() {
+ return _search_reset_button;
+ }
+
+ private void init() {
+ _draw_phylogram = new ArrayList<Boolean>();
+ setSpeciesColors( new HashMap<String, Color>() );
+ setAnnotationColors( new HashMap<String, Color>() );
+ }
+
+ private boolean isDrawPhylogram( final int index ) {
+ return getIsDrawPhylogramList().get( index );
+ }
+
+ private void search( final MainPanel main_panel, final Phylogeny tree, final String query_str ) {
+ getSearchFoundCountsLabel().setVisible( true );
+ getSearchResetButton().setEnabled( true );
+ getSearchResetButton().setVisible( true );
+ String[] queries = null;
+ List<PhylogenyNode> nodes = null;
+ if ( query_str.indexOf( ',' ) >= 0 ) {
+ queries = query_str.split( ",+" );
+ }
+ else {
+ queries = new String[ 1 ];
+ queries[ 0 ] = query_str.trim();
+ }
+ if ( ( queries != null ) && ( queries.length > 0 ) ) {
+ nodes = new ArrayList<PhylogenyNode>();
+ for( String query : queries ) {
+ if ( ForesterUtil.isEmpty( query ) ) {
+ continue;
+ }
+ query = query.trim();
+ if ( query.indexOf( '+' ) >= 0 ) {
+ nodes.addAll( PhylogenyMethods.searchDataLogicalAnd( query.split( "\\++" ),
+ tree,
+ getOptions().isSearchCaseSensitive(),
+ !getOptions().isMatchWholeTermsOnly(),
+ isShowDomainArchitectures() ) );
+ }
+ else {
+ nodes.addAll( PhylogenyMethods.searchData( query,
+ tree,
+ getOptions().isSearchCaseSensitive(),
+ !getOptions().isMatchWholeTermsOnly(),
+ isShowDomainArchitectures() ) );
+ }
+ }
+ if ( getOptions().isInverseSearchResult() ) {
+ final List<PhylogenyNode> all = PhylogenyMethods.obtainAllNodesAsList( tree );
+ all.removeAll( nodes );
+ nodes = all;
+ }
+ }
+ if ( ( nodes != null ) && ( nodes.size() > 0 ) ) {
+ main_panel.getCurrentTreePanel().setFoundNodes( new HashSet<Integer>() );
+ for( final PhylogenyNode node : nodes ) {
+ main_panel.getCurrentTreePanel().getFoundNodes().add( node.getId() );
+ }
+ setSearchFoundCountsOnLabel( nodes.size() );
+ }
+ else {
+ setSearchFoundCountsOnLabel( 0 );
+ searchReset();
+ }
+ }
+
+ void searchReset() {
+ if ( getMainPanel().getCurrentTreePanel() != null ) {
+ getMainPanel().getCurrentTreePanel().setFoundNodes( null );
+ }
+ }
+
+ private void setDrawPhylogram( final int index, final boolean b ) {
+ getIsDrawPhylogramList().set( index, b );
+ }
+
+ void setSearchFoundCountsOnLabel( final int counts ) {
+ getSearchFoundCountsLabel().setText( "Found: " + counts );
+ }
+
+ private void setupClickToOptions() {
+ final int default_option = _configuration.getDefaultDisplayClicktoOption();
+ int selected_index = 0;
+ int cb_index = 0;
+ if ( _configuration.doDisplayClickToOption( Configuration.display_node_data ) ) {
+ _show_data_item = cb_index;
+ addClickToOption( Configuration.display_node_data,
+ _configuration.getClickToTitle( Configuration.display_node_data ) );
+ if ( default_option == Configuration.display_node_data ) {
+ selected_index = cb_index;
+ }
+ cb_index++;
+ }
+ if ( _configuration.doDisplayClickToOption( Configuration.collapse_uncollapse ) ) {
+ _collapse_cb_item = cb_index;
+ addClickToOption( Configuration.collapse_uncollapse,
+ _configuration.getClickToTitle( Configuration.collapse_uncollapse ) );
+ if ( default_option == Configuration.collapse_uncollapse ) {
+ selected_index = cb_index;
+ }
+ cb_index++;
+ }
+ if ( _configuration.doDisplayClickToOption( Configuration.reroot ) ) {
+ _reroot_cb_item = cb_index;
+ addClickToOption( Configuration.reroot, _configuration.getClickToTitle( Configuration.reroot ) );
+ if ( default_option == Configuration.reroot ) {
+ selected_index = cb_index;
+ }
+ cb_index++;