2 // FORESTER -- software libraries and applications
3 // for evolutionary biology research and applications.
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
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.
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.
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
26 // Contact: phylosoft @ gmail . com
27 // WWW: www.phylosoft.org/forester
29 package org.forester.archaeopteryx;
31 import java.awt.Color;
32 import java.io.BufferedReader;
34 import java.io.FileReader;
35 import java.io.IOException;
36 import java.io.InputStreamReader;
37 import java.net.MalformedURLException;
39 import java.util.Arrays;
40 import java.util.Hashtable;
42 import java.util.SortedMap;
43 import java.util.StringTokenizer;
44 import java.util.TreeMap;
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;
55 public final class Configuration {
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_kalign = 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 // ------------------
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 // ---------------------------
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" } };
178 // This option is selected in the dropdown
179 int default_clickto = Configuration.display_node_data;
183 TreeColorSet tree_color_set;
187 TreeFontSet tree_font_set;
191 private static Hashtable<String, Color> _species_colors;
195 private static Hashtable<String, Color> _domain_colors;
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 = "";
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;
220 if ( ForesterUtil.isEmpty( DEFAULT_FONT_FAMILY ) ) {
221 DEFAULT_FONT_FAMILY = Constants.DEFAULT_FONT_CHOICES[ Constants.DEFAULT_FONT_CHOICES.length - 1 ];
225 public Configuration() {
226 this( null, false, false, false );
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;
234 config_filename = cf;
236 setWebLinks( new TreeMap<String, WebLink>() );
237 setDisplayColors( new TreeMap<String, Color>() );
238 config_filename = config_filename.trim();
241 // If URL, open accordingly
243 u = new URL( config_filename );
245 final InputStreamReader isr = new InputStreamReader( u.openStream() );
246 final BufferedReader bf = new BufferedReader( isr );
249 ForesterUtil.programMessage( Constants.PRG_NAME, "successfully read from configuration url ["
250 + config_filename + "]" );
252 catch ( final Exception e ) {
253 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "failed to read configuration from ["
254 + config_filename + "]: " + e.getLocalizedMessage() );
257 catch ( final Exception e ) {
258 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "cannot find or open configuration url ["
259 + config_filename + "]" );
263 // Otherwise, open as a file
264 File f = new File( config_filename );
266 f = new File( config_filename + ".txt" );
268 if ( f.exists() && f.canRead() ) {
270 final BufferedReader bf = new BufferedReader( new FileReader( f ) );
274 catch ( final Exception e ) {
276 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "failed to read configuration from ["
277 + config_filename + "]: " + e );
283 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "cannot find or open configuration file ["
284 + config_filename + "]" );
290 private void createWebLink( final String url_str, final String desc, final String source_identifier ) {
291 WebLink weblink = null;
294 weblink = new WebLink( new URL( url_str.trim() ), desc.trim(), source_identifier.trim() );
296 catch ( final MalformedURLException e ) {
297 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "could not create URL from [" + url_str + "]" );
300 if ( !ex && ( weblink != null ) ) {
301 getWebLinks().put( weblink.getSourceIdentifier().toLowerCase(), weblink );
305 boolean displaySequenceRelations() {
306 return _display_sequence_relations;
309 boolean doCheckOption( final int which ) {
310 return ( display_options[ which ][ 2 ].equalsIgnoreCase( "yes" ) )
311 || ( display_options[ which ][ 2 ].equalsIgnoreCase( "true" ) );
314 boolean doDisplayClickToOption( final int which ) {
315 return clickto_options[ which ][ 1 ].equalsIgnoreCase( "display" );
318 boolean doDisplayOption( final int which ) {
319 return display_options[ which ][ 1 ].equalsIgnoreCase( "display" );
323 * Will attempt to use the phylogeny to determine whether to check
324 * this or not (e.g. phylogram)
327 boolean doGuessCheckOption( final int which ) {
328 return display_options[ which ][ 2 ].equals( "?" );
331 Map<String, Color> getAnnotationColors() {
332 if ( _annotation_colors == null ) {
333 _annotation_colors = new Hashtable<String, Color>();
335 return _annotation_colors;
338 public String getBaseFontFamilyName() {
339 return _base_font_family_name;
342 int getBaseFontSize() {
343 return _base_font_size;
346 CLADOGRAM_TYPE getCladogramType() {
347 return _cladogram_type;
350 private int getClickToIndex( final String name ) {
352 if ( name.equals( "edit_info" ) ) {
353 index = Configuration.display_node_data;
355 .printWarningMessage( Constants.PRG_NAME,
356 "configuration key [edit_info] is deprecated, use [display node data] instead" );
358 else if ( name.equals( "display_node_data" ) ) {
359 index = Configuration.display_node_data;
361 else if ( name.equals( "collapse_uncollapse" ) ) {
362 index = Configuration.collapse_uncollapse;
364 else if ( name.equals( "reroot" ) ) {
365 index = Configuration.reroot;
367 else if ( name.equals( "subtree" ) ) {
368 index = Configuration.subtree;
370 else if ( name.equals( "swap" ) ) {
371 index = Configuration.swap;
373 else if ( name.equals( "sort_descendants" ) ) {
374 index = Configuration.sort_descendents;
376 else if ( name.equals( "display_sequences" ) ) {
378 .printWarningMessage( Constants.PRG_NAME, "configuration key [display_sequences] is deprecated" );
381 else if ( name.equals( "open_seq_web" ) ) {
382 index = Configuration.open_seq_web;
384 else if ( name.equals( "open_tax_web" ) ) {
385 index = Configuration.open_tax_web;
387 else if ( name.equals( "blast" ) ) {
388 index = Configuration.blast;
390 else if ( name.equals( "cut_subtree" ) ) {
391 index = Configuration.cut_subtree;
393 else if ( name.equals( "copy_subtree" ) ) {
394 index = Configuration.copy_subtree;
396 else if ( name.equals( "paste_subtree" ) ) {
397 index = Configuration.paste_subtree;
399 else if ( name.equals( "delete" ) ) {
400 index = Configuration.delete_subtree_or_node;
402 else if ( name.equals( "add_new_node" ) ) {
403 index = Configuration.add_new_node;
405 else if ( name.equals( "edit_node_data" ) ) {
406 index = Configuration.edit_node_data;
408 else if ( name.equals( "display_node_popup" ) ) {
409 ForesterUtil.printWarningMessage( Constants.PRG_NAME,
410 "configuration key [display_node_popup] is deprecated" );
413 else if ( name.equals( "custom_option" ) ) {
414 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "configuration key [custom_option] is deprecated" );
417 else if ( name.equals( "color_subtree" ) ) {
418 index = Configuration.color_subtree;
420 else if ( name.equals( "go_to_swiss_prot" ) ) {
421 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "configuration key [go_to_swiss_prot] is deprecated" );
427 int getClickToOptionsCount() {
428 return clickto_options.length;
431 String getClickToTitle( final int which ) {
432 return clickto_options[ which ][ 0 ];
435 public int getDefaultBootstrapSamples() {
436 return _default_bootstrap_samples;
439 public File getpathToLocalMafft() {
440 return _path_to_local_mafft;
443 public File getPathToLocalKalign() {
444 return _path_to_local_kalign;
447 public File getPathToLocalFastme() {
448 return _path_to_local_fastme;
451 public File getPathToLocalRaxml() {
452 return _path_to_local_raxml;
455 int getDefaultDisplayClicktoOption() {
456 return default_clickto;
459 public NodeFill getDefaultNodeFill() {
460 return _default_node_fill;
463 public NodeShape getDefaultNodeShape() {
464 return _default_node_shape;
467 public short getDefaultNodeShapeSize() {
468 return _default_node_shape_size;
471 SortedMap<String, Color> getDisplayColors() {
472 return _display_colors;
475 String getDisplayTitle( final int which ) {
476 return display_options[ which ][ 0 ];
479 Map<String, Color> getDomainColors() {
480 if ( _domain_colors == null ) {
481 _domain_colors = new Hashtable<String, Color>();
483 return _domain_colors;
486 public Color getDomainStructureBaseColor() {
487 return _domain_structure_base_color;
490 public Color getDomainStructureFontColor() {
491 return _domain_structure_font_color;
494 int getGraphicsExportX() {
495 return _graphics_export_x;
498 int getGraphicsExportY() {
499 return _graphics_export_y;
502 Color getGuiBackgroundColor() {
503 return _gui_background_color;
506 Color getGuiButtonBackgroundColor() {
507 return _gui_button_background_color;
510 Color getGuiButtonBorderColor() {
511 return _gui_button_border_color;
514 Color getGuiButtonTextColor() {
515 return _gui_button_text_color;
518 Color getGuiCheckboxAndButtonActiveColor() {
519 return _gui_checkbox_and_button_active_color;
522 Color getGuiCheckboxTextColor() {
523 return _gui_checkbox_text_color;
526 Color getGuiMenuBackgroundColor() {
527 return _gui_menu_background_color;
530 Color getGuiMenuTextColor() {
531 return _gui_menu_text_color;
534 double getMinConfidenceValue() {
535 return _min_confidence_value;
538 NODE_LABEL_DIRECTION getNodeLabelDirection() {
539 return _node_label_direction;
542 short getNumberOfDigitsAfterCommaForBranchLengthValues() {
543 return _number_of_digits_after_comma_for_branch_length_values;
546 short getNumberOfDigitsAfterCommaForConfidenceValues() {
547 return _number_of_digits_after_comma_for_confidence_values;
550 short getOvMaxHeight() {
551 return _ov_max_height;
554 short getOvMaxWidth() {
555 return _ov_max_width;
558 OVERVIEW_PLACEMENT_TYPE getOvPlacement() {
559 return _ov_placement;
562 PHYLOGENY_GRAPHICS_TYPE getPhylogenyGraphicsType() {
563 return _phylogeny_graphics_type;
566 float getPrintLineWidth() {
567 return _print_line_width;
570 Hashtable<String, Color> getSpeciesColors() {
571 if ( _species_colors == null ) {
572 _species_colors = new Hashtable<String, Color>();
574 return _species_colors;
577 TreeColorSet getTreeColorSet() {
581 TreeFontSet getTreeFontSet() {
585 WebLink getWebLink( final String source ) {
586 return getWebLinks().get( source );
589 Map<String, WebLink> getWebLinks() {
593 public boolean isAbbreviateScientificTaxonNames() {
594 return _abbreviate_scientific_names;
597 boolean isAntialiasScreen() {
598 return _antialias_screen;
601 public boolean isBackgroundColorGradient() {
602 return _background_color_gradient;
605 public boolean isColorLabelsSameAsParentBranch() {
606 return _color_labels_same_as_parent_branch;
610 * Convenience method.
612 * @return true if value in configuration file was 'yes'
614 boolean isDrawAsPhylogram() {
615 return doCheckOption( display_as_phylogram );
618 boolean isEditable() {
622 boolean isExtractPfamTaxonomyCodesInNhParsing() {
623 return _nh_parsing_extract_pfam_taxonomy_codes;
626 boolean isHasWebLink( final String source ) {
627 return getWebLinks().containsKey( source );
631 * Only used by ArchaeoptryxE.
634 boolean isHideControlPanelAndMenubar() {
635 return _hide_controls_and_menus;
638 boolean isInternalNumberAreConfidenceForNhParsing() {
639 return _internal_number_are_confidence_for_nh_parsing;
642 boolean isReplaceUnderscoresInNhParsing() {
643 return _nh_parsing_replace_underscores;
646 boolean isShowBranchLengthValues() {
647 return _show_branch_length_values;
650 public boolean isShowDefaultNodeShapes() {
651 return _show_default_node_shapes;
654 public boolean isShowDomainLabels() {
655 return _show_domain_labels;
658 boolean isShowOverview() {
659 return _show_overview;
662 boolean isShowScale() {
666 public boolean isTaxonomyColorizeNodeShapes() {
667 return _taxonomy_colorize_node_shapes;
670 final boolean isUseNativeUI() {
671 if ( ( _ui == UI.UNKNOWN ) && AptxUtil.isMac() && AptxUtil.isJava15() ) {
674 return _ui == UI.NATIVE;
678 * Only used by ArchaeoptryxE.
681 boolean isUseTabbedDisplay() {
682 return _use_tabbed_display;
685 boolean isValidatePhyloXmlAgainstSchema() {
686 return _validate_against_phyloxml_xsd_schema;
689 private boolean parseBoolean( final String str ) {
690 final String my_str = str.trim().toLowerCase();
691 if ( my_str.equals( "yes" ) || my_str.equals( "true" ) ) {
694 else if ( my_str.equals( "no" ) || my_str.equals( "false" ) ) {
698 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "could not parse boolean value from [" + str + "]" );
703 private double parseDouble( final String str ) {
706 d = Double.parseDouble( str );
708 catch ( final Exception e ) {
709 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "could not parse double from [" + str + "]" );
715 private float parseFloat( final String str ) {
718 f = Float.parseFloat( str );
720 catch ( final Exception e ) {
721 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "could not parse float from [" + str + "]" );
727 private int parseInt( final String str ) {
730 i = Integer.parseInt( str );
732 catch ( final Exception e ) {
733 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "could not parse integer from [" + str + "]" );
739 private short parseShort( final String str ) {
742 i = Short.parseShort( str );
744 catch ( final Exception e ) {
745 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "could not parse short from [" + str + "]" );
751 private void processFontFamily( final StringTokenizer st ) {
752 setBaseFontFamilyName( "" );
753 final String font_str = ( ( String ) st.nextElement() ).trim();
754 final String[] fonts = font_str.split( ",+" );
755 for( String font : fonts ) {
756 font = font.replace( '_', ' ' ).trim();
757 if ( Arrays.binarySearch( AptxUtil.getAvailableFontFamiliesSorted(), font ) >= 0 ) {
758 setBaseFontFamilyName( font );
764 public void putDisplayColors( final String key, final Color color ) {
765 getDisplayColors().put( key, color );
769 * read each line of config file, process non-comment lines
770 * @throws IOException
772 private void readConfig( final BufferedReader conf_in ) throws IOException {
775 line = conf_in.readLine();
776 if ( line != null ) {
778 // skip comments and blank lines
779 if ( !line.startsWith( "#" ) && ( !ForesterUtil.isEmpty( line ) ) ) {
780 // convert runs of spaces to tabs
781 line = line.replaceAll( "\\s+", "\t" );
782 final StringTokenizer st = new StringTokenizer( line, "\t" );
786 } while ( line != null );
789 public void setAbbreviateScientificTaxonNames( final boolean abbreviate_scientific_names ) {
790 _abbreviate_scientific_names = abbreviate_scientific_names;
793 private void setAntialiasScreen( final boolean antialias_screen ) {
794 _antialias_screen = antialias_screen;
797 public void setBackgroundColorGradient( final boolean background_color_gradient ) {
798 _background_color_gradient = background_color_gradient;
801 public void setBaseFontFamilyName( final String base_font_family_name ) {
802 _base_font_family_name = base_font_family_name;
805 public void setBaseFontSize( final int base_font_size ) {
806 _base_font_size = base_font_size;
809 private void setCladogramType( final CLADOGRAM_TYPE cladogram_type ) {
810 _cladogram_type = cladogram_type;
813 public void setColorizeBranches( final boolean b ) {
814 display_options[ color_branches ][ 2 ] = b ? "yes" : "no";
817 public void setColorLabelsSameAsParentBranch( final boolean color_labels_same_as_parent_branch ) {
818 _color_labels_same_as_parent_branch = color_labels_same_as_parent_branch;
821 private void setDefaultBootstrapSamples( final int default_bootstrap_samples ) {
822 _default_bootstrap_samples = default_bootstrap_samples;
825 private void setPathToLocalMafft( final File path_to_local_mafft ) {
826 _path_to_local_mafft = path_to_local_mafft;
829 private void setPathToLocalKalign( final File path_to_local_kalign ) {
830 _path_to_local_kalign = path_to_local_kalign;
833 private void setPathToLocalFastme( final File path_to_local_fastme ) {
834 _path_to_local_fastme = path_to_local_fastme;
837 private void setPathToLocalRaxml( final File path_to_local_raxml ) {
838 _path_to_local_raxml = path_to_local_raxml;
841 public File getPathToLocalClustalOmega() {
842 return _path_to_local_clustalo;
845 public void setPathToLocalClustalOmega( final File path_to_local_clustalo ) {
846 _path_to_local_clustalo = path_to_local_clustalo;
849 public void setDefaultNodeFill( final NodeFill default_node_fill ) {
850 _default_node_fill = default_node_fill;
853 public void setDefaultNodeShape( final NodeShape default_node_shape ) {
854 _default_node_shape = default_node_shape;
857 public void setDefaultNodeShapeSize( final short default_node_shape_size ) {
858 _default_node_shape_size = default_node_shape_size;
861 public void setDisplayAsPhylogram( final boolean b ) {
862 display_options[ display_as_phylogram ][ 2 ] = b ? "yes" : "no";
865 public void setDisplayColors( final SortedMap<String, Color> display_colors ) {
866 _display_colors = display_colors;
869 public void setDisplayConfidenceValues( final boolean b ) {
870 display_options[ write_confidence_values ][ 2 ] = b ? "yes" : "no";
873 public void setDisplayInternalData( final boolean b ) {
874 display_options[ display_internal_data ][ 2 ] = b ? "yes" : "no";
877 public void setDisplayNodeNames( final boolean b ) {
878 display_options[ show_node_names ][ 2 ] = b ? "yes" : "no";
881 public void setDisplaySequenceAcc( final boolean b ) {
882 display_options[ show_sequence_acc ][ 2 ] = b ? "yes" : "no";
885 public void setDisplaySequenceNames( final boolean b ) {
886 display_options[ show_gene_names ][ 2 ] = b ? "yes" : "no";
889 public void setDisplaySequenceRelations( final boolean display_sequence_relations ) {
890 _display_sequence_relations = display_sequence_relations;
893 public void setDisplaySequenceSymbols( final boolean b ) {
894 display_options[ show_gene_symbols ][ 2 ] = b ? "yes" : "no";
897 public void setDisplayTaxonomyCode( final boolean b ) {
898 display_options[ show_tax_code ][ 2 ] = b ? "yes" : "no";
901 public void setDisplayTaxonomyCommonNames( final boolean b ) {
902 display_options[ show_taxonomy_common_names ][ 2 ] = b ? "yes" : "no";
905 public void setDisplayTaxonomyImages( final boolean b ) {
906 display_options[ show_taxonomy_images ][ 2 ] = b ? "yes" : "no";
909 public void setDisplayTaxonomyScientificNames( final boolean b ) {
910 display_options[ show_taxonomy_scientific_names ][ 2 ] = b ? "yes" : "no";
913 public void setDynamicallyHideData( final boolean b ) {
914 display_options[ dynamically_hide_data ][ 2 ] = b ? "yes" : "no";
917 private void setEditable( final boolean editable ) {
918 _editable = editable;
921 public void setExtractPfamTaxonomyCodesInNhParsing( final boolean nh_parsing_extract_pfam_taxonomy_codes ) {
922 _nh_parsing_extract_pfam_taxonomy_codes = nh_parsing_extract_pfam_taxonomy_codes;
925 private void setGraphicsExportX( final int graphics_export_x ) {
926 _graphics_export_x = graphics_export_x;
929 private void setGraphicsExportY( final int graphics_export_y ) {
930 _graphics_export_y = graphics_export_y;
933 private void setInternalNumberAreConfidenceForNhParsing( final boolean internal_number_are_confidence_for_nh_parsing ) {
934 _internal_number_are_confidence_for_nh_parsing = internal_number_are_confidence_for_nh_parsing;
938 * Set a key-value(s) tuple
940 private void setKeyValue( final StringTokenizer st ) {
941 String key = ( String ) st.nextElement();
942 key = key.replace( ':', ' ' );
944 key = key.toLowerCase();
945 // Handle single value settings first:
946 if ( key.equals( "default_click_to" ) ) {
947 final String clickto_name = ( String ) st.nextElement();
948 default_clickto = getClickToIndex( clickto_name );
949 if ( default_clickto == -1 ) {
950 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "invalid value [" + clickto_name
951 + "] for [default_click_to]" );
954 else if ( default_clickto == DEPRECATED ) {
958 else if ( key.equals( "native_ui" ) ) {
959 final String my_str = ( ( String ) st.nextElement() ).trim().toLowerCase();
960 if ( my_str.equals( "yes" ) || my_str.equals( "true" ) ) {
963 else if ( my_str.equals( "no" ) || my_str.equals( "false" ) ) {
964 _ui = UI.CROSSPLATFORM;
966 else if ( my_str.equals( "?" ) ) {
970 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "could not parse yes/no/? value from [" + my_str
975 else if ( key.equals( VALIDATE_AGAINST_PHYLOXML_XSD_SCHEMA ) ) {
976 setValidatePhyloXmlAgainstSchema( parseBoolean( ( String ) st.nextElement() ) );
978 else if ( key.equals( "antialias_screen" ) ) {
979 setAntialiasScreen( parseBoolean( ( String ) st.nextElement() ) );
981 else if ( key.equals( "phylogeny_graphics_type" ) ) {
982 final String type_str = ( ( String ) st.nextElement() ).trim();
983 if ( type_str.equalsIgnoreCase( PHYLOGENY_GRAPHICS_TYPE.CONVEX.toString() ) ) {
984 setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CONVEX );
986 else if ( type_str.equalsIgnoreCase( PHYLOGENY_GRAPHICS_TYPE.CURVED.toString() ) ) {
987 setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CURVED );
989 else if ( type_str.equalsIgnoreCase( PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE.toString() ) ) {
990 setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE );
992 else if ( type_str.equalsIgnoreCase( PHYLOGENY_GRAPHICS_TYPE.ROUNDED.toString() ) ) {
993 setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.ROUNDED );
995 else if ( type_str.equalsIgnoreCase( PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR.toString() ) ) {
996 setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR );
998 else if ( type_str.equalsIgnoreCase( PHYLOGENY_GRAPHICS_TYPE.TRIANGULAR.toString() ) ) {
999 setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.TRIANGULAR );
1001 else if ( type_str.equalsIgnoreCase( PHYLOGENY_GRAPHICS_TYPE.UNROOTED.toString() ) ) {
1002 setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.UNROOTED );
1004 else if ( type_str.equalsIgnoreCase( PHYLOGENY_GRAPHICS_TYPE.CIRCULAR.toString() ) ) {
1005 setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CIRCULAR );
1008 setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR );
1009 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown value [" + type_str
1010 + "] for [phylogeny_graphics_type]" );
1013 else if ( key.equals( "min_confidence_value" ) ) {
1014 final String mcv_str = ( ( String ) st.nextElement() ).trim();
1015 final double d = parseDouble( mcv_str );
1016 setMinConfidenceValue( d );
1018 else if ( key.equals( "font_family" ) ) {
1019 processFontFamily( st );
1021 else if ( key.equals( "font_size" ) ) {
1022 final String size_str = ( ( String ) st.nextElement() ).trim();
1023 final int i = parseInt( size_str );
1024 setBaseFontSize( i );
1026 else if ( key.equals( "graphics_export_x" ) ) {
1027 final String str = ( ( String ) st.nextElement() ).trim();
1028 final int i = parseInt( str );
1029 setGraphicsExportX( i );
1031 else if ( key.equals( "graphics_export_y" ) ) {
1032 final String str = ( ( String ) st.nextElement() ).trim();
1033 final int i = parseInt( str );
1034 setGraphicsExportY( i );
1036 else if ( key.equals( "pdf_export_line_width" ) ) {
1037 final String str = ( ( String ) st.nextElement() ).trim();
1038 final float f = parseFloat( str );
1040 setPrintLineWidth( f );
1043 ForesterUtil.printWarningMessage( Constants.PRG_NAME,
1044 "value for [pdf_export_line_width] cannot be zero or negative" );
1047 else if ( key.equals( "default_number_of_bootstrap_resamples" ) ) {
1048 final String str = ( ( String ) st.nextElement() ).trim();
1049 final int i = parseInt( str );
1051 setDefaultBootstrapSamples( i );
1055 .printWarningMessage( Constants.PRG_NAME,
1056 "value for [default_number_of_bootstrap_resamples] cannot be negative" );
1059 else if ( key.equals( "clustalo_local" ) ) {
1060 final String str = ( ( String ) st.nextElement() ).trim();
1061 if ( !ForesterUtil.isEmpty( str ) ) {
1062 setPathToLocalClustalOmega( new File( str ) );
1065 else if ( key.equals( "mafft_local" ) ) {
1066 final String str = ( ( String ) st.nextElement() ).trim();
1067 if ( !ForesterUtil.isEmpty( str ) ) {
1068 setPathToLocalMafft( new File( str ) );
1071 else if ( key.equals( "kalign_local" ) ) {
1072 final String str = ( ( String ) st.nextElement() ).trim();
1073 if ( !ForesterUtil.isEmpty( str ) ) {
1074 setPathToLocalKalign( new File( str ) );
1077 else if ( key.equals( "fastme_local" ) ) {
1078 final String str = ( ( String ) st.nextElement() ).trim();
1079 if ( !ForesterUtil.isEmpty( str ) ) {
1080 setPathToLocalFastme( new File( str ) );
1083 else if ( key.equals( "raxml_local" ) ) {
1084 final String str = ( ( String ) st.nextElement() ).trim();
1085 if ( !ForesterUtil.isEmpty( str ) ) {
1086 setPathToLocalRaxml( new File( str ) );
1089 else if ( key.equals( "show_scale" ) ) {
1090 setShowScale( parseBoolean( ( String ) st.nextElement() ) );
1092 else if ( key.equals( "show_overview" ) ) {
1093 setShowOverview( parseBoolean( ( String ) st.nextElement() ) );
1095 else if ( key.equals( "show_branch_length_values" ) ) {
1096 setShowBranchLengthValues( parseBoolean( ( String ) st.nextElement() ) );
1098 else if ( key.equals( "background_gradient" ) ) {
1099 setBackgroundColorGradient( parseBoolean( ( String ) st.nextElement() ) );
1101 else if ( key.equals( "color_labels_same_as_branch_length_values" ) ) {
1102 setColorLabelsSameAsParentBranch( parseBoolean( ( String ) st.nextElement() ) );
1104 else if ( key.equals( "show_domain_labels" ) ) {
1105 setShowDomainLabels( parseBoolean( ( String ) st.nextElement() ) );
1107 else if ( key.equals( "abbreviate_scientific_names" ) ) {
1108 setAbbreviateScientificTaxonNames( parseBoolean( ( String ) st.nextElement() ) );
1110 else if ( key.equals( "cladogram_type" ) ) {
1111 final String type_str = ( ( String ) st.nextElement() ).trim();
1112 if ( type_str.equalsIgnoreCase( Options.CLADOGRAM_TYPE.NON_LINED_UP.toString() ) ) {
1113 setCladogramType( Options.CLADOGRAM_TYPE.NON_LINED_UP );
1115 else if ( type_str.equalsIgnoreCase( Options.CLADOGRAM_TYPE.EXT_NODE_SUM_DEP.toString() ) ) {
1116 setCladogramType( Options.CLADOGRAM_TYPE.EXT_NODE_SUM_DEP );
1118 else if ( type_str.equalsIgnoreCase( Options.CLADOGRAM_TYPE.TOTAL_NODE_SUM_DEP.toString() ) ) {
1119 setCladogramType( Options.CLADOGRAM_TYPE.TOTAL_NODE_SUM_DEP );
1122 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown value [" + type_str
1123 + "] for [cladogram_type]" );
1126 else if ( key.equals( "non_lined_up_cladogram" ) ) {
1128 .printWarningMessage( Constants.PRG_NAME,
1129 "configuration key [non_lined_up_cladogram] is deprecated, use [cladogram_type] instead" );
1131 else if ( key.equals( "hide_controls_and_menus" ) ) {
1132 _hide_controls_and_menus = parseBoolean( ( String ) st.nextElement() );
1134 else if ( key.equals( "use_tabbed_display" ) ) {
1135 _use_tabbed_display = parseBoolean( ( String ) st.nextElement() );
1137 else if ( key.equals( "overview_width" ) ) {
1138 final short i = parseShort( ( ( String ) st.nextElement() ).trim() );
1141 else if ( key.equals( "overview_height" ) ) {
1142 final short i = parseShort( ( ( String ) st.nextElement() ).trim() );
1143 setOvMaxHeight( i );
1145 else if ( key.equals( "overview_placement_type" ) ) {
1146 final String type_str = ( ( String ) st.nextElement() ).trim();
1147 if ( type_str.equalsIgnoreCase( OVERVIEW_PLACEMENT_TYPE.UPPER_LEFT.toTag() ) ) {
1148 setOvPlacement( OVERVIEW_PLACEMENT_TYPE.UPPER_LEFT );
1150 else if ( type_str.equalsIgnoreCase( OVERVIEW_PLACEMENT_TYPE.UPPER_RIGHT.toTag() ) ) {
1151 setOvPlacement( OVERVIEW_PLACEMENT_TYPE.UPPER_RIGHT );
1153 else if ( type_str.equalsIgnoreCase( OVERVIEW_PLACEMENT_TYPE.LOWER_LEFT.toTag() ) ) {
1154 setOvPlacement( OVERVIEW_PLACEMENT_TYPE.LOWER_LEFT );
1156 else if ( type_str.equalsIgnoreCase( OVERVIEW_PLACEMENT_TYPE.LOWER_RIGHT.toTag() ) ) {
1157 setOvPlacement( OVERVIEW_PLACEMENT_TYPE.LOWER_RIGHT );
1160 setOvPlacement( OVERVIEW_PLACEMENT_TYPE.UPPER_LEFT );
1161 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown value [" + type_str
1162 + "] for [overview_placement_type]" );
1165 else if ( key.equals( "node_label_direction" ) ) {
1166 final String type_str = ( ( String ) st.nextElement() ).trim();
1167 if ( type_str.equalsIgnoreCase( NODE_LABEL_DIRECTION.HORIZONTAL.toString() ) ) {
1168 setNodeLabelDirection( NODE_LABEL_DIRECTION.HORIZONTAL );
1170 else if ( type_str.equalsIgnoreCase( NODE_LABEL_DIRECTION.RADIAL.toString() ) ) {
1171 setNodeLabelDirection( NODE_LABEL_DIRECTION.RADIAL );
1174 setNodeLabelDirection( NODE_LABEL_DIRECTION.HORIZONTAL );
1175 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown value [" + type_str
1176 + "] for [node_label_direction]" );
1179 else if ( key.equals( "branch_length_value_digits" ) ) {
1180 final short i = parseShort( ( ( String ) st.nextElement() ).trim() );
1182 setNumberOfDigitsAfterCommaForBranchLengthValue( i );
1185 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "illegal value [" + i
1186 + "] for [branch_length_value_digits]" );
1189 else if ( key.equals( "confidence_value_digits" ) ) {
1190 final short i = parseShort( ( ( String ) st.nextElement() ).trim() );
1192 setNumberOfDigitsAfterCommaForConfidenceValues( i );
1195 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "illegal value [" + i
1196 + "] for [confidence_value_digits]" );
1199 else if ( key.equals( "allow_editing" ) ) {
1200 setEditable( parseBoolean( ( String ) st.nextElement() ) );
1202 else if ( key.equals( "display_sequence_relations" ) ) {
1203 setDisplaySequenceRelations( parseBoolean( ( String ) st.nextElement() ) );
1205 else if ( key.equals( "replace_underscores_in_nh_parsing" ) ) {
1206 final boolean r = parseBoolean( ( String ) st.nextElement() );
1207 if ( r && isExtractPfamTaxonomyCodesInNhParsing() ) {
1209 .printWarningMessage( Constants.PRG_NAME,
1210 "attempt to extract taxonomies and replace underscores at the same time" );
1213 setReplaceUnderscoresInNhParsing( r );
1216 else if ( key.equals( "extract_taxonomy_codes_in_nh_parsing" ) ) {
1217 final boolean e = parseBoolean( ( String ) st.nextElement() );
1218 if ( e && isReplaceUnderscoresInNhParsing() ) {
1220 .printWarningMessage( Constants.PRG_NAME,
1221 "attempt to extract taxonomies and replace underscores at the same time" );
1224 setExtractPfamTaxonomyCodesInNhParsing( e );
1227 else if ( key.equals( "internal_labels_are_confidence_values" ) ) {
1228 setInternalNumberAreConfidenceForNhParsing( parseBoolean( ( String ) st.nextElement() ) );
1230 else if ( key.equals( "gui_background_color" ) ) {
1231 _gui_background_color = Color.decode( ( String ) st.nextElement() );
1233 else if ( key.equals( "gui_checkbox_text_color" ) ) {
1234 _gui_checkbox_text_color = Color.decode( ( String ) st.nextElement() );
1236 else if ( key.equals( "gui_checkbox_and_button_active_color" ) ) {
1237 _gui_checkbox_and_button_active_color = Color.decode( ( String ) st.nextElement() );
1239 else if ( key.equals( "gui_button_text_color" ) ) {
1240 _gui_button_text_color = Color.decode( ( String ) st.nextElement() );
1242 else if ( key.equals( "gui_button_background_color" ) ) {
1243 _gui_button_background_color = Color.decode( ( String ) st.nextElement() );
1245 else if ( key.equals( "gui_menu_background_color" ) ) {
1246 _gui_menu_background_color = Color.decode( ( String ) st.nextElement() );
1248 else if ( key.equals( "gui_menu_text_color" ) ) {
1249 _gui_menu_text_color = Color.decode( ( String ) st.nextElement() );
1251 else if ( key.equals( "gui_button_border_color" ) ) {
1252 _gui_button_border_color = Color.decode( ( String ) st.nextElement() );
1254 else if ( key.equals( "domain_structure_font_color" ) ) {
1255 _domain_structure_font_color = Color.decode( ( String ) st.nextElement() );
1257 else if ( key.equals( "domain_structure_base_color" ) ) {
1258 _domain_structure_base_color = Color.decode( ( String ) st.nextElement() );
1260 else if ( key.equals( "show_default_node_shapes" ) ) {
1261 setShowDefaultNodeShapes( parseBoolean( ( ( String ) st.nextElement() ).trim() ) );
1263 else if ( key.equals( "default_node_size" ) ) {
1264 final short i = parseShort( ( ( String ) st.nextElement() ).trim() );
1265 setDefaultNodeShapeSize( i );
1267 else if ( key.equals( "default_node_fill" ) ) {
1268 final String fill_str = ( ( String ) st.nextElement() ).trim();
1269 if ( fill_str.equalsIgnoreCase( NodeVisualization.NodeFill.NONE.toString() ) ) {
1270 setDefaultNodeFill( NodeFill.NONE );
1272 else if ( fill_str.equalsIgnoreCase( NodeVisualization.NodeFill.GRADIENT.toString() ) ) {
1273 setDefaultNodeFill( NodeFill.GRADIENT );
1275 else if ( fill_str.equalsIgnoreCase( NodeVisualization.NodeFill.SOLID.toString() ) ) {
1276 setDefaultNodeFill( NodeFill.SOLID );
1279 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown value [" + fill_str
1280 + "] for [default_node_fill]" );
1283 else if ( key.equals( "default_node_shape" ) ) {
1284 final String shape_str = ( ( String ) st.nextElement() ).trim();
1285 if ( shape_str.equalsIgnoreCase( NodeVisualization.NodeShape.CIRCLE.toString() ) ) {
1286 setDefaultNodeShape( NodeShape.CIRCLE );
1288 else if ( shape_str.equalsIgnoreCase( NodeVisualization.NodeShape.RECTANGLE.toString() ) ) {
1289 setDefaultNodeShape( NodeShape.RECTANGLE );
1292 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown value [" + shape_str
1293 + "] for [default_node_shape]" );
1296 else if ( key.equals( "taxonomy_colorize_node_shapes" ) ) {
1297 setTaxonomyColorizeNodeShapes( parseBoolean( ( String ) st.nextElement() ) );
1299 else if ( st.countTokens() >= 2 ) { // counts the tokens that are not
1302 if ( key.equals( "use_real_br_lengths" ) || key.equals( "phylogram" ) ) {
1303 key_index = Configuration.display_as_phylogram;
1304 if ( key.equals( "use_real_br_lengths" ) ) {
1306 .printWarningMessage( Constants.PRG_NAME,
1307 "configuration key [use_real_br_lengths] is deprecated, use [phylogram] instead" );
1310 else if ( key.equals( "rollover" ) ) {
1311 key_index = Configuration.node_data_popup;
1313 else if ( key.equals( "color_according_to_species" ) ) {
1314 key_index = Configuration.color_according_to_species;
1316 else if ( key.equals( "show_node_names" ) ) {
1317 key_index = Configuration.show_node_names;
1319 else if ( key.equals( "show_taxonomy" ) || key.equals( "show_taxonomy_code" ) ) {
1320 key_index = Configuration.show_tax_code;
1321 if ( key.equals( "show_taxonomy" ) ) {
1323 .printWarningMessage( Constants.PRG_NAME,
1324 "configuration key [show_taxonomy] is deprecated, use [show_taxonomy_code] instead" );
1327 else if ( key.equals( "write_br_length_values" ) ) {
1328 ForesterUtil.printWarningMessage( Constants.PRG_NAME,
1329 "configuration key [write_br_length_values] is deprecated" );
1330 key_index = DEPRECATED;
1332 else if ( key.equals( "write_bootstrap_values" ) || key.equals( "write_confidence_values" ) ) {
1333 key_index = Configuration.write_confidence_values;
1334 if ( key.equals( "write_bootstrap_values" ) ) {
1336 .printWarningMessage( Constants.PRG_NAME,
1337 "configuration key [write_bootstrap_values] is deprecated, use [write_confidence_values] instead" );
1340 else if ( key.equals( "write_events" ) || key.equals( "write_dup_spec" ) ) {
1341 key_index = Configuration.write_events;
1342 if ( key.equals( "write_dup_spec" ) ) {
1344 .printWarningMessage( Constants.PRG_NAME,
1345 "configuration key [write_dup_spec] is deprecated, use [write_events] instead" );
1348 else if ( key.equals( "color_branches" ) ) {
1349 key_index = Configuration.color_branches;
1351 else if ( key.equals( "width_branches" ) ) {
1352 key_index = Configuration.width_branches;
1354 else if ( key.equals( "color_orthologous" ) ) {
1355 ForesterUtil.printWarningMessage( Constants.PRG_NAME,
1356 "configuration key [color_orthologous] is deprecated" );
1358 else if ( key.equals( "color_subtree_neighbors" ) ) {
1359 ForesterUtil.printWarningMessage( Constants.PRG_NAME,
1360 "configuration key [color_subtree_neighbors] is deprecated" );
1362 else if ( key.equals( "color_super_orthologous" ) ) {
1363 ForesterUtil.printWarningMessage( Constants.PRG_NAME,
1364 "configuration key [color_super_orthologous] is deprecated" );
1366 else if ( key.equals( "mark_nodes_with_box" ) ) {
1367 ForesterUtil.printWarningMessage( Constants.PRG_NAME,
1368 "configuration key [mark_nodes_with_box] is deprecated" );
1369 key_index = DEPRECATED;
1371 else if ( key.equals( "show_domain_architectures" ) ) {
1372 key_index = Configuration.show_domain_architectures;
1374 else if ( key.equals( "show_annotations" ) ) {
1375 key_index = Configuration.show_annotation;
1377 else if ( key.equals( "show_binary_characters" ) ) {
1378 key_index = Configuration.show_binary_characters;
1380 else if ( key.equals( "show_binary_character_counts" ) ) {
1381 key_index = Configuration.show_binary_character_counts;
1383 else if ( key.equals( "show_gene_names" ) ) {
1384 key_index = Configuration.show_gene_names;
1386 else if ( key.equals( "show_gene_symbols" ) ) {
1387 key_index = Configuration.show_gene_symbols;
1389 else if ( key.equals( "show_sequence_acc" ) ) {
1390 key_index = Configuration.show_sequence_acc;
1392 else if ( key.equals( "show_node_ids" ) ) {
1394 .printWarningMessage( Constants.PRG_NAME, "configuration key [show_node_ids] is deprecated" );
1395 key_index = DEPRECATED;
1397 else if ( key.equals( "display_internal_data" ) ) {
1398 key_index = Configuration.display_internal_data;
1400 else if ( key.equals( "dynamically_hide_data" ) ) {
1401 key_index = Configuration.dynamically_hide_data;
1403 else if ( key.equals( "show_taxonomy_names" ) ) {
1404 ForesterUtil.printWarningMessage( Constants.PRG_NAME,
1405 "configuration key [show_taxonomy_names] is deprecated" );
1406 key_index = DEPRECATED;
1408 else if ( key.equals( "show_taxonomy_scientific_names" ) ) {
1409 key_index = Configuration.show_taxonomy_scientific_names;
1411 else if ( key.equals( "show_taxonomy_common_names" ) ) {
1412 key_index = Configuration.show_taxonomy_common_names;
1414 else if ( key.equals( "show_taxonomy_images" ) ) {
1415 key_index = Configuration.show_taxonomy_images;
1417 else if ( key.equals( "color_according_to_annotation" ) ) {
1418 key_index = Configuration.color_according_to_annotation;
1420 else if ( key.equals( "show_vector_data" ) ) {
1421 key_index = Configuration.show_vector_data;
1423 else if ( key.equals( "show_properties" ) ) {
1424 key_index = Configuration.show_properties;
1426 else if ( key.equals( "show_relation_confidence" ) ) {
1427 key_index = Configuration.show_relation_confidence;
1429 else if ( key.equals( "show_custom_node_shapes" ) ) {
1430 key_index = Configuration.show_custom_node_shapes;
1432 // If we've found the key, set the values
1433 if ( key_index >= 0 ) {
1434 display_options[ key_index ][ 1 ] = ( String ) st.nextElement();
1435 display_options[ key_index ][ 2 ] = ( String ) st.nextElement();
1436 // otherwise, keep looking
1439 if ( key_index == DEPRECATED ) {
1442 else if ( key.equals( "click_to" ) ) {
1443 final String click_to_name = ( String ) st.nextElement();
1444 key_index = getClickToIndex( click_to_name );
1445 if ( key_index >= 0 ) {
1446 clickto_options[ key_index ][ 1 ] = ( String ) st.nextElement();
1448 else if ( key_index == DEPRECATED ) {
1452 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown click-to option: "
1456 else if ( key.equals( "species_color" ) ) {
1457 getSpeciesColors().put( ( String ) st.nextElement(), Color.decode( ( String ) st.nextElement() ) );
1459 else if ( key.equals( "domain_color" ) ) {
1460 getDomainColors().put( ( String ) st.nextElement(), Color.decode( ( String ) st.nextElement() ) );
1462 else if ( key.equals( "annotation_color" ) ) {
1463 getAnnotationColors()
1464 .put( ( String ) st.nextElement(), Color.decode( ( String ) st.nextElement() ) );
1466 else if ( key.equals( "function_color" ) ) {
1467 ForesterUtil.printWarningMessage( Constants.PRG_NAME,
1468 "configuration key [function_color] is deprecated" );
1470 else if ( key.equals( DISPLAY_COLOR_KEY ) ) {
1471 putDisplayColors( ( String ) st.nextElement(), Color.decode( ( String ) st.nextElement() ) );
1473 else if ( key.equals( WEB_LINK_KEY ) ) {
1474 if ( st.countTokens() == 3 ) {
1475 createWebLink( ( String ) st.nextElement(),
1476 ( String ) st.nextElement(),
1477 ( String ) st.nextElement() );
1480 ForesterUtil.printWarningMessage( Constants.PRG_NAME,
1481 "illegal format in configuration file for key [" + key + "]" );
1485 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown configuration key [" + key
1486 + "] in: " + config_filename );
1491 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown configuration key [" + key + "] in: "
1492 + config_filename );
1496 public void setMinConfidenceValue( final double min_confidence_value ) {
1497 _min_confidence_value = min_confidence_value;
1500 public void setNodeLabelDirection( final NODE_LABEL_DIRECTION node_label_direction ) {
1501 _node_label_direction = node_label_direction;
1504 public void setNumberOfDigitsAfterCommaForBranchLengthValue( final short _number_of_digits_after_comma_for_branch_length_values ) {
1505 this._number_of_digits_after_comma_for_branch_length_values = _number_of_digits_after_comma_for_branch_length_values;
1508 public void setNumberOfDigitsAfterCommaForConfidenceValues( final short _number_of_digits_after_comma_for_confidence_values ) {
1509 this._number_of_digits_after_comma_for_confidence_values = _number_of_digits_after_comma_for_confidence_values;
1512 private void setOvMaxHeight( final short ov_max_height ) {
1513 _ov_max_height = ov_max_height;
1516 private void setOvMaxWidth( final short ov_max_width ) {
1517 _ov_max_width = ov_max_width;
1520 private void setOvPlacement( final OVERVIEW_PLACEMENT_TYPE ov_placement ) {
1521 _ov_placement = ov_placement;
1524 public void setPhylogenyGraphicsType( final PHYLOGENY_GRAPHICS_TYPE phylogeny_graphics_type ) {
1525 _phylogeny_graphics_type = phylogeny_graphics_type;
1528 public void setPrintLineWidth( final float print_line_width ) {
1529 _print_line_width = print_line_width;
1532 public void setReplaceUnderscoresInNhParsing( final boolean nh_parsing_replace_underscores ) {
1533 _nh_parsing_replace_underscores = nh_parsing_replace_underscores;
1536 public void setShowBranchLengthValues( final boolean show_branch_length_values ) {
1537 _show_branch_length_values = show_branch_length_values;
1540 public void setShowDefaultNodeShapes( final boolean show_default_node_shapes ) {
1541 _show_default_node_shapes = show_default_node_shapes;
1544 public void setShowDomainLabels( final boolean show_domain_labels ) {
1545 _show_domain_labels = show_domain_labels;
1548 private void setShowOverview( final boolean show_overview ) {
1549 _show_overview = show_overview;
1552 public void setShowScale( final boolean show_scale ) {
1553 _show_scale = show_scale;
1556 public void setTaxonomyColorize( final boolean b ) {
1557 display_options[ color_according_to_species ][ 2 ] = b ? "yes" : "no";
1560 public void setTaxonomyColorizeNodeShapes( final boolean taxonomy_colorize_node_shapes ) {
1561 _taxonomy_colorize_node_shapes = taxonomy_colorize_node_shapes;
1564 public void setUseBranchesWidths( final boolean b ) {
1565 display_options[ width_branches ][ 2 ] = b ? "yes" : "no";
1568 private void setValidatePhyloXmlAgainstSchema( final boolean validate_against_phyloxml_xsd_schema ) {
1569 _validate_against_phyloxml_xsd_schema = validate_against_phyloxml_xsd_schema;
1572 void setWebLinks( final SortedMap<String, WebLink> weblinks ) {
1573 _weblinks = weblinks;
1576 static String getDefaultFontFamilyName() {
1577 return DEFAULT_FONT_FAMILY;
1580 static enum TRIPLET {
1581 TRUE, FALSE, UNKNOWN
1585 NATIVE, CROSSPLATFORM, NIMBUS, UNKNOWN