From ebc019e52cc784faa96c1360f23e0d4b8c12ecf5 Mon Sep 17 00:00:00 2001 From: "cmzmasek@gmail.com" Date: Fri, 10 Jun 2011 02:59:26 +0000 Subject: [PATCH] in progress --- .../org/forester/archaeopteryx/Configuration.java | 43 ++-- .../src/org/forester/archaeopteryx/MainFrame.java | 101 ++++---- .../forester/archaeopteryx/MainFrameApplet.java | 3 +- .../archaeopteryx/MainFrameApplication.java | 15 +- .../src/org/forester/archaeopteryx/Options.java | 21 +- .../src/org/forester/archaeopteryx/TreePanel.java | 261 +++++++++++--------- 6 files changed, 230 insertions(+), 214 deletions(-) diff --git a/forester/java/src/org/forester/archaeopteryx/Configuration.java b/forester/java/src/org/forester/archaeopteryx/Configuration.java index 162ac79..0eead28 100644 --- a/forester/java/src/org/forester/archaeopteryx/Configuration.java +++ b/forester/java/src/org/forester/archaeopteryx/Configuration.java @@ -94,10 +94,10 @@ public final class Configuration { private boolean _color_labels_same_as_parent_branch = false; private int _default_bootstrap_samples = -1; private boolean _show_default_node_shapes = false; - private NodeShape _default_node_shape = NodeShape.NONE; + private NodeShape _default_node_shape = NodeShape.CIRCLE; private NodeFill _default_node_fill = NodeFill.GRADIENT; private short _default_node_shape_size = Constants.DEFAULT_NODE_SHAPE_SIZE_DEFAULT; - private boolean _taxonomy_colorize_node_shapes = false; + private boolean _taxonomy_colorize_node_shapes = false; final static int display_as_phylogram = 0; final static int show_node_names = 1; final static int show_tax_code = 2; @@ -155,15 +155,15 @@ public final class Configuration { { "Phylogram", "display", "?" }, { "Node Name", "display", "yes" }, { "Taxonomy Code", "display", "yes" }, { "Annotation", "nodisplay", "no" }, { "Confidence Value", "display", "?" }, { "Event", "display", "?" }, { "Taxonomy Colorize", "display", "yes" }, { "Colorize Branches", "display", "no" }, - { "Use Branch-Width", "nodisplay", "no" }, { "Show Custom Nodes", "display", "yes"}, { "Domains", "nodisplay", "no" }, - { "Binary Characters", "nodisplay", "no" }, { "Binary Char Counts", "nodisplay", "no" }, - { "Prot/Gene Name", "display", "no" }, { "Prot/Gene Acc", "display", "no" }, - { "Show Internal Data", "display", "yes" }, { "Dyna Hide", "display", "yes" }, - { "Taxonomy Scientific", "display", "yes" }, { "Taxonomy Common", "display", "no" }, - { "Annotation Colorize", "nodisplay", "no" }, { "Property", "nodisplay", "no" }, - { "Prot/Gene Symbol", "display", "no" }, { "Rollover", "display", "yes" }, - { "Relation Confidence", "display", "no" }, { "Vector Data", "display", "no" }, - { "Taxonomy Images", "display", "no" } }; + { "Use Branch-Width", "nodisplay", "no" }, { "Show Custom Nodes", "display", "yes" }, + { "Domains", "nodisplay", "no" }, { "Binary Characters", "nodisplay", "no" }, + { "Binary Char Counts", "nodisplay", "no" }, { "Prot/Gene Name", "display", "no" }, + { "Prot/Gene Acc", "display", "no" }, { "Show Internal Data", "display", "yes" }, + { "Dyna Hide", "display", "yes" }, { "Taxonomy Scientific", "display", "yes" }, + { "Taxonomy Common", "display", "no" }, { "Annotation Colorize", "nodisplay", "no" }, + { "Property", "nodisplay", "no" }, { "Prot/Gene Symbol", "display", "no" }, + { "Rollover", "display", "yes" }, { "Relation Confidence", "display", "no" }, + { "Vector Data", "display", "no" }, { "Taxonomy Images", "display", "no" } }; final static String clickto_options[][] = { { "Display Node Data", "display" }, { "Collapse/Uncollapse", "display" }, { "Root/Reroot", "display" }, { "Sub/Super Tree", "display" }, { "Swap Descendants", "display" }, { "Colorize Subtree", "display" }, @@ -366,7 +366,6 @@ public final class Configuration { return _cladogram_type; } - private int getClickToIndex( final String name ) { int index = -1; if ( name.equals( "edit_info" ) ) { @@ -1065,7 +1064,6 @@ public final class Configuration { else if ( key.equals( "domain_structure_base_color" ) ) { _domain_structure_base_color = Color.decode( ( String ) st.nextElement() ); } - // else if ( key.equals( "show_default_node_shapes" ) ) { setShowDefaultNodeShapes( parseBoolean( ( ( String ) st.nextElement() ).trim() ) ); } @@ -1091,10 +1089,7 @@ public final class Configuration { } else if ( key.equals( "default_node_shape" ) ) { final String shape_str = ( ( String ) st.nextElement() ).trim(); - if ( shape_str.equalsIgnoreCase( Options.NodeShape.NONE.toString() ) ) { - setDefaultNodeShape( NodeShape.NONE ); - } - else if ( shape_str.equalsIgnoreCase( Options.NodeShape.CIRCLE.toString() ) ) { + if ( shape_str.equalsIgnoreCase( Options.NodeShape.CIRCLE.toString() ) ) { setDefaultNodeShape( NodeShape.CIRCLE ); } else if ( shape_str.equalsIgnoreCase( Options.NodeShape.RECTANGLE.toString() ) ) { @@ -1424,12 +1419,12 @@ public final class Configuration { public boolean isTaxonomyColorizeNodeShapes() { return _taxonomy_colorize_node_shapes; } - + public boolean isShowDefaultNodeShapes() { - return _show_default_node_shapes; - } - private void setShowDefaultNodeShapes(boolean show_default_node_shapes) { - _show_default_node_shapes =show_default_node_shapes; - } - + return _show_default_node_shapes; + } + + private void setShowDefaultNodeShapes( final boolean show_default_node_shapes ) { + _show_default_node_shapes = show_default_node_shapes; + } } diff --git a/forester/java/src/org/forester/archaeopteryx/MainFrame.java b/forester/java/src/org/forester/archaeopteryx/MainFrame.java index 0b5433b..fdff501 100644 --- a/forester/java/src/org/forester/archaeopteryx/MainFrame.java +++ b/forester/java/src/org/forester/archaeopteryx/MainFrame.java @@ -33,7 +33,6 @@ import java.util.List; import java.util.Locale; import java.util.Map; -import javax.swing.Icon; import javax.swing.JApplet; import javax.swing.JCheckBoxMenuItem; import javax.swing.JFrame; @@ -52,48 +51,48 @@ import org.forester.util.ForesterUtil; public abstract class MainFrame extends JFrame implements ActionListener { - static final String USE_MOUSEWHEEL_SHIFT_TO_ROTATE = "In this display type, use mousewheel + Shift to rotate [or A and S]"; - static final String PHYLOXML_REF_TOOL_TIP = Constants.PHYLOXML_REFERENCE; //TODO //FIXME - static final String APTX_REF_TOOL_TIP = Constants.APTX_REFERENCE; - private static final long serialVersionUID = 3655000897845508358L; - final static Font menu_font = new Font( Configuration.getDefaultFontFamilyName(), - Font.PLAIN, - 10 ); - static final String TYPE_MENU_HEADER = "Type"; - static final String RECTANGULAR_TYPE_CBMI_LABEL = "Rectangular"; - static final String EURO_TYPE_CBMI_LABEL = "Euro Type"; - static final String CURVED_TYPE_CBMI_LABEL = "Curved"; - static final String TRIANGULAR_TYPE_CBMI_LABEL = "Triangular"; - static final String CONVEX_TYPE_CBMI_LABEL = "Convex"; - static final String ROUNDED_TYPE_CBMI_LABEL = "Rounded"; - static final String UNROOTED_TYPE_CBMI_LABEL = "Unrooted (alpha)"; //TODO - static final String CIRCULAR_TYPE_CBMI_LABEL = "Circular (alpha)"; //TODO - static final String OPTIONS_HEADER = "Options"; - static final String SEARCH_SUBHEADER = "Search:"; - static final String DISPLAY_SUBHEADER = "Display:"; - static final String SEARCH_TERMS_ONLY_LABEL = "Match Complete Terms Only"; - static final String SEARCH_CASE_SENSITIVE_LABEL = "Case Sensitive"; - static final String INVERSE_SEARCH_RESULT_LABEL = "Negate Result"; - static final String DISPLAY_BRANCH_LENGTH_VALUES_LABEL = "Display Branch Length Values"; - static final String DISPLAY_SCALE_LABEL = "Display Scale"; - static final String NON_LINED_UP_CLADOGRAMS_LABEL = "Non-Lined Up Cladograms"; - static final String UNIFORM_CLADOGRAMS_LABEL = "Total Node Sum Dependent Cladograms"; - static final String LABEL_DIRECTION_LABEL = "Radial Labels"; - static final String LABEL_DIRECTION_TIP = "To use radial node labels in radial and unrooted display types"; - static final String SCREEN_ANTIALIAS_LABEL = "Antialias"; - static final String COLOR_LABELS_LABEL = "Colorize Labels Same as Parent Branch"; - static final String BG_GRAD_LABEL = "Background Color Gradient"; - static final String DISPLAY_NODE_BOXES_LABEL = "Display Node Shapes"; - static final String SHOW_OVERVIEW_LABEL = "Show Overview"; - static final String FONT_SIZE_MENU_LABEL = "Font Size"; - static final String NONUNIFORM_CLADOGRAMS_LABEL = "External Node Sum Dependent Cladograms"; - static final String SHOW_DOMAIN_LABELS_LABEL = "Show Domain Labels"; - static final String COLOR_LABELS_TIP = "To use parent branch colors for node labels as well, need to turn off taxonomy dependent colorization and turn on branch colorization for this to become apparent"; - static final String ABBREV_SN_LABEL = "Abbreviate Scientific Taxonomic Names"; - static final String TAXONOMY_COLORIZE_NODE_SHAPES_LABEL = "Colorize Node Shapes According to Taxonomy"; - static final String CYCLE_NODE_SHAPE_LABEL = "Cycle Node Shapes"; - static final String CYCLE_NODE_FILL_LABEL = "Cycle Node Fill Type"; - static final String CHOOSE_NODE_SIZE_LABEL = "Choose Node Shape Size"; + static final String USE_MOUSEWHEEL_SHIFT_TO_ROTATE = "In this display type, use mousewheel + Shift to rotate [or A and S]"; + static final String PHYLOXML_REF_TOOL_TIP = Constants.PHYLOXML_REFERENCE; //TODO //FIXME + static final String APTX_REF_TOOL_TIP = Constants.APTX_REFERENCE; + private static final long serialVersionUID = 3655000897845508358L; + final static Font menu_font = new Font( Configuration.getDefaultFontFamilyName(), + Font.PLAIN, + 10 ); + static final String TYPE_MENU_HEADER = "Type"; + static final String RECTANGULAR_TYPE_CBMI_LABEL = "Rectangular"; + static final String EURO_TYPE_CBMI_LABEL = "Euro Type"; + static final String CURVED_TYPE_CBMI_LABEL = "Curved"; + static final String TRIANGULAR_TYPE_CBMI_LABEL = "Triangular"; + static final String CONVEX_TYPE_CBMI_LABEL = "Convex"; + static final String ROUNDED_TYPE_CBMI_LABEL = "Rounded"; + static final String UNROOTED_TYPE_CBMI_LABEL = "Unrooted (alpha)"; //TODO + static final String CIRCULAR_TYPE_CBMI_LABEL = "Circular (alpha)"; //TODO + static final String OPTIONS_HEADER = "Options"; + static final String SEARCH_SUBHEADER = "Search:"; + static final String DISPLAY_SUBHEADER = "Display:"; + static final String SEARCH_TERMS_ONLY_LABEL = "Match Complete Terms Only"; + static final String SEARCH_CASE_SENSITIVE_LABEL = "Case Sensitive"; + static final String INVERSE_SEARCH_RESULT_LABEL = "Negate Result"; + static final String DISPLAY_BRANCH_LENGTH_VALUES_LABEL = "Display Branch Length Values"; + static final String DISPLAY_SCALE_LABEL = "Display Scale"; + static final String NON_LINED_UP_CLADOGRAMS_LABEL = "Non-Lined Up Cladograms"; + static final String UNIFORM_CLADOGRAMS_LABEL = "Total Node Sum Dependent Cladograms"; + static final String LABEL_DIRECTION_LABEL = "Radial Labels"; + static final String LABEL_DIRECTION_TIP = "To use radial node labels in radial and unrooted display types"; + static final String SCREEN_ANTIALIAS_LABEL = "Antialias"; + static final String COLOR_LABELS_LABEL = "Colorize Labels Same as Parent Branch"; + static final String BG_GRAD_LABEL = "Background Color Gradient"; + static final String DISPLAY_NODE_BOXES_LABEL = "Display Node Shapes"; + static final String SHOW_OVERVIEW_LABEL = "Show Overview"; + static final String FONT_SIZE_MENU_LABEL = "Font Size"; + static final String NONUNIFORM_CLADOGRAMS_LABEL = "External Node Sum Dependent Cladograms"; + static final String SHOW_DOMAIN_LABELS_LABEL = "Show Domain Labels"; + static final String COLOR_LABELS_TIP = "To use parent branch colors for node labels as well, need to turn off taxonomy dependent colorization and turn on branch colorization for this to become apparent"; + static final String ABBREV_SN_LABEL = "Abbreviate Scientific Taxonomic Names"; + static final String TAXONOMY_COLORIZE_NODE_SHAPES_LABEL = "Colorize Node Shapes According to Taxonomy"; + static final String CYCLE_NODE_SHAPE_LABEL = "Cycle Node Shapes"; + static final String CYCLE_NODE_FILL_LABEL = "Cycle Node Fill Type"; + static final String CHOOSE_NODE_SIZE_LABEL = "Choose Node Shape Size"; JMenuBar _jmenubar; JMenu _file_jmenu; JMenu _tools_menu; @@ -116,7 +115,7 @@ public abstract class MainFrame extends JFrame implements ActionListener { JMenuItem _confcolor_item; JMenuItem _infer_common_sn_names_item; JMenuItem _collapse_species_specific_subtrees; - JMenuItem _collapse_below_threshold; //TODO implememt me + JMenuItem _collapse_below_threshold; //TODO implememt me JMenuItem _obtain_detailed_taxonomic_information_jmi; JMenuItem _obtain_uniprot_seq_information_jmi; JMenuItem _move_node_names_to_tax_sn_jmi; @@ -136,24 +135,22 @@ public abstract class MainFrame extends JFrame implements ActionListener { // _ screen display JCheckBoxMenuItem _screen_antialias_cbmi; JCheckBoxMenuItem _background_gradient_cbmi; - JRadioButtonMenuItem _non_lined_up_cladograms_rbmi; JRadioButtonMenuItem _uniform_cladograms_rbmi; JRadioButtonMenuItem _ext_node_dependent_cladogram_rbmi; JCheckBoxMenuItem _show_branch_length_values_cbmi; - JCheckBoxMenuItem _show_scale_cbmi; //TODO fix me + JCheckBoxMenuItem _show_scale_cbmi; //TODO fix me JCheckBoxMenuItem _show_overview_cbmi; JCheckBoxMenuItem _show_domain_labels; JCheckBoxMenuItem _abbreviate_scientific_names; JCheckBoxMenuItem _color_labels_same_as_parent_branch; JMenuItem _overview_placment_mi; JMenuItem _choose_minimal_confidence_mi; - JCheckBoxMenuItem _show_default_node_shapes_cbmi; JMenuItem _cycle_node_shape_mi; JMenuItem _cycle_node_fill_mi; JMenuItem _choose_node_size_mi; - JCheckBoxMenuItem _taxonomy_colorize_node_shapes_cbmi; + JCheckBoxMenuItem _taxonomy_colorize_node_shapes_cbmi; // _ print JCheckBoxMenuItem _graphics_export_visible_only_cbmi; JCheckBoxMenuItem _antialias_print_cbmi; @@ -337,7 +334,6 @@ public abstract class MainFrame extends JFrame implements ActionListener { else if ( o == _taxonomy_colorize_node_shapes_cbmi ) { updateOptions( getOptions() ); } - else if ( o == _non_lined_up_cladograms_rbmi ) { updateOptions( getOptions() ); showWhole(); @@ -866,9 +862,10 @@ public abstract class MainFrame extends JFrame implements ActionListener { options.setColorLabelsSameAsParentBranch( ( _color_labels_same_as_parent_branch != null ) && _color_labels_same_as_parent_branch.isSelected() ); //TODO FIXME ~~ - options.setShowDefaultNodeShapes( ( _show_default_node_shapes_cbmi != null ) && _show_default_node_shapes_cbmi.isSelected() ); - options.setTaxonomyColorizeNodeShapes( ( _taxonomy_colorize_node_shapes_cbmi != null ) && _taxonomy_colorize_node_shapes_cbmi.isSelected() ); - + options.setShowDefaultNodeShapes( ( _show_default_node_shapes_cbmi != null ) + && _show_default_node_shapes_cbmi.isSelected() ); + options.setTaxonomyColorizeNodeShapes( ( _taxonomy_colorize_node_shapes_cbmi != null ) + && _taxonomy_colorize_node_shapes_cbmi.isSelected() ); //TODO FIXME ~~ if ( ( _non_lined_up_cladograms_rbmi != null ) && ( _non_lined_up_cladograms_rbmi.isSelected() ) ) { options.setCladogramType( CLADOGRAM_TYPE.NON_LINED_UP ); diff --git a/forester/java/src/org/forester/archaeopteryx/MainFrameApplet.java b/forester/java/src/org/forester/archaeopteryx/MainFrameApplet.java index ec01faf..7eb1f4f 100644 --- a/forester/java/src/org/forester/archaeopteryx/MainFrameApplet.java +++ b/forester/java/src/org/forester/archaeopteryx/MainFrameApplet.java @@ -178,7 +178,8 @@ public final class MainFrameApplet extends MainFrame { _radio_group_1.add( _ext_node_dependent_cladogram_rbmi ); _radio_group_1.add( _uniform_cladograms_rbmi ); _radio_group_1.add( _non_lined_up_cladograms_rbmi ); - _options_jmenu.add( _show_default_node_shapes_cbmi = new JCheckBoxMenuItem( MainFrame.DISPLAY_NODE_BOXES_LABEL ) ); + _options_jmenu + .add( _show_default_node_shapes_cbmi = new JCheckBoxMenuItem( MainFrame.DISPLAY_NODE_BOXES_LABEL ) ); _options_jmenu.add( _show_scale_cbmi = new JCheckBoxMenuItem( MainFrame.DISPLAY_SCALE_LABEL ) ); _options_jmenu .add( _show_branch_length_values_cbmi = new JCheckBoxMenuItem( MainFrame.DISPLAY_BRANCH_LENGTH_VALUES_LABEL ) ); diff --git a/forester/java/src/org/forester/archaeopteryx/MainFrameApplication.java b/forester/java/src/org/forester/archaeopteryx/MainFrameApplication.java index 4ef0472..f37e8a7 100644 --- a/forester/java/src/org/forester/archaeopteryx/MainFrameApplication.java +++ b/forester/java/src/org/forester/archaeopteryx/MainFrameApplication.java @@ -44,7 +44,6 @@ import java.util.List; import java.util.Set; import javax.swing.ButtonGroup; -import javax.swing.Icon; import javax.swing.JCheckBoxMenuItem; import javax.swing.JFileChooser; import javax.swing.JMenu; @@ -188,7 +187,6 @@ public final class MainFrameApplication extends MainFrame { private final static SequencesFileFilter seqsfilter = new SequencesFileFilter(); private final static DefaultFilter defaultfilter = new DefaultFilter(); private static final long serialVersionUID = -799735726778865234L; - private final JFileChooser _values_filechooser; private final JFileChooser _open_filechooser; private final JFileChooser _msa_filechooser; @@ -713,17 +711,14 @@ public final class MainFrameApplication extends MainFrame { _radio_group_1.add( _ext_node_dependent_cladogram_rbmi ); _radio_group_1.add( _uniform_cladograms_rbmi ); _radio_group_1.add( _non_lined_up_cladograms_rbmi ); - // _options_jmenu.add( _show_default_node_shapes_cbmi = new JCheckBoxMenuItem( DISPLAY_NODE_BOXES_LABEL ) ); - - - _options_jmenu.add( _taxonomy_colorize_node_shapes_cbmi = new JCheckBoxMenuItem( MainFrame.TAXONOMY_COLORIZE_NODE_SHAPES_LABEL) ); - _options_jmenu.add( _cycle_node_shape_mi = new JMenuItem( MainFrame.CYCLE_NODE_SHAPE_LABEL)); - _options_jmenu.add( _cycle_node_fill_mi = new JMenuItem( MainFrame.CYCLE_NODE_FILL_LABEL )); - _options_jmenu.add( _choose_node_size_mi = new JMenuItem( MainFrame.CHOOSE_NODE_SIZE_LABEL )); + _options_jmenu + .add( _taxonomy_colorize_node_shapes_cbmi = new JCheckBoxMenuItem( MainFrame.TAXONOMY_COLORIZE_NODE_SHAPES_LABEL ) ); + _options_jmenu.add( _cycle_node_shape_mi = new JMenuItem( MainFrame.CYCLE_NODE_SHAPE_LABEL ) ); + _options_jmenu.add( _cycle_node_fill_mi = new JMenuItem( MainFrame.CYCLE_NODE_FILL_LABEL ) ); + _options_jmenu.add( _choose_node_size_mi = new JMenuItem( MainFrame.CHOOSE_NODE_SIZE_LABEL ) ); // - _options_jmenu.add( _show_scale_cbmi = new JCheckBoxMenuItem( DISPLAY_SCALE_LABEL ) ); _options_jmenu .add( _show_branch_length_values_cbmi = new JCheckBoxMenuItem( DISPLAY_BRANCH_LENGTH_VALUES_LABEL ) ); diff --git a/forester/java/src/org/forester/archaeopteryx/Options.java b/forester/java/src/org/forester/archaeopteryx/Options.java index 294afdc..0f9b7a0 100644 --- a/forester/java/src/org/forester/archaeopteryx/Options.java +++ b/forester/java/src/org/forester/archaeopteryx/Options.java @@ -71,7 +71,7 @@ final public class Options { private NodeFill _default_node_fill; private short _default_node_shape_size; private boolean _taxonomy_colorize_node_shapes; - private boolean _show_default_node_shapes; + private boolean _show_default_node_shapes; private Options() { init(); @@ -138,7 +138,7 @@ final public class Options { } final private void init() { - _default_node_shape = NodeShape.NONE; + _default_node_shape = NodeShape.CIRCLE; _default_node_fill = NodeFill.GRADIENT; _default_node_shape_size = Constants.DEFAULT_NODE_SHAPE_SIZE_DEFAULT; _taxonomy_colorize_node_shapes = false; @@ -425,12 +425,14 @@ final public class Options { return new Options(); } - boolean isShowDefaultNodeShapes() { - return _show_default_node_shapes; - } - void setShowDefaultNodeShapes(boolean show_default_node_shapes) { - _show_default_node_shapes = show_default_node_shapes; + boolean isShowDefaultNodeShapes() { + return _show_default_node_shapes; } + + void setShowDefaultNodeShapes( final boolean show_default_node_shapes ) { + _show_default_node_shapes = show_default_node_shapes; + } + final static Options createInstance( final Configuration configuration ) { final Options instance = createDefaultInstance(); if ( configuration != null ) { @@ -487,8 +489,7 @@ final public class Options { if ( configuration.getDefaultNodeShapeSize() >= 0 ) { instance.setDefaultNodeShapeSize( configuration.getDefaultNodeShapeSize() ); } - instance.setTaxonomyColorizeNodeShapes( configuration - .isTaxonomyColorizeNodeShapes() ); + instance.setTaxonomyColorizeNodeShapes( configuration.isTaxonomyColorizeNodeShapes() ); instance.setShowDefaultNodeShapes( configuration.isShowDefaultNodeShapes() ); } return instance; @@ -507,7 +508,7 @@ final public class Options { } enum NodeShape { - NONE, CIRCLE, RECTANGLE + CIRCLE, RECTANGLE } static enum OVERVIEW_PLACEMENT_TYPE { diff --git a/forester/java/src/org/forester/archaeopteryx/TreePanel.java b/forester/java/src/org/forester/archaeopteryx/TreePanel.java index 8e94a08..fc2c074 100644 --- a/forester/java/src/org/forester/archaeopteryx/TreePanel.java +++ b/forester/java/src/org/forester/archaeopteryx/TreePanel.java @@ -448,12 +448,12 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee } } - final void assignGraphicsForNodeBoxWithColorForParentBranch( final PhylogenyNode node, final Graphics g ) { + final Color getGraphicsForNodeBoxWithColorForParentBranch( final PhylogenyNode node ) { if ( getControlPanel().isColorBranches() && ( PhylogenyMethods.getBranchColorValue( node ) != null ) ) { - g.setColor( PhylogenyMethods.getBranchColorValue( node ) ); + return ( PhylogenyMethods.getBranchColorValue( node ) ); } else { - g.setColor( getTreeColorSet().getBranchColor() ); + return ( getTreeColorSet().getBranchColor() ); } } @@ -2307,7 +2307,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee final private void paintBranchRectangular( final Graphics2D g, final float x1, final float x2, - float y1, + final float y1, final float y2, final PhylogenyNode node, final boolean to_pdf, @@ -2328,88 +2328,89 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee g.draw( _cubic_curve ); } else { - float x2a = x2; - float x1a = x1; + final float x2a = x2; + final float x1a = x1; // draw the vertical line - boolean draw_horizontal = true; + // boolean draw_horizontal = true; float y2_r = 0; if ( node.isFirstChildNode() || node.isLastChildNode() || ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE ) || ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.ROUNDED ) ) { - boolean draw_vertical = true; - final PhylogenyNode parent = node.getParent(); - if ( ( ( ( getOptions().getDefaultNodeShape() != Options.NodeShape.NONE ) && !to_pdf && !to_graphics_file ) || ( ( getControlPanel() - .isEvents() ) && ( parent != null ) && parent.isHasAssignedEvent() ) ) - && ( _phylogeny.isRooted() || !( ( parent != null ) && parent.isRoot() ) ) - && !( ( to_pdf || to_graphics_file ) && getOptions().isPrintBlackAndWhite() && !parent - .isDuplication() ) ) { - if ( ( getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE ) - && ( getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.ROUNDED ) ) { - if ( Math.abs( y2 - y1 ) <= _half_box_size ) { - draw_vertical = false; - } - else { - if ( y1 < y2 ) { - y1 += _half_box_size; - } - else { - if ( !to_pdf ) { - y1 -= _half_box_size + 1; - } - else { - y1 -= _half_box_size; - } - } - } - } - if ( ( x2 - x1 ) <= _half_box_size ) { - draw_horizontal = false; - } - else if ( !draw_vertical ) { - x1a += _half_box_size; - } - if ( ( ( x2 - x1a ) > _half_box_size ) - && !( ( to_pdf || to_graphics_file ) && getOptions().isPrintBlackAndWhite() && !node - .isDuplication() ) ) { - x2a -= _half_box_size; - } + //boolean draw_vertical = true; + // final PhylogenyNode parent = node.getParent(); + //TODO fix below -- actually this might not be necessay anymore? test pdf, though! + // if ( ( ( ( getOptions().isShowDefaultNodeShapes() ) && !to_pdf && !to_graphics_file ) || ( ( getControlPanel() + // .isEvents() ) && ( parent != null ) && parent.isHasAssignedEvent() ) ) + // && ( _phylogeny.isRooted() || !( ( parent != null ) && parent.isRoot() ) ) + // && !( ( to_pdf || to_graphics_file ) && getOptions().isPrintBlackAndWhite() && !parent + // .isDuplication() ) ) { + // if ( ( getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE ) + // && ( getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.ROUNDED ) ) { + // if ( Math.abs( y2 - y1 ) <= _half_box_size ) { + // draw_vertical = false; + // } + // else { + // if ( y1 < y2 ) { + // y1 += _half_box_size; + // } + // else { + // if ( !to_pdf ) { + // y1 -= _half_box_size + 1; + // } + // else { + // y1 -= _half_box_size; + // } + // } + // } + // } + // if ( ( x2 - x1 ) <= _half_box_size ) { + // draw_horizontal = false; + // } + // else if ( !draw_vertical ) { + // x1a += _half_box_size; + // } + // if ( ( ( x2 - x1a ) > _half_box_size ) + // && !( ( to_pdf || to_graphics_file ) && getOptions().isPrintBlackAndWhite() && !node + // .isDuplication() ) ) { + // x2a -= _half_box_size; + // } + // } + //if ( draw_vertical ) { + if ( !to_graphics_file + && !to_pdf + && ( ( ( y2 < getVisibleRect().getMinY() - 20 ) && ( y1 < getVisibleRect().getMinY() - 20 ) ) || ( ( y2 > getVisibleRect() + .getMaxY() + 20 ) && ( y1 > getVisibleRect().getMaxY() + 20 ) ) ) ) { + // Do nothing. } - if ( draw_vertical ) { - if ( !to_graphics_file - && !to_pdf - && ( ( ( y2 < getVisibleRect().getMinY() - 20 ) && ( y1 < getVisibleRect().getMinY() - 20 ) ) || ( ( y2 > getVisibleRect() - .getMaxY() + 20 ) && ( y1 > getVisibleRect().getMaxY() + 20 ) ) ) ) { - // Do nothing. - } - else { - if ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE ) { - float x2c = x1 + EURO_D; - if ( x2c > x2a ) { - x2c = x2a; - } - drawLine( x1, y1, x2c, y2, g ); + else { + if ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE ) { + float x2c = x1 + EURO_D; + if ( x2c > x2a ) { + x2c = x2a; } - else if ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.ROUNDED ) { - if ( y2 > y1 ) { - y2_r = y2 - ROUNDED_D; - if ( y2_r < y1 ) { - y2_r = y1; - } - drawLine( x1, y1, x1, y2_r, g ); - } - else { - y2_r = y2 + ROUNDED_D; - if ( y2_r > y1 ) { - y2_r = y1; - } - drawLine( x1, y1, x1, y2_r, g ); + drawLine( x1, y1, x2c, y2, g ); + } + else if ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.ROUNDED ) { + if ( y2 > y1 ) { + y2_r = y2 - ROUNDED_D; + if ( y2_r < y1 ) { + y2_r = y1; } + drawLine( x1, y1, x1, y2_r, g ); } else { - drawLine( x1, y1, x1, y2, g ); + y2_r = y2 + ROUNDED_D; + if ( y2_r > y1 ) { + y2_r = y1; + } + drawLine( x1, y1, x1, y2_r, g ); } } + else { + drawLine( x1, y1, x1, y2, g ); + } } + //} } // draw the horizontal line if ( !to_graphics_file && !to_pdf @@ -2417,43 +2418,43 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee return; } float x1_r = 0; - if ( draw_horizontal ) { - if ( !getControlPanel().isWidthBranches() || ( PhylogenyMethods.getBranchWidthValue( node ) == 1 ) ) { - if ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.ROUNDED ) { - x1_r = x1a + ROUNDED_D; - if ( x1_r < x2a ) { - drawLine( x1_r, y2, x2a, y2, g ); - } + // if ( draw_horizontal ) { + if ( !getControlPanel().isWidthBranches() || ( PhylogenyMethods.getBranchWidthValue( node ) == 1 ) ) { + if ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.ROUNDED ) { + x1_r = x1a + ROUNDED_D; + if ( x1_r < x2a ) { + drawLine( x1_r, y2, x2a, y2, g ); } - else if ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE ) { - final float x1c = x1a + EURO_D; - if ( x1c < x2a ) { - drawLine( x1c, y2, x2a, y2, g ); - } - } - else { - drawLine( x1a, y2, x2a, y2, g ); + } + else if ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE ) { + final float x1c = x1a + EURO_D; + if ( x1c < x2a ) { + drawLine( x1c, y2, x2a, y2, g ); } } else { - final double w = PhylogenyMethods.getBranchWidthValue( node ); - if ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.ROUNDED ) { - x1_r = x1a + ROUNDED_D; - if ( x1_r < x2a ) { - drawRectFilled( x1_r, y2 - ( w / 2 ), x2a - x1_r, w, g ); - } - } - else if ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE ) { - final float x1c = x1a + EURO_D; - if ( x1c < x2a ) { - drawRectFilled( x1c, y2 - ( w / 2 ), x2a - x1c, w, g ); - } + drawLine( x1a, y2, x2a, y2, g ); + } + } + else { + final double w = PhylogenyMethods.getBranchWidthValue( node ); + if ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.ROUNDED ) { + x1_r = x1a + ROUNDED_D; + if ( x1_r < x2a ) { + drawRectFilled( x1_r, y2 - ( w / 2 ), x2a - x1_r, w, g ); } - else { - drawRectFilled( x1a, y2 - ( w / 2 ), x2a - x1a, w, g ); + } + else if ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE ) { + final float x1c = x1a + EURO_D; + if ( x1c < x2a ) { + drawRectFilled( x1c, y2 - ( w / 2 ), x2a - x1c, w, g ); } } + else { + drawRectFilled( x1a, y2 - ( w / 2 ), x2a - x1a, w, g ); + } } + //} if ( ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.ROUNDED ) ) { if ( x1_r > x2a ) { x1_r = x2a; @@ -2781,25 +2782,29 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee paintFoundNode( ForesterUtil.roundToInt( x ), ForesterUtil.roundToInt( y ), g ); } else { + Color outline_color = null; if ( ( to_pdf || to_graphics_file ) && getOptions().isPrintBlackAndWhite() ) { - g.setColor( Color.BLACK ); + outline_color = Color.BLACK; } else if ( getControlPanel().isEvents() && Util.isHasAssignedEvent( node ) ) { final Event event = node.getNodeData().getEvent(); if ( event.isDuplication() ) { - g.setColor( getTreeColorSet().getDuplicationBoxColor() ); + outline_color = getTreeColorSet().getDuplicationBoxColor(); } else if ( event.isSpeciation() ) { - g.setColor( getTreeColorSet().getSpecBoxColor() ); + outline_color = getTreeColorSet().getSpecBoxColor(); } else if ( event.isSpeciationOrDuplication() ) { - g.setColor( getTreeColorSet().getDuplicationOrSpeciationColor() ); + outline_color = getTreeColorSet().getDuplicationOrSpeciationColor(); } } + else if ( getOptions().isTaxonomyColorizeNodeShapes() ) { + outline_color = getTaxonomyBasedColor( node ); + } else { - assignGraphicsForNodeBoxWithColorForParentBranch( node, g ); + outline_color = getGraphicsForNodeBoxWithColorForParentBranch( node ); } - if ( ( ( getOptions().getDefaultNodeShape() != Options.NodeShape.NONE ) && !to_pdf && !to_graphics_file ) + if ( ( ( getOptions().isShowDefaultNodeShapes() ) /*&& !to_pdf && !to_graphics_file*/) || ( getControlPanel().isEvents() && node.isHasAssignedEvent() ) ) { if ( to_pdf || to_graphics_file ) { if ( node.isDuplication() || !getOptions().isPrintBlackAndWhite() ) { @@ -2810,9 +2815,9 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee _box_size, _box_size, g, - Color.BLACK, - g.getColor(), - g.getColor() ); + outline_color, + getBackground(), + outline_color ); } } else { @@ -2825,11 +2830,22 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee _box_size, _box_size, g, - Color.BLACK, - g.getColor(), - g.getColor() ); + outline_color, + getBackground(), + outline_color ); + } + else if ( getOptions().getDefaultNodeFill() == NodeFill.NONE ) { + drawOvalGradient( x - _half_box_size, + y - _half_box_size, + _box_size, + _box_size, + g, + getBackground(), + getBackground(), + outline_color ); } else if ( getOptions().getDefaultNodeFill() == NodeFill.SOLID ) { + g.setColor( outline_color ); drawOvalFilled( x - _half_box_size, y - _half_box_size, _box_size, _box_size, g ); } } @@ -2840,11 +2856,22 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee _box_size, _box_size, g, - Color.BLACK, - g.getColor(), - g.getColor() ); + outline_color, + getBackground(), + outline_color ); + } + else if ( getOptions().getDefaultNodeFill() == NodeFill.NONE ) { + drawRectGradient( x - _half_box_size, + y - _half_box_size, + _box_size, + _box_size, + g, + getBackground(), + getBackground(), + outline_color ); } else if ( getOptions().getDefaultNodeFill() == NodeFill.SOLID ) { + g.setColor( outline_color ); drawRectFilled( x - _half_box_size, y - _half_box_size, _box_size, _box_size, g ); } } -- 1.7.10.2