X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=forester%2Fjava%2Fsrc%2Forg%2Fforester%2Farchaeopteryx%2FTreePanel.java;h=632131577a5c3ca3af78ca992ac053935cfd80d4;hb=3087ea10ac51cf1a8b2eb8d8abe010513ce9998f;hp=6d0c4aec3c67f9a8f891cb1691cc9d2873f6369b;hpb=f6b29c53c14e1ef16e4cd614c7f9465e0073309e;p=jalview.git diff --git a/forester/java/src/org/forester/archaeopteryx/TreePanel.java b/forester/java/src/org/forester/archaeopteryx/TreePanel.java index 6d0c4ae..6321315 100644 --- a/forester/java/src/org/forester/archaeopteryx/TreePanel.java +++ b/forester/java/src/org/forester/archaeopteryx/TreePanel.java @@ -78,13 +78,13 @@ import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Hashtable; +import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; import java.util.SortedSet; import javax.swing.BorderFactory; -import javax.swing.JApplet; import javax.swing.JColorChooser; import javax.swing.JDialog; import javax.swing.JMenuItem; @@ -97,7 +97,6 @@ import javax.swing.PopupFactory; import org.forester.archaeopteryx.Configuration.EXT_NODE_DATA_RETURN_ON; import org.forester.archaeopteryx.ControlPanel.NodeClickAction; -import org.forester.archaeopteryx.ControlPanel.TreeDisplayType; import org.forester.archaeopteryx.Options.CLADOGRAM_TYPE; import org.forester.archaeopteryx.Options.NODE_LABEL_DIRECTION; import org.forester.archaeopteryx.Options.PHYLOGENY_GRAPHICS_TYPE; @@ -123,8 +122,6 @@ import org.forester.phylogeny.data.NodeVisualData; import org.forester.phylogeny.data.NodeVisualData.NodeFill; import org.forester.phylogeny.data.NodeVisualData.NodeShape; import org.forester.phylogeny.data.PhylogenyDataUtil; -import org.forester.phylogeny.data.PropertiesMap; -import org.forester.phylogeny.data.Property; import org.forester.phylogeny.data.ProteinDomain; import org.forester.phylogeny.data.Sequence; import org.forester.phylogeny.data.SequenceRelation; @@ -132,7 +129,6 @@ import org.forester.phylogeny.data.Taxonomy; import org.forester.phylogeny.data.Uri; import org.forester.phylogeny.iterators.PhylogenyNodeIterator; import org.forester.phylogeny.iterators.PreorderTreeIterator; -import org.forester.util.BasicDescriptiveStatistics; import org.forester.util.DescriptiveStatistics; import org.forester.util.ForesterConstants; import org.forester.util.ForesterUtil; @@ -262,7 +258,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee 2.0f }, 0f ); private static final double TWO_PI = 2 * Math.PI; - private final static int WIGGLE = 2; + private final static int WIGGLE = 3; private static final String SHOW_ONLY_THIS_CONF_TYPE = null; //TODO remove me HashMap _nodeid_dist_to_leaf = new HashMap(); final private Arc2D _arc = new Arc2D.Double(); @@ -384,7 +380,6 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee init(); // if ( !_phylogeny.isEmpty() ) { _phylogeny.recalculateNumberOfExternalDescendants( true ); - checkForVectorProperties( _phylogeny ); // } setBackground( getTreeColorSet().getBackgroundColor() ); final MouseListener mouse_listener = new MouseListener( this ); @@ -539,20 +534,9 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee @Override final public void paintComponent( final Graphics g ) { - // Dimension currentSize = getSize(); - // if ( offscreenImage == null || !currentSize.equals( offscreenDimension ) ) { - // call the 'java.awt.Component.createImage(...)' method to get an - // image - // offscreenImage = createImage( currentSize.width, currentSize.height ); - // offscreenGraphics = offscreenImage.getGraphics(); - // offscreenDimension = currentSize; - // } - // super.paintComponent( g ); //why? - //final Graphics2D g2d = ( Graphics2D ) offscreenGraphics; final Graphics2D g2d = ( Graphics2D ) g; g2d.setRenderingHints( _rendering_hints ); paintPhylogeny( g2d, false, false, 0, 0, 0, 0 ); - //g.drawImage( offscreenImage, 0, 0, this ); } @Override @@ -741,12 +725,8 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee type = 'n'; } } - JApplet applet = null; - if ( isApplet() ) { - applet = obtainApplet(); - } try { - Blast.openNcbiBlastWeb( query, type == 'n', applet, this ); + Blast.openNcbiBlastWeb( query, type == 'n', this ); } catch ( final Exception e ) { e.printStackTrace(); @@ -1307,17 +1287,6 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee return _last_drag_point_y; } - final private short getMaxBranchesToLeaf( final PhylogenyNode node ) { - if ( !_nodeid_dist_to_leaf.containsKey( node.getId() ) ) { - final short m = PhylogenyMethods.calculateMaxBranchesToLeaf( node ); - _nodeid_dist_to_leaf.put( node.getId(), m ); - return m; - } - else { - return _nodeid_dist_to_leaf.get( node.getId() ); - } - } - final private double getMaxDistanceToRoot() { if ( _max_distance_to_root < 0 ) { recalculateMaxDistanceToRoot(); @@ -1456,7 +1425,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee sortDescendants( node ); break; case GET_EXT_DESC_DATA: - showExtDescNodeData( node ); + showExtDescNodeData( node, '_' ); break; case UNCOLLAPSE_ALL: uncollapseAll( node ); @@ -1744,7 +1713,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee decreaseOvSize(); } } - if ( e.getKeyCode() == KeyEvent.VK_HOME ) { + if ( e.getKeyCode() == KeyEvent.VK_HOME || e.getKeyCode() == KeyEvent.VK_ESCAPE ) { getControlPanel().showWhole(); } else if ( e.getKeyCode() == KeyEvent.VK_PAGE_UP ) { @@ -2004,10 +1973,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee if ( !ForesterUtil.isEmpty( uri_strs ) ) { for( final String uri_str : uri_strs ) { try { - AptxUtil.launchWebBrowser( new URI( uri_str ), - isApplet(), - isApplet() ? obtainApplet() : null, - "_aptx_seq" ); + AptxUtil.launchWebBrowser( new URI( uri_str ), "_aptx_seq" ); } catch ( final IOException e ) { AptxUtil.showErrorMessage( this, e.toString() ); @@ -2032,10 +1998,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee final String uri_str = TreePanelUtil.createUriForSeqWeb( node, getConfiguration(), this ); if ( !ForesterUtil.isEmpty( uri_str ) ) { try { - AptxUtil.launchWebBrowser( new URI( uri_str ), - isApplet(), - isApplet() ? obtainApplet() : null, - "_aptx_seq" ); + AptxUtil.launchWebBrowser( new URI( uri_str ), "_aptx_seq" ); } catch ( final IOException e ) { AptxUtil.showErrorMessage( this, e.toString() ); @@ -2114,10 +2077,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee } if ( !ForesterUtil.isEmpty( uri_str ) ) { try { - AptxUtil.launchWebBrowser( new URI( uri_str ), - isApplet(), - isApplet() ? obtainApplet() : null, - "_aptx_tax" ); + AptxUtil.launchWebBrowser( new URI( uri_str ), "_aptx_tax" ); } catch ( final IOException e ) { AptxUtil.showErrorMessage( this, e.toString() ); @@ -2138,7 +2098,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee final boolean to_pdf, final boolean to_graphics_file ) { g.setFont( getTreeFontSet().getSmallFont() ); - if ( ( to_pdf || to_graphics_file ) && getOptions().isPrintBlackAndWhite() ) { + if ( to_pdf || ( to_graphics_file && getOptions().isPrintBlackAndWhite() ) ) { g.setColor( Color.BLACK ); } else { @@ -2423,19 +2383,28 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee final boolean to_graphics_file, final boolean to_pdf, final boolean is_in_found_nodes ) { + //// + //// TODO + //// Color c = null; + int res[] = null; + if ( _found_nodes_0 != null || _found_nodes_1 != null ) { + res = calcFoundNodesInSubtree( node ); + } if ( ( to_pdf || to_graphics_file ) && getOptions().isPrintBlackAndWhite() ) { c = Color.BLACK; } - else if ( is_in_found_nodes ) { - c = getColorForFoundNode( node ); - } - else if ( getControlPanel().isColorAccordingToSequence() ) { - c = getSequenceBasedColor( node ); - } - else if ( getControlPanel().isColorAccordingToTaxonomy() ) { - c = getTaxonomyBasedColor( node ); - } + //TODO + //FIXME + // else if ( is_in_found_nodes ) { + // c = getColorForFoundNode( node ); + // } + // else if ( getControlPanel().isColorAccordingToSequence() ) { + // c = getSequenceBasedColor( node ); + // } + // else if ( getControlPanel().isColorAccordingToTaxonomy() ) { + // c = getTaxonomyBasedColor( node ); + // } else if ( getOptions().isColorLabelsSameAsParentBranch() && getControlPanel().isUseVisualStyles() && ( PhylogenyMethods.getBranchColorValue( node ) != null ) ) { c = PhylogenyMethods.getBranchColorValue( node ); @@ -2562,7 +2531,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee else if ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.ROUNDED ) { x += ROUNDED_D; } - if ( ( to_pdf || to_graphics_file ) && getOptions().isPrintBlackAndWhite() ) { + if ( to_pdf || ( to_graphics_file && getOptions().isPrintBlackAndWhite() ) ) { g.setColor( Color.BLACK ); } else { @@ -2595,11 +2564,12 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee ( node.getYcoord() - getFontMetricsForLargeDefaultFont().getMaxDescent() ), g ); g.setColor( getTreeColorSet().getLostCharactersColor() ); - TreePanel.drawString( lost, - parent_x + ( ( x - parent_x - - getFontMetricsForLargeDefaultFont().stringWidth( lost ) ) / 2 ), - ( node.getYcoord() + getFontMetricsForLargeDefaultFont().getMaxAscent() ), - g ); + TreePanel + .drawString( lost, + parent_x + ( ( x - parent_x - getFontMetricsForLargeDefaultFont().stringWidth( lost ) ) + / 2 ), + ( node.getYcoord() + getFontMetricsForLargeDefaultFont().getMaxAscent() ), + g ); } } @@ -2660,14 +2630,11 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee || ( getOptions().isShowDefaultNodeShapesForMarkedNodes() && ( node.getNodeData().getNodeVisualData() != null ) && ( !node.getNodeData().getNodeVisualData().isEmpty() ) ) - || ( getControlPanel().isUseVisualStyles() - && ( ( node.getNodeData().getNodeVisualData() != null ) - && ( ( node.getNodeData().getNodeVisualData().getNodeColor() != null ) - || ( node.getNodeData().getNodeVisualData() - .getSize() != NodeVisualData.DEFAULT_SIZE ) - || ( node.getNodeData().getNodeVisualData().getFillType() != NodeFill.DEFAULT ) - || ( node.getNodeData().getNodeVisualData() - .getShape() != NodeShape.DEFAULT ) ) ) ) + || ( getControlPanel().isUseVisualStyles() && ( ( node.getNodeData().getNodeVisualData() != null ) + && ( ( node.getNodeData().getNodeVisualData().getNodeColor() != null ) + || ( node.getNodeData().getNodeVisualData().getSize() != NodeVisualData.DEFAULT_SIZE ) + || ( node.getNodeData().getNodeVisualData().getFillType() != NodeFill.DEFAULT ) + || ( node.getNodeData().getNodeVisualData().getShape() != NodeShape.DEFAULT ) ) ) ) || ( getControlPanel().isEvents() && node.isHasAssignedEvent() && ( node.getNodeData().getEvent().isDuplication() || node.getNodeData().getEvent().isSpeciation() @@ -2851,6 +2818,9 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee if ( !getControlPanel().isShowInternalData() && !node.isExternal() && !node.isCollapse() ) { return 0; } + if ( !getControlPanel().isShowExternalData() && ( node.isExternal() || node.isCollapse() ) ) { + return 0; + } _sb.setLength( 0 ); int x = 0; if ( add > 0 ) { @@ -2884,7 +2854,8 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee && !ForesterUtil.isEmpty( last.getNodeData().getTaxonomy().getTaxonomyCode() ) ) { addLabelForCollapsed( first.getNodeData().getTaxonomy().getTaxonomyCode(), last.getNodeData().getTaxonomy().getTaxonomyCode(), - node.getAllExternalDescendants().size() ); + node.getAllExternalDescendants().size(), + node ); } else if ( getControlPanel().isShowTaxonomyScientificNames() && first.getNodeData().isHasTaxonomy() && last.getNodeData().isHasTaxonomy() @@ -2892,7 +2863,8 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee && !ForesterUtil.isEmpty( last.getNodeData().getTaxonomy().getScientificName() ) ) { addLabelForCollapsed( first.getNodeData().getTaxonomy().getScientificName(), last.getNodeData().getTaxonomy().getScientificName(), - node.getAllExternalDescendants().size() ); + node.getAllExternalDescendants().size(), + node ); } else if ( getControlPanel().isShowSeqNames() && first.getNodeData().isHasSequence() && last.getNodeData().isHasSequence() @@ -2900,21 +2872,33 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee && !ForesterUtil.isEmpty( last.getNodeData().getSequence().getName() ) ) { addLabelForCollapsed( first.getNodeData().getSequence().getName(), last.getNodeData().getSequence().getName(), - node.getAllExternalDescendants().size() ); + node.getAllExternalDescendants().size(), + node ); } else if ( getControlPanel().isShowNodeNames() && !ForesterUtil.isEmpty( first.getName() ) && !ForesterUtil.isEmpty( last.getName() ) ) { addLabelForCollapsed( first.getName(), last.getName(), - node.getAllExternalDescendants().size() ); + node.getAllExternalDescendants().size(), + node ); } } } else if ( ( _sb.length() > 0 ) || saw_species ) { // _sb.setLength( 0 ); - _sb.append( " (" ); + _sb.append( " [" ); _sb.append( node.getAllExternalDescendants().size() ); - _sb.append( ")" ); + _sb.append( "]" ); + if ( _found_nodes_0 != null || _found_nodes_1 != null ) { + int[] res = calcFoundNodesInSubtree( node ); + if ( res[ 0 ] > 0 ) { + _sb.append( " [" ); + _sb.append( res[ 0 ] ); + _sb.append( "/" ); + _sb.append( res[ 1 ] ); + _sb.append( "]" ); + } + } } } else { @@ -2927,7 +2911,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee down_shift_factor = 1; } float pos_x; - if ( getControlPanel().getTreeDisplayType() == TreeDisplayType.ALIGNED_PHYLOGRAM + if ( getControlPanel().getTreeDisplayType() == Options.PHYLOGENY_DISPLAY_TYPE.ALIGNED_PHYLOGRAM && ( node.isExternal() || node.isCollapse() ) ) { pos_x = ( float ) ( ( getMaxDistanceToRoot() * getXcorrectionFactor() ) + ( getOptions().getDefaultNodeShapeSize() / 2 ) + x + ( 2 * TreePanel.MOVE ) + getXdistance() @@ -2943,7 +2927,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee else { pos_y = ( node.getYcoord() + ( getFontMetrics( g.getFont() ).getAscent() / down_shift_factor ) ); } - if ( getControlPanel().getTreeDisplayType() == TreeDisplayType.ALIGNED_PHYLOGRAM + if ( getControlPanel().getTreeDisplayType() == Options.PHYLOGENY_DISPLAY_TYPE.ALIGNED_PHYLOGRAM && ( node.isExternal() || node.isCollapse() ) ) { drawConnection( node.getXcoord(), pos_x - x, node.getYcoord(), 5, 20, g, to_pdf ); if ( node.isCollapse() ) { @@ -3145,13 +3129,47 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee } } - private final void addLabelForCollapsed( final String first, final String last, final int size ) { + private final void addLabelForCollapsed( final String first, + final String last, + final int size, + final PhylogenyNode node ) { _sb.append( first.length() < AptxConstants.MAX_LENGTH_FOR_COLLAPSED_NAME ? first : first.substring( 0, AptxConstants.MAX_LENGTH_FOR_COLLAPSED_NAME - 1 ) ); _sb.append( " ... " ); _sb.append( last.length() < AptxConstants.MAX_LENGTH_FOR_COLLAPSED_NAME ? last : last.substring( 0, AptxConstants.MAX_LENGTH_FOR_COLLAPSED_NAME - 1 ) ); _sb.append( " (" + size + ")" ); + if ( _found_nodes_0 != null || _found_nodes_1 != null ) { + ///// + ///// + int[] res = calcFoundNodesInSubtree( node ); + if ( res[ 0 ] > 0 ) { + _sb.append( " [" ); + _sb.append( res[ 0 ] ); + _sb.append( "/" ); + _sb.append( res[ 1 ] ); + _sb.append( "]" ); + } + } + } + + private final int[] calcFoundNodesInSubtree( final PhylogenyNode node ) { + final List all_descs = PhylogenyMethods.getAllDescendants( node ); + int res[] = new int[ 2 ]; + int found = 0; + int total = 0; + for( final PhylogenyNode desc : all_descs ) { + if ( desc.isHasNodeData() ) { + if ( ( _found_nodes_0 != null && _found_nodes_0.contains( desc.getId() ) ) + || ( _found_nodes_1 != null && _found_nodes_1.contains( desc.getId() ) ) ) { + ++found; + } + ++total; + } + } + res[ 0 ] = found; + res[ 1 ] = total; + return res; } private final boolean isAllowAttributedStrings() { @@ -3315,7 +3333,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee if ( !node.isExternal() && !node.isCollapse() ) { boolean first_child = true; float y2 = 0.0f; - final int parent_max_branch_to_leaf = getMaxBranchesToLeaf( node ); + //final int parent_max_branch_to_leaf = getMaxBranchesToLeaf( node ); for( int i = 0; i < node.getNumberOfDescendants(); ++i ) { final PhylogenyNode child_node = node.getChildNode( i ); final int factor_x = node.getNumberOfExternalNodes() - child_node.getNumberOfExternalNodes(); @@ -3427,8 +3445,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee && ( !ForesterUtil.isEmpty( node.getNodeData().getSequence().getMolecularSequence() ) ) ) { paintMolecularSequences( g, node, to_pdf ); } - if ( dynamically_hide && !is_in_found_nodes && ( ( node.isExternal() - && ( ( _external_node_index % dynamic_hiding_factor ) != 1 ) ) + if ( dynamically_hide && ( ( node.isExternal() && ( ( _external_node_index % dynamic_hiding_factor ) != 1 ) ) || ( !node.isExternal() && ( ( new_x_min < 20 ) || ( ( _y_distance * node.getNumberOfExternalNodes() ) < getFontMetricsForLargeDefaultFont() .getHeight() ) ) ) ) ) { @@ -3449,6 +3466,9 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee if ( ( !getControlPanel().isShowInternalData() && !node.isExternal() ) ) { return; } + if ( ( !getControlPanel().isShowExternalData() && node.isExternal() ) ) { + return; + } if ( getControlPanel().isShowDomainArchitectures() && node.getNodeData().isHasSequence() && ( node.getNodeData().getSequence().getDomainArchitecture() != null ) && ( node.getNodeData() .getSequence().getDomainArchitecture() instanceof RenderableDomainArchitecture ) ) { @@ -3471,7 +3491,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee if ( getOptions().isLineUpRendarableNodeData() ) { if ( getOptions().isRightLineUpDomains() ) { rds.render( ( float ) ( ( getMaxDistanceToRoot() * getXcorrectionFactor() ) - + _length_of_longest_text + + _length_of_longest_text + 50 //TODO why plus 50? + ( ( _longest_domain - rds.getTotalLength() ) * rds.getRenderingFactorWidth() ) ), node.getYcoord() - ( h / 2.0f ), g, @@ -3480,7 +3500,11 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee } else { rds.render( ( float ) ( ( getMaxDistanceToRoot() * getXcorrectionFactor() ) - + _length_of_longest_text ), node.getYcoord() - ( h / 2.0f ), g, this, to_pdf ); + + _length_of_longest_text + 50 ), + node.getYcoord() - ( h / 2.0f ), + g, + this, + to_pdf ); } } else { @@ -3529,7 +3553,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee //if ( getControlPanel().isShowMolSequences() && ( node.getNodeData().isHasSequence() ) // && ( node.getNodeData().getSequence().isMolecularSequenceAligned() ) // && ( !ForesterUtil.isEmpty( node.getNodeData().getSequence().getMolecularSequence() ) ) ) { - // paintMolecularSequences( g, node, to_pdf ); + // paintMolecularSequences( g, node, to_pdf ); //} } @@ -3650,7 +3674,8 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee final boolean using_visual_font = setFont( g, node, is_in_found_nodes ); setColor( g, node, to_graphics_file, to_pdf, is_in_found_nodes, getTreeColorSet().getTaxonomyColor() ); float start_x = node.getXcoord() + 3 + ( getOptions().getDefaultNodeShapeSize() / 2 ) + x_shift; - if ( getControlPanel().getTreeDisplayType() == TreeDisplayType.ALIGNED_PHYLOGRAM && node.isExternal() ) { + if ( getControlPanel().getTreeDisplayType() == Options.PHYLOGENY_DISPLAY_TYPE.ALIGNED_PHYLOGRAM + && node.isExternal() ) { start_x = ( float ) ( ( getMaxDistanceToRoot() * getXcorrectionFactor() ) + ( getOptions().getDefaultNodeShapeSize() / 2 ) + x_shift + ( 2 * TreePanel.MOVE ) + getXdistance() + 3 ); @@ -3890,25 +3915,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee } private final StringBuffer propertiesToString( final PhylogenyNode node ) { - final PropertiesMap properties = node.getNodeData().getProperties(); - final StringBuffer sb = new StringBuffer(); - boolean first = true; - for( final String ref : properties.getPropertyRefs() ) { - if ( first ) { - first = false; - } - else { - sb.append( " " ); - } - final Property p = properties.getProperty( ref ); - sb.append( TreePanelUtil.getPartAfterColon( p.getRef() ) ); - sb.append( "=" ); - sb.append( p.getValue() ); - if ( !ForesterUtil.isEmpty( p.getUnit() ) ) { - sb.append( TreePanelUtil.getPartAfterColon( p.getUnit() ) ); - } - } - return sb; + return node.getNodeData().getProperties().asText(); } private void setColor( final Graphics2D g, @@ -4070,7 +4077,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee _urt_factor_ov = urt_factor_ov; } - private void showExtDescNodeData( final PhylogenyNode node ) { + private void showExtDescNodeData( final PhylogenyNode node, final char separator ) { final List data = new ArrayList(); final List nodes = node.getAllExternalDescendants(); if ( ( getFoundNodes0() != null ) || ( getFoundNodes1() != null ) ) { @@ -4110,44 +4117,50 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee if ( n.getNodeData().isHasSequence() && !ForesterUtil.isEmpty( n.getNodeData().getSequence().getMolecularSequence() ) ) { final StringBuilder ann = new StringBuilder(); - if ( !ForesterUtil.isEmpty( n.getName() ) ) { + if ( getControlPanel().isShowNodeNames() && !ForesterUtil.isEmpty( n.getName() ) ) { ann.append( n.getName() ); - ann.append( "|" ); + ann.append( separator ); } - if ( !ForesterUtil.isEmpty( n.getNodeData().getSequence().getSymbol() ) ) { - ann.append( "SYM=" ); + if ( n.getNodeData().isHasTaxonomy() ) { + if ( getControlPanel().isShowTaxonomyCode() + && !ForesterUtil.isEmpty( n.getNodeData().getTaxonomy().getTaxonomyCode() ) ) { + ann.append( n.getNodeData().getTaxonomy().getTaxonomyCode() ); + ann.append( separator ); + } + if ( getControlPanel().isShowTaxonomyScientificNames() + && !ForesterUtil.isEmpty( n.getNodeData().getTaxonomy().getScientificName() ) ) { + ann.append( n.getNodeData().getTaxonomy().getScientificName() ); + ann.append( separator ); + } + if ( getControlPanel().isShowTaxonomyCommonNames() + && !ForesterUtil.isEmpty( n.getNodeData().getTaxonomy().getCommonName() ) ) { + ann.append( n.getNodeData().getTaxonomy().getCommonName() ); + ann.append( separator ); + } + } + if ( getControlPanel().isShowSeqSymbols() + && !ForesterUtil.isEmpty( n.getNodeData().getSequence().getSymbol() ) ) { ann.append( n.getNodeData().getSequence().getSymbol() ); - ann.append( "|" ); + ann.append( separator ); } - if ( !ForesterUtil.isEmpty( n.getNodeData().getSequence().getName() ) ) { - ann.append( "NAME=" ); + if ( getControlPanel().isShowSeqNames() + && !ForesterUtil.isEmpty( n.getNodeData().getSequence().getName() ) ) { ann.append( n.getNodeData().getSequence().getName() ); - ann.append( "|" ); + ann.append( separator ); } - if ( !ForesterUtil.isEmpty( n.getNodeData().getSequence().getGeneName() ) ) { - ann.append( "GN=" ); + if ( getControlPanel().isShowGeneNames() + && !ForesterUtil.isEmpty( n.getNodeData().getSequence().getGeneName() ) ) { ann.append( n.getNodeData().getSequence().getGeneName() ); - ann.append( "|" ); + ann.append( separator ); } - if ( n.getNodeData().getSequence().getAccession() != null ) { - ann.append( "ACC=" ); + if ( getControlPanel().isShowSequenceAcc() + && n.getNodeData().getSequence().getAccession() != null ) { ann.append( n.getNodeData().getSequence().getAccession().asText() ); - ann.append( "|" ); + ann.append( separator ); } - 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 ) == '|' ) { + + final String ann_str; + if ( ann.length() > 0 && ann.charAt( ann.length() - 1 ) == separator ) { ann_str = ann.substring( 0, ann.length() - 1 ); } else { @@ -4268,14 +4281,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee + ", 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 ); - } + getMainPanel().getMainFrame().showTextFrame( s, title ); } } } @@ -4466,17 +4472,10 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee } } if ( node.getNodeData().isHasProperties() ) { - final PropertiesMap properties = node.getNodeData().getProperties(); - for( final String ref : properties.getPropertyRefs() ) { + if ( _popup_buffer.length() > 0 ) { _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() ) ); - } } + _popup_buffer.append( node.getNodeData().getProperties().asText() ); } if ( _popup_buffer.length() > 0 ) { if ( !getConfiguration().isUseNativeUI() ) { @@ -4587,14 +4586,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee else { getControlPanel().setDrawPhylogramEnabled( false ); } - if ( getMainPanel().getMainFrame() == null ) { - // Must be "E" applet version. - ( ( ArchaeopteryxE ) ( ( MainPanelApplets ) getMainPanel() ).getApplet() ) - .setSelectedTypeInTypeMenu( getPhylogenyGraphicsType() ); - } - else { - getMainPanel().getMainFrame().setSelectedTypeInTypeMenu( getPhylogenyGraphicsType() ); - } + getMainPanel().getMainFrame().setSelectedTypeInTypeMenu( getPhylogenyGraphicsType() ); } final void calcMaxDepth() { @@ -4877,67 +4869,6 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee } } - void checkForVectorProperties( final Phylogeny phy ) { - final DescriptiveStatistics stats = new BasicDescriptiveStatistics(); - for( final PhylogenyNodeIterator iter = phy.iteratorPreorder(); iter.hasNext(); ) { - final PhylogenyNode node = iter.next(); - if ( node.getNodeData().getProperties() != null ) { - final PropertiesMap pm = node.getNodeData().getProperties(); - final double[] vector = new double[ pm.getProperties().size() ]; - int counter = 0; - for( final String ref : pm.getProperties().keySet() ) { - if ( ref.startsWith( PhyloXmlUtil.VECTOR_PROPERTY_REF ) ) { - final Property p = pm.getProperty( ref ); - final String value_str = p.getValue(); - final String index_str = ref.substring( PhyloXmlUtil.VECTOR_PROPERTY_REF.length(), - ref.length() ); - double d = -100; - try { - d = Double.parseDouble( value_str ); - } - catch ( final NumberFormatException e ) { - JOptionPane.showMessageDialog( this, - "Could not parse \"" + value_str + "\" into a decimal value", - "Problem with Vector Data", - JOptionPane.ERROR_MESSAGE ); - return; - } - int i = -1; - try { - i = Integer.parseInt( index_str ); - } - catch ( final NumberFormatException e ) { - JOptionPane.showMessageDialog( this, - "Could not parse \"" + index_str - + "\" into index for vector data", - "Problem with Vector Data", - JOptionPane.ERROR_MESSAGE ); - return; - } - if ( i < 0 ) { - JOptionPane.showMessageDialog( this, - "Attempt to use negative index for vector data", - "Problem with Vector Data", - JOptionPane.ERROR_MESSAGE ); - return; - } - vector[ i ] = d; - ++counter; - stats.addValue( d ); - } - } - final List vector_l = new ArrayList( counter ); - for( int i = 0; i < counter; ++i ) { - vector_l.add( vector[ i ] ); - } - node.getNodeData().setVector( vector_l ); - } - } - if ( stats.getN() > 0 ) { - _statistics_for_vector_data = stats; - } - } - void clearCurrentExternalNodesDataBuffer() { setCurrentExternalNodesDataBuffer( new StringBuilder() ); } @@ -5094,7 +5025,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee * @param y * @return pointer to the node at x,y, null if not found */ - final PhylogenyNode findNode( final int x, final int y ) { + public final PhylogenyNode findNode( final int x, final int y ) { if ( ( _phylogeny == null ) || _phylogeny.isEmpty() ) { return null; } @@ -5132,15 +5063,15 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee return _domain_structure_e_value_thr_exp; } - final Set getFoundNodes0() { + public final Set getFoundNodes0() { return _found_nodes_0; } - final Set getFoundNodes1() { + public final Set getFoundNodes1() { return _found_nodes_1; } - List getFoundNodesAsListOfPhylogenyNodes() { + public List getFoundNodesAsListOfPhylogenyNodes() { final List additional_nodes = new ArrayList(); if ( getFoundNodes0() != null ) { for( final Long id : getFoundNodes0() ) { @@ -5301,10 +5232,6 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee && ( e.getY() <= ( getOvRectangle().getY() + getOvRectangle().getHeight() + 1 ) ) ); } - final boolean isApplet() { - return getMainPanel() instanceof MainPanelApplets; - } - final boolean isCanCollapse() { return ( getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.UNROOTED ); } @@ -5606,10 +5533,6 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee _urt_factor *= f; } - final JApplet obtainApplet() { - return ( ( MainPanelApplets ) getMainPanel() ).getApplet(); - } - final void paintBranchCircular( final PhylogenyNode p, final PhylogenyNode c, final Graphics2D g, @@ -5816,10 +5739,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee } } final boolean disallow_shortcutting = ( dynamic_hiding_factor < 40 ) - || getControlPanel().isUseVisualStyles() || getOptions().isShowDefaultNodeShapesForMarkedNodes() - || ( ( getFoundNodes0() != null ) && !getFoundNodes0().isEmpty() ) - || ( ( getFoundNodes1() != null ) && !getFoundNodes1().isEmpty() ) - || ( ( getCurrentExternalNodes() != null ) && !getCurrentExternalNodes().isEmpty() ) + /* || getControlPanel().isUseVisualStyles() || getOptions().isShowDefaultNodeShapesForMarkedNodes()*/ //TODO check if this is really not needed. || to_graphics_file || to_pdf; for( final PhylogenyNode element : _nodes_in_preorder ) { paintNodeRectangular( g, @@ -6069,11 +5989,11 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee _current_external_nodes_data_buffer = sb; } - final void setFoundNodes0( final Set found_nodes ) { + public final void setFoundNodes0( final Set found_nodes ) { _found_nodes_0 = found_nodes; } - final void setFoundNodes1( final Set found_nodes ) { + public final void setFoundNodes1( final Set found_nodes ) { _found_nodes_1 = found_nodes; }