changed order
[jalview.git] / forester / java / src / org / forester / archaeopteryx / Configuration.java
index d9a657d..ffc9104 100644 (file)
@@ -47,15 +47,21 @@ import org.forester.archaeopteryx.Options.CLADOGRAM_TYPE;
 import org.forester.archaeopteryx.Options.NODE_LABEL_DIRECTION;
 import org.forester.archaeopteryx.Options.OVERVIEW_PLACEMENT_TYPE;
 import org.forester.archaeopteryx.Options.PHYLOGENY_GRAPHICS_TYPE;
+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;
 
 public final class Configuration {
 
+    public enum UI {
+        NATIVE, CROSSPLATFORM, NIMBUS, UNKNOWN
+    }
     static final String                     VALIDATE_AGAINST_PHYLOXML_XSD_SCHEMA                   = "validate_against_phyloxml_xsd_schema";
     private static final String             WEB_LINK_KEY                                           = "web_link";
     private static final String             DISPLAY_COLOR_KEY                                      = "display_color";
     private static final int                DEPRECATED                                             = -2;
-    private TRIPLET                         _native_ui                                             = TRIPLET.FALSE;
+    private UI                              _ui                                                    = UI.UNKNOWN;
     private boolean                         _use_tabbed_display                                    = false;
     private boolean                         _hide_controls_and_menus                               = false;
     private CLADOGRAM_TYPE                  _cladogram_type                                        = Constants.CLADOGRAM_TYPE_DEFAULT;
@@ -88,6 +94,11 @@ public final class Configuration {
     private boolean                         _abbreviate_scientific_names                           = false;
     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.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;
     final static int                        display_as_phylogram                                   = 0;
     final static int                        show_node_names                                        = 1;
     final static int                        show_tax_code                                          = 2;
@@ -97,22 +108,23 @@ public final class Configuration {
     final static int                        color_according_to_species                             = 6;
     final static int                        color_branches                                         = 7;
     final static int                        width_branches                                         = 8;
-    final static int                        show_domain_architectures                              = 9;
-    final static int                        show_binary_characters                                 = 10;
-    final static int                        show_binary_character_counts                           = 11;
-    final static int                        show_gene_names                                        = 12;
-    final static int                        show_sequence_acc                                      = 13;
-    final static int                        display_internal_data                                  = 14;
-    final static int                        dynamically_hide_data                                  = 15;
-    final static int                        show_taxonomy_scientific_names                         = 16;
-    final static int                        show_taxonomy_common_names                             = 17;
-    final static int                        color_according_to_annotation                          = 18;
-    final static int                        show_property                                          = 19;
-    final static int                        show_gene_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                        show_taxonomy_images                                   = 24;
+    final static int                        show_custom_node_shapes                                = 9;
+    final static int                        show_domain_architectures                              = 10;
+    final static int                        show_binary_characters                                 = 11;
+    final static int                        show_binary_character_counts                           = 12;
+    final static int                        show_gene_names                                        = 13;
+    final static int                        show_sequence_acc                                      = 14;
+    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_property                                          = 20;
+    final static int                        show_gene_symbols                                      = 21;
+    final static int                        node_data_popup                                        = 22;
+    final static int                        show_relation_confidence                               = 23;
+    final static int                        show_vector_data                                       = 24;
+    final static int                        show_taxonomy_images                                   = 25;
     // ------------------
     // Click-to options
     // ------------------
@@ -144,15 +156,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" }, { "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-Widths", "display", "no" }, { "Show Custom Nodes", "display", "yes" },
+            { "Domains", "nodisplay", "no" }, { "Binary Characters", "nodisplay", "no" },
+            { "Binary Char Counts", "nodisplay", "no" }, { "Prot/Gene Name", "display", "yes" },
+            { "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", "yes" },
+            { "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" },
@@ -183,7 +195,6 @@ public final class Configuration {
     private static Hashtable<String, Color> _annotation_colors;
     boolean                                 verbose                                                = Constants.VERBOSE_DEFAULT;
     private NODE_LABEL_DIRECTION            _node_label_direction                                  = NODE_LABEL_DIRECTION.HORIZONTAL;
-    private TRIPLET                         _use_native_ui;
     private Color                           _gui_background_color                                  = Constants.GUI_BACKGROUND_DEFAULT;
     private Color                           _gui_checkbox_text_color                               = Constants.CHECKBOX_TEXT_COLOR_DEFAULT;
     private Color                           _gui_checkbox_and_button_active_color                  = Constants.CHECKBOX_AND_BUTTON_ACTIVE_COLOR_DEFAULT;
@@ -462,7 +473,7 @@ public final class Configuration {
         return _graphics_export_y;
     }
 
-    int getDefaultBootstrapSamples() {
+    public int getDefaultBootstrapSamples() {
         return _default_bootstrap_samples;
     }
 
@@ -583,18 +594,10 @@ public final class Configuration {
     }
 
     final boolean isUseNativeUI() {
-        if ( ( _use_native_ui == null ) || ( _use_native_ui == TRIPLET.UNKNOWN ) ) {
-            if ( ( _native_ui == TRIPLET.UNKNOWN ) && Util.isMac() && Util.isJava15() ) {
-                _use_native_ui = TRIPLET.TRUE;
-            }
-            else if ( _native_ui == TRIPLET.TRUE ) {
-                _use_native_ui = TRIPLET.TRUE;
-            }
-            else {
-                _use_native_ui = TRIPLET.FALSE;
-            }
+        if ( ( _ui == UI.UNKNOWN ) && Util.isMac() && Util.isJava15() ) {
+            _ui = UI.NATIVE;
         }
-        return _use_native_ui == TRIPLET.TRUE;
+        return _ui == UI.NATIVE;
     }
 
     /**
@@ -793,18 +796,18 @@ public final class Configuration {
         else if ( key.equals( "native_ui" ) ) {
             final String my_str = ( ( String ) st.nextElement() ).trim().toLowerCase();
             if ( my_str.equals( "yes" ) || my_str.equals( "true" ) ) {
-                _native_ui = TRIPLET.TRUE;
+                _ui = UI.NATIVE;
             }
             else if ( my_str.equals( "no" ) || my_str.equals( "false" ) ) {
-                _native_ui = TRIPLET.FALSE;
+                _ui = UI.CROSSPLATFORM;
             }
             else if ( my_str.equals( "?" ) ) {
-                _native_ui = TRIPLET.UNKNOWN;
+                _ui = UI.UNKNOWN;
             }
             else {
                 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "could not parse yes/no/? value from [" + my_str
                         + "]" );
-                _native_ui = TRIPLET.FALSE;
+                _ui = UI.UNKNOWN;
             }
         }
         else if ( key.equals( VALIDATE_AGAINST_PHYLOXML_XSD_SCHEMA ) ) {
@@ -1062,6 +1065,45 @@ 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() ) );
+        }
+        else if ( key.equals( "default_node_size" ) ) {
+            final short i = parseShort( ( ( String ) st.nextElement() ).trim() );
+            setDefaultNodeShapeSize( i );
+        }
+        else if ( key.equals( "default_node_fill" ) ) {
+            final String fill_str = ( ( String ) st.nextElement() ).trim();
+            if ( fill_str.equalsIgnoreCase( NodeVisualization.NodeFill.NONE.toString() ) ) {
+                setDefaultNodeFill( NodeFill.NONE );
+            }
+            else if ( fill_str.equalsIgnoreCase( NodeVisualization.NodeFill.GRADIENT.toString() ) ) {
+                setDefaultNodeFill( NodeFill.GRADIENT );
+            }
+            else if ( fill_str.equalsIgnoreCase( NodeVisualization.NodeFill.SOLID.toString() ) ) {
+                setDefaultNodeFill( NodeFill.SOLID );
+            }
+            else {
+                ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown value [" + fill_str
+                        + "] for [default_node_fill]" );
+            }
+        }
+        else if ( key.equals( "default_node_shape" ) ) {
+            final String shape_str = ( ( String ) st.nextElement() ).trim();
+            if ( shape_str.equalsIgnoreCase( NodeVisualization.NodeShape.CIRCLE.toString() ) ) {
+                setDefaultNodeShape( NodeShape.CIRCLE );
+            }
+            else if ( shape_str.equalsIgnoreCase( NodeVisualization.NodeShape.RECTANGLE.toString() ) ) {
+                setDefaultNodeShape( NodeShape.RECTANGLE );
+            }
+            else {
+                ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown value [" + shape_str
+                        + "] for [default_node_shape]" );
+            }
+        }
+        else if ( key.equals( "taxonomy_colorize_node_shapes" ) ) {
+            setTaxonomyColorizeNodeShapes( parseBoolean( ( String ) st.nextElement() ) );
+        }
         else if ( st.countTokens() >= 2 ) { // counts the tokens that are not
             // yet retrieved!
             int key_index = -1;
@@ -1192,6 +1234,9 @@ public final class Configuration {
             else if ( key.equals( "show_relation_confidence" ) ) {
                 key_index = Configuration.show_relation_confidence;
             }
+            else if ( key.equals( "show_custom_node_shapes" ) ) {
+                key_index = Configuration.show_custom_node_shapes;
+            }
             // If we've found the key, set the values
             if ( key_index >= 0 ) {
                 display_options[ key_index ][ 1 ] = ( String ) st.nextElement();
@@ -1343,4 +1388,44 @@ public final class Configuration {
     public boolean isAbbreviateScientificTaxonNames() {
         return _abbreviate_scientific_names;
     }
+
+    public NodeShape getDefaultNodeShape() {
+        return _default_node_shape;
+    }
+
+    private void setDefaultNodeShape( final NodeShape default_node_shape ) {
+        _default_node_shape = default_node_shape;
+    }
+
+    private void setDefaultNodeFill( final NodeFill default_node_fill ) {
+        _default_node_fill = default_node_fill;
+    }
+
+    public NodeFill getDefaultNodeFill() {
+        return _default_node_fill;
+    }
+
+    private void setDefaultNodeShapeSize( final short default_node_shape_size ) {
+        _default_node_shape_size = default_node_shape_size;
+    }
+
+    public short getDefaultNodeShapeSize() {
+        return _default_node_shape_size;
+    }
+
+    private void setTaxonomyColorizeNodeShapes( final boolean taxonomy_colorize_node_shapes ) {
+        _taxonomy_colorize_node_shapes = taxonomy_colorize_node_shapes;
+    }
+
+    public boolean isTaxonomyColorizeNodeShapes() {
+        return _taxonomy_colorize_node_shapes;
+    }
+
+    public boolean isShowDefaultNodeShapes() {
+        return _show_default_node_shapes;
+    }
+
+    private void setShowDefaultNodeShapes( final boolean show_default_node_shapes ) {
+        _show_default_node_shapes = show_default_node_shapes;
+    }
 }