- return sb;
- }
-
- final private void setCopiedAndPastedNodes( final Set<Long> nodeIds ) {
- getMainPanel().setCopiedAndPastedNodes( nodeIds );
- }
-
- final private void setCutOrCopiedTree( final Phylogeny cut_or_copied_tree ) {
- getMainPanel().setCutOrCopiedTree( cut_or_copied_tree );
- }
-
- final private void setInOv( final boolean in_ov ) {
- _in_ov = in_ov;
- }
-
- final private void setOvMaxHeight( final float ov_max_height ) {
- _ov_max_height = ov_max_height;
- }
-
- final private void setOvMaxWidth( final float ov_max_width ) {
- _ov_max_width = ov_max_width;
- }
-
- final private void setOvXcorrectionFactor( final float f ) {
- _ov_x_correction_factor = f;
- }
-
- final private void setOvXDistance( final float ov_x_distance ) {
- _ov_x_distance = ov_x_distance;
- }
-
- final private void setOvXPosition( final int ov_x_position ) {
- _ov_x_position = ov_x_position;
- }
-
- final private void setOvYDistance( final float ov_y_distance ) {
- _ov_y_distance = ov_y_distance;
- }
-
- final private void setOvYPosition( final int ov_y_position ) {
- _ov_y_position = ov_y_position;
- }
-
- final private void setOvYStart( final int ov_y_start ) {
- _ov_y_start = ov_y_start;
- }
-
- final private void setScaleDistance( final double scale_distance ) {
- _scale_distance = scale_distance;
- }
-
- final private void setScaleLabel( final String scale_label ) {
- _scale_label = scale_label;
- }
-
- private final void setupStroke( final Graphics2D g ) {
- if ( getYdistance() < 0.001 ) {
- g.setStroke( STROKE_005 );
- }
- else if ( getYdistance() < 0.01 ) {
- g.setStroke( STROKE_01 );
- }
- else if ( getYdistance() < 0.5 ) {
- g.setStroke( STROKE_025 );
- }
- else if ( getYdistance() < 1 ) {
- g.setStroke( STROKE_05 );
- }
- else if ( getYdistance() < 2 ) {
- g.setStroke( STROKE_075 );
- }
- else if ( getYdistance() < 20 ) {
- g.setStroke( STROKE_1 );
- }
- else {
- g.setStroke( STROKE_2 );
- }
- }
-
- final private void setUpUrtFactor() {
- final int d = getVisibleRect().width < getVisibleRect().height ? getVisibleRect().width
- : getVisibleRect().height;
- if ( isPhyHasBranchLengths() && getControlPanel().isDrawPhylogram() ) {
- setUrtFactor( ( float ) ( d / ( 2 * getMaxDistanceToRoot() ) ) );
- }
- else {
- final int max_depth = _circ_max_depth;
- if ( max_depth > 0 ) {
- setUrtFactor( d / ( 2 * max_depth ) );
- }
- else {
- setUrtFactor( d / 2 );
- }
- }
- setUrtFactorOv( getUrtFactor() );
- }
-
- final private void setUrtFactor( final float urt_factor ) {
- _urt_factor = urt_factor;
- }
-
- final private void setUrtFactorOv( final float urt_factor_ov ) {
- _urt_factor_ov = urt_factor_ov;
- }
-
- private void showExtDescNodeData( final PhylogenyNode node ) {
- final List<String> data = new ArrayList<String>();
- final List<PhylogenyNode> nodes = node.getAllExternalDescendants();
- if ( ( getFoundNodes0() != null ) && !getFoundNodes0().isEmpty() ) {
- for( final PhylogenyNode n : getFoundNodes0AsListOfPhylogenyNodes() ) {
- if ( !nodes.contains( n ) ) {
- nodes.add( n );
- }
- }
- }
- if ( ( getFoundNodes1() != null ) && !getFoundNodes1().isEmpty() ) {
- for( final PhylogenyNode n : getFoundNodes1AsListOfPhylogenyNodes() ) {
- if ( !nodes.contains( n ) ) {
- nodes.add( n );
- }
- }
- }
- for( final PhylogenyNode n : nodes ) {
- switch ( getOptions().getExtDescNodeDataToReturn() ) {
- case NODE_NAME:
- if ( !ForesterUtil.isEmpty( n.getName() ) ) {
- data.add( n.getName() );
- }
- break;
- case SEQUENCE_NAME:
- if ( n.getNodeData().isHasSequence()
- && !ForesterUtil.isEmpty( n.getNodeData().getSequence().getName() ) ) {
- data.add( n.getNodeData().getSequence().getName() );
- }
- break;
- case GENE_NAME:
- if ( n.getNodeData().isHasSequence()
- && !ForesterUtil.isEmpty( n.getNodeData().getSequence().getGeneName() ) ) {
- data.add( n.getNodeData().getSequence().getGeneName() );
- }
- break;
- case SEQUENCE_SYMBOL:
- if ( n.getNodeData().isHasSequence()
- && !ForesterUtil.isEmpty( n.getNodeData().getSequence().getSymbol() ) ) {
- data.add( n.getNodeData().getSequence().getSymbol() );
- }
- break;
- case SEQUENCE_MOL_SEQ:
- if ( n.getNodeData().isHasSequence()
- && !ForesterUtil.isEmpty( n.getNodeData().getSequence().getMolecularSequence() ) ) {
- data.add( n.getNodeData().getSequence().getMolecularSequence() );
- }
- break;
- case SEQUENCE_MOL_SEQ_FASTA:
- final StringBuilder sb = new StringBuilder();
- if ( n.getNodeData().isHasSequence()
- && !ForesterUtil.isEmpty( n.getNodeData().getSequence().getMolecularSequence() ) ) {
- final StringBuilder ann = new StringBuilder();
- if ( !ForesterUtil.isEmpty( n.getName() ) ) {
- ann.append( n.getName() );
- ann.append( "|" );
- }
- if ( !ForesterUtil.isEmpty( n.getNodeData().getSequence().getSymbol() ) ) {
- ann.append( "SYM=" );
- ann.append( n.getNodeData().getSequence().getSymbol() );
- ann.append( "|" );
- }
- if ( !ForesterUtil.isEmpty( n.getNodeData().getSequence().getName() ) ) {
- ann.append( "NAME=" );
- ann.append( n.getNodeData().getSequence().getName() );
- ann.append( "|" );
- }
- if ( !ForesterUtil.isEmpty( n.getNodeData().getSequence().getGeneName() ) ) {
- ann.append( "GN=" );
- ann.append( n.getNodeData().getSequence().getGeneName() );
- ann.append( "|" );
- }
- if ( n.getNodeData().getSequence().getAccession() != null ) {
- ann.append( "ACC=" );
- ann.append( n.getNodeData().getSequence().getAccession().asText() );
- ann.append( "|" );
- }
- if ( n.getNodeData().isHasTaxonomy() ) {
- if ( !ForesterUtil.isEmpty( n.getNodeData().getTaxonomy().getTaxonomyCode() ) ) {
- ann.append( "TAXID=" );
- ann.append( n.getNodeData().getTaxonomy().getTaxonomyCode() );
- ann.append( "|" );
- }
- if ( !ForesterUtil.isEmpty( n.getNodeData().getTaxonomy().getScientificName() ) ) {
- ann.append( "SN=" );
- ann.append( n.getNodeData().getTaxonomy().getScientificName() );
- ann.append( "|" );
- }
- }
- String ann_str;
- if ( ann.charAt( ann.length() - 1 ) == '|' ) {
- ann_str = ann.substring( 0, ann.length() - 1 );
- }
- else {
- ann_str = ann.toString();
- }
- sb.append( SequenceWriter.toFasta( ann_str, n.getNodeData().getSequence()
- .getMolecularSequence(), 60 ) );
- data.add( sb.toString() );
- }
- break;
- case SEQUENCE_ACC:
- if ( n.getNodeData().isHasSequence() && ( n.getNodeData().getSequence().getAccession() != null )
- && !ForesterUtil.isEmpty( n.getNodeData().getSequence().getAccession().toString() ) ) {
- data.add( n.getNodeData().getSequence().getAccession().toString() );
- }
- break;
- case TAXONOMY_SCIENTIFIC_NAME:
- if ( n.getNodeData().isHasTaxonomy()
- && !ForesterUtil.isEmpty( n.getNodeData().getTaxonomy().getScientificName() ) ) {
- data.add( n.getNodeData().getTaxonomy().getScientificName() );
- }
- break;
- case TAXONOMY_COMM0N_NAME:
- if ( n.getNodeData().isHasTaxonomy()
- && !ForesterUtil.isEmpty( n.getNodeData().getTaxonomy().getCommonName() ) ) {
- data.add( n.getNodeData().getTaxonomy().getCommonName() );
- }
- break;
- case TAXONOMY_CODE:
- if ( n.getNodeData().isHasTaxonomy()
- && !ForesterUtil.isEmpty( n.getNodeData().getTaxonomy().getTaxonomyCode() ) ) {
- data.add( n.getNodeData().getTaxonomy().getTaxonomyCode() );
- }
- break;
- case UNKNOWN:
- TreePanelUtil.showExtDescNodeDataUserSelectedHelper( getControlPanel(), n, data );
- break;
- default:
- throw new IllegalArgumentException( "unknown data element: "
- + getOptions().getExtDescNodeDataToReturn() );
- }
- } // for loop
- final StringBuilder sb = new StringBuilder();
- final int size = TreePanelUtil.makeSB( data, getOptions(), sb );
- if ( ( getConfiguration().getExtNodeDataReturnOn() == EXT_NODE_DATA_RETURN_ON.CONSOLE )
- || ( getConfiguration().getExtNodeDataReturnOn() == EXT_NODE_DATA_RETURN_ON.BUFFER_ONLY ) ) {
- if ( getConfiguration().getExtNodeDataReturnOn() == EXT_NODE_DATA_RETURN_ON.CONSOLE ) {
- System.out.println( sb );
- }
- if ( sb.length() < 1 ) {
- clearCurrentExternalNodesDataBuffer();
- }
- else {
- setCurrentExternalNodesDataBuffer( sb );
- }
- }
- else if ( getConfiguration().getExtNodeDataReturnOn() == EXT_NODE_DATA_RETURN_ON.WINODW ) {
- if ( sb.length() < 1 ) {
- TreePanelUtil.showInformationMessage( this, "No Appropriate Data (" + obtainTitleForExtDescNodeData()
- + ")", "Descendants of selected node do not contain selected data" );
- clearCurrentExternalNodesDataBuffer();
- }
- else {
- setCurrentExternalNodesDataBuffer( sb );
- String title;
- if ( ( getFoundNodes0() != null ) && !getFoundNodes0().isEmpty() ) {
- title = ( getOptions().getExtDescNodeDataToReturn() == NODE_DATA.UNKNOWN ? "Data"
- : obtainTitleForExtDescNodeData() )
- + " for "
- + data.size()
- + " nodes, unique entries: "
- + size;
- }
- else {
- title = ( getOptions().getExtDescNodeDataToReturn() == NODE_DATA.UNKNOWN ? "Data"
- : obtainTitleForExtDescNodeData() )
- + " for "
- + data.size()
- + "/"
- + node.getNumberOfExternalNodes()
- + " external descendats of node "
- + node
- + ", unique entries: " + size;
- }
- final String s = sb.toString().trim();
- if ( getMainPanel().getMainFrame() == null ) {
- // Must be "E" applet version.
- final ArchaeopteryxE ae = ( ArchaeopteryxE ) ( ( MainPanelApplets ) getMainPanel() ).getApplet();
- ae.showTextFrame( s, title );
- }
- else {
- getMainPanel().getMainFrame().showTextFrame( s, title );
- }
- }
- }
- }
-
- final private void showNodeDataPopup( final MouseEvent e, final PhylogenyNode node ) {
- try {
- if ( ( node.getName().length() > 0 )
- || ( node.getNodeData().isHasTaxonomy() && !TreePanelUtil.isTaxonomyEmpty( node.getNodeData()
- .getTaxonomy() ) )
- || ( node.getNodeData().isHasSequence() && !TreePanelUtil.isSequenceEmpty( node.getNodeData()
- .getSequence() ) ) || ( node.getNodeData().isHasDate() )
- || ( node.getNodeData().isHasDistribution() ) || node.getBranchData().isHasConfidences() ) {
- _popup_buffer.setLength( 0 );
- short lines = 0;
- if ( node.getName().length() > 0 ) {
- lines++;
- _popup_buffer.append( node.getName() );
- }
- if ( node.getNodeData().isHasTaxonomy()
- && !TreePanelUtil.isTaxonomyEmpty( node.getNodeData().getTaxonomy() ) ) {
- lines++;
- boolean enc_data = false;
- final Taxonomy tax = node.getNodeData().getTaxonomy();
- if ( _popup_buffer.length() > 0 ) {
- _popup_buffer.append( "\n" );
- }
- if ( !ForesterUtil.isEmpty( tax.getTaxonomyCode() ) ) {
- _popup_buffer.append( "[" );
- _popup_buffer.append( tax.getTaxonomyCode() );
- _popup_buffer.append( "]" );
- enc_data = true;
- }
- if ( !ForesterUtil.isEmpty( tax.getScientificName() ) ) {
- if ( enc_data ) {
- _popup_buffer.append( " " );
- }
- _popup_buffer.append( tax.getScientificName() );
- enc_data = true;
- }
- if ( !ForesterUtil.isEmpty( tax.getCommonName() ) ) {
- if ( enc_data ) {
- _popup_buffer.append( " (" );
- }
- else {
- _popup_buffer.append( "(" );
- }
- _popup_buffer.append( tax.getCommonName() );
- _popup_buffer.append( ")" );
- enc_data = true;
- }
- if ( !ForesterUtil.isEmpty( tax.getAuthority() ) ) {
- if ( enc_data ) {
- _popup_buffer.append( " (" );
- }
- else {
- _popup_buffer.append( "(" );
- }
- _popup_buffer.append( tax.getAuthority() );
- _popup_buffer.append( ")" );
- enc_data = true;
- }
- if ( !ForesterUtil.isEmpty( tax.getRank() ) ) {
- if ( enc_data ) {
- _popup_buffer.append( " [" );
- }
- else {
- _popup_buffer.append( "[" );
- }
- _popup_buffer.append( tax.getRank() );
- _popup_buffer.append( "]" );
- enc_data = true;
- }
- if ( tax.getSynonyms().size() > 0 ) {
- if ( enc_data ) {
- _popup_buffer.append( " " );
- }
- _popup_buffer.append( "[" );
- int counter = 1;
- for( final String syn : tax.getSynonyms() ) {
- if ( !ForesterUtil.isEmpty( syn ) ) {
- enc_data = true;
- _popup_buffer.append( syn );
- if ( counter < tax.getSynonyms().size() ) {
- _popup_buffer.append( ", " );
- }
- }
- counter++;
- }
- _popup_buffer.append( "]" );
- }
- if ( !enc_data ) {
- if ( ( tax.getIdentifier() != null ) && !ForesterUtil.isEmpty( tax.getIdentifier().getValue() ) ) {
- if ( !ForesterUtil.isEmpty( tax.getIdentifier().getProvider() ) ) {
- _popup_buffer.append( "[" );
- _popup_buffer.append( tax.getIdentifier().getProvider() );
- _popup_buffer.append( "] " );
- }
- _popup_buffer.append( tax.getIdentifier().getValue() );
- }
- }
- }
- if ( node.getNodeData().isHasSequence()
- && !TreePanelUtil.isSequenceEmpty( node.getNodeData().getSequence() ) ) {
- lines++;
- boolean enc_data = false;
- if ( _popup_buffer.length() > 0 ) {
- _popup_buffer.append( "\n" );
- }
- final Sequence seq = node.getNodeData().getSequence();
- if ( seq.getAccession() != null ) {
- _popup_buffer.append( "[" );
- if ( !ForesterUtil.isEmpty( seq.getAccession().getSource() ) ) {
- _popup_buffer.append( seq.getAccession().getSource() );
- _popup_buffer.append( ":" );
- }
- _popup_buffer.append( seq.getAccession().getValue() );
- _popup_buffer.append( "]" );
- enc_data = true;
- }
- if ( !ForesterUtil.isEmpty( seq.getSymbol() ) ) {
- if ( enc_data ) {
- _popup_buffer.append( " [" );
- }
- else {
- _popup_buffer.append( "[" );
- }
- _popup_buffer.append( seq.getSymbol() );
- _popup_buffer.append( "]" );
- enc_data = true;
- }
- if ( !ForesterUtil.isEmpty( seq.getGeneName() ) ) {
- if ( enc_data ) {
- _popup_buffer.append( " [" );
- }
- else {
- _popup_buffer.append( "[" );
- }
- _popup_buffer.append( seq.getGeneName() );
- _popup_buffer.append( "]" );
- enc_data = true;
- }
- if ( !ForesterUtil.isEmpty( seq.getName() ) ) {
- if ( enc_data ) {
- _popup_buffer.append( " " );
- }
- _popup_buffer.append( seq.getName() );
- }
- }
- if ( node.getNodeData().isHasDate() ) {
- lines++;
- if ( _popup_buffer.length() > 0 ) {
- _popup_buffer.append( "\n" );
- }
- _popup_buffer.append( node.getNodeData().getDate().asSimpleText() );
- }
- if ( node.getNodeData().isHasDistribution() ) {
- lines++;
- if ( _popup_buffer.length() > 0 ) {
- _popup_buffer.append( "\n" );
- }
- _popup_buffer.append( node.getNodeData().getDistribution().asSimpleText() );
- }
- if ( node.getBranchData().isHasConfidences() ) {
- final List<Confidence> confs = node.getBranchData().getConfidences();
- for( final Confidence confidence : confs ) {
- lines++;
- if ( _popup_buffer.length() > 0 ) {
- _popup_buffer.append( "\n" );
- }
- if ( !ForesterUtil.isEmpty( confidence.getType() ) ) {
- _popup_buffer.append( "[" );
- _popup_buffer.append( confidence.getType() );
- _popup_buffer.append( "] " );
- }
- _popup_buffer
- .append( FORMATTER_CONFIDENCE.format( ForesterUtil.round( confidence.getValue(),
- getOptions()
- .getNumberOfDigitsAfterCommaForConfidenceValues() ) ) );
- if ( confidence.getStandardDeviation() != Confidence.CONFIDENCE_DEFAULT_VALUE ) {
- _popup_buffer.append( " (sd=" );
- _popup_buffer.append( FORMATTER_CONFIDENCE.format( ForesterUtil.round( confidence
- .getStandardDeviation(), getOptions()
- .getNumberOfDigitsAfterCommaForConfidenceValues() ) ) );
- _popup_buffer.append( ")" );
- }
- }
- }
- if ( node.getNodeData().isHasProperties() ) {
- final PropertiesMap properties = node.getNodeData().getProperties();
- for( final String ref : properties.getPropertyRefs() ) {
- _popup_buffer.append( "\n" );
- final Property p = properties.getProperty( ref );
- _popup_buffer.append( TreePanelUtil.getPartAfterColon( p.getRef() ) );
- _popup_buffer.append( "=" );
- _popup_buffer.append( p.getValue() );
- if ( !ForesterUtil.isEmpty( p.getUnit() ) ) {
- _popup_buffer.append( TreePanelUtil.getPartAfterColon( p.getUnit() ) );
- }
- }
- }
- if ( _popup_buffer.length() > 0 ) {
- if ( !getConfiguration().isUseNativeUI() ) {
- _rollover_popup
- .setBorder( BorderFactory.createLineBorder( getTreeColorSet().getBranchColor() ) );
- _rollover_popup.setBackground( getTreeColorSet().getBackgroundColor() );
- if ( isInFoundNodes0( node ) && !isInFoundNodes1( node ) ) {
- _rollover_popup.setForeground( getTreeColorSet().getFoundColor0() );
- }
- else if ( !isInFoundNodes0( node ) && isInFoundNodes1( node ) ) {
- _rollover_popup.setForeground( getTreeColorSet().getFoundColor1() );
- }
- else if ( isInFoundNodes0( node ) && isInFoundNodes1( node ) ) {
- _rollover_popup.setForeground( getTreeColorSet().getFoundColor0and1() );
- }
- else if ( getControlPanel().isColorAccordingToTaxonomy() ) {
- _rollover_popup.setForeground( getTaxonomyBasedColor( node ) );
- }
- else {
- _rollover_popup.setForeground( getTreeColorSet().getSequenceColor() );
- }
- }
- else {
- _rollover_popup.setBorder( BorderFactory.createLineBorder( Color.BLACK ) );
- }
- _rollover_popup.setText( _popup_buffer.toString() );
- _node_desc_popup = PopupFactory.getSharedInstance().getPopup( null,
- _rollover_popup,
- e.getLocationOnScreen().x + 10,
- e.getLocationOnScreen().y
- - ( lines * 20 ) );
- _node_desc_popup.show();
- }
- }
- }
- catch ( final Exception ex ) {
- // Do nothing.