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