From: cmzmasek@gmail.com Date: Tue, 1 Apr 2014 00:24:17 +0000 (+0000) Subject: inprogress X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=17b76e136bdd9b46c3d15021cd2cf6bb224695b7;p=jalview.git inprogress --- diff --git a/forester/java/src/org/forester/archaeopteryx/Configuration.java b/forester/java/src/org/forester/archaeopteryx/Configuration.java index 15a3d91..cf3330d 100644 --- a/forester/java/src/org/forester/archaeopteryx/Configuration.java +++ b/forester/java/src/org/forester/archaeopteryx/Configuration.java @@ -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; } diff --git a/forester/java/src/org/forester/archaeopteryx/ControlPanel.java b/forester/java/src/org/forester/archaeopteryx/ControlPanel.java index 29a69e8..a2f0c68 100644 --- a/forester/java/src/org/forester/archaeopteryx/ControlPanel.java +++ b/forester/java/src/org/forester/archaeopteryx/ControlPanel.java @@ -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 ) ); diff --git a/forester/java/src/org/forester/archaeopteryx/TreePanel.java b/forester/java/src/org/forester/archaeopteryx/TreePanel.java index 8eeddae..f831e03 100644 --- a/forester/java/src/org/forester/archaeopteryx/TreePanel.java +++ b/forester/java/src/org/forester/archaeopteryx/TreePanel.java @@ -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 ) { diff --git a/forester/java/src/org/forester/phylogeny/data/NodeVisualData.java b/forester/java/src/org/forester/phylogeny/data/NodeVisualData.java index e3b19a4..ffeb8af 100644 --- a/forester/java/src/org/forester/phylogeny/data/NodeVisualData.java +++ b/forester/java/src/org/forester/phylogeny/data/NodeVisualData.java @@ -2,6 +2,7 @@ package org.forester.phylogeny.data; import java.awt.Color; +import java.awt.Font; import java.io.IOException; import java.io.Writer; import java.util.ArrayList; @@ -179,6 +180,26 @@ public final class NodeVisualData implements PhylogenyData { _transparancy = transparancy; } + public final int getFontStyle() { + if ( getFontType() == FontType.BOLD ) { + return Font.BOLD; + } + else if ( getFontType() == FontType.ITALIC ) { + return Font.ITALIC; + } + else if ( getFontType() == FontType.BOLD_ITALIC ) { + return Font.BOLD & Font.ITALIC; + } + return Font.PLAIN; + } + + public final Font getFontObject() { + if ( !ForesterUtil.isEmpty( getFont() ) ) { + return new Font( getFont(), getFontStyle(), getFontSize() ); + } + return null; + } + @Override public final StringBuffer toNHX() { throw new UnsupportedOperationException();