cleanup
authorcmzmasek@gmail.com <cmzmasek@gmail.com@ca865154-3058-d1c3-3e42-d8f55a55bdbd>
Sat, 29 Mar 2014 03:02:27 +0000 (03:02 +0000)
committercmzmasek@gmail.com <cmzmasek@gmail.com@ca865154-3058-d1c3-3e42-d8f55a55bdbd>
Sat, 29 Mar 2014 03:02:27 +0000 (03:02 +0000)
forester/java/src/org/forester/archaeopteryx/Configuration.java
forester/java/src/org/forester/archaeopteryx/ControlPanel.java
forester/java/src/org/forester/archaeopteryx/TreePanel.java

index 7c46dff..4b14d16 100644 (file)
@@ -55,30 +55,37 @@ import org.forester.util.ForesterUtil;
 
 public final class Configuration {
 
-    final static int                        add_new_node                                           = 14;
-    final static int                        blast                                                  = 9;
     final static String                     clickto_options[][]                                    = {
             { "Display Node Data", "display" }, { "Collapse/Uncollapse", "display" }, { "Root/Reroot", "display" },
-            { "Sub/Super Tree", "display" }, { "Swap Descendants", "display" },
-            { "Colorize Subtree/Node(s)", "display" }, { "Open Sequence DB", "display" }, { "Open PDB", "display" },
+            { "Sub/Super Tree", "display" }, { "Swap Descendants", "display" }, { "Colorize Subtree(s)", "display" },
+            { "Colorize Node Font", "display" }, { "Open Sequence DB", "display" }, { "Open PDB", "display" },
             { "Open Taxonomy DB", "display" }, { "Blast", "display" }, { "Cut Subtree", "display" },
             { "Copy Subtree", "display" }, { "Paste Subtree", "display" }, { "Delete Subtree/Node", "display" },
             { "Add New Node", "display" }, { "Edit Node Data", "display" }, { "Sort Descendants", "display" },
             { "Return", "display" }, { "Select Node(s)", "display" }                              };
+    final static int                        display_node_data                                      = 0;
     final static int                        collapse_uncollapse                                    = 1;
-    final static int                        color_according_to_annotation                          = 19;
-    final static int                        color_according_to_species                             = 6;
-    final static int                        color_branches                                         = 7;
+    final static int                        reroot                                                 = 2;
+    final static int                        subtree                                                = 3;
+    final static int                        swap                                                   = 4;
     final static int                        color_subtree                                          = 5;
-    final static int                        copy_subtree                                           = 11;
-    final static int                        cut_subtree                                            = 10;
-    final static int                        delete_subtree_or_node                                 = 13;
-    final static int                        display_as_phylogram                                   = 0;
-    final static int                        display_internal_data                                  = 15;
+    final static int                        color_node_font                                        = 6;
+    final static int                        open_seq_web                                           = 7;
+    final static int                        open_pdb_web                                           = 8;
+    final static int                        open_tax_web                                           = 9;
+    final static int                        blast                                                  = 10;
+    final static int                        cut_subtree                                            = 11;
+    final static int                        copy_subtree                                           = 12;
+    final static int                        paste_subtree                                          = 13;
+    final static int                        delete_subtree_or_node                                 = 14;
+    final static int                        add_new_node                                           = 15;
+    final static int                        edit_node_data                                         = 16;
+    final static int                        sort_descendents                                       = 17;
+    final static int                        get_ext_desc_data                                      = 18;
+    final static int                        select_nodes                                           = 19;
     // ------------------
     // Click-to options
     // ------------------
-    final static int                        display_node_data                                      = 0;
     final static String                     display_options[][]                                    = {
             { "Phylogram", "display", "?" }, { "Node Name", "display", "yes" }, { "Taxonomy Code", "display", "yes" },
             { "Seq Annotations", "nodisplay", "no" }, { "Confidence Values", "display", "?" },
@@ -93,40 +100,34 @@ public final class Configuration {
             { "Rollover", "display", "yes" }, { "Relation Confidence", "nodisplay", "no" },
             { "Vector Data", "nodisplay", "no" }, { "Taxonomy Images", "display", "no" },
             { "Properties", "nodisplay", "no" }, { "Gene Name", "display", "yes" }                };
-    final static int                        dynamically_hide_data                                  = 16;
-    final static int                        edit_node_data                                         = 15;
-    final static int                        get_ext_desc_data                                      = 17;
-    final static int                        node_data_popup                                        = 21;
-    final static int                        open_pdb_web                                           = 7;
-    final static int                        open_seq_web                                           = 6;
-    final static int                        open_tax_web                                           = 8;
-    final static int                        paste_subtree                                          = 12;
-    final static int                        reroot                                                 = 2;
-    final static int                        select_nodes                                           = 18;
+    final static int                        display_as_phylogram                                   = 0;
+    final static int                        show_node_names                                        = 1;
+    final static int                        show_tax_code                                          = 2;
     final static int                        show_annotation                                        = 3;
-    final static int                        show_binary_character_counts                           = 12;
-    final static int                        show_binary_characters                                 = 11;
+    final static int                        write_confidence_values                                = 4;
+    final static int                        write_events                                           = 5;
+    final static int                        color_according_to_species                             = 6;
+    final static int                        color_branches                                         = 7;
+    final static int                        width_branches                                         = 8;
     final static int                        show_custom_node_shapes                                = 9;
     final static int                        show_domain_architectures                              = 10;
-    final static int                        show_gene_names                                        = 26;
-    final static int                        show_node_names                                        = 1;
-    final static int                        show_properties                                        = 25;
-    final static int                        show_relation_confidence                               = 22;
+    final static int                        show_binary_characters                                 = 11;
+    final static int                        show_binary_character_counts                           = 12;
     final static int                        show_seq_names                                         = 13;
-    final static int                        show_seq_symbols                                       = 20;
     final static int                        show_sequence_acc                                      = 14;
-    final static int                        show_tax_code                                          = 2;
-    final static int                        show_taxonomy_common_names                             = 18;
-    final static int                        show_taxonomy_images                                   = 24;
+    final static int                        display_internal_data                                  = 15;
+    final static int                        dynamically_hide_data                                  = 16;
     final static int                        show_taxonomy_scientific_names                         = 17;
+    final static int                        show_taxonomy_common_names                             = 18;
+    final static int                        color_according_to_annotation                          = 19;
+    final static int                        show_seq_symbols                                       = 20;
+    final static int                        node_data_popup                                        = 21;
+    final static int                        show_relation_confidence                               = 22;
     final static int                        show_vector_data                                       = 23;
-    final static int                        sort_descendents                                       = 16;
-    final static int                        subtree                                                = 3;
-    final static int                        swap                                                   = 4;
+    final static int                        show_taxonomy_images                                   = 24;
+    final static int                        show_properties                                        = 25;
+    final static int                        show_gene_names                                        = 26;
     static final String                     VALIDATE_AGAINST_PHYLOXML_XSD_SCHEMA                   = "validate_against_phyloxml_xsd_schema";
-    final static int                        width_branches                                         = 8;
-    final static int                        write_confidence_values                                = 4;
-    final static int                        write_events                                           = 5;
     // ----------------
     // Function colors
     // ----------------
index 846c531..29a69e8 100644 (file)
@@ -116,6 +116,7 @@ final class ControlPanel extends JPanel implements ActionListener {
     private int                  _open_pdb_item;
     private int                  _open_seq_web_item;
     private int                  _open_tax_web_item;
+    private int                  _color_node_font_item;
     private JButton              _order;
     private boolean              _order_of_appearance;
     private int                  _paste_subtree_item;
@@ -1166,6 +1167,9 @@ final class ControlPanel extends JPanel implements ActionListener {
         else if ( action == _open_pdb_item ) {
             setActionWhenNodeClicked( NodeClickAction.OPEN_PDB_WEB );
         }
+        else if ( action == _color_node_font_item ) {
+            setActionWhenNodeClicked( NodeClickAction.COLOR_NODE_FONT );
+        }
         else {
             throw new RuntimeException( "unknown action: " + action );
         }
@@ -1894,6 +1898,15 @@ final class ControlPanel extends JPanel implements ActionListener {
             }
             cb_index++;
         }
+        if ( _configuration.doDisplayClickToOption( Configuration.color_node_font ) ) {
+            _color_node_font_item = cb_index;
+            addClickToOption( Configuration.color_node_font,
+                              _configuration.getClickToTitle( Configuration.color_node_font ) );
+            if ( default_option == Configuration.color_node_font ) {
+                selected_index = cb_index;
+            }
+            cb_index++;
+        }
         if ( _configuration.doDisplayClickToOption( Configuration.open_seq_web ) ) {
             _open_seq_web_item = cb_index;
             addClickToOption( Configuration.open_seq_web, _configuration.getClickToTitle( Configuration.open_seq_web ) );
@@ -2231,6 +2244,8 @@ final class ControlPanel extends JPanel implements ActionListener {
         SHOW_DATA,
         SORT_DESCENDENTS,
         SUBTREE,
-        SWAP;
+        SWAP,
+        CHANGE_NODE_FONT,
+        COLOR_NODE_FONT;
     }
 }
index d0ae1e8..8eeddae 100644 (file)
@@ -2430,6 +2430,35 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
         repaint();
     }
 
+    final private void colorizeNodes( final Color c,
+                                      final PhylogenyNode node,
+                                      final List<PhylogenyNode> additional_nodes ) {
+        _control_panel.setColorBranches( true );
+        if ( _control_panel.getColorBranchesCb() != null ) {
+            _control_panel.getColorBranchesCb().setSelected( true );
+        }
+        if ( node != null ) {
+            colorizeNodesHelper( c, node );
+        }
+        if ( additional_nodes != null ) {
+            for( final PhylogenyNode n : additional_nodes ) {
+                colorizeNodesHelper( c, n );
+            }
+        }
+        repaint();
+    }
+
+    private final static void colorizeNodesHelper( final Color c, final PhylogenyNode node ) {
+        NodeVisualData v;
+        if ( node.getNodeData().getNodeVisualData() != null ) {
+            v = node.getNodeData().getNodeVisualData();
+        }
+        else {
+            v = new NodeVisualData();
+        }
+        v.setFontColor( new Color( c.getRed(), c.getGreen(), c.getBlue() ) );
+    }
+
     final private void colorSubtree( final PhylogenyNode node ) {
         if ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) {
             JOptionPane.showMessageDialog( this,
@@ -2452,6 +2481,25 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
         dialog.setVisible( true );
     }
 
+    private void colorNodeFont( PhylogenyNode node ) {
+        _color_chooser.setPreviewPanel( new JPanel() );
+        NodeColorizationActionListener al;
+        if ( ( getFoundNodes0() != null ) && !getFoundNodes0().isEmpty() ) {
+            final List<PhylogenyNode> additional_nodes = getFoundNodes0AsListOfPhylogenyNodes();
+            al = new NodeColorizationActionListener( _color_chooser, node, additional_nodes );
+        }
+        else {
+            al = new NodeColorizationActionListener( _color_chooser, node );
+        }
+        final JDialog dialog = JColorChooser
+                .createDialog( this, "Subtree colorization", true, _color_chooser, al, null );
+        dialog.setVisible( true );
+    }
+
+    private void changeNodeFont( PhylogenyNode node ) {
+        // TODO Auto-generated method stub
+    }
+
     final private void copySubtree( final PhylogenyNode node ) {
         if ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) {
             errorMessageNoCutCopyPasteInUnrootedDisplay();
@@ -2894,6 +2942,12 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
             case COLOR_SUBTREE:
                 colorSubtree( node );
                 break;
+            case COLOR_NODE_FONT:
+                colorNodeFont( node );
+                break;
+            case CHANGE_NODE_FONT:
+                changeNodeFont( node );
+                break;
             case OPEN_SEQ_WEB:
                 openSeqWeb( node );
                 break;
@@ -5742,4 +5796,32 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
             }
         }
     }
+
+    final private class NodeColorizationActionListener implements ActionListener {
+
+        List<PhylogenyNode> _additional_nodes = null;
+        JColorChooser       _chooser          = null;
+        PhylogenyNode       _node             = null;
+
+        NodeColorizationActionListener( final JColorChooser chooser, final PhylogenyNode node ) {
+            _chooser = chooser;
+            _node = node;
+        }
+
+        NodeColorizationActionListener( final JColorChooser chooser,
+                                        final PhylogenyNode node,
+                                        final List<PhylogenyNode> additional_nodes ) {
+            _chooser = chooser;
+            _node = node;
+            _additional_nodes = additional_nodes;
+        }
+
+        @Override
+        public void actionPerformed( final ActionEvent e ) {
+            final Color c = _chooser.getColor();
+            if ( c != null ) {
+                colorizeNodes( c, _node, _additional_nodes );
+            }
+        }
+    }
 }