final static int collapse_uncollapse = 1;
final static int reroot = 2;
final static int subtree = 3;
- final static int swap = 4;
+ final static int swap = 4;
final static int color_subtree = 5;
final static int open_seq_web = 6;
final static int open_tax_web = 7;
final static int add_new_node = 12;
final static int edit_node_data = 13;
final static int blast = 14;
+ final static int sort_descendents = 15;
+
+
// ---------------------------
// Display options for trees
// ---------------------------
{ "Sub/Super Tree", "display" }, { "Swap Descendants", "display" }, { "Colorize Subtree", "display" },
{ "Open Sequence Web", "display" }, { "Open Taxonomy Web", "display" }, { "Cut Subtree", "display" },
{ "Copy Subtree", "display" }, { "Paste Subtree", "display" }, { "Delete Subtree/Node", "display" },
- { "Add New Node", "display" }, { "Edit Node Data", "display" }, { "Blast", "nodisplay" } };
+ { "Add New Node", "display" }, { "Edit Node Data", "display" }, { "Blast", "nodisplay" }, { "Sort Descendants", "display" } };
// This option is selected in the dropdown
int default_clickto = Configuration.display_node_data;
// --------------
else if ( name.equals( "swap" ) ) {
index = Configuration.swap;
}
+ else if ( name.equals( "sort_descendants" ) ) {
+ index = Configuration.sort_descendents;
+ }
else if ( name.equals( "display_sequences" ) ) {
ForesterUtil
.printWarningMessage( Constants.PRG_NAME, "configuration key [display_sequences] is deprecated" );
private int _subtree_cb_item;
private int _color_subtree_cb_item;
private int _open_seq_web_item;
+ private int _sort_descendents_item;
private int _open_tax_web_item;
private int _cut_subtree_item;
private int _copy_subtree_item;
else if ( action == _open_seq_web_item ) {
setActionWhenNodeClicked( NodeClickAction.OPEN_SEQ_WEB );
}
+ else if ( action == _sort_descendents_item ) {
+ setActionWhenNodeClicked( NodeClickAction.SORT_DESCENDENTS );
+ }
else if ( action == _blast_item ) {
if ( !Constants.__RELEASE && !Constants.__SNAPSHOT_RELEASE ) {
setActionWhenNodeClicked( NodeClickAction.BLAST );
}
cb_index++;
}
+ if ( _configuration.doDisplayClickToOption( Configuration.sort_descendents ) ) {
+ _sort_descendents_item = cb_index;
+ addClickToOption( Configuration.sort_descendents, _configuration.getClickToTitle( Configuration.sort_descendents ) );
+ if ( default_option == Configuration.sort_descendents ) {
+ selected_index = cb_index;
+ }
+ cb_index++;
+ }
if ( _configuration.doDisplayClickToOption( Configuration.color_subtree ) ) {
_color_subtree_cb_item = cb_index;
addClickToOption( Configuration.color_subtree, _configuration.getClickToTitle( Configuration.color_subtree ) );
PASTE_SUBTREE,
ADD_NEW_NODE,
EDIT_NODE_DATA,
+ SORT_DESCENDENTS,
BLAST;
}
}
case EDIT_NODE_DATA:
showNodeEditFrame( node );
break;
+ case SORT_DESCENDENTS:
+ sortDescendants( node );
+ break;
default:
throw new IllegalArgumentException( "unknown action: " + action );
}
}
repaint();
}
-
+
+
+ final void sortDescendants( final PhylogenyNode node ) {
+ if ( !node.isExternal() ) {
+ PhylogenyMethods.sortNodeDescendents( node );
+ setNodeInPreorderToNull();
+ }
+ repaint();
+ }
+
+
final private void switchDisplaygetPhylogenyGraphicsType() {
switch ( getPhylogenyGraphicsType() ) {
case RECTANGULAR:
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
}
}
}
+
+
+
+ final static public void sortNodeDescendents( PhylogenyNode node ) {
+ final List<PhylogenyNode> descs = node.getDescendants();
+ // Collections.sort( arg0, comparator );
+ Collections.sort( descs );
+
+ int i = 0;
+ for( PhylogenyNode desc : descs ) {
+ node.setChildNode( i++, desc );
+ }
+
+ }
+
final static public void transferNodeNameToField( final Phylogeny phy,
final PhylogenyMethods.PhylogenyNodeField field ) {