+ private void showExtDescNodeData( final PhylogenyNode node ) {
+ final List<String> data = new ArrayList<String>();
+ for( final PhylogenyNode n : node.getAllExternalDescendants() ) {
+ switch ( getOptions().getExtDescNodeDataToReturn() ) {
+ case NODE_NAME:
+ if ( !ForesterUtil.isEmpty( n.getName() ) ) {
+ data.add( n.getName() );
+ }
+ break;
+ case SEQUENCE_NAME:
+ if ( n.getNodeData().isHasSequence()
+ && !ForesterUtil.isEmpty( n.getNodeData().getSequence().getName() ) ) {
+ data.add( n.getNodeData().getSequence().getName() );
+ }
+ break;
+ case SEQUENCE_SYMBOL:
+ if ( n.getNodeData().isHasSequence()
+ && !ForesterUtil.isEmpty( n.getNodeData().getSequence().getSymbol() ) ) {
+ 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_ACC:
+ if ( n.getNodeData().isHasSequence() && ( n.getNodeData().getSequence().getAccession() != null )
+ && !ForesterUtil.isEmpty( n.getNodeData().getSequence().getAccession().toString() ) ) {
+ data.add( n.getNodeData().getSequence().getAccession().toString() );
+ }
+ break;
+ case TAXONOMY_SCIENTIFIC_NAME:
+ if ( n.getNodeData().isHasTaxonomy()
+ && !ForesterUtil.isEmpty( n.getNodeData().getTaxonomy().getScientificName() ) ) {
+ data.add( n.getNodeData().getTaxonomy().getScientificName() );
+ }
+ break;
+ case TAXONOMY_CODE:
+ if ( n.getNodeData().isHasTaxonomy()
+ && !ForesterUtil.isEmpty( n.getNodeData().getTaxonomy().getTaxonomyCode() ) ) {
+ data.add( n.getNodeData().getTaxonomy().getTaxonomyCode() );
+ }
+ break;
+ case UNKNOWN:
+ AptxUtil.showExtDescNodeDataUserSelectedHelper( getControlPanel(), n, data );
+ break;
+ default:
+ throw new IllegalArgumentException( "unknown data element: "
+ + getOptions().getExtDescNodeDataToReturn() );
+ }
+ } // for loop
+ if ( getConfiguration().getExtNodeDataReturnOn() == EXT_NODE_DATA_RETURN_ON.CONSOLE ) {
+ for( final String d : data ) {
+ if ( !ForesterUtil.isEmpty( d ) ) {
+ System.out.println( d );
+ }
+ }
+ }
+ else if ( getConfiguration().getExtNodeDataReturnOn() == EXT_NODE_DATA_RETURN_ON.WINODW ) {
+ final StringBuilder sb = new StringBuilder();
+ for( final String d : data ) {
+ if ( !ForesterUtil.isEmpty( d ) ) {
+ sb.append( d );
+ sb.append( "\n" );
+ }
+ }
+ if ( sb.length() < 1 ) {
+ AptxUtil.showInformationMessage( this,
+ "No Appropriate Data (" + obtainTitleForExtDescNodeData() + ")",
+ "Descendants of selected node do not contain selected data" );
+ }
+ else {
+ final String title = "External Descendants "
+ + ( getOptions().getExtDescNodeDataToReturn() == NODE_DATA.UNKNOWN ? "Data"
+ : obtainTitleForExtDescNodeData() ) + " (" + data.size() + "/"
+ + node.getNumberOfExternalNodes() + ") For Node " + node;
+ if ( getMainPanel().getMainFrame() == null ) {
+ // Must be "E" applet version.
+ final ArchaeopteryxE ae = ( ArchaeopteryxE ) ( ( MainPanelApplets ) getMainPanel() ).getApplet();
+ final String s = sb.toString().trim();
+ ae.showTextFrame( s, title );
+ ae.setCurrentExternalNodesDataBuffer( s );
+ }
+ else {
+ getMainPanel().getMainFrame().showTextFrame( sb.toString(), title );
+ }
+ }
+ }
+ }
+
+ private final String obtainTitleForExtDescNodeData() {
+ switch ( getOptions().getExtDescNodeDataToReturn() ) {
+ case NODE_NAME:
+ return "Node Names";
+ case SEQUENCE_NAME:
+ return "Sequence Names";
+ case SEQUENCE_SYMBOL:
+ return "Sequence Symbols";
+ case SEQUENCE_MOL_SEQ:
+ return "Molecular Sequences";
+ case SEQUENCE_ACC:
+ return "Sequence Accessors";
+ case TAXONOMY_SCIENTIFIC_NAME:
+ return "Scientific Names";
+ case TAXONOMY_CODE:
+ return "Taxonomy Codes";
+ case UNKNOWN:
+ return "User Selected Data";
+ default:
+ throw new IllegalArgumentException( "unknown data element: "
+ + getOptions().getExtDescNodeDataToReturn() );
+ }
+ }
+