added AGRESSIVE tax extraction ^^
[jalview.git] / forester / java / src / org / forester / archaeopteryx / Options.java
index d0c6c92..a0c70f3 100644 (file)
@@ -5,7 +5,7 @@
 // Copyright (C) 2009 Christian M. Zmasek
 // Copyright (C) 2009 Burnham Institute for Medical Research
 // All rights reserved
-// 
+//
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 // License as published by the Free Software Foundation; either
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 // Lesser General Public License for more details.
-// 
+//
 // You should have received a copy of the GNU Lesser General Public
 // License along with this library; if not, write to the Free Software
 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
 //
 // Contact: phylosoft @ gmail . com
-// WWW: www.phylosoft.org/forester
+// WWW: https://sites.google.com/site/cmzmasek/home/software/forester
 
 package org.forester.archaeopteryx;
 
 import java.awt.Font;
 
+import org.forester.io.parsers.nhx.NHXParser.TAXONOMY_EXTRACTION;
+import org.forester.phylogeny.PhylogenyNode.NH_CONVERSION_SUPPORT_VALUE_STYLE;
+import org.forester.phylogeny.data.NodeData;
+import org.forester.phylogeny.data.NodeData.NODE_DATA;
+import org.forester.phylogeny.data.NodeVisualization;
+import org.forester.phylogeny.data.NodeVisualization.NodeFill;
+import org.forester.phylogeny.data.NodeVisualization.NodeShape;
 import org.forester.util.ForesterUtil;
 
 /*
@@ -34,45 +41,77 @@ import org.forester.util.ForesterUtil;
  */
 final public class Options {
 
-    static final double             MIN_CONFIDENCE_DEFAULT = 0.0;
-    private boolean                 _show_node_boxes;
-    private boolean                 _show_branch_length_values;
-    private boolean                 _internal_number_are_confidence_for_nh_parsing;
-    private boolean                 _show_scale;
-    private boolean                 _show_overview;
-    private boolean                 _antialias_screen;
-    private boolean                 _antialias_print;
-    private boolean                 _graphics_export_visible_only;
-    private int                     _print_size_x;
-    private int                     _print_size_y;
-    private double                  _min_confidence_value;
-    private boolean                 _print_black_and_white;
-    private boolean                 _print_using_actual_size;
-    private boolean                 _graphics_export_using_actual_size;
-    private PHYLOGENY_GRAPHICS_TYPE _phylogeny_graphics_type;
-    private CLADOGRAM_TYPE          _cladogram_type;
-    private OVERVIEW_PLACEMENT_TYPE _ov_placement;
-    private NODE_LABEL_DIRECTION    _node_label_direction;
-    private Font                    _base_font;
-    private boolean                 _match_whole_terms_only;
-    private boolean                 _search_case_sensitive;
-    private float                   _print_line_width;
-    private boolean                 _inverse_search_result;
-    private double                  _scale_bar_length;
-    private short                   _number_of_digits_after_comma_for_confidence_values;
-    private short                   _number_of_digits_after_comma_for_branch_length_values;
-    private boolean                 _nh_parsing_replace_underscores;
-    private boolean                 _nh_parsing_extract_pfam_taxonomy_codes;
-    private boolean                 _editable;
-    private boolean                 _background_color_gradient;
-    private boolean                 _show_domain_labels;
-    private boolean                 _color_labels_same_as_parent_branch;
-    private boolean                 _abbreviate_scientific_names;
+    static final double                       MIN_CONFIDENCE_DEFAULT = 0.0;
+    private boolean                           _show_branch_length_values;
+    private boolean                           _internal_number_are_confidence_for_nh_parsing;
+    private boolean                           _show_scale;
+    private boolean                           _show_overview;
+    private boolean                           _antialias_screen;
+    private boolean                           _antialias_print;
+    private boolean                           _graphics_export_visible_only;
+    private int                               _print_size_x;
+    private int                               _print_size_y;
+    private double                            _min_confidence_value;
+    private boolean                           _print_black_and_white;
+    private boolean                           _print_using_actual_size;
+    private boolean                           _graphics_export_using_actual_size;
+    private PHYLOGENY_GRAPHICS_TYPE           _phylogeny_graphics_type;
+    private CLADOGRAM_TYPE                    _cladogram_type;
+    private OVERVIEW_PLACEMENT_TYPE           _ov_placement;
+    private NODE_LABEL_DIRECTION              _node_label_direction;
+    private Font                              _base_font;
+    private boolean                           _match_whole_terms_only;
+    private boolean                           _search_case_sensitive;
+    private float                             _print_line_width;
+    private boolean                           _inverse_search_result;
+    private double                            _scale_bar_length;
+    private short                             _number_of_digits_after_comma_for_confidence_values;
+    private short                             _number_of_digits_after_comma_for_branch_length_values;
+    private boolean                           _nh_parsing_replace_underscores;
+    private TAXONOMY_EXTRACTION               _taxonomy_extraction;
+    private boolean                           _editable;
+    private boolean                           _background_color_gradient;
+    private boolean                           _show_domain_labels;
+    private boolean                           _color_labels_same_as_parent_branch;
+    private boolean                           _abbreviate_scientific_names;
+    private NodeVisualization.NodeShape       _default_node_shape;
+    private NodeVisualization.NodeFill        _default_node_fill;
+    private short                             _default_node_shape_size;
+    private boolean                           _taxonomy_colorize_node_shapes;
+    private boolean                           _show_default_node_shapes_internal;
+    private boolean                           _show_default_node_shapes_external;
+    private boolean                           _show_confidence_stddev;
+    private NH_CONVERSION_SUPPORT_VALUE_STYLE _nh_conversion_support_value_style;
+    private NODE_DATA                         _ext_desc_data_to_return;
 
     private Options() {
         init();
     }
 
+    public NodeData.NODE_DATA getExtDescNodeDataToReturn() {
+        return _ext_desc_data_to_return;
+    }
+
+    public final boolean isShowDomainLabels() {
+        return _show_domain_labels;
+    }
+
+    public void setBackgroundColorGradient( final boolean background_color_gradient ) {
+        _background_color_gradient = background_color_gradient;
+    }
+
+    public void setColorLabelsSameAsParentBranch( final boolean color_labels_same_as_parent_branch ) {
+        _color_labels_same_as_parent_branch = color_labels_same_as_parent_branch;
+    }
+
+    public void setExtDescNodeDataToReturn( final NODE_DATA ext_desc_data_to_return ) {
+        _ext_desc_data_to_return = ext_desc_data_to_return;
+    }
+
+    public void setShowDomainLabels( final boolean show_domain_labels ) {
+        _show_domain_labels = show_domain_labels;
+    }
+
     final Font getBaseFont() {
         return _base_font;
     }
@@ -81,10 +120,26 @@ final public class Options {
         return _cladogram_type;
     }
 
+    final NodeFill getDefaultNodeFill() {
+        return _default_node_fill;
+    }
+
+    final NodeShape getDefaultNodeShape() {
+        return _default_node_shape;
+    }
+
+    final short getDefaultNodeShapeSize() {
+        return _default_node_shape_size;
+    }
+
     final double getMinConfidenceValue() {
         return _min_confidence_value;
     }
 
+    NH_CONVERSION_SUPPORT_VALUE_STYLE getNhConversionSupportValueStyle() {
+        return _nh_conversion_support_value_style;
+    }
+
     final NODE_LABEL_DIRECTION getNodeLabelDirection() {
         return _node_label_direction;
     }
@@ -121,46 +176,16 @@ final public class Options {
         return _scale_bar_length;
     }
 
-    final private void init() {
-        _show_node_boxes = false;
-        _show_branch_length_values = false;
-        _internal_number_are_confidence_for_nh_parsing = false;
-        _show_scale = false;
-        _antialias_screen = true;
-        _antialias_print = true;
-        _graphics_export_visible_only = false;
-        _editable = true;
-        _background_color_gradient = false;
-        if ( Util.isUsOrCanada() ) {
-            _print_size_x = Constants.US_LETTER_SIZE_X;
-            _print_size_y = Constants.US_LETTER_SIZE_Y;
-        }
-        else {
-            _print_size_x = Constants.A4_SIZE_X;
-            _print_size_y = Constants.A4_SIZE_Y;
-        }
-        _min_confidence_value = MIN_CONFIDENCE_DEFAULT;
-        _print_black_and_white = false;
-        _print_using_actual_size = false;
-        _graphics_export_using_actual_size = true;
-        _phylogeny_graphics_type = PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR;
-        _base_font = new Font( Configuration.getDefaultFontFamilyName(), Font.PLAIN, 10 );
-        _match_whole_terms_only = false;
-        _search_case_sensitive = false;
-        _print_line_width = Constants.PDF_LINE_WIDTH_DEFAULT;
-        _show_overview = true;
-        _ov_placement = OVERVIEW_PLACEMENT_TYPE.UPPER_LEFT;
-        _node_label_direction = NODE_LABEL_DIRECTION.HORIZONTAL;
-        _inverse_search_result = false;
-        _scale_bar_length = 0.0;
-        _number_of_digits_after_comma_for_branch_length_values = Constants.NUMBER_OF_DIGITS_AFTER_COMMA_FOR_BRANCH_LENGTH_VALUES_DEFAULT;
-        _number_of_digits_after_comma_for_confidence_values = Constants.NUMBER_OF_DIGITS_AFTER_COMMA_FOR_CONFIDENCE_VALUES_DEFAULT;
-        _nh_parsing_replace_underscores = false;
-        _nh_parsing_extract_pfam_taxonomy_codes = false;
-        _cladogram_type = Constants.CLADOGRAM_TYPE_DEFAULT;
-        _show_domain_labels = true;
-        setAbbreviateScientificTaxonNames( false );
-        _color_labels_same_as_parent_branch = false;
+    final TAXONOMY_EXTRACTION getTaxonomyExtraction() {
+        return _taxonomy_extraction;
+    }
+
+    final boolean isAbbreviateScientificTaxonNames() {
+        return _abbreviate_scientific_names;
+    }
+
+    boolean isAllowMagnificationOfTaxonomyImages() {
+        return true;
     }
 
     final boolean isAntialiasPrint() {
@@ -175,10 +200,6 @@ final public class Options {
         return _background_color_gradient;
     }
 
-    public final boolean isShowDomainLabels() {
-        return _show_domain_labels;
-    }
-
     final boolean isColorLabelsSameAsParentBranch() {
         return _color_labels_same_as_parent_branch;
     }
@@ -187,10 +208,6 @@ final public class Options {
         return _editable;
     }
 
-    final boolean isExtractPfamTaxonomyCodesInNhParsing() {
-        return _nh_parsing_extract_pfam_taxonomy_codes;
-    }
-
     final boolean isGraphicsExportUsingActualSize() {
         return _graphics_export_using_actual_size;
     }
@@ -231,8 +248,16 @@ final public class Options {
         return _show_branch_length_values;
     }
 
-    final boolean isShowNodeBoxes() {
-        return _show_node_boxes;
+    boolean isShowConfidenceStddev() {
+        return _show_confidence_stddev;
+    }
+
+    boolean isShowDefaultNodeShapesExternal() {
+        return _show_default_node_shapes_external;
+    }
+
+    boolean isShowDefaultNodeShapesInternal() {
+        return _show_default_node_shapes_internal;
     }
 
     final boolean isShowOverview() {
@@ -243,6 +268,14 @@ final public class Options {
         return _show_scale;
     }
 
+    boolean isTaxonomyColorizeNodeShapes() {
+        return _taxonomy_colorize_node_shapes;
+    }
+
+    final void setAbbreviateScientificTaxonNames( final boolean abbreviate_scientific_names ) {
+        _abbreviate_scientific_names = abbreviate_scientific_names;
+    }
+
     final void setAntialiasPrint( final boolean antialias_print ) {
         _antialias_print = antialias_print;
     }
@@ -251,34 +284,30 @@ final public class Options {
         _antialias_screen = antialias_screen;
     }
 
-    public void setBackgroundColorGradient( final boolean background_color_gradient ) {
-        _background_color_gradient = background_color_gradient;
+    final void setBaseFont( final Font base_font ) {
+        _base_font = base_font;
     }
 
-    public void setShowDomainLabels( final boolean show_domain_labels ) {
-        _show_domain_labels = show_domain_labels;
+    final void setCladogramType( final CLADOGRAM_TYPE cladogram_type ) {
+        _cladogram_type = cladogram_type;
     }
 
-    public void setColorLabelsSameAsParentBranch( final boolean color_labels_same_as_parent_branch ) {
-        _color_labels_same_as_parent_branch = color_labels_same_as_parent_branch;
+    final void setDefaultNodeFill( final NodeFill default_node_fill ) {
+        _default_node_fill = default_node_fill;
     }
 
-    final void setBaseFont( final Font base_font ) {
-        _base_font = base_font;
+    final void setDefaultNodeShape( final NodeShape default_node_shape ) {
+        _default_node_shape = default_node_shape;
     }
 
-    final void setCladogramType( final CLADOGRAM_TYPE cladogram_type ) {
-        _cladogram_type = cladogram_type;
+    final void setDefaultNodeShapeSize( final short default_node_shape_size ) {
+        _default_node_shape_size = default_node_shape_size;
     }
 
     final void setEditable( final boolean editable ) {
         _editable = editable;
     }
 
-    final void setExtractPfamTaxonomyCodesInNhParsing( final boolean nh_parsing_extract_pfam_taxonomy_codes ) {
-        _nh_parsing_extract_pfam_taxonomy_codes = nh_parsing_extract_pfam_taxonomy_codes;
-    }
-
     final void setGraphicsExportUsingActualSize( final boolean graphics_export_using_actual_size ) {
         _graphics_export_using_actual_size = graphics_export_using_actual_size;
         if ( !graphics_export_using_actual_size ) {
@@ -309,16 +338,12 @@ final public class Options {
         _min_confidence_value = min_confidence_value;
     }
 
-    final void setNodeLabelDirection( final NODE_LABEL_DIRECTION node_label_direction ) {
-        _node_label_direction = node_label_direction;
-    }
-
-    final private void setNumberOfDigitsAfterCommaForBranchLength( final short number_of_digits_after_comma_for_branch_length_values ) {
-        _number_of_digits_after_comma_for_branch_length_values = number_of_digits_after_comma_for_branch_length_values;
+    void setNhConversionSupportValueStyle( final NH_CONVERSION_SUPPORT_VALUE_STYLE nh_conversion_support_value_style ) {
+        _nh_conversion_support_value_style = nh_conversion_support_value_style;
     }
 
-    final private void setNumberOfDigitsAfterCommaForConfidenceValues( final short number_of_digits_after_comma_for_confidence_values ) {
-        _number_of_digits_after_comma_for_confidence_values = number_of_digits_after_comma_for_confidence_values;
+    final void setNodeLabelDirection( final NODE_LABEL_DIRECTION node_label_direction ) {
+        _node_label_direction = node_label_direction;
     }
 
     final void setOvPlacement( final OVERVIEW_PLACEMENT_TYPE ov_placement ) {
@@ -365,8 +390,16 @@ final public class Options {
         _show_branch_length_values = show_branch_length_values;
     }
 
-    final void setShowNodeBoxes( final boolean show_node_boxes ) {
-        _show_node_boxes = show_node_boxes;
+    void setShowConfidenceStddev( final boolean show_confidence_stddev ) {
+        _show_confidence_stddev = show_confidence_stddev;
+    }
+
+    void setShowDefaultNodeShapesExternal( final boolean show_default_node_shapes_external ) {
+        _show_default_node_shapes_external = show_default_node_shapes_external;
+    }
+
+    void setShowDefaultNodeShapesInternal( final boolean show_default_node_shapes_internal ) {
+        _show_default_node_shapes_internal = show_default_node_shapes_internal;
     }
 
     final void setShowOverview( final boolean show_overview ) {
@@ -377,11 +410,73 @@ final public class Options {
         _show_scale = show_scale;
     }
 
-    final static Options createDefaultInstance() {
-        return new Options();
+    void setTaxonomyColorizeNodeShapes( final boolean taxonomy_colorize_node_shapes ) {
+        _taxonomy_colorize_node_shapes = taxonomy_colorize_node_shapes;
     }
 
-    final static Options createInstance( final Configuration configuration ) {
+    final void setTaxonomyExtractio( final TAXONOMY_EXTRACTION taxonomy_extraction ) {
+        _taxonomy_extraction = taxonomy_extraction;
+    }
+
+    final private void init() {
+        _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;
+        _show_branch_length_values = false;
+        _internal_number_are_confidence_for_nh_parsing = false;
+        _show_scale = false;
+        _antialias_screen = true;
+        _antialias_print = true;
+        _graphics_export_visible_only = false;
+        _editable = true;
+        _background_color_gradient = false;
+        _show_default_node_shapes_internal = false;
+        _show_default_node_shapes_external = false;
+        if ( AptxUtil.isUsOrCanada() ) {
+            _print_size_x = Constants.US_LETTER_SIZE_X;
+            _print_size_y = Constants.US_LETTER_SIZE_Y;
+        }
+        else {
+            _print_size_x = Constants.A4_SIZE_X;
+            _print_size_y = Constants.A4_SIZE_Y;
+        }
+        _min_confidence_value = MIN_CONFIDENCE_DEFAULT;
+        _print_black_and_white = false;
+        _print_using_actual_size = false;
+        _graphics_export_using_actual_size = true;
+        _phylogeny_graphics_type = PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR;
+        _base_font = new Font( Configuration.getDefaultFontFamilyName(), Font.PLAIN, 10 );
+        _match_whole_terms_only = false;
+        _search_case_sensitive = false;
+        _print_line_width = Constants.PDF_LINE_WIDTH_DEFAULT;
+        _show_overview = true;
+        _ov_placement = OVERVIEW_PLACEMENT_TYPE.UPPER_LEFT;
+        _node_label_direction = NODE_LABEL_DIRECTION.HORIZONTAL;
+        _inverse_search_result = false;
+        _scale_bar_length = 0.0;
+        _number_of_digits_after_comma_for_branch_length_values = Constants.NUMBER_OF_DIGITS_AFTER_COMMA_FOR_BRANCH_LENGTH_VALUES_DEFAULT;
+        _number_of_digits_after_comma_for_confidence_values = Constants.NUMBER_OF_DIGITS_AFTER_COMMA_FOR_CONFIDENCE_VALUES_DEFAULT;
+        _nh_parsing_replace_underscores = false;
+        _taxonomy_extraction = TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT;
+        _cladogram_type = Constants.CLADOGRAM_TYPE_DEFAULT;
+        _show_domain_labels = true;
+        setAbbreviateScientificTaxonNames( false );
+        _color_labels_same_as_parent_branch = false;
+        _show_confidence_stddev = true;
+        _nh_conversion_support_value_style = NH_CONVERSION_SUPPORT_VALUE_STYLE.NONE;
+        _ext_desc_data_to_return = NODE_DATA.UNKNOWN;
+    }
+
+    final private void setNumberOfDigitsAfterCommaForBranchLength( final short number_of_digits_after_comma_for_branch_length_values ) {
+        _number_of_digits_after_comma_for_branch_length_values = number_of_digits_after_comma_for_branch_length_values;
+    }
+
+    final private void setNumberOfDigitsAfterCommaForConfidenceValues( final short number_of_digits_after_comma_for_confidence_values ) {
+        _number_of_digits_after_comma_for_confidence_values = number_of_digits_after_comma_for_confidence_values;
+    }
+
+    public final static Options createInstance( final Configuration configuration ) {
         final Options instance = createDefaultInstance();
         if ( configuration != null ) {
             instance.setAntialiasScreen( configuration.isAntialiasScreen() );
@@ -401,7 +496,7 @@ final public class Options {
                 instance.setNumberOfDigitsAfterCommaForConfidenceValues( configuration
                         .getNumberOfDigitsAfterCommaForConfidenceValues() );
             }
-            instance.setExtractPfamTaxonomyCodesInNhParsing( configuration.isExtractPfamTaxonomyCodesInNhParsing() );
+            instance.setTaxonomyExtractio( configuration.getTaxonomyExtraction() );
             instance.setReplaceUnderscoresInNhParsing( configuration.isReplaceUnderscoresInNhParsing() );
             instance.setInternalNumberAreConfidenceForNhParsing( configuration
                     .isInternalNumberAreConfidenceForNhParsing() );
@@ -428,26 +523,41 @@ final public class Options {
             if ( configuration.getPhylogenyGraphicsType() != null ) {
                 instance.setPhylogenyGraphicsType( configuration.getPhylogenyGraphicsType() );
             }
+            if ( configuration.getDefaultNodeFill() != null ) {
+                instance.setDefaultNodeFill( configuration.getDefaultNodeFill() );
+            }
+            if ( configuration.getDefaultNodeShape() != null ) {
+                instance.setDefaultNodeShape( configuration.getDefaultNodeShape() );
+            }
+            if ( configuration.getDefaultNodeShapeSize() >= 0 ) {
+                instance.setDefaultNodeShapeSize( configuration.getDefaultNodeShapeSize() );
+            }
+            instance.setTaxonomyColorizeNodeShapes( configuration.isTaxonomyColorizeNodeShapes() );
+            instance.setShowDefaultNodeShapesInternal( configuration.isShowDefaultNodeShapesInternal() );
+            instance.setShowDefaultNodeShapesExternal( configuration.isShowDefaultNodeShapesExternal() );
+            if ( configuration.getExtDescNodeDataToReturn() != null ) {
+                instance.setExtDescNodeDataToReturn( configuration.getExtDescNodeDataToReturn() );
+            }
         }
         return instance;
     }
 
-    final void setAbbreviateScientificTaxonNames( final boolean abbreviate_scientific_names ) {
-        _abbreviate_scientific_names = abbreviate_scientific_names;
-    }
-
-    final boolean isAbbreviateScientificTaxonNames() {
-        return _abbreviate_scientific_names;
+    final static Options createDefaultInstance() {
+        return new Options();
     }
 
-    static enum CLADOGRAM_TYPE {
+    public static enum CLADOGRAM_TYPE {
         NON_LINED_UP, EXT_NODE_SUM_DEP, TOTAL_NODE_SUM_DEP;
     }
 
-    static enum NODE_LABEL_DIRECTION {
+    public static enum NODE_LABEL_DIRECTION {
         HORIZONTAL, RADIAL;
     }
 
+    public static enum PHYLOGENY_GRAPHICS_TYPE {
+        RECTANGULAR, TRIANGULAR, EURO_STYLE, ROUNDED, CONVEX, CURVED, UNROOTED, CIRCULAR;
+    }
+
     static enum OVERVIEW_PLACEMENT_TYPE {
         UPPER_LEFT( "upper left" ),
         UPPER_RIGHT( "upper right" ),
@@ -470,12 +580,7 @@ final public class Options {
         }
     }
 
-    static enum PHYLOGENY_GRAPHICS_TYPE {
-        RECTANGULAR, TRIANGULAR, EURO_STYLE, ROUNDED, CONVEX, CURVED, UNROOTED, CIRCULAR;
-    }
-
-    boolean isAllowMagnificationOfTaxonomyImages() {
-        // TODO Auto-generated method stub
+    public boolean isAllowFontSizeChange() {
         return true;
     }
 }