import java.util.Hashtable;
import java.util.List;
import java.util.Set;
+import java.util.SortedSet;
import javax.swing.BorderFactory;
import javax.swing.JApplet;
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;
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,
}
}
- 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;
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<Integer>() );
}
getFoundNodes().add( node.getId() );
+ getControlPanel().setSearchFoundCountsOnLabel( getFoundNodes().size() );
}
}
}
}
- final private Color calculateColorForAnnotation( final PhylogenyData ann ) {
+ final private Color calculateColorForAnnotation( final SortedSet<Annotation> 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;
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 ) );
if ( _sb.length() > 0 ) {
x += getTreeFontSet()._fm_large.stringWidth( _sb.toString() ) + 5;
}
- final Annotation ann = node.getNodeData().getSequence().getAnnotation( 0 );
+ final SortedSet<Annotation> 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 );
}
}
+ private String createAnnotationString( final SortedSet<Annotation> 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,
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() );
}