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