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