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