X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=forester%2Fjava%2Fsrc%2Forg%2Fforester%2Farchaeopteryx%2FTreePanel.java;h=907a20f4a49eca1171d523609fe02028c2a2d811;hb=8a0a03d1fe15e36142994518585a185fb0ea6543;hp=fb1316b0b8ec49feffc1f2c0cef77515fa7190e5;hpb=af491ecd10f96da4bd1f06b8a7a01a0aa9d0f516;p=jalview.git diff --git a/forester/java/src/org/forester/archaeopteryx/TreePanel.java b/forester/java/src/org/forester/archaeopteryx/TreePanel.java index fb1316b..907a20f 100644 --- a/forester/java/src/org/forester/archaeopteryx/TreePanel.java +++ b/forester/java/src/org/forester/archaeopteryx/TreePanel.java @@ -76,6 +76,7 @@ import java.util.HashSet; import java.util.Hashtable; import java.util.List; import java.util.Set; +import java.util.SortedSet; import javax.swing.BorderFactory; import javax.swing.JApplet; @@ -111,7 +112,6 @@ import org.forester.phylogeny.data.NodeData.NODE_DATA; import org.forester.phylogeny.data.NodeVisualization; import org.forester.phylogeny.data.NodeVisualization.NodeFill; import org.forester.phylogeny.data.NodeVisualization.NodeShape; -import org.forester.phylogeny.data.PhylogenyData; import org.forester.phylogeny.data.PhylogenyDataUtil; import org.forester.phylogeny.data.PropertiesMap; import org.forester.phylogeny.data.Property; @@ -223,9 +223,6 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee private boolean _edited = false; private Popup _node_desc_popup; private JTextArea _rollover_popup; - // private final int _box_size; - // private final int _half_box_size; - //private final short _skip_counter = 0; private final StringBuffer _popup_buffer = new StringBuffer(); final private static Font POPUP_FONT = new Font( Configuration.getDefaultFontFamilyName(), Font.PLAIN, @@ -971,16 +968,6 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee } } - final void inferCommonPartOfScientificNames() { - if ( ( _phylogeny == null ) || ( _phylogeny.getNumberOfExternalNodes() < 2 ) ) { - return; - } - setWaitCursor(); - AptxUtil.inferCommonPartOfScientificNames( _phylogeny ); - setArrowCursor(); - repaint(); - } - final void initNodeData() { if ( ( _phylogeny == null ) || _phylogeny.isEmpty() ) { return; @@ -1728,12 +1715,20 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee final void selectNode( final PhylogenyNode node ) { if ( ( getFoundNodes() != null ) && getFoundNodes().contains( node.getId() ) ) { getFoundNodes().remove( node.getId() ); + getControlPanel().setSearchFoundCountsOnLabel( getFoundNodes().size() ); + if ( getFoundNodes().size() < 1 ) { + getControlPanel().searchReset(); + } } else { + getControlPanel().getSearchFoundCountsLabel().setVisible( true ); + getControlPanel().getSearchResetButton().setEnabled( true ); + getControlPanel().getSearchResetButton().setVisible( true ); if ( getFoundNodes() == null ) { setFoundNodes( new HashSet() ); } getFoundNodes().add( node.getId() ); + getControlPanel().setSearchFoundCountsOnLabel( getFoundNodes().size() ); } } @@ -2244,12 +2239,23 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee } } - final private Color calculateColorForAnnotation( final PhylogenyData ann ) { + final private Color calculateColorForAnnotation( final SortedSet ann ) { Color c = getTreeColorSet().getAnnotationColor(); if ( getControlPanel().isColorAccordingToAnnotation() && ( getControlPanel().getAnnotationColors() != null ) ) { - c = getControlPanel().getAnnotationColors().get( ann.asSimpleText().toString() ); - if ( c == null ) { - c = getTreeColorSet().getAnnotationColor(); + final StringBuilder sb = new StringBuilder(); + for( final Annotation a : ann ) { + sb.append( !ForesterUtil.isEmpty( a.getRef() ) ? a.getRef() : a.getDesc() ); + } + final String ann_str = sb.toString(); + if ( !ForesterUtil.isEmpty( ann_str ) ) { + c = getControlPanel().getAnnotationColors().get( ann_str ); + if ( c == null ) { + c = AptxUtil.calculateColorFromString( ann_str ); + getControlPanel().getAnnotationColors().put( ann_str, c ); + } + if ( c == null ) { + c = getTreeColorSet().getAnnotationColor(); + } } } return c; @@ -3840,6 +3846,11 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee else if ( getControlPanel().isColorAccordingToTaxonomy() ) { g.setColor( getTaxonomyBasedColor( node ) ); } + else if ( getControlPanel().isColorAccordingToAnnotation() + && ( node.getNodeData().isHasSequence() && ( node.getNodeData().getSequence().getAnnotations() != null ) && ( !node + .getNodeData().getSequence().getAnnotations().isEmpty() ) ) ) { + g.setColor( calculateColorForAnnotation( node.getNodeData().getSequence().getAnnotations() ) ); + } else if ( getOptions().isColorLabelsSameAsParentBranch() && getControlPanel().isColorBranches() && ( PhylogenyMethods.getBranchColorValue( node ) != null ) ) { g.setColor( PhylogenyMethods.getBranchColorValue( node ) ); @@ -3975,14 +3986,14 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee if ( _sb.length() > 0 ) { x += getTreeFontSet()._fm_large.stringWidth( _sb.toString() ) + 5; } - final Annotation ann = node.getNodeData().getSequence().getAnnotation( 0 ); + final SortedSet ann = node.getNodeData().getSequence().getAnnotations(); if ( ( to_pdf || to_graphics_file ) && getOptions().isPrintBlackAndWhite() ) { g.setColor( Color.BLACK ); } - else { + else if ( getControlPanel().isColorAccordingToAnnotation() ) { g.setColor( calculateColorForAnnotation( ann ) ); } - final String ann_str = ann.asSimpleText().toString(); + final String ann_str = createAnnotationString( ann ); TreePanel.drawString( ann_str, node.getXcoord() + x + 3 + half_box_size, node.getYcoord() + ( getTreeFontSet()._fm_large.getAscent() / down_shift_factor ), g ); _sb.setLength( 0 ); @@ -4024,6 +4035,22 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee } } + private String createAnnotationString( final SortedSet ann ) { + final StringBuilder sb = new StringBuilder(); + boolean first = true; + for( final Annotation a : ann ) { + if ( !first ) { + sb.append( "|" ); + } + else { + first = false; + } + sb.append( a.asSimpleText() ); + } + final String ann_str = sb.toString(); + return ann_str; + } + final private void paintNodeDataUnrootedCirc( final Graphics2D g, final PhylogenyNode node, final boolean to_pdf, @@ -4043,6 +4070,11 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee else if ( getControlPanel().isColorAccordingToTaxonomy() ) { g.setColor( getTaxonomyBasedColor( node ) ); } + else if ( getControlPanel().isColorAccordingToAnnotation() + && ( node.getNodeData().isHasSequence() && ( node.getNodeData().getSequence().getAnnotations() != null ) && ( !node + .getNodeData().getSequence().getAnnotations().isEmpty() ) ) ) { + g.setColor( calculateColorForAnnotation( node.getNodeData().getSequence().getAnnotations() ) ); + } else { g.setColor( getTreeColorSet().getSequenceColor() ); }