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