in progress
[jalview.git] / forester / java / src / org / forester / archaeopteryx / Configuration.java
1 // $Id:
2 // FORESTER -- software libraries and applications
3 // for evolutionary biology research and applications.
4 //
5 // Copyright (C) 2008-2009 Christian M. Zmasek
6 // Copyright (C) 2008-2009 Burnham Institute for Medical Research
7 // Copyright (C) 2000-2001 Washington University School of Medicine
8 // and Howard Hughes Medical Institute
9 // Copyright (C) 2003-2007 Ethalinda K.S. Cannon
10 // All rights reserved
11 //
12 // This library is free software; you can redistribute it and/or
13 // modify it under the terms of the GNU Lesser General Public
14 // License as published by the Free Software Foundation; either
15 // version 2.1 of the License, or (at your option) any later version.
16 //
17 // This library is distributed in the hope that it will be useful,
18 // but WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 // Lesser General Public License for more details.
21 //
22 // You should have received a copy of the GNU Lesser General Public
23 // License along with this library; if not, write to the Free Software
24 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
25 //
26 // Contact: phylosoft @ gmail . com
27 // WWW: www.phylosoft.org/forester
28
29 package org.forester.archaeopteryx;
30
31 import java.awt.Color;
32 import java.io.BufferedReader;
33 import java.io.File;
34 import java.io.FileReader;
35 import java.io.IOException;
36 import java.io.InputStreamReader;
37 import java.net.MalformedURLException;
38 import java.net.URL;
39 import java.util.Arrays;
40 import java.util.Hashtable;
41 import java.util.Map;
42 import java.util.SortedMap;
43 import java.util.StringTokenizer;
44 import java.util.TreeMap;
45
46 import org.forester.archaeopteryx.Options.CLADOGRAM_TYPE;
47 import org.forester.archaeopteryx.Options.NODE_LABEL_DIRECTION;
48 import org.forester.archaeopteryx.Options.OVERVIEW_PLACEMENT_TYPE;
49 import org.forester.archaeopteryx.Options.PHYLOGENY_GRAPHICS_TYPE;
50 import org.forester.phylogeny.data.NodeVisualization;
51 import org.forester.phylogeny.data.NodeVisualization.NodeFill;
52 import org.forester.phylogeny.data.NodeVisualization.NodeShape;
53 import org.forester.util.ForesterUtil;
54
55 public final class Configuration {
56
57     static final String                     VALIDATE_AGAINST_PHYLOXML_XSD_SCHEMA                   = "validate_against_phyloxml_xsd_schema";
58     private static final String             WEB_LINK_KEY                                           = "web_link";
59     private static final String             DISPLAY_COLOR_KEY                                      = "display_color";
60     private static final int                DEPRECATED                                             = -2;
61     private UI                              _ui                                                    = UI.UNKNOWN;
62     private boolean                         _use_tabbed_display                                    = false;
63     private boolean                         _hide_controls_and_menus                               = false;
64     private CLADOGRAM_TYPE                  _cladogram_type                                        = Constants.CLADOGRAM_TYPE_DEFAULT;
65     private File                            _mafft                                                 = null;
66     private File                            _clustalo                                              = null;
67     private File                            _fastme                                                = null;
68     private SortedMap<String, WebLink>      _weblinks                                              = null;
69     private SortedMap<String, Color>        _display_colors                                        = null;
70     private boolean                         _antialias_screen                                      = true;
71     private PHYLOGENY_GRAPHICS_TYPE         _phylogeny_graphics_type                               = PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR;
72     private String                          _base_font_family_name                                 = "";
73     private int                             _base_font_size                                        = -1;
74     private int                             _graphics_export_x                                     = -1;
75     private int                             _graphics_export_y                                     = -1;
76     private short                           _ov_max_width                                          = 80;
77     private short                           _ov_max_height                                         = 80;
78     private OVERVIEW_PLACEMENT_TYPE         _ov_placement                                          = OVERVIEW_PLACEMENT_TYPE.UPPER_LEFT;
79     private double                          _min_confidence_value                                  = Options.MIN_CONFIDENCE_DEFAULT;
80     private float                           _print_line_width                                      = Constants.PDF_LINE_WIDTH_DEFAULT;
81     private boolean                         _show_scale                                            = false;
82     private boolean                         _show_branch_length_values                             = false;
83     private boolean                         _show_overview                                         = true;
84     private short                           _number_of_digits_after_comma_for_confidence_values    = Constants.NUMBER_OF_DIGITS_AFTER_COMMA_FOR_CONFIDENCE_VALUES_DEFAULT;
85     private short                           _number_of_digits_after_comma_for_branch_length_values = Constants.NUMBER_OF_DIGITS_AFTER_COMMA_FOR_BRANCH_LENGTH_VALUES_DEFAULT;
86     private boolean                         _editable                                              = true;
87     private boolean                         _nh_parsing_replace_underscores                        = false;
88     private boolean                         _nh_parsing_extract_pfam_taxonomy_codes                = false;
89     private boolean                         _internal_number_are_confidence_for_nh_parsing         = false;
90     private boolean                         _display_sequence_relations                            = false;
91     private boolean                         _validate_against_phyloxml_xsd_schema                  = Constants.VALIDATE_AGAINST_PHYLOXML_XSD_SCJEMA_DEFAULT;
92     private boolean                         _background_color_gradient                             = false;
93     private boolean                         _show_domain_labels                                    = true;
94     private boolean                         _abbreviate_scientific_names                           = false;
95     private boolean                         _color_labels_same_as_parent_branch                    = false;
96     private int                             _default_bootstrap_samples                             = -1;
97     private boolean                         _show_default_node_shapes                              = false;
98     private NodeShape                       _default_node_shape                                    = NodeShape.CIRCLE;
99     private NodeFill                        _default_node_fill                                     = NodeFill.GRADIENT;
100     private short                           _default_node_shape_size                               = Constants.DEFAULT_NODE_SHAPE_SIZE_DEFAULT;
101     private boolean                         _taxonomy_colorize_node_shapes                         = false;
102     final static int                        display_as_phylogram                                   = 0;
103     final static int                        show_node_names                                        = 1;
104     final static int                        show_tax_code                                          = 2;
105     final static int                        show_annotation                                        = 3;
106     final static int                        write_confidence_values                                = 4;
107     final static int                        write_events                                           = 5;
108     final static int                        color_according_to_species                             = 6;
109     final static int                        color_branches                                         = 7;
110     final static int                        width_branches                                         = 8;
111     final static int                        show_custom_node_shapes                                = 9;
112     final static int                        show_domain_architectures                              = 10;
113     final static int                        show_binary_characters                                 = 11;
114     final static int                        show_binary_character_counts                           = 12;
115     final static int                        show_gene_names                                        = 13;
116     final static int                        show_sequence_acc                                      = 14;
117     final static int                        display_internal_data                                  = 15;
118     final static int                        dynamically_hide_data                                  = 16;
119     final static int                        show_taxonomy_scientific_names                         = 17;
120     final static int                        show_taxonomy_common_names                             = 18;
121     final static int                        color_according_to_annotation                          = 19;
122     final static int                        show_gene_symbols                                      = 20;
123     final static int                        node_data_popup                                        = 21;
124     final static int                        show_relation_confidence                               = 22;
125     final static int                        show_vector_data                                       = 23;
126     final static int                        show_taxonomy_images                                   = 24;
127     final static int                        show_properties                                        = 25;
128     // ------------------
129     // Click-to options
130     // ------------------
131     final static int                        display_node_data                                      = 0;
132     final static int                        collapse_uncollapse                                    = 1;
133     final static int                        reroot                                                 = 2;
134     final static int                        subtree                                                = 3;
135     final static int                        swap                                                   = 4;
136     final static int                        color_subtree                                          = 5;
137     final static int                        open_seq_web                                           = 6;
138     final static int                        open_tax_web                                           = 7;
139     final static int                        blast                                                  = 8;
140     final static int                        cut_subtree                                            = 9;
141     final static int                        copy_subtree                                           = 10;
142     final static int                        paste_subtree                                          = 11;
143     final static int                        delete_subtree_or_node                                 = 12;
144     final static int                        add_new_node                                           = 13;
145     final static int                        edit_node_data                                         = 14;
146     final static int                        sort_descendents                                       = 15;
147     // ---------------------------
148     // Display options for trees
149     // ---------------------------
150     // ---------------------------------
151     // Pertaining to the config itself
152     // ---------------------------------
153     // Full path to config (may be URL)
154     String                                  config_filename;
155     String                                  default_config_filename                                = Constants.DEFAULT_CONFIGURATION_FILE_NAME;
156     final static String                     display_options[][]                                    = {
157             { "Phylogram", "display", "?" }, { "Node Name", "display", "yes" }, { "Taxonomy Code", "display", "yes" },
158             { "Annotation", "nodisplay", "no" }, { "Confidence Values", "display", "?" }, { "Event", "display", "?" },
159             { "Taxonomy Colorize", "display", "no" }, { "Colorize Branches", "display", "no" },
160             { "Use Branch-Widths", "display", "no" }, { "Show Custom Nodes", "display", "yes" },
161             { "Domains", "nodisplay", "no" }, { "Binary Characters", "nodisplay", "no" },
162             { "Binary Char Counts", "nodisplay", "no" }, { "Prot/Gene Name", "display", "yes" },
163             { "Prot/Gene Acc", "display", "no" }, { "Show Internal Data", "display", "yes" },
164             { "Dyna Hide", "display", "yes" }, { "Taxonomy Scientific", "display", "yes" },
165             { "Taxonomy Common", "display", "no" }, { "Annotation Colorize", "nodisplay", "no" },
166             { "Prot/Gene Symbol", "display", "yes" }, { "Rollover", "display", "yes" },
167             { "Relation Confidence", "display", "no" }, { "Vector Data", "display", "no" },
168             { "Taxonomy Images", "display", "no" }, { "Properties", "display", "no" }             };
169     final static String                     clickto_options[][]                                    = {
170             { "Display Node Data", "display" }, { "Collapse/Uncollapse", "display" }, { "Root/Reroot", "display" },
171             { "Sub/Super Tree", "display" }, { "Swap Descendants", "display" }, { "Colorize Subtree", "display" },
172             { "Open Sequence Web", "display" }, { "Open Taxonomy Web", "display" }, { "Blast", "display" },
173             { "Cut Subtree", "display" }, { "Copy Subtree", "display" }, { "Paste Subtree", "display" },
174             { "Delete Subtree/Node", "display" }, { "Add New Node", "display" }, { "Edit Node Data", "display" },
175             { "Sort Descendants", "display" }                                                     };
176     // This option is selected in the dropdown
177     int                                     default_clickto                                        = Configuration.display_node_data;
178     // --------------
179     // Color set
180     // --------------
181     TreeColorSet                            tree_color_set;
182     // -------
183     // Fonts
184     // -------
185     TreeFontSet                             tree_font_set;
186     // ----------------
187     // Species colors
188     // ----------------
189     private static Hashtable<String, Color> _species_colors;
190     // ----------------
191     // Domain colors
192     // ----------------
193     private static Hashtable<String, Color> _domain_colors;
194     // ----------------
195     // Function colors
196     // ----------------
197     private static Hashtable<String, Color> _annotation_colors;
198     boolean                                 verbose                                                = Constants.VERBOSE_DEFAULT;
199     private NODE_LABEL_DIRECTION            _node_label_direction                                  = NODE_LABEL_DIRECTION.HORIZONTAL;
200     private Color                           _gui_background_color                                  = Constants.GUI_BACKGROUND_DEFAULT;
201     private Color                           _gui_checkbox_text_color                               = Constants.CHECKBOX_TEXT_COLOR_DEFAULT;
202     private Color                           _gui_checkbox_and_button_active_color                  = Constants.CHECKBOX_AND_BUTTON_ACTIVE_COLOR_DEFAULT;
203     private Color                           _gui_button_text_color                                 = Constants.BUTTON_TEXT_COLOR_DEFAULT;
204     private Color                           _gui_button_background_color                           = Constants.BUTTON_BACKGROUND_COLOR_DEFAULT;
205     private Color                           _gui_menu_background_color                             = Constants.MENU_BACKGROUND_COLOR_DEFAULT;
206     private Color                           _gui_menu_text_color                                   = Constants.MENU_TEXT_COLOR_DEFAULT;
207     private Color                           _gui_button_border_color                               = Constants.BUTTON_BORDER_COLOR_DEFAULT;
208     private Color                           _domain_structure_font_color                           = Constants.DOMAIN_STRUCTURE_FONT_COLOR_DEFAULT;
209     private Color                           _domain_structure_base_color                           = Constants.DOMAIN_STRUCTURE_BASE_COLOR_DEFAULT;
210     private static String                   DEFAULT_FONT_FAMILY                                    = "";
211     static {
212         for( final String font_name : Constants.DEFAULT_FONT_CHOICES ) {
213             if ( Arrays.binarySearch( AptxUtil.getAvailableFontFamiliesSorted(), font_name ) >= 0 ) {
214                 DEFAULT_FONT_FAMILY = font_name;
215                 break;
216             }
217         }
218         if ( ForesterUtil.isEmpty( DEFAULT_FONT_FAMILY ) ) {
219             DEFAULT_FONT_FAMILY = Constants.DEFAULT_FONT_CHOICES[ Constants.DEFAULT_FONT_CHOICES.length - 1 ];
220         }
221     }
222
223     public Configuration() {
224         this( null, false, false, false );
225     }
226
227     public Configuration( final String cf, final boolean is_url, final boolean is_applet, final boolean verbose ) {
228         if ( ForesterUtil.isEmpty( cf ) ) {
229             config_filename = default_config_filename;
230         }
231         else {
232             config_filename = cf;
233         }
234         setWebLinks( new TreeMap<String, WebLink>() );
235         setDisplayColors( new TreeMap<String, Color>() );
236         config_filename = config_filename.trim();
237         URL u = null;
238         if ( is_url ) {
239             // If URL, open accordingly
240             try {
241                 u = new URL( config_filename );
242                 try {
243                     final InputStreamReader isr = new InputStreamReader( u.openStream() );
244                     final BufferedReader bf = new BufferedReader( isr );
245                     readConfig( bf );
246                     bf.close();
247                     ForesterUtil.programMessage( Constants.PRG_NAME, "successfully read from configuration url ["
248                             + config_filename + "]" );
249                 }
250                 catch ( final Exception e ) {
251                     ForesterUtil.printWarningMessage( Constants.PRG_NAME, "failed to read configuration from ["
252                             + config_filename + "]: " + e.getLocalizedMessage() );
253                 }
254             }
255             catch ( final Exception e ) {
256                 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "cannot find or open configuration url ["
257                         + config_filename + "]" );
258             }
259         }
260         else {
261             // Otherwise, open as a file
262             File f = new File( config_filename );
263             if ( !f.exists() ) {
264                 f = new File( config_filename + ".txt" );
265             }
266             if ( f.exists() && f.canRead() ) {
267                 try {
268                     final BufferedReader bf = new BufferedReader( new FileReader( f ) );
269                     readConfig( bf );
270                     bf.close();
271                 }
272                 catch ( final Exception e ) {
273                     if ( verbose ) {
274                         ForesterUtil.printWarningMessage( Constants.PRG_NAME, "failed to read configuration from ["
275                                 + config_filename + "]: " + e );
276                     }
277                 }
278             }
279             else {
280                 if ( verbose ) {
281                     ForesterUtil.printWarningMessage( Constants.PRG_NAME, "cannot find or open configuration file ["
282                             + config_filename + "]" );
283                 }
284             }
285         }
286     }
287
288     private void createWebLink( final String url_str, final String desc, final String source_identifier ) {
289         WebLink weblink = null;
290         boolean ex = false;
291         try {
292             weblink = new WebLink( new URL( url_str.trim() ), desc.trim(), source_identifier.trim() );
293         }
294         catch ( final MalformedURLException e ) {
295             ForesterUtil.printWarningMessage( Constants.PRG_NAME, "could not create URL from [" + url_str + "]" );
296             ex = true;
297         }
298         if ( !ex && ( weblink != null ) ) {
299             getWebLinks().put( weblink.getSourceIdentifier().toLowerCase(), weblink );
300         }
301     }
302
303     boolean displaySequenceRelations() {
304         return _display_sequence_relations;
305     }
306
307     boolean doCheckOption( final int which ) {
308         return ( display_options[ which ][ 2 ].equalsIgnoreCase( "yes" ) )
309                 || ( display_options[ which ][ 2 ].equalsIgnoreCase( "true" ) );
310     }
311
312     boolean doDisplayClickToOption( final int which ) {
313         return clickto_options[ which ][ 1 ].equalsIgnoreCase( "display" );
314     }
315
316     boolean doDisplayOption( final int which ) {
317         return display_options[ which ][ 1 ].equalsIgnoreCase( "display" );
318     }
319
320     /**
321      * Will attempt to use the phylogeny to determine whether to check
322      * this or not (e.g. phylogram)
323      * 
324      */
325     boolean doGuessCheckOption( final int which ) {
326         return display_options[ which ][ 2 ].equals( "?" );
327     }
328
329     Map<String, Color> getAnnotationColors() {
330         if ( _annotation_colors == null ) {
331             _annotation_colors = new Hashtable<String, Color>();
332         }
333         return _annotation_colors;
334     }
335
336     public String getBaseFontFamilyName() {
337         return _base_font_family_name;
338     }
339
340     int getBaseFontSize() {
341         return _base_font_size;
342     }
343
344     CLADOGRAM_TYPE getCladogramType() {
345         return _cladogram_type;
346     }
347
348     private int getClickToIndex( final String name ) {
349         int index = -1;
350         if ( name.equals( "edit_info" ) ) {
351             index = Configuration.display_node_data;
352             ForesterUtil
353                     .printWarningMessage( Constants.PRG_NAME,
354                                           "configuration key [edit_info] is deprecated, use [display node data] instead" );
355         }
356         else if ( name.equals( "display_node_data" ) ) {
357             index = Configuration.display_node_data;
358         }
359         else if ( name.equals( "collapse_uncollapse" ) ) {
360             index = Configuration.collapse_uncollapse;
361         }
362         else if ( name.equals( "reroot" ) ) {
363             index = Configuration.reroot;
364         }
365         else if ( name.equals( "subtree" ) ) {
366             index = Configuration.subtree;
367         }
368         else if ( name.equals( "swap" ) ) {
369             index = Configuration.swap;
370         }
371         else if ( name.equals( "sort_descendants" ) ) {
372             index = Configuration.sort_descendents;
373         }
374         else if ( name.equals( "display_sequences" ) ) {
375             ForesterUtil
376                     .printWarningMessage( Constants.PRG_NAME, "configuration key [display_sequences] is deprecated" );
377             return DEPRECATED;
378         }
379         else if ( name.equals( "open_seq_web" ) ) {
380             index = Configuration.open_seq_web;
381         }
382         else if ( name.equals( "open_tax_web" ) ) {
383             index = Configuration.open_tax_web;
384         }
385         else if ( name.equals( "blast" ) ) {
386             index = Configuration.blast;
387         }
388         else if ( name.equals( "cut_subtree" ) ) {
389             index = Configuration.cut_subtree;
390         }
391         else if ( name.equals( "copy_subtree" ) ) {
392             index = Configuration.copy_subtree;
393         }
394         else if ( name.equals( "paste_subtree" ) ) {
395             index = Configuration.paste_subtree;
396         }
397         else if ( name.equals( "delete" ) ) {
398             index = Configuration.delete_subtree_or_node;
399         }
400         else if ( name.equals( "add_new_node" ) ) {
401             index = Configuration.add_new_node;
402         }
403         else if ( name.equals( "edit_node_data" ) ) {
404             index = Configuration.edit_node_data;
405         }
406         else if ( name.equals( "display_node_popup" ) ) {
407             ForesterUtil.printWarningMessage( Constants.PRG_NAME,
408                                               "configuration key [display_node_popup] is deprecated" );
409             return DEPRECATED;
410         }
411         else if ( name.equals( "custom_option" ) ) {
412             ForesterUtil.printWarningMessage( Constants.PRG_NAME, "configuration key [custom_option] is deprecated" );
413             return DEPRECATED;
414         }
415         else if ( name.equals( "color_subtree" ) ) {
416             index = Configuration.color_subtree;
417         }
418         else if ( name.equals( "go_to_swiss_prot" ) ) {
419             ForesterUtil.printWarningMessage( Constants.PRG_NAME, "configuration key [go_to_swiss_prot] is deprecated" );
420             return DEPRECATED;
421         }
422         return index;
423     }
424
425     int getClickToOptionsCount() {
426         return clickto_options.length;
427     }
428
429     String getClickToTitle( final int which ) {
430         return clickto_options[ which ][ 0 ];
431     }
432
433     public int getDefaultBootstrapSamples() {
434         return _default_bootstrap_samples;
435     }
436
437     int getDefaultDisplayClicktoOption() {
438         return default_clickto;
439     }
440
441     public NodeFill getDefaultNodeFill() {
442         return _default_node_fill;
443     }
444
445     public NodeShape getDefaultNodeShape() {
446         return _default_node_shape;
447     }
448
449     public short getDefaultNodeShapeSize() {
450         return _default_node_shape_size;
451     }
452
453     SortedMap<String, Color> getDisplayColors() {
454         return _display_colors;
455     }
456
457     String getDisplayTitle( final int which ) {
458         return display_options[ which ][ 0 ];
459     }
460
461     Map<String, Color> getDomainColors() {
462         if ( _domain_colors == null ) {
463             _domain_colors = new Hashtable<String, Color>();
464         }
465         return _domain_colors;
466     }
467
468     public Color getDomainStructureBaseColor() {
469         return _domain_structure_base_color;
470     }
471
472     public Color getDomainStructureFontColor() {
473         return _domain_structure_font_color;
474     }
475
476     int getGraphicsExportX() {
477         return _graphics_export_x;
478     }
479
480     int getGraphicsExportY() {
481         return _graphics_export_y;
482     }
483
484     Color getGuiBackgroundColor() {
485         return _gui_background_color;
486     }
487
488     Color getGuiButtonBackgroundColor() {
489         return _gui_button_background_color;
490     }
491
492     Color getGuiButtonBorderColor() {
493         return _gui_button_border_color;
494     }
495
496     Color getGuiButtonTextColor() {
497         return _gui_button_text_color;
498     }
499
500     Color getGuiCheckboxAndButtonActiveColor() {
501         return _gui_checkbox_and_button_active_color;
502     }
503
504     Color getGuiCheckboxTextColor() {
505         return _gui_checkbox_text_color;
506     }
507
508     Color getGuiMenuBackgroundColor() {
509         return _gui_menu_background_color;
510     }
511
512     Color getGuiMenuTextColor() {
513         return _gui_menu_text_color;
514     }
515
516     double getMinConfidenceValue() {
517         return _min_confidence_value;
518     }
519
520     NODE_LABEL_DIRECTION getNodeLabelDirection() {
521         return _node_label_direction;
522     }
523
524     short getNumberOfDigitsAfterCommaForBranchLengthValues() {
525         return _number_of_digits_after_comma_for_branch_length_values;
526     }
527
528     short getNumberOfDigitsAfterCommaForConfidenceValues() {
529         return _number_of_digits_after_comma_for_confidence_values;
530     }
531
532     short getOvMaxHeight() {
533         return _ov_max_height;
534     }
535
536     short getOvMaxWidth() {
537         return _ov_max_width;
538     }
539
540     OVERVIEW_PLACEMENT_TYPE getOvPlacement() {
541         return _ov_placement;
542     }
543
544     PHYLOGENY_GRAPHICS_TYPE getPhylogenyGraphicsType() {
545         return _phylogeny_graphics_type;
546     }
547
548     float getPrintLineWidth() {
549         return _print_line_width;
550     }
551
552     Hashtable<String, Color> getSpeciesColors() {
553         if ( _species_colors == null ) {
554             _species_colors = new Hashtable<String, Color>();
555         }
556         return _species_colors;
557     }
558
559     TreeColorSet getTreeColorSet() {
560         return null;
561     }
562
563     TreeFontSet getTreeFontSet() {
564         return null;
565     }
566
567     WebLink getWebLink( final String source ) {
568         return getWebLinks().get( source );
569     }
570
571     Map<String, WebLink> getWebLinks() {
572         return _weblinks;
573     }
574
575     public boolean isAbbreviateScientificTaxonNames() {
576         return _abbreviate_scientific_names;
577     }
578
579     boolean isAntialiasScreen() {
580         return _antialias_screen;
581     }
582
583     public boolean isBackgroundColorGradient() {
584         return _background_color_gradient;
585     }
586
587     public boolean isColorLabelsSameAsParentBranch() {
588         return _color_labels_same_as_parent_branch;
589     }
590
591     /**
592      * Convenience method.
593      * 
594      * @return true if value in configuration file was 'yes'
595      */
596     boolean isDrawAsPhylogram() {
597         return doCheckOption( display_as_phylogram );
598     }
599
600     boolean isEditable() {
601         return _editable;
602     }
603
604     boolean isExtractPfamTaxonomyCodesInNhParsing() {
605         return _nh_parsing_extract_pfam_taxonomy_codes;
606     }
607
608     boolean isHasWebLink( final String source ) {
609         return getWebLinks().containsKey( source );
610     }
611
612     /**
613      * Only used by ArchaeoptryxE.
614      *
615      */
616     boolean isHideControlPanelAndMenubar() {
617         return _hide_controls_and_menus;
618     }
619
620     boolean isInternalNumberAreConfidenceForNhParsing() {
621         return _internal_number_are_confidence_for_nh_parsing;
622     }
623
624     boolean isReplaceUnderscoresInNhParsing() {
625         return _nh_parsing_replace_underscores;
626     }
627
628     boolean isShowBranchLengthValues() {
629         return _show_branch_length_values;
630     }
631
632     public boolean isShowDefaultNodeShapes() {
633         return _show_default_node_shapes;
634     }
635
636     public boolean isShowDomainLabels() {
637         return _show_domain_labels;
638     }
639
640     boolean isShowOverview() {
641         return _show_overview;
642     }
643
644     boolean isShowScale() {
645         return _show_scale;
646     }
647
648     public boolean isTaxonomyColorizeNodeShapes() {
649         return _taxonomy_colorize_node_shapes;
650     }
651
652     final boolean isUseNativeUI() {
653         if ( ( _ui == UI.UNKNOWN ) && AptxUtil.isMac() && AptxUtil.isJava15() ) {
654             _ui = UI.NATIVE;
655         }
656         return _ui == UI.NATIVE;
657     }
658
659     /**
660      * Only used by ArchaeoptryxE.
661      *
662      */
663     boolean isUseTabbedDisplay() {
664         return _use_tabbed_display;
665     }
666
667     boolean isValidatePhyloXmlAgainstSchema() {
668         return _validate_against_phyloxml_xsd_schema;
669     }
670
671     private boolean parseBoolean( final String str ) {
672         final String my_str = str.trim().toLowerCase();
673         if ( my_str.equals( "yes" ) || my_str.equals( "true" ) ) {
674             return true;
675         }
676         else if ( my_str.equals( "no" ) || my_str.equals( "false" ) ) {
677             return false;
678         }
679         else {
680             ForesterUtil.printWarningMessage( Constants.PRG_NAME, "could not parse boolean value from [" + str + "]" );
681             return false;
682         }
683     }
684
685     private double parseDouble( final String str ) {
686         double d = 0.0;
687         try {
688             d = Double.parseDouble( str );
689         }
690         catch ( final Exception e ) {
691             ForesterUtil.printWarningMessage( Constants.PRG_NAME, "could not parse double from [" + str + "]" );
692             d = 0.0;
693         }
694         return d;
695     }
696
697     private float parseFloat( final String str ) {
698         float f = 0.0f;
699         try {
700             f = Float.parseFloat( str );
701         }
702         catch ( final Exception e ) {
703             ForesterUtil.printWarningMessage( Constants.PRG_NAME, "could not parse float from [" + str + "]" );
704             f = 0.0f;
705         }
706         return f;
707     }
708
709     private int parseInt( final String str ) {
710         int i = -1;
711         try {
712             i = Integer.parseInt( str );
713         }
714         catch ( final Exception e ) {
715             ForesterUtil.printWarningMessage( Constants.PRG_NAME, "could not parse integer from [" + str + "]" );
716             i = -1;
717         }
718         return i;
719     }
720
721     private short parseShort( final String str ) {
722         short i = -1;
723         try {
724             i = Short.parseShort( str );
725         }
726         catch ( final Exception e ) {
727             ForesterUtil.printWarningMessage( Constants.PRG_NAME, "could not parse short from [" + str + "]" );
728             i = -1;
729         }
730         return i;
731     }
732
733     private void processFontFamily( final StringTokenizer st ) {
734         setBaseFontFamilyName( "" );
735         final String font_str = ( ( String ) st.nextElement() ).trim();
736         final String[] fonts = font_str.split( ",+" );
737         for( String font : fonts ) {
738             font = font.replace( '_', ' ' ).trim();
739             if ( Arrays.binarySearch( AptxUtil.getAvailableFontFamiliesSorted(), font ) >= 0 ) {
740                 setBaseFontFamilyName( font );
741                 break;
742             }
743         }
744     }
745
746     public void putDisplayColors( final String key, final Color color ) {
747         getDisplayColors().put( key, color );
748     }
749
750     /**
751      * read each line of config file, process non-comment lines
752      * @throws IOException 
753      */
754     private void readConfig( final BufferedReader conf_in ) throws IOException {
755         String line;
756         do {
757             line = conf_in.readLine();
758             if ( line != null ) {
759                 line = line.trim();
760                 // skip comments and blank lines
761                 if ( !line.startsWith( "#" ) && ( !ForesterUtil.isEmpty( line ) ) ) {
762                     // convert runs of spaces to tabs
763                     line = line.replaceAll( "\\s+", "\t" );
764                     final StringTokenizer st = new StringTokenizer( line, "\t" );
765                     setKeyValue( st );
766                 }
767             }
768         } while ( line != null );
769     }
770
771     public void setAbbreviateScientificTaxonNames( final boolean abbreviate_scientific_names ) {
772         _abbreviate_scientific_names = abbreviate_scientific_names;
773     }
774
775     private void setAntialiasScreen( final boolean antialias_screen ) {
776         _antialias_screen = antialias_screen;
777     }
778
779     public void setBackgroundColorGradient( final boolean background_color_gradient ) {
780         _background_color_gradient = background_color_gradient;
781     }
782
783     public void setBaseFontFamilyName( final String base_font_family_name ) {
784         _base_font_family_name = base_font_family_name;
785     }
786
787     public void setBaseFontSize( final int base_font_size ) {
788         _base_font_size = base_font_size;
789     }
790
791     private void setCladogramType( final CLADOGRAM_TYPE cladogram_type ) {
792         _cladogram_type = cladogram_type;
793     }
794
795     public void setColorizeBranches( final boolean b ) {
796         display_options[ color_branches ][ 2 ] = b ? "yes" : "no";
797     }
798
799     public void setColorLabelsSameAsParentBranch( final boolean color_labels_same_as_parent_branch ) {
800         _color_labels_same_as_parent_branch = color_labels_same_as_parent_branch;
801     }
802
803     private void setDefaultBootstrapSamples( final int default_bootstrap_samples ) {
804         _default_bootstrap_samples = default_bootstrap_samples;
805     }
806
807     public void setDefaultNodeFill( final NodeFill default_node_fill ) {
808         _default_node_fill = default_node_fill;
809     }
810
811     public void setDefaultNodeShape( final NodeShape default_node_shape ) {
812         _default_node_shape = default_node_shape;
813     }
814
815     public void setDefaultNodeShapeSize( final short default_node_shape_size ) {
816         _default_node_shape_size = default_node_shape_size;
817     }
818
819     public void setDisplayAsPhylogram( final boolean b ) {
820         display_options[ display_as_phylogram ][ 2 ] = b ? "yes" : "no";
821     }
822
823     public void setDisplayColors( final SortedMap<String, Color> display_colors ) {
824         _display_colors = display_colors;
825     }
826
827     public void setDisplayConfidenceValues( final boolean b ) {
828         display_options[ write_confidence_values ][ 2 ] = b ? "yes" : "no";
829     }
830
831     public void setDisplayInternalData( final boolean b ) {
832         display_options[ display_internal_data ][ 2 ] = b ? "yes" : "no";
833     }
834
835     public void setDisplayNodeNames( final boolean b ) {
836         display_options[ show_node_names ][ 2 ] = b ? "yes" : "no";
837     }
838
839     public void setDisplaySequenceAcc( final boolean b ) {
840         display_options[ show_sequence_acc ][ 2 ] = b ? "yes" : "no";
841     }
842
843     public void setDisplaySequenceNames( final boolean b ) {
844         display_options[ show_gene_names ][ 2 ] = b ? "yes" : "no";
845     }
846
847     public void setDisplaySequenceRelations( final boolean display_sequence_relations ) {
848         _display_sequence_relations = display_sequence_relations;
849     }
850
851     public void setDisplaySequenceSymbols( final boolean b ) {
852         display_options[ show_gene_symbols ][ 2 ] = b ? "yes" : "no";
853     }
854
855     public void setDisplayTaxonomyCode( final boolean b ) {
856         display_options[ show_tax_code ][ 2 ] = b ? "yes" : "no";
857     }
858
859     public void setDisplayTaxonomyCommonNames( final boolean b ) {
860         display_options[ show_taxonomy_common_names ][ 2 ] = b ? "yes" : "no";
861     }
862
863     public void setDisplayTaxonomyImages( final boolean b ) {
864         display_options[ show_taxonomy_images ][ 2 ] = b ? "yes" : "no";
865     }
866
867     public void setDisplayTaxonomyScientificNames( final boolean b ) {
868         display_options[ show_taxonomy_scientific_names ][ 2 ] = b ? "yes" : "no";
869     }
870
871     public void setDynamicallyHideData( final boolean b ) {
872         display_options[ dynamically_hide_data ][ 2 ] = b ? "yes" : "no";
873     }
874
875     private void setEditable( final boolean editable ) {
876         _editable = editable;
877     }
878
879     public void setExtractPfamTaxonomyCodesInNhParsing( final boolean nh_parsing_extract_pfam_taxonomy_codes ) {
880         _nh_parsing_extract_pfam_taxonomy_codes = nh_parsing_extract_pfam_taxonomy_codes;
881     }
882
883     private void setGraphicsExportX( final int graphics_export_x ) {
884         _graphics_export_x = graphics_export_x;
885     }
886
887     private void setGraphicsExportY( final int graphics_export_y ) {
888         _graphics_export_y = graphics_export_y;
889     }
890
891     private void setInternalNumberAreConfidenceForNhParsing( final boolean internal_number_are_confidence_for_nh_parsing ) {
892         _internal_number_are_confidence_for_nh_parsing = internal_number_are_confidence_for_nh_parsing;
893     }
894
895     /**
896      * Set a key-value(s) tuple
897      */
898     private void setKeyValue( final StringTokenizer st ) {
899         String key = ( String ) st.nextElement();
900         key = key.replace( ':', ' ' );
901         key = key.trim();
902         key = key.toLowerCase();
903         // Handle single value settings first:
904         if ( key.equals( "default_click_to" ) ) {
905             final String clickto_name = ( String ) st.nextElement();
906             default_clickto = getClickToIndex( clickto_name );
907             if ( default_clickto == -1 ) {
908                 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "invalid value [" + clickto_name
909                         + "] for [default_click_to]" );
910                 default_clickto = 0;
911             }
912             else if ( default_clickto == DEPRECATED ) {
913                 // Deprecated.
914             }
915         }
916         else if ( key.equals( "native_ui" ) ) {
917             final String my_str = ( ( String ) st.nextElement() ).trim().toLowerCase();
918             if ( my_str.equals( "yes" ) || my_str.equals( "true" ) ) {
919                 _ui = UI.NATIVE;
920             }
921             else if ( my_str.equals( "no" ) || my_str.equals( "false" ) ) {
922                 _ui = UI.CROSSPLATFORM;
923             }
924             else if ( my_str.equals( "?" ) ) {
925                 _ui = UI.UNKNOWN;
926             }
927             else {
928                 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "could not parse yes/no/? value from [" + my_str
929                         + "]" );
930                 _ui = UI.UNKNOWN;
931             }
932         }
933         else if ( key.equals( "path_to_mafft" ) ) {
934             setPathToMafft( new File( ( String ) st.nextElement() ) );
935         }
936         else if ( key.equals( "path_to_clustalo" ) ) {
937             setPathToClustalOmega( new File( ( String ) st.nextElement() ) );
938         }
939         else if ( key.equals( "path_to_fastme" ) ) {
940             setPathToFastME( new File( ( String ) st.nextElement() ) );
941         }
942         else if ( key.equals( "path_to_mafft" ) ) {
943             setPathToMafft( new File( ( String ) st.nextElement() ) );
944         }
945         else if ( key.equals( VALIDATE_AGAINST_PHYLOXML_XSD_SCHEMA ) ) {
946             setValidatePhyloXmlAgainstSchema( parseBoolean( ( String ) st.nextElement() ) );
947         }
948         else if ( key.equals( "antialias_screen" ) ) {
949             setAntialiasScreen( parseBoolean( ( String ) st.nextElement() ) );
950         }
951         else if ( key.equals( "phylogeny_graphics_type" ) ) {
952             final String type_str = ( ( String ) st.nextElement() ).trim();
953             if ( type_str.equalsIgnoreCase( PHYLOGENY_GRAPHICS_TYPE.CONVEX.toString() ) ) {
954                 setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CONVEX );
955             }
956             else if ( type_str.equalsIgnoreCase( PHYLOGENY_GRAPHICS_TYPE.CURVED.toString() ) ) {
957                 setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CURVED );
958             }
959             else if ( type_str.equalsIgnoreCase( PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE.toString() ) ) {
960                 setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE );
961             }
962             else if ( type_str.equalsIgnoreCase( PHYLOGENY_GRAPHICS_TYPE.ROUNDED.toString() ) ) {
963                 setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.ROUNDED );
964             }
965             else if ( type_str.equalsIgnoreCase( PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR.toString() ) ) {
966                 setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR );
967             }
968             else if ( type_str.equalsIgnoreCase( PHYLOGENY_GRAPHICS_TYPE.TRIANGULAR.toString() ) ) {
969                 setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.TRIANGULAR );
970             }
971             else if ( type_str.equalsIgnoreCase( PHYLOGENY_GRAPHICS_TYPE.UNROOTED.toString() ) ) {
972                 setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.UNROOTED );
973             }
974             else if ( type_str.equalsIgnoreCase( PHYLOGENY_GRAPHICS_TYPE.CIRCULAR.toString() ) ) {
975                 setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CIRCULAR );
976             }
977             else {
978                 setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR );
979                 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown value [" + type_str
980                         + "] for [phylogeny_graphics_type]" );
981             }
982         }
983         else if ( key.equals( "min_confidence_value" ) ) {
984             final String mcv_str = ( ( String ) st.nextElement() ).trim();
985             final double d = parseDouble( mcv_str );
986             setMinConfidenceValue( d );
987         }
988         else if ( key.equals( "font_family" ) ) {
989             processFontFamily( st );
990         }
991         else if ( key.equals( "font_size" ) ) {
992             final String size_str = ( ( String ) st.nextElement() ).trim();
993             final int i = parseInt( size_str );
994             setBaseFontSize( i );
995         }
996         else if ( key.equals( "graphics_export_x" ) ) {
997             final String str = ( ( String ) st.nextElement() ).trim();
998             final int i = parseInt( str );
999             setGraphicsExportX( i );
1000         }
1001         else if ( key.equals( "graphics_export_y" ) ) {
1002             final String str = ( ( String ) st.nextElement() ).trim();
1003             final int i = parseInt( str );
1004             setGraphicsExportY( i );
1005         }
1006         else if ( key.equals( "pdf_export_line_width" ) ) {
1007             final String str = ( ( String ) st.nextElement() ).trim();
1008             final float f = parseFloat( str );
1009             if ( f > 0 ) {
1010                 setPrintLineWidth( f );
1011             }
1012             else {
1013                 ForesterUtil.printWarningMessage( Constants.PRG_NAME,
1014                                                   "value for [pdf_export_line_width] cannot be zero or negative" );
1015             }
1016         }
1017         else if ( key.equals( "default_number_of_bootstrap_resamples" ) ) {
1018             final String str = ( ( String ) st.nextElement() ).trim();
1019             final int i = parseInt( str );
1020             if ( i >= 0 ) {
1021                 setDefaultBootstrapSamples( i );
1022             }
1023             else {
1024                 ForesterUtil
1025                         .printWarningMessage( Constants.PRG_NAME,
1026                                               "value for [default_number_of_bootstrap_resamples] cannot be negative" );
1027             }
1028         }
1029         else if ( key.equals( "show_scale" ) ) {
1030             setShowScale( parseBoolean( ( String ) st.nextElement() ) );
1031         }
1032         else if ( key.equals( "show_overview" ) ) {
1033             setShowOverview( parseBoolean( ( String ) st.nextElement() ) );
1034         }
1035         else if ( key.equals( "show_branch_length_values" ) ) {
1036             setShowBranchLengthValues( parseBoolean( ( String ) st.nextElement() ) );
1037         }
1038         else if ( key.equals( "background_gradient" ) ) {
1039             setBackgroundColorGradient( parseBoolean( ( String ) st.nextElement() ) );
1040         }
1041         else if ( key.equals( "color_labels_same_as_branch_length_values" ) ) {
1042             setColorLabelsSameAsParentBranch( parseBoolean( ( String ) st.nextElement() ) );
1043         }
1044         else if ( key.equals( "show_domain_labels" ) ) {
1045             setShowDomainLabels( parseBoolean( ( String ) st.nextElement() ) );
1046         }
1047         else if ( key.equals( "abbreviate_scientific_names" ) ) {
1048             setAbbreviateScientificTaxonNames( parseBoolean( ( String ) st.nextElement() ) );
1049         }
1050         else if ( key.equals( "cladogram_type" ) ) {
1051             final String type_str = ( ( String ) st.nextElement() ).trim();
1052             if ( type_str.equalsIgnoreCase( Options.CLADOGRAM_TYPE.NON_LINED_UP.toString() ) ) {
1053                 setCladogramType( Options.CLADOGRAM_TYPE.NON_LINED_UP );
1054             }
1055             else if ( type_str.equalsIgnoreCase( Options.CLADOGRAM_TYPE.EXT_NODE_SUM_DEP.toString() ) ) {
1056                 setCladogramType( Options.CLADOGRAM_TYPE.EXT_NODE_SUM_DEP );
1057             }
1058             else if ( type_str.equalsIgnoreCase( Options.CLADOGRAM_TYPE.TOTAL_NODE_SUM_DEP.toString() ) ) {
1059                 setCladogramType( Options.CLADOGRAM_TYPE.TOTAL_NODE_SUM_DEP );
1060             }
1061             else {
1062                 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown value [" + type_str
1063                         + "] for [cladogram_type]" );
1064             }
1065         }
1066         else if ( key.equals( "non_lined_up_cladogram" ) ) {
1067             ForesterUtil
1068                     .printWarningMessage( Constants.PRG_NAME,
1069                                           "configuration key [non_lined_up_cladogram] is deprecated, use [cladogram_type] instead" );
1070         }
1071         else if ( key.equals( "hide_controls_and_menus" ) ) {
1072             _hide_controls_and_menus = parseBoolean( ( String ) st.nextElement() );
1073         }
1074         else if ( key.equals( "use_tabbed_display" ) ) {
1075             _use_tabbed_display = parseBoolean( ( String ) st.nextElement() );
1076         }
1077         else if ( key.equals( "overview_width" ) ) {
1078             final short i = parseShort( ( ( String ) st.nextElement() ).trim() );
1079             setOvMaxWidth( i );
1080         }
1081         else if ( key.equals( "overview_height" ) ) {
1082             final short i = parseShort( ( ( String ) st.nextElement() ).trim() );
1083             setOvMaxHeight( i );
1084         }
1085         else if ( key.equals( "overview_placement_type" ) ) {
1086             final String type_str = ( ( String ) st.nextElement() ).trim();
1087             if ( type_str.equalsIgnoreCase( OVERVIEW_PLACEMENT_TYPE.UPPER_LEFT.toTag() ) ) {
1088                 setOvPlacement( OVERVIEW_PLACEMENT_TYPE.UPPER_LEFT );
1089             }
1090             else if ( type_str.equalsIgnoreCase( OVERVIEW_PLACEMENT_TYPE.UPPER_RIGHT.toTag() ) ) {
1091                 setOvPlacement( OVERVIEW_PLACEMENT_TYPE.UPPER_RIGHT );
1092             }
1093             else if ( type_str.equalsIgnoreCase( OVERVIEW_PLACEMENT_TYPE.LOWER_LEFT.toTag() ) ) {
1094                 setOvPlacement( OVERVIEW_PLACEMENT_TYPE.LOWER_LEFT );
1095             }
1096             else if ( type_str.equalsIgnoreCase( OVERVIEW_PLACEMENT_TYPE.LOWER_RIGHT.toTag() ) ) {
1097                 setOvPlacement( OVERVIEW_PLACEMENT_TYPE.LOWER_RIGHT );
1098             }
1099             else {
1100                 setOvPlacement( OVERVIEW_PLACEMENT_TYPE.UPPER_LEFT );
1101                 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown value [" + type_str
1102                         + "] for [overview_placement_type]" );
1103             }
1104         }
1105         else if ( key.equals( "node_label_direction" ) ) {
1106             final String type_str = ( ( String ) st.nextElement() ).trim();
1107             if ( type_str.equalsIgnoreCase( NODE_LABEL_DIRECTION.HORIZONTAL.toString() ) ) {
1108                 setNodeLabelDirection( NODE_LABEL_DIRECTION.HORIZONTAL );
1109             }
1110             else if ( type_str.equalsIgnoreCase( NODE_LABEL_DIRECTION.RADIAL.toString() ) ) {
1111                 setNodeLabelDirection( NODE_LABEL_DIRECTION.RADIAL );
1112             }
1113             else {
1114                 setNodeLabelDirection( NODE_LABEL_DIRECTION.HORIZONTAL );
1115                 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown value [" + type_str
1116                         + "] for [node_label_direction]" );
1117             }
1118         }
1119         else if ( key.equals( "branch_length_value_digits" ) ) {
1120             final short i = parseShort( ( ( String ) st.nextElement() ).trim() );
1121             if ( i >= 0 ) {
1122                 setNumberOfDigitsAfterCommaForBranchLengthValue( i );
1123             }
1124             else {
1125                 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "illegal value [" + i
1126                         + "] for [branch_length_value_digits]" );
1127             }
1128         }
1129         else if ( key.equals( "confidence_value_digits" ) ) {
1130             final short i = parseShort( ( ( String ) st.nextElement() ).trim() );
1131             if ( i >= 0 ) {
1132                 setNumberOfDigitsAfterCommaForConfidenceValues( i );
1133             }
1134             else {
1135                 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "illegal value [" + i
1136                         + "] for [confidence_value_digits]" );
1137             }
1138         }
1139         else if ( key.equals( "allow_editing" ) ) {
1140             setEditable( parseBoolean( ( String ) st.nextElement() ) );
1141         }
1142         else if ( key.equals( "display_sequence_relations" ) ) {
1143             setDisplaySequenceRelations( parseBoolean( ( String ) st.nextElement() ) );
1144         }
1145         else if ( key.equals( "replace_underscores_in_nh_parsing" ) ) {
1146             final boolean r = parseBoolean( ( String ) st.nextElement() );
1147             if ( r && isExtractPfamTaxonomyCodesInNhParsing() ) {
1148                 ForesterUtil
1149                         .printWarningMessage( Constants.PRG_NAME,
1150                                               "attempt to extract taxonomies and replace underscores at the same time" );
1151             }
1152             else {
1153                 setReplaceUnderscoresInNhParsing( r );
1154             }
1155         }
1156         else if ( key.equals( "extract_taxonomy_codes_in_nh_parsing" ) ) {
1157             final boolean e = parseBoolean( ( String ) st.nextElement() );
1158             if ( e && isReplaceUnderscoresInNhParsing() ) {
1159                 ForesterUtil
1160                         .printWarningMessage( Constants.PRG_NAME,
1161                                               "attempt to extract taxonomies and replace underscores at the same time" );
1162             }
1163             else {
1164                 setExtractPfamTaxonomyCodesInNhParsing( e );
1165             }
1166         }
1167         else if ( key.equals( "internal_labels_are_confidence_values" ) ) {
1168             setInternalNumberAreConfidenceForNhParsing( parseBoolean( ( String ) st.nextElement() ) );
1169         }
1170         else if ( key.equals( "gui_background_color" ) ) {
1171             _gui_background_color = Color.decode( ( String ) st.nextElement() );
1172         }
1173         else if ( key.equals( "gui_checkbox_text_color" ) ) {
1174             _gui_checkbox_text_color = Color.decode( ( String ) st.nextElement() );
1175         }
1176         else if ( key.equals( "gui_checkbox_and_button_active_color" ) ) {
1177             _gui_checkbox_and_button_active_color = Color.decode( ( String ) st.nextElement() );
1178         }
1179         else if ( key.equals( "gui_button_text_color" ) ) {
1180             _gui_button_text_color = Color.decode( ( String ) st.nextElement() );
1181         }
1182         else if ( key.equals( "gui_button_background_color" ) ) {
1183             _gui_button_background_color = Color.decode( ( String ) st.nextElement() );
1184         }
1185         else if ( key.equals( "gui_menu_background_color" ) ) {
1186             _gui_menu_background_color = Color.decode( ( String ) st.nextElement() );
1187         }
1188         else if ( key.equals( "gui_menu_text_color" ) ) {
1189             _gui_menu_text_color = Color.decode( ( String ) st.nextElement() );
1190         }
1191         else if ( key.equals( "gui_button_border_color" ) ) {
1192             _gui_button_border_color = Color.decode( ( String ) st.nextElement() );
1193         }
1194         else if ( key.equals( "domain_structure_font_color" ) ) {
1195             _domain_structure_font_color = Color.decode( ( String ) st.nextElement() );
1196         }
1197         else if ( key.equals( "domain_structure_base_color" ) ) {
1198             _domain_structure_base_color = Color.decode( ( String ) st.nextElement() );
1199         }
1200         else if ( key.equals( "show_default_node_shapes" ) ) {
1201             setShowDefaultNodeShapes( parseBoolean( ( ( String ) st.nextElement() ).trim() ) );
1202         }
1203         else if ( key.equals( "default_node_size" ) ) {
1204             final short i = parseShort( ( ( String ) st.nextElement() ).trim() );
1205             setDefaultNodeShapeSize( i );
1206         }
1207         else if ( key.equals( "default_node_fill" ) ) {
1208             final String fill_str = ( ( String ) st.nextElement() ).trim();
1209             if ( fill_str.equalsIgnoreCase( NodeVisualization.NodeFill.NONE.toString() ) ) {
1210                 setDefaultNodeFill( NodeFill.NONE );
1211             }
1212             else if ( fill_str.equalsIgnoreCase( NodeVisualization.NodeFill.GRADIENT.toString() ) ) {
1213                 setDefaultNodeFill( NodeFill.GRADIENT );
1214             }
1215             else if ( fill_str.equalsIgnoreCase( NodeVisualization.NodeFill.SOLID.toString() ) ) {
1216                 setDefaultNodeFill( NodeFill.SOLID );
1217             }
1218             else {
1219                 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown value [" + fill_str
1220                         + "] for [default_node_fill]" );
1221             }
1222         }
1223         else if ( key.equals( "default_node_shape" ) ) {
1224             final String shape_str = ( ( String ) st.nextElement() ).trim();
1225             if ( shape_str.equalsIgnoreCase( NodeVisualization.NodeShape.CIRCLE.toString() ) ) {
1226                 setDefaultNodeShape( NodeShape.CIRCLE );
1227             }
1228             else if ( shape_str.equalsIgnoreCase( NodeVisualization.NodeShape.RECTANGLE.toString() ) ) {
1229                 setDefaultNodeShape( NodeShape.RECTANGLE );
1230             }
1231             else {
1232                 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown value [" + shape_str
1233                         + "] for [default_node_shape]" );
1234             }
1235         }
1236         else if ( key.equals( "taxonomy_colorize_node_shapes" ) ) {
1237             setTaxonomyColorizeNodeShapes( parseBoolean( ( String ) st.nextElement() ) );
1238         }
1239         else if ( st.countTokens() >= 2 ) { // counts the tokens that are not
1240             // yet retrieved!
1241             int key_index = -1;
1242             if ( key.equals( "use_real_br_lengths" ) || key.equals( "phylogram" ) ) {
1243                 key_index = Configuration.display_as_phylogram;
1244                 if ( key.equals( "use_real_br_lengths" ) ) {
1245                     ForesterUtil
1246                             .printWarningMessage( Constants.PRG_NAME,
1247                                                   "configuration key [use_real_br_lengths] is deprecated, use [phylogram] instead" );
1248                 }
1249             }
1250             else if ( key.equals( "rollover" ) ) {
1251                 key_index = Configuration.node_data_popup;
1252             }
1253             else if ( key.equals( "color_according_to_species" ) ) {
1254                 key_index = Configuration.color_according_to_species;
1255             }
1256             else if ( key.equals( "show_node_names" ) ) {
1257                 key_index = Configuration.show_node_names;
1258             }
1259             else if ( key.equals( "show_taxonomy" ) || key.equals( "show_taxonomy_code" ) ) {
1260                 key_index = Configuration.show_tax_code;
1261                 if ( key.equals( "show_taxonomy" ) ) {
1262                     ForesterUtil
1263                             .printWarningMessage( Constants.PRG_NAME,
1264                                                   "configuration key [show_taxonomy] is deprecated, use [show_taxonomy_code] instead" );
1265                 }
1266             }
1267             else if ( key.equals( "write_br_length_values" ) ) {
1268                 ForesterUtil.printWarningMessage( Constants.PRG_NAME,
1269                                                   "configuration key [write_br_length_values] is deprecated" );
1270                 key_index = DEPRECATED;
1271             }
1272             else if ( key.equals( "write_bootstrap_values" ) || key.equals( "write_confidence_values" ) ) {
1273                 key_index = Configuration.write_confidence_values;
1274                 if ( key.equals( "write_bootstrap_values" ) ) {
1275                     ForesterUtil
1276                             .printWarningMessage( Constants.PRG_NAME,
1277                                                   "configuration key [write_bootstrap_values] is deprecated, use [write_confidence_values] instead" );
1278                 }
1279             }
1280             else if ( key.equals( "write_events" ) || key.equals( "write_dup_spec" ) ) {
1281                 key_index = Configuration.write_events;
1282                 if ( key.equals( "write_dup_spec" ) ) {
1283                     ForesterUtil
1284                             .printWarningMessage( Constants.PRG_NAME,
1285                                                   "configuration key [write_dup_spec] is deprecated, use [write_events] instead" );
1286                 }
1287             }
1288             else if ( key.equals( "color_branches" ) ) {
1289                 key_index = Configuration.color_branches;
1290             }
1291             else if ( key.equals( "width_branches" ) ) {
1292                 key_index = Configuration.width_branches;
1293             }
1294             else if ( key.equals( "color_orthologous" ) ) {
1295                 ForesterUtil.printWarningMessage( Constants.PRG_NAME,
1296                                                   "configuration key [color_orthologous] is deprecated" );
1297             }
1298             else if ( key.equals( "color_subtree_neighbors" ) ) {
1299                 ForesterUtil.printWarningMessage( Constants.PRG_NAME,
1300                                                   "configuration key [color_subtree_neighbors] is deprecated" );
1301             }
1302             else if ( key.equals( "color_super_orthologous" ) ) {
1303                 ForesterUtil.printWarningMessage( Constants.PRG_NAME,
1304                                                   "configuration key [color_super_orthologous] is deprecated" );
1305             }
1306             else if ( key.equals( "mark_nodes_with_box" ) ) {
1307                 ForesterUtil.printWarningMessage( Constants.PRG_NAME,
1308                                                   "configuration key [mark_nodes_with_box] is deprecated" );
1309                 key_index = DEPRECATED;
1310             }
1311             else if ( key.equals( "show_domain_architectures" ) ) {
1312                 key_index = Configuration.show_domain_architectures;
1313             }
1314             else if ( key.equals( "show_annotations" ) ) {
1315                 key_index = Configuration.show_annotation;
1316             }
1317             else if ( key.equals( "show_binary_characters" ) ) {
1318                 key_index = Configuration.show_binary_characters;
1319             }
1320             else if ( key.equals( "show_binary_character_counts" ) ) {
1321                 key_index = Configuration.show_binary_character_counts;
1322             }
1323             else if ( key.equals( "show_gene_names" ) ) {
1324                 key_index = Configuration.show_gene_names;
1325             }
1326             else if ( key.equals( "show_gene_symbols" ) ) {
1327                 key_index = Configuration.show_gene_symbols;
1328             }
1329             else if ( key.equals( "show_sequence_acc" ) ) {
1330                 key_index = Configuration.show_sequence_acc;
1331             }
1332             else if ( key.equals( "show_node_ids" ) ) {
1333                 ForesterUtil
1334                         .printWarningMessage( Constants.PRG_NAME, "configuration key [show_node_ids] is deprecated" );
1335                 key_index = DEPRECATED;
1336             }
1337             else if ( key.equals( "display_internal_data" ) ) {
1338                 key_index = Configuration.display_internal_data;
1339             }
1340             else if ( key.equals( "dynamically_hide_data" ) ) {
1341                 key_index = Configuration.dynamically_hide_data;
1342             }
1343             else if ( key.equals( "show_taxonomy_names" ) ) {
1344                 ForesterUtil.printWarningMessage( Constants.PRG_NAME,
1345                                                   "configuration key [show_taxonomy_names] is deprecated" );
1346                 key_index = DEPRECATED;
1347             }
1348             else if ( key.equals( "show_taxonomy_scientific_names" ) ) {
1349                 key_index = Configuration.show_taxonomy_scientific_names;
1350             }
1351             else if ( key.equals( "show_taxonomy_common_names" ) ) {
1352                 key_index = Configuration.show_taxonomy_common_names;
1353             }
1354             else if ( key.equals( "show_taxonomy_images" ) ) {
1355                 key_index = Configuration.show_taxonomy_images;
1356             }
1357             else if ( key.equals( "color_according_to_annotation" ) ) {
1358                 key_index = Configuration.color_according_to_annotation;
1359             }
1360             else if ( key.equals( "show_vector_data" ) ) {
1361                 key_index = Configuration.show_vector_data;
1362             }
1363             else if ( key.equals( "show_properties" ) ) {
1364                 key_index = Configuration.show_properties;
1365             }
1366             else if ( key.equals( "show_relation_confidence" ) ) {
1367                 key_index = Configuration.show_relation_confidence;
1368             }
1369             else if ( key.equals( "show_custom_node_shapes" ) ) {
1370                 key_index = Configuration.show_custom_node_shapes;
1371             }
1372             // If we've found the key, set the values
1373             if ( key_index >= 0 ) {
1374                 display_options[ key_index ][ 1 ] = ( String ) st.nextElement();
1375                 display_options[ key_index ][ 2 ] = ( String ) st.nextElement();
1376                 // otherwise, keep looking
1377             }
1378             else {
1379                 if ( key_index == DEPRECATED ) {
1380                     // Deprecated.
1381                 }
1382                 else if ( key.equals( "click_to" ) ) {
1383                     final String click_to_name = ( String ) st.nextElement();
1384                     key_index = getClickToIndex( click_to_name );
1385                     if ( key_index >= 0 ) {
1386                         clickto_options[ key_index ][ 1 ] = ( String ) st.nextElement();
1387                     }
1388                     else if ( key_index == DEPRECATED ) {
1389                         // Deprecated.
1390                     }
1391                     else {
1392                         ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown click-to option: "
1393                                 + click_to_name );
1394                     }
1395                 }
1396                 else if ( key.equals( "species_color" ) ) {
1397                     getSpeciesColors().put( ( String ) st.nextElement(), Color.decode( ( String ) st.nextElement() ) );
1398                 }
1399                 else if ( key.equals( "domain_color" ) ) {
1400                     getDomainColors().put( ( String ) st.nextElement(), Color.decode( ( String ) st.nextElement() ) );
1401                 }
1402                 else if ( key.equals( "annotation_color" ) ) {
1403                     getAnnotationColors()
1404                             .put( ( String ) st.nextElement(), Color.decode( ( String ) st.nextElement() ) );
1405                 }
1406                 else if ( key.equals( "function_color" ) ) {
1407                     ForesterUtil.printWarningMessage( Constants.PRG_NAME,
1408                                                       "configuration key [function_color] is deprecated" );
1409                 }
1410                 else if ( key.equals( DISPLAY_COLOR_KEY ) ) {
1411                     putDisplayColors( ( String ) st.nextElement(), Color.decode( ( String ) st.nextElement() ) );
1412                 }
1413                 else if ( key.equals( WEB_LINK_KEY ) ) {
1414                     if ( st.countTokens() == 3 ) {
1415                         createWebLink( ( String ) st.nextElement(),
1416                                        ( String ) st.nextElement(),
1417                                        ( String ) st.nextElement() );
1418                     }
1419                     else {
1420                         ForesterUtil.printWarningMessage( Constants.PRG_NAME,
1421                                                           "illegal format in configuration file for key [" + key + "]" );
1422                     }
1423                 }
1424                 else {
1425                     ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown configuration key [" + key
1426                             + "] in: " + config_filename );
1427                 }
1428             }
1429         }
1430         else {
1431             ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown configuration key [" + key + "] in: "
1432                     + config_filename );
1433         }
1434     }
1435
1436     public void setMinConfidenceValue( final double min_confidence_value ) {
1437         _min_confidence_value = min_confidence_value;
1438     }
1439
1440     public void setNodeLabelDirection( final NODE_LABEL_DIRECTION node_label_direction ) {
1441         _node_label_direction = node_label_direction;
1442     }
1443
1444     public void setNumberOfDigitsAfterCommaForBranchLengthValue( final short _number_of_digits_after_comma_for_branch_length_values ) {
1445         this._number_of_digits_after_comma_for_branch_length_values = _number_of_digits_after_comma_for_branch_length_values;
1446     }
1447
1448     public void setNumberOfDigitsAfterCommaForConfidenceValues( final short _number_of_digits_after_comma_for_confidence_values ) {
1449         this._number_of_digits_after_comma_for_confidence_values = _number_of_digits_after_comma_for_confidence_values;
1450     }
1451
1452     private void setOvMaxHeight( final short ov_max_height ) {
1453         _ov_max_height = ov_max_height;
1454     }
1455
1456     private void setOvMaxWidth( final short ov_max_width ) {
1457         _ov_max_width = ov_max_width;
1458     }
1459
1460     private void setOvPlacement( final OVERVIEW_PLACEMENT_TYPE ov_placement ) {
1461         _ov_placement = ov_placement;
1462     }
1463
1464     public void setPhylogenyGraphicsType( final PHYLOGENY_GRAPHICS_TYPE phylogeny_graphics_type ) {
1465         _phylogeny_graphics_type = phylogeny_graphics_type;
1466     }
1467
1468     public void setPrintLineWidth( final float print_line_width ) {
1469         _print_line_width = print_line_width;
1470     }
1471
1472     public void setReplaceUnderscoresInNhParsing( final boolean nh_parsing_replace_underscores ) {
1473         _nh_parsing_replace_underscores = nh_parsing_replace_underscores;
1474     }
1475
1476     public void setShowBranchLengthValues( final boolean show_branch_length_values ) {
1477         _show_branch_length_values = show_branch_length_values;
1478     }
1479
1480     public void setShowDefaultNodeShapes( final boolean show_default_node_shapes ) {
1481         _show_default_node_shapes = show_default_node_shapes;
1482     }
1483
1484     public void setShowDomainLabels( final boolean show_domain_labels ) {
1485         _show_domain_labels = show_domain_labels;
1486     }
1487
1488     private void setShowOverview( final boolean show_overview ) {
1489         _show_overview = show_overview;
1490     }
1491
1492     public void setShowScale( final boolean show_scale ) {
1493         _show_scale = show_scale;
1494     }
1495
1496     public void setTaxonomyColorize( final boolean b ) {
1497         display_options[ color_according_to_species ][ 2 ] = b ? "yes" : "no";
1498     }
1499
1500     public void setTaxonomyColorizeNodeShapes( final boolean taxonomy_colorize_node_shapes ) {
1501         _taxonomy_colorize_node_shapes = taxonomy_colorize_node_shapes;
1502     }
1503
1504     public void setUseBranchesWidths( final boolean b ) {
1505         display_options[ width_branches ][ 2 ] = b ? "yes" : "no";
1506     }
1507
1508     private void setValidatePhyloXmlAgainstSchema( final boolean validate_against_phyloxml_xsd_schema ) {
1509         _validate_against_phyloxml_xsd_schema = validate_against_phyloxml_xsd_schema;
1510     }
1511
1512     void setWebLinks( final SortedMap<String, WebLink> weblinks ) {
1513         _weblinks = weblinks;
1514     }
1515
1516     static String getDefaultFontFamilyName() {
1517         return DEFAULT_FONT_FAMILY;
1518     }
1519
1520     public File getPathToMafft() {
1521         return _mafft;
1522     }
1523
1524     public File getPathToClustalOmega() {
1525         return _clustalo;
1526     }
1527
1528     public File getPathToFastME() {
1529         return _fastme;
1530     }
1531
1532     public void setPathToMafft( final File mafft ) {
1533         _mafft = mafft;
1534     }
1535
1536     public void setPathToClustalOmega( final File clustalo ) {
1537         _clustalo = clustalo;
1538     }
1539
1540     public void setPathToFastME( final File fastme ) {
1541         _fastme = fastme;
1542     }
1543
1544     static enum TRIPLET {
1545         TRUE, FALSE, UNKNOWN
1546     }
1547
1548     public enum UI {
1549         NATIVE, CROSSPLATFORM, NIMBUS, UNKNOWN
1550     }
1551 }