- if ( getControlPanel().isShowSeqSymbols() && ( node.getNodeData().getSequence().getSymbol().length() > 0 ) ) {
- if ( _sb.length() > 0 ) {
- _sb.append( " " );
- }
- _sb.append( node.getNodeData().getSequence().getSymbol() );
- }
- if ( getControlPanel().isShowGeneNames() && ( node.getNodeData().getSequence().getGeneName().length() > 0 ) ) {
- if ( _sb.length() > 0 ) {
- _sb.append( " " );
- }
- _sb.append( node.getNodeData().getSequence().getGeneName() );
- }
- if ( getControlPanel().isShowSeqNames() && ( node.getNodeData().getSequence().getName().length() > 0 ) ) {
- if ( _sb.length() > 0 ) {
- _sb.append( " " );
- }
- _sb.append( node.getNodeData().getSequence().getName() );
- }
- if ( getControlPanel().isShowSequenceAcc() && ( node.getNodeData().getSequence().getAccession() != null ) ) {
- if ( _sb.length() > 0 ) {
- _sb.append( " " );
- }
- if ( !ForesterUtil.isEmpty( node.getNodeData().getSequence().getAccession().getSource() ) ) {
- _sb.append( node.getNodeData().getSequence().getAccession().getSource() );
- _sb.append( ":" );
- }
- _sb.append( node.getNodeData().getSequence().getAccession().getValue() );
- }
- }
- if ( getControlPanel().isShowProperties() && node.getNodeData().isHasProperties() ) {
- if ( _sb.length() > 0 ) {
- _sb.append( " " );
- }
- _sb.append( propertiesToString( node ) );
- }
- Font visual_font = null;
- if ( getControlPanel().isUseVisualStyles() && ( node.getNodeData().getNodeVisualData() != null ) ) {
- visual_font = node.getNodeData().getNodeVisualData().getFont();
- g.setFont( visual_font != null ? visual_font : getTreeFontSet().getLargeFont() );
- }
- else {
- g.setFont( getTreeFontSet().getLargeFont() );
- }
- if ( is_in_found_nodes ) {
- g.setFont( getTreeFontSet().getLargeFont().deriveFont( Font.BOLD ) );
- }
- double down_shift_factor = 3.0;
- if ( !node.isExternal() && ( node.getNumberOfDescendants() == 1 ) ) {
- down_shift_factor = 1;
- }
- final double pos_x = node.getXcoord() + x + 2 + half_box_size;
- double pos_y;
- if ( visual_font == null ) {
- pos_y = ( node.getYcoord() + ( getTreeFontSet()._fm_large.getAscent() / down_shift_factor ) );
- }
- else {
- pos_y = ( node.getYcoord() + ( getFontMetrics( visual_font ).getAscent() / down_shift_factor ) );
- }
- final String sb_str = _sb.toString();
- // GUILHEM_BEG ______________
- if ( _control_panel.isShowSequenceRelations() && node.getNodeData().isHasSequence()
- && ( _query_sequence != null ) ) {
- int nodeTextBoundsWidth = 0;
- if ( sb_str.length() > 0 ) {
- final Rectangle2D node_text_bounds = new TextLayout( sb_str, g.getFont(), _frc ).getBounds(); //would like to remove this 'new', but how...
- nodeTextBoundsWidth = ( int ) node_text_bounds.getWidth();
- }
- if ( node.getNodeData().getSequence().equals( _query_sequence ) ) {
- if ( nodeTextBoundsWidth > 0 ) { // invert font color and background color to show that this is the query sequence
- g.fillRect( ( int ) pos_x - 1, ( int ) pos_y - 8, nodeTextBoundsWidth + 5, 11 );
- g.setColor( getTreeColorSet().getBackgroundColor() );
- }
- }
- else {
- final List<SequenceRelation> seqRelations = node.getNodeData().getSequence().getSequenceRelations();
- for( final SequenceRelation seqRelation : seqRelations ) {
- final boolean fGotRelationWithQuery = ( seqRelation.getRef0().isEqual( _query_sequence ) || seqRelation
- .getRef1().isEqual( _query_sequence ) )
- && seqRelation.getType().equals( getControlPanel().getSequenceRelationTypeBox()
- .getSelectedItem() );
- if ( fGotRelationWithQuery ) { // we will underline the text to show that this sequence is ortholog to the query
- final double linePosX = node.getXcoord() + 2 + half_box_size;
- final String sConfidence = ( !getControlPanel().isShowSequenceRelationConfidence() || ( seqRelation
- .getConfidence() == null ) ) ? null : " (" + seqRelation.getConfidence().getValue()
- + ")";
- if ( sConfidence != null ) {
- double confidenceX = pos_x;
- if ( sb_str.length() > 0 ) {
- confidenceX += new TextLayout( sb_str, g.getFont(), _frc ).getBounds().getWidth()
- + CONFIDENCE_LEFT_MARGIN;
- }
- if ( confidenceX > linePosX ) { // let's only display confidence value if we are already displaying at least one of Prot/Gene Name and Taxonomy Code
- final int confidenceWidth = ( int ) new TextLayout( sConfidence, g.getFont(), _frc )
- .getBounds().getWidth();
- TreePanel.drawString( sConfidence, confidenceX, pos_y, g );
- x += CONFIDENCE_LEFT_MARGIN + confidenceWidth;
- }
- }
- if ( ( x + nodeTextBoundsWidth ) > 0 ) /* we only underline if there is something displayed */
- {
- if ( nodeTextBoundsWidth == 0 ) {
- nodeTextBoundsWidth -= 3; /* the gap between taxonomy code and node name should not be underlined if nothing comes after it */
- }
- else {
- nodeTextBoundsWidth += 2;
- }
- g.drawLine( ( int ) linePosX + 1, 3 + ( int ) pos_y, ( int ) linePosX + x
- + nodeTextBoundsWidth, 3 + ( int ) pos_y );
- break;
- }
- }
- }
- }
- }
- if ( sb_str.length() > 0 ) {
- TreePanel.drawString( sb_str, pos_x, pos_y, g );
- }
- // GUILHEM_END _____________
- // COMMENTED_OUT_BY_GUILHEM_BEG _______________
- // TODO FIXME need to check this one!
- //if ( _sb.length() > 0 ) {
- // TreePanel.drawString( _sb.toString(), node.getXcoord() + x + 2 + TreePanel.HALF_BOX_SIZE, node.getYcoord()
- // + ( getTreeFontSet()._fm_large.getAscent() / down_shift_factor ), g );
- //}
- // COMMENTED_OUT_BY_GUILHEM_END ________________
- if ( getControlPanel().isShowAnnotation() && node.getNodeData().isHasSequence()
- && ( node.getNodeData().getSequence().getAnnotations() != null )
- && ( !node.getNodeData().getSequence().getAnnotations().isEmpty() ) ) {
- if ( _sb.length() > 0 ) {
- x += getTreeFontSet()._fm_large.stringWidth( _sb.toString() ) + 5;
- }
- final SortedSet<Annotation> ann = node.getNodeData().getSequence().getAnnotations();
- if ( ( to_pdf || to_graphics_file ) && getOptions().isPrintBlackAndWhite() ) {
- g.setColor( Color.BLACK );
- }
- else if ( getControlPanel().isColorAccordingToAnnotation() ) {
- g.setColor( calculateColorForAnnotation( ann ) );
- }
- final String ann_str = TreePanelUtil.createAnnotationString( ann, getOptions().isShowAnnotationRefSource() );
- TreePanel.drawString( ann_str, node.getXcoord() + x + 3 + half_box_size, node.getYcoord()
- + ( getTreeFontSet()._fm_large.getAscent() / down_shift_factor ), g );
- _sb.setLength( 0 );
- _sb.append( ann_str );
- }
- if ( ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR )
- || ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE )
- || ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.ROUNDED ) ) {
- if ( ( getControlPanel().isShowBinaryCharacters() || getControlPanel().isShowBinaryCharacterCounts() )
- && node.getNodeData().isHasBinaryCharacters() ) {
- if ( _sb.length() > 0 ) {
- x += getTreeFontSet()._fm_large.stringWidth( _sb.toString() ) + 5;
- }
- if ( ( to_pdf || to_graphics_file ) && getOptions().isPrintBlackAndWhite() ) {
- g.setColor( Color.BLACK );
- }
- else {
- g.setColor( getTreeColorSet().getBinaryDomainCombinationsColor() );
- }
- if ( getControlPanel().isShowBinaryCharacters() ) {
- TreePanel.drawString( node.getNodeData().getBinaryCharacters().getPresentCharactersAsStringBuffer()
- .toString(), node.getXcoord() + x + 1 + half_box_size, node.getYcoord()
- + ( getTreeFontSet()._fm_large.getAscent() / down_shift_factor ), g );
- paintGainedAndLostCharacters( g, node, node.getNodeData().getBinaryCharacters()
- .getGainedCharactersAsStringBuffer().toString(), node.getNodeData().getBinaryCharacters()
- .getLostCharactersAsStringBuffer().toString() );
- }
- else {
- TreePanel.drawString( " " + node.getNodeData().getBinaryCharacters().getPresentCount(),
- node.getXcoord() + x + 4 + half_box_size,
- node.getYcoord()
- + ( getTreeFontSet()._fm_large.getAscent() / down_shift_factor ),
- g );
- paintGainedAndLostCharacters( g, node, "+"
- + node.getNodeData().getBinaryCharacters().getGainedCount(), "-"
- + node.getNodeData().getBinaryCharacters().getLostCount() );
- }
- }