X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=forester%2Fjava%2Fsrc%2Forg%2Fforester%2Farchaeopteryx%2FTreePanel.java;h=38afbce942c16853aa662c5156c9cf25005747e5;hb=558788e2eb321d781f6cd9d4ceee91ed5c98661b;hp=a32284e118f92b1f91f3e75c2478cf1f5eed2942;hpb=3ce13fed094f2f10da69eb4f22ee6136af51c133;p=jalview.git diff --git a/forester/java/src/org/forester/archaeopteryx/TreePanel.java b/forester/java/src/org/forester/archaeopteryx/TreePanel.java index a32284e..38afbce 100644 --- a/forester/java/src/org/forester/archaeopteryx/TreePanel.java +++ b/forester/java/src/org/forester/archaeopteryx/TreePanel.java @@ -77,11 +77,8 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Hashtable; import java.util.List; -import java.util.Map; import java.util.Set; -import java.util.SortedMap; import java.util.SortedSet; -import java.util.TreeMap; import javax.swing.BorderFactory; import javax.swing.JApplet; @@ -117,7 +114,7 @@ import org.forester.phylogeny.data.BranchColor; import org.forester.phylogeny.data.Confidence; import org.forester.phylogeny.data.DomainArchitecture; import org.forester.phylogeny.data.Event; -import org.forester.phylogeny.data.NodeData.NODE_DATA; +import org.forester.phylogeny.data.NodeDataField; import org.forester.phylogeny.data.NodeVisualData; import org.forester.phylogeny.data.NodeVisualData.NodeFill; import org.forester.phylogeny.data.NodeVisualData.NodeShape; @@ -179,7 +176,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee private static final BasicStroke STROKE_2 = new BasicStroke( 2f ); private static final double TWO_PI = 2 * Math.PI; private final static int WIGGLE = 2; - private static final String SHOW_ONLY_THIS_CONF_TYPE = "posterior probability"; //TODO remove me + 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(); private AffineTransform _at; @@ -3408,7 +3405,11 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee else { _node_popup_menu_items[ i ].setEnabled( false ); } - // + } + else if ( title.startsWith( Configuration.clickto_options[ Configuration.get_ext_desc_data ][ 0 ] ) ) { + _node_popup_menu_items[ i ] + .setText( Configuration.clickto_options[ Configuration.get_ext_desc_data ][ 0 ] + ": " + + getOptions().getExtDescNodeDataToReturn().toString() ); } else if ( title.equals( Configuration.clickto_options[ Configuration.open_tax_web ][ 0 ] ) ) { _node_popup_menu_items[ i ].setEnabled( isCanOpenTaxWeb( node ) ); @@ -3578,41 +3579,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee } private final String obtainTitleForExtDescNodeData() { - switch ( getOptions().getExtDescNodeDataToReturn() ) { - case NODE_NAME: - return "Node Names"; - case GENE_NAME: - return "Gene Names"; - case SEQUENCE_NAME: - return "Sequence Names"; - case SEQUENCE_SYMBOL: - return "Sequence Symbols"; - case SEQUENCE_MOL_SEQ: - return "Molecular Sequences"; - case SEQUENCE_MOL_SEQ_FASTA: - return "Molecular Sequences (Fasta)"; - case SEQUENCE_ACC: - return "Sequence Accessors"; - case TAXONOMY_SCIENTIFIC_NAME: - return "Scientific Names"; - case TAXONOMY_CODE: - return "Taxonomy Codes"; - case TAXONOMY_COMM0N_NAME: - return "Taxonomy Common Names"; - case DOMAINS_ALL: - return "Domains [E-value threshold: " + Math.pow( 10, getDomainStructureEvalueThresholdExp() ) + "]"; - case DOMAINS_COLLAPSED_PER_PROTEIN: - return "Domains [collapsed per protein, E-value threshold: " + Math.pow( 10, getDomainStructureEvalueThresholdExp() ) + "]"; - case GO_ANNOTATIONS: - return "Go Annotations"; - case GO_ANNOTATIONS_WITH_COUNTS: - return "Go Annotations [with counts]"; - case UNKNOWN: - return "User Selected Data"; - default: - throw new IllegalArgumentException( "unknown data element: " - + getOptions().getExtDescNodeDataToReturn() ); - } + return getOptions().getExtDescNodeDataToReturn().toString(); } final private void openPdbWeb( final PhylogenyNode node ) { @@ -4823,6 +4790,11 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee } paintNodeBox( node.getXcoord(), node.getYcoord(), node, g, to_pdf, to_graphics_file ); } + if ( getControlPanel().isShowMolSequences() && ( node.getNodeData().isHasSequence() ) + && ( node.getNodeData().getSequence().isMolecularSequenceAligned() ) + && ( !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 ) ) || ( !node @@ -4925,33 +4897,37 @@ 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() ) ) ) { - final RenderableMsaSequence rs = RenderableMsaSequence.createInstance( node.getNodeData().getSequence() - .getMolecularSequence(), node.getNodeData().getSequence().getType(), getConfiguration() ); - if ( rs != null ) { - final int default_height = 7; - float y = getYdistance(); - if ( getControlPanel().isDynamicallyHideData() ) { - y = getTreeFontSet().getFontMetricsLarge().getHeight(); - } - final int h = y < default_height ? ForesterUtil.roundToInt( y ) : default_height; - rs.setRenderingHeight( h > 1 ? h : 2 ); - if ( getControlPanel().isDrawPhylogram() ) { - rs.render( ( float ) ( ( getMaxDistanceToRoot() * getXcorrectionFactor() ) + _length_of_longest_text ), - node.getYcoord() - ( h / 2.0f ), - g, - this, - to_pdf ); - } - else { - rs.render( getPhylogeny().getFirstExternalNode().getXcoord() + _length_of_longest_text, - node.getYcoord() - ( h / 2.0f ), - g, - this, - to_pdf ); - } + + //if ( getControlPanel().isShowMolSequences() && ( node.getNodeData().isHasSequence() ) + // && ( node.getNodeData().getSequence().isMolecularSequenceAligned() ) + // && ( !ForesterUtil.isEmpty( node.getNodeData().getSequence().getMolecularSequence() ) ) ) { + // paintMolecularSequences( g, node, to_pdf ); + //} + } + + private void paintMolecularSequences( final Graphics2D g, final PhylogenyNode node, final boolean to_pdf ) { + final RenderableMsaSequence rs = RenderableMsaSequence.createInstance( node.getNodeData().getSequence() + .getMolecularSequence(), node.getNodeData().getSequence().getType(), getConfiguration() ); + if ( rs != null ) { + final int default_height = 8; + float y = getYdistance(); + + final int h = ( y / 2) < default_height ? ForesterUtil.roundToInt( y * 2 ) : default_height; + rs.setRenderingHeight( h > 1 ? h : 1 ); + + if ( getControlPanel().isDrawPhylogram() ) { + rs.render( ( float ) ( ( getMaxDistanceToRoot() * getXcorrectionFactor() ) + _length_of_longest_text ), + node.getYcoord() - ( h / 2.0f ), + g, + this, + to_pdf ); + } + else { + rs.render( getPhylogeny().getFirstExternalNode().getXcoord() + _length_of_longest_text, + node.getYcoord() - ( h / 2.0f ), + g, + this, + to_pdf ); } } } @@ -5536,12 +5512,6 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee 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() @@ -5607,22 +5577,16 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee 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 DOMAINS_ALL: + case DOMAINS_ALL: case DOMAINS_COLLAPSED_PER_PROTEIN: if ( n.getNodeData().isHasSequence() - && n.getNodeData().getSequence().getDomainArchitecture() != null ) { + && ( n.getNodeData().getSequence().getDomainArchitecture() != null ) ) { final DomainArchitecture da = n.getNodeData().getSequence().getDomainArchitecture(); final Set s = new HashSet(); for( int i = 0; i < da.getDomains().size(); ++i ) { @@ -5631,25 +5595,40 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee final String name = d.getName(); if ( !( s.contains( name ) ) ) { data.add( name ); - if ( getOptions().getExtDescNodeDataToReturn() == NODE_DATA.DOMAINS_COLLAPSED_PER_PROTEIN ) { + if ( getOptions().getExtDescNodeDataToReturn() == NodeDataField.DOMAINS_COLLAPSED_PER_PROTEIN ) { s.add( name ); } } } } } - break; - case GO_ANNOTATIONS: + break; + case SEQ_ANNOTATIONS: if ( n.getNodeData().isHasSequence() ) { if ( n.getNodeData().isHasSequence() - && n.getNodeData().getSequence().getAnnotations() != null ) { + && ( n.getNodeData().getSequence().getAnnotations() != null ) ) { final SortedSet a = n.getNodeData().getSequence().getAnnotations(); for( int i = 0; i < a.size(); ++i ) { - data.add( n.getNodeData().getSequence().getAnnotation( i ).toString() ); + data.add( n.getNodeData().getSequence().getAnnotation( i ).toString() ); } } } - break; + break; + case GO_TERM_IDS: + if ( n.getNodeData().isHasSequence() ) { + if ( n.getNodeData().isHasSequence() + && ( n.getNodeData().getSequence().getAnnotations() != null ) ) { + final SortedSet a = n.getNodeData().getSequence().getAnnotations(); + for( int i = 0; i < a.size(); ++i ) { + final Annotation ann = n.getNodeData().getSequence().getAnnotation( i ); + final String ref = ann.getRef(); + if ( ref.toUpperCase().startsWith( "GO:" ) ) { + data.add( ref ); + } + } + } + } + break; case UNKNOWN: TreePanelUtil.showExtDescNodeDataUserSelectedHelper( getControlPanel(), n, data ); break; @@ -5658,11 +5637,8 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee + getOptions().getExtDescNodeDataToReturn() ); } } // for loop - final StringBuilder sb = new StringBuilder(); - - - final int size = TreePanelUtil.makeSB( data, getOptions(), sb ); + final int size = TreePanelUtil.nodeDataIntoStringBuffer( 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 ) { @@ -5685,7 +5661,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee setCurrentExternalNodesDataBuffer( sb ); String title; if ( ( getFoundNodes0() != null ) && !getFoundNodes0().isEmpty() ) { - title = ( getOptions().getExtDescNodeDataToReturn() == NODE_DATA.UNKNOWN ? "Data" + title = ( getOptions().getExtDescNodeDataToReturn() == NodeDataField.UNKNOWN ? "Data" : obtainTitleForExtDescNodeData() ) + " for " + data.size() @@ -5693,7 +5669,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee + size; } else { - title = ( getOptions().getExtDescNodeDataToReturn() == NODE_DATA.UNKNOWN ? "Data" + title = ( getOptions().getExtDescNodeDataToReturn() == NodeDataField.UNKNOWN ? "Data" : obtainTitleForExtDescNodeData() ) + " for " + data.size()