inprogress
authorcmzmasek@gmail.com <cmzmasek@gmail.com@ca865154-3058-d1c3-3e42-d8f55a55bdbd>
Tue, 1 Apr 2014 00:24:17 +0000 (00:24 +0000)
committercmzmasek@gmail.com <cmzmasek@gmail.com@ca865154-3058-d1c3-3e42-d8f55a55bdbd>
Tue, 1 Apr 2014 00:24:17 +0000 (00:24 +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
forester/java/src/org/forester/phylogeny/data/NodeVisualData.java

index 15a3d91..cf3330d 100644 (file)
@@ -58,11 +58,11 @@ public final class Configuration {
     final static String                     clickto_options[][]                                    = {
             { "Display Node Data", "display" }, { "Collapse/Uncollapse", "display" }, { "Root/Reroot", "display" },
             { "Sub/Super Tree", "display" }, { "Swap Descendants", "display" }, { "Colorize Subtree(s)", "display" },
-            { "Colorize Node", "display" },  { "Change Node Font", "display" }, { "Open Sequence DB", "display" }, { "Go to 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" }                              };
+            { "Colorize Node", "display" }, { "Change Node Font", "display" }, { "Open Sequence DB", "display" },
+            { "Go to 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                        reroot                                                 = 2;
@@ -70,7 +70,7 @@ public final class Configuration {
     final static int                        swap                                                   = 4;
     final static int                        color_subtree                                          = 5;
     final static int                        color_node_font                                        = 6;
-    final static int                        change_node_font                                        = 7;
+    final static int                        change_node_font                                       = 7;
     final static int                        open_seq_web                                           = 8;
     final static int                        open_pdb_web                                           = 9;
     final static int                        open_tax_web                                           = 10;
@@ -878,20 +878,15 @@ public final class Configuration {
         else if ( name.equals( "color_subtree" ) ) {
             index = Configuration.color_subtree;
         }
-        
         else if ( name.equals( "change_node_font" ) ) {
             index = Configuration.change_node_font;
         }
-        
         else if ( name.equals( "color_node_font" ) ) {
             index = Configuration.color_node_font;
         }
-        
         else if ( name.equals( "color_subtree" ) ) {
             index = Configuration.color_subtree;
         }
-        
-        
         return index;
     }
 
index 29a69e8..a2f0c68 100644 (file)
@@ -95,6 +95,7 @@ final class ControlPanel extends JPanel implements ActionListener {
     private boolean              _color_branches;
     private JCheckBox            _color_branches_cb;
     private int                  _color_subtree_cb_item;
+    private int                  _change_node_font_item;
     // The settings from the conf file
     private final Configuration  _configuration;
     private int                  _copy_subtree_item;
@@ -1170,6 +1171,9 @@ final class ControlPanel extends JPanel implements ActionListener {
         else if ( action == _color_node_font_item ) {
             setActionWhenNodeClicked( NodeClickAction.COLOR_NODE_FONT );
         }
+        else if ( action == _change_node_font_item ) {
+            setActionWhenNodeClicked( NodeClickAction.CHANGE_NODE_FONT );
+        }
         else {
             throw new RuntimeException( "unknown action: " + action );
         }
@@ -1907,6 +1911,15 @@ final class ControlPanel extends JPanel implements ActionListener {
             }
             cb_index++;
         }
+        if ( _configuration.doDisplayClickToOption( Configuration.change_node_font ) ) {
+            _change_node_font_item = cb_index;
+            addClickToOption( Configuration.change_node_font,
+                              _configuration.getClickToTitle( Configuration.change_node_font ) );
+            if ( default_option == Configuration.change_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 ) );
index 8eeddae..f831e03 100644 (file)
@@ -113,6 +113,7 @@ import org.forester.phylogeny.data.Confidence;
 import org.forester.phylogeny.data.Event;
 import org.forester.phylogeny.data.NodeData.NODE_DATA;
 import org.forester.phylogeny.data.NodeVisualData;
+import org.forester.phylogeny.data.NodeVisualData.FontType;
 import org.forester.phylogeny.data.NodeVisualData.NodeFill;
 import org.forester.phylogeny.data.NodeVisualData.NodeShape;
 import org.forester.phylogeny.data.PhylogenyDataUtil;
@@ -2481,7 +2482,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
         dialog.setVisible( true );
     }
 
-    private void colorNodeFont( PhylogenyNode node ) {
+    private void colorNodeFont( final PhylogenyNode node ) {
         _color_chooser.setPreviewPanel( new JPanel() );
         NodeColorizationActionListener al;
         if ( ( getFoundNodes0() != null ) && !getFoundNodes0().isEmpty() ) {
@@ -2496,8 +2497,37 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
         dialog.setVisible( true );
     }
 
-    private void changeNodeFont( PhylogenyNode node ) {
-        // TODO Auto-generated method stub
+    private void changeNodeFont( final PhylogenyNode node ) {
+        final FontChooser fc = new FontChooser();
+        Font f = null;
+        if ( node.getNodeData().getNodeVisualData() != null && !node.getNodeData().getNodeVisualData().isEmpty() ) {
+            f = node.getNodeData().getNodeVisualData().getFontObject();
+        }
+        if ( f != null ) {
+            fc.setFont( f );
+        }
+        else {
+            fc.setFont( getMainPanel().getTreeFontSet().getLargeFont() );
+        }
+        fc.showDialog( this, "Select Font" );
+        if ( fc.getFont() != null ) {
+            NodeVisualData v = node.getNodeData().getNodeVisualData();
+            Font ff = fc.getFont();
+            v.setFont( ff.getFamily() );
+            v.setFontSize( ( byte ) ( ff.getSize() ) );
+            if ( ff.getStyle() == Font.BOLD && ff.getStyle() == Font.ITALIC ) {
+                v.setFontType( FontType.BOLD_ITALIC );
+            }
+            else if ( ff.getStyle() == Font.ITALIC ) {
+                v.setFontType( FontType.ITALIC );
+            }
+            else if ( ff.getStyle() == Font.BOLD ) {
+                v.setFontType( FontType.BOLD );
+            }
+            else {
+                v.setFontType( FontType.NORMAL );
+            }
+        }
     }
 
     final private void copySubtree( final PhylogenyNode node ) {
index e3b19a4..ffeb8af 100644 (file)
@@ -2,6 +2,7 @@
 package org.forester.phylogeny.data;\r
 \r
 import java.awt.Color;\r
+import java.awt.Font;\r
 import java.io.IOException;\r
 import java.io.Writer;\r
 import java.util.ArrayList;\r
@@ -179,6 +180,26 @@ public final class NodeVisualData implements PhylogenyData {
         _transparancy = transparancy;\r
     }\r
 \r
+    public final int getFontStyle() {\r
+        if ( getFontType() == FontType.BOLD ) {\r
+            return Font.BOLD;\r
+        }\r
+        else if ( getFontType() == FontType.ITALIC ) {\r
+            return Font.ITALIC;\r
+        }\r
+        else if ( getFontType() == FontType.BOLD_ITALIC ) {\r
+            return Font.BOLD & Font.ITALIC;\r
+        }\r
+        return Font.PLAIN;\r
+    }\r
+\r
+    public final Font getFontObject() {\r
+        if ( !ForesterUtil.isEmpty( getFont() ) ) {\r
+            return new Font( getFont(), getFontStyle(), getFontSize() );\r
+        }\r
+        return null;\r
+    }\r
+\r
     @Override\r
     public final StringBuffer toNHX() {\r
         throw new UnsupportedOperationException();\r