import java.util.HashSet;
import java.util.Hashtable;
import java.util.List;
-import java.util.Map.Entry;
import java.util.Set;
-import java.util.SortedMap;
import java.util.SortedSet;
-import java.util.TreeMap;
import javax.swing.BorderFactory;
import javax.swing.JApplet;
_color_chooser.setPreviewPanel( new JPanel() );
SubtreeColorizationActionListener al;
if ( ( getFoundNodes() != null ) && !getFoundNodes().isEmpty() ) {
- final List<PhylogenyNode> additional_nodes = new ArrayList<PhylogenyNode>();
- for( final Long id : getFoundNodes() ) {
- additional_nodes.add( _phylogeny.getNode( id ) );
- }
+ final List<PhylogenyNode> additional_nodes = getFoundNodesAsListOfPhylogenyNodes();
al = new SubtreeColorizationActionListener( _color_chooser, node, additional_nodes );
}
else {
dialog.setVisible( true );
}
+ private List<PhylogenyNode> getFoundNodesAsListOfPhylogenyNodes() {
+ final List<PhylogenyNode> additional_nodes = new ArrayList<PhylogenyNode>();
+ for( final Long id : getFoundNodes() ) {
+ additional_nodes.add( _phylogeny.getNode( id ) );
+ }
+ return additional_nodes;
+ }
+
final private void copySubtree( final PhylogenyNode node ) {
if ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) {
errorMessageNoCutCopyPasteInUnrootedDisplay();
private void showExtDescNodeData( final PhylogenyNode node ) {
final List<String> data = new ArrayList<String>();
- for( final PhylogenyNode n : node.getAllExternalDescendants() ) {
+ final List<PhylogenyNode> nodes = node.getAllExternalDescendants();
+ if ( ( getFoundNodes() != null ) && !getFoundNodes().isEmpty() ) {
+ for( final PhylogenyNode n : getFoundNodesAsListOfPhylogenyNodes() ) {
+ if ( !nodes.contains( n ) ) {
+ nodes.add( n );
+ }
+ }
+ }
+ for( final PhylogenyNode n : nodes ) {
switch ( getOptions().getExtDescNodeDataToReturn() ) {
case NODE_NAME:
if ( !ForesterUtil.isEmpty( n.getName() ) ) {
ann.append( "|" );
}
}
- String ann_str = ann.toString().trim();
- if ( ann_str.endsWith( "|" ) ) {
- ann_str = ann_str.substring( 0, ann_str.length() - 1 );
+ String ann_str;
+ if ( ann.charAt( ann.length() - 1 ) == '|' ) {
+ ann_str = ann.substring( 0, ann.length() - 1 );
+ }
+ else {
+ ann_str = ann.toString();
}
sb.append( SequenceWriter.toFasta( ann_str, n.getNodeData().getSequence()
.getMolecularSequence(), 60 ) );
}
} // for loop
final StringBuilder sb = new StringBuilder();
- final int size = makeSB( data, getOptions(), sb );
+ final int size = TreePanelUtil.makeSB( 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 ) {
}
else {
setCurrentExternalNodesDataBuffer( sb );
- final String title = ( getOptions().getExtDescNodeDataToReturn() == NODE_DATA.UNKNOWN ? "Data"
- : obtainTitleForExtDescNodeData() )
- + " for "
- + data.size()
- + "/"
- + node.getNumberOfExternalNodes()
- + " external descendats of node "
- + node
- + ", unique entries: " + size;
+ String title;
+ if ( ( getFoundNodes() != null ) && !getFoundNodes().isEmpty() ) {
+ title = ( getOptions().getExtDescNodeDataToReturn() == NODE_DATA.UNKNOWN ? "Data"
+ : obtainTitleForExtDescNodeData() )
+ + " for "
+ + data.size()
+ + " nodes, unique entries: "
+ + size;
+ }
+ else {
+ title = ( getOptions().getExtDescNodeDataToReturn() == NODE_DATA.UNKNOWN ? "Data"
+ : obtainTitleForExtDescNodeData() )
+ + " for "
+ + data.size()
+ + "/"
+ + node.getNumberOfExternalNodes()
+ + " external descendats of node "
+ + node
+ + ", unique entries: " + size;
+ }
final String s = sb.toString().trim();
if ( getMainPanel().getMainFrame() == null ) {
// Must be "E" applet version.
}
}
- private int makeSB( final List<String> data, final Options optz, final StringBuilder sb ) {
- final SortedMap<String, Integer> map = new TreeMap<String, Integer>();
- if ( ( optz.getExtDescNodeDataToReturn() != NODE_DATA.SEQUENCE_MOL_SEQ )
- && ( optz.getExtDescNodeDataToReturn() != NODE_DATA.SEQUENCE_MOL_SEQ_FASTA ) ) {
- for( final String d : data ) {
- if ( !ForesterUtil.isEmpty( d ) ) {
- if ( map.containsKey( d ) ) {
- map.put( d, map.get( d ) + 1 );
- }
- else {
- map.put( d, 1 );
- }
- }
- }
- }
- int size = 0;
- if ( ( optz.getExtDescNodeDataToReturn() != NODE_DATA.SEQUENCE_MOL_SEQ )
- && ( optz.getExtDescNodeDataToReturn() != NODE_DATA.SEQUENCE_MOL_SEQ_FASTA ) ) {
- for( final Entry<String, Integer> e : map.entrySet() ) {
- final String v = e.getKey();
- final Object c = e.getValue();
- sb.append( v );
- sb.append( "\t" );
- sb.append( c );
- sb.append( ForesterUtil.LINE_SEPARATOR );
- }
- size = map.size();
- }
- else {
- for( final String d : data ) {
- if ( !ForesterUtil.isEmpty( d ) ) {
- sb.append( d );
- sb.append( ForesterUtil.LINE_SEPARATOR );
- }
- }
- size = data.size();
- }
- return size;
- }
-
final private void showNodeDataPopup( final MouseEvent e, final PhylogenyNode node ) {
try {
if ( ( node.getName().length() > 0 )
import org.forester.phylogeny.PhylogenyNode;
import org.forester.phylogeny.data.Annotation;
import org.forester.phylogeny.data.BranchColor;
+import org.forester.phylogeny.data.NodeData.NODE_DATA;
import org.forester.phylogeny.data.Sequence;
import org.forester.phylogeny.data.Taxonomy;
import org.forester.phylogeny.iterators.PhylogenyNodeIterator;
public class TreePanelUtil {
+ static int makeSB( final List<String> data, final Options optz, final StringBuilder sb ) {
+ final SortedMap<String, Integer> map = new TreeMap<String, Integer>();
+ if ( ( optz.getExtDescNodeDataToReturn() != NODE_DATA.SEQUENCE_MOL_SEQ )
+ && ( optz.getExtDescNodeDataToReturn() != NODE_DATA.SEQUENCE_MOL_SEQ_FASTA ) ) {
+ for( final String d : data ) {
+ if ( !ForesterUtil.isEmpty( d ) ) {
+ if ( map.containsKey( d ) ) {
+ map.put( d, map.get( d ) + 1 );
+ }
+ else {
+ map.put( d, 1 );
+ }
+ }
+ }
+ }
+ int size = 0;
+ if ( ( optz.getExtDescNodeDataToReturn() != NODE_DATA.SEQUENCE_MOL_SEQ )
+ && ( optz.getExtDescNodeDataToReturn() != NODE_DATA.SEQUENCE_MOL_SEQ_FASTA ) ) {
+ for( final Entry<String, Integer> e : map.entrySet() ) {
+ final String v = e.getKey();
+ final Object c = e.getValue();
+ sb.append( v );
+ sb.append( "\t" );
+ sb.append( c );
+ sb.append( ForesterUtil.LINE_SEPARATOR );
+ }
+ size = map.size();
+ }
+ else {
+ for( final String d : data ) {
+ if ( !ForesterUtil.isEmpty( d ) ) {
+ sb.append( d );
+ sb.append( ForesterUtil.LINE_SEPARATOR );
+ }
+ }
+ size = data.size();
+ }
+ return size;
+ }
+
public final static String createUriForSeqWeb( final PhylogenyNode node,
final Configuration conf,
final TreePanel tp ) {