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 int _default_bootstrap_samples = -1;
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 final static int display_as_phylogram = 0;
100 final static int show_node_names = 1;
101 final static int show_tax_code = 2;
102 final static int show_annotation = 3;
103 final static int write_confidence_values = 4;
104 final static int write_events = 5;
105 final static int color_according_to_species = 6;
106 final static int color_branches = 7;
107 final static int width_branches = 8;
108 final static int show_custom_node_shapes = 9;
109 final static int show_domain_architectures = 10;
110 final static int show_binary_characters = 11;
111 final static int show_binary_character_counts = 12;
112 final static int show_gene_names = 13;
113 final static int show_sequence_acc = 14;
114 final static int display_internal_data = 15;
115 final static int dynamically_hide_data = 16;
116 final static int show_taxonomy_scientific_names = 17;
117 final static int show_taxonomy_common_names = 18;
118 final static int color_according_to_annotation = 19;
119 final static int show_gene_symbols = 20;
120 final static int node_data_popup = 21;
121 final static int show_relation_confidence = 22;
122 final static int show_vector_data = 23;
123 final static int show_taxonomy_images = 24;
124 final static int show_properties = 25;
125 final static int write_confidence_values_sd = 26;
126 // ------------------
128 // ------------------
129 final static int display_node_data = 0;
130 final static int collapse_uncollapse = 1;
131 final static int reroot = 2;
132 final static int subtree = 3;
133 final static int swap = 4;
134 final static int color_subtree = 5;
135 final static int open_seq_web = 6;
136 final static int open_tax_web = 7;
137 final static int cut_subtree = 8;
138 final static int copy_subtree = 9;
139 final static int paste_subtree = 10;
140 final static int delete_subtree_or_node = 11;
141 final static int add_new_node = 12;
142 final static int edit_node_data = 13;
143 final static int blast = 14;
144 // ---------------------------
145 // Display options for trees
146 // ---------------------------
147 // ---------------------------------
148 // Pertaining to the config itself
149 // ---------------------------------
150 // Full path to config (may be URL)
151 String config_filename;
152 String default_config_filename = Constants.DEFAULT_CONFIGURATION_FILE_NAME;
153 final static String display_options[][] = {
154 { "Phylogram", "display", "?" }, { "Node Name", "display", "yes" }, { "Taxonomy Code", "display", "yes" },
155 { "Annotation", "nodisplay", "no" }, { "Confidence Values", "display", "?" }, { "Event", "display", "?" },
156 { "Taxonomy Colorize", "display", "no" }, { "Colorize Branches", "display", "no" },
157 { "Use Branch-Widths", "display", "no" }, { "Show Custom Nodes", "display", "yes" },
158 { "Domains", "nodisplay", "no" }, { "Binary Characters", "nodisplay", "no" },
159 { "Binary Char Counts", "nodisplay", "no" }, { "Prot/Gene Name", "display", "yes" },
160 { "Prot/Gene Acc", "display", "no" }, { "Show Internal Data", "display", "yes" },
161 { "Dyna Hide", "display", "yes" }, { "Taxonomy Scientific", "display", "yes" },
162 { "Taxonomy Common", "display", "no" }, { "Annotation Colorize", "nodisplay", "no" },
163 { "Prot/Gene Symbol", "display", "yes" }, { "Rollover", "display", "yes" },
164 { "Relation Confidence", "display", "no" }, { "Vector Data", "display", "no" },
165 { "Taxonomy Images", "display", "no" }, { "Properties", "display", "no" },
166 { "Confidence StdDev", "display", "no" } };
167 final static String clickto_options[][] = {
168 { "Display Node Data", "display" }, { "Collapse/Uncollapse", "display" }, { "Root/Reroot", "display" },
169 { "Sub/Super Tree", "display" }, { "Swap Descendants", "display" }, { "Colorize Subtree", "display" },
170 { "Open Sequence Web", "display" }, { "Open Taxonomy Web", "display" }, { "Cut Subtree", "display" },
171 { "Copy Subtree", "display" }, { "Paste Subtree", "display" }, { "Delete Subtree/Node", "display" },
172 { "Add New Node", "display" }, { "Edit Node Data", "display" }, { "Blast", "nodisplay" } };
173 // This option is selected in the dropdown
174 int default_clickto = Configuration.display_node_data;
178 TreeColorSet tree_color_set;
182 TreeFontSet tree_font_set;
186 private static Hashtable<String, Color> _species_colors;
190 private static Hashtable<String, Color> _domain_colors;
194 private static Hashtable<String, Color> _annotation_colors;
195 boolean verbose = Constants.VERBOSE_DEFAULT;
196 private NODE_LABEL_DIRECTION _node_label_direction = NODE_LABEL_DIRECTION.HORIZONTAL;
197 private Color _gui_background_color = Constants.GUI_BACKGROUND_DEFAULT;
198 private Color _gui_checkbox_text_color = Constants.CHECKBOX_TEXT_COLOR_DEFAULT;
199 private Color _gui_checkbox_and_button_active_color = Constants.CHECKBOX_AND_BUTTON_ACTIVE_COLOR_DEFAULT;
200 private Color _gui_button_text_color = Constants.BUTTON_TEXT_COLOR_DEFAULT;
201 private Color _gui_button_background_color = Constants.BUTTON_BACKGROUND_COLOR_DEFAULT;
202 private Color _gui_menu_background_color = Constants.MENU_BACKGROUND_COLOR_DEFAULT;
203 private Color _gui_menu_text_color = Constants.MENU_TEXT_COLOR_DEFAULT;
204 private Color _gui_button_border_color = Constants.BUTTON_BORDER_COLOR_DEFAULT;
205 private Color _domain_structure_font_color = Constants.DOMAIN_STRUCTURE_FONT_COLOR_DEFAULT;
206 private Color _domain_structure_base_color = Constants.DOMAIN_STRUCTURE_BASE_COLOR_DEFAULT;
207 private static String DEFAULT_FONT_FAMILY = "";
209 for( final String font_name : Constants.DEFAULT_FONT_CHOICES ) {
210 if ( Arrays.binarySearch( AptxUtil.getAvailableFontFamiliesSorted(), font_name ) >= 0 ) {
211 DEFAULT_FONT_FAMILY = font_name;
215 if ( ForesterUtil.isEmpty( DEFAULT_FONT_FAMILY ) ) {
216 DEFAULT_FONT_FAMILY = Constants.DEFAULT_FONT_CHOICES[ Constants.DEFAULT_FONT_CHOICES.length - 1 ];
220 public Configuration() {
221 this( null, false, false, false );
224 public Configuration( final String cf, final boolean is_url, final boolean is_applet, final boolean verbose ) {
225 if ( ForesterUtil.isEmpty( cf ) ) {
226 config_filename = default_config_filename;
229 config_filename = cf;
231 setWebLinks( new TreeMap<String, WebLink>() );
232 setDisplayColors( new TreeMap<String, Color>() );
233 config_filename = config_filename.trim();
236 // If URL, open accordingly
238 u = new URL( config_filename );
240 final InputStreamReader isr = new InputStreamReader( u.openStream() );
241 final BufferedReader bf = new BufferedReader( isr );
244 ForesterUtil.programMessage( Constants.PRG_NAME, "successfully read from configuration url ["
245 + config_filename + "]" );
247 catch ( final Exception e ) {
248 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "failed to read configuration from ["
249 + config_filename + "]: " + e.getLocalizedMessage() );
252 catch ( final Exception e ) {
253 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "cannot find or open configuration url ["
254 + config_filename + "]" );
258 // Otherwise, open as a file
259 File f = new File( config_filename );
261 f = new File( config_filename + ".txt" );
263 if ( f.exists() && f.canRead() ) {
265 final BufferedReader bf = new BufferedReader( new FileReader( f ) );
269 catch ( final Exception e ) {
271 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "failed to read configuration from ["
272 + config_filename + "]: " + e );
278 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "cannot find or open configuration file ["
279 + config_filename + "]" );
285 private void createWebLink( final String url_str, final String desc, final String source_identifier ) {
286 WebLink weblink = null;
289 weblink = new WebLink( new URL( url_str.trim() ), desc.trim(), source_identifier.trim() );
291 catch ( final MalformedURLException e ) {
292 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "could not create URL from [" + url_str + "]" );
295 if ( !ex && ( weblink != null ) ) {
296 getWebLinks().put( weblink.getSourceIdentifier().toLowerCase(), weblink );
300 boolean displaySequenceRelations() {
301 return _display_sequence_relations;
304 boolean doCheckOption( final int which ) {
305 return ( display_options[ which ][ 2 ].equalsIgnoreCase( "yes" ) )
306 || ( display_options[ which ][ 2 ].equalsIgnoreCase( "true" ) );
309 boolean doDisplayClickToOption( final int which ) {
310 return clickto_options[ which ][ 1 ].equalsIgnoreCase( "display" );
313 boolean doDisplayOption( final int which ) {
314 return display_options[ which ][ 1 ].equalsIgnoreCase( "display" );
318 * Will attempt to use the phylogeny to determine whether to check
319 * this or not (e.g. phylogram)
322 boolean doGuessCheckOption( final int which ) {
323 return display_options[ which ][ 2 ].equals( "?" );
326 Map<String, Color> getAnnotationColors() {
327 if ( _annotation_colors == null ) {
328 _annotation_colors = new Hashtable<String, Color>();
330 return _annotation_colors;
333 public String getBaseFontFamilyName() {
334 return _base_font_family_name;
337 int getBaseFontSize() {
338 return _base_font_size;
341 CLADOGRAM_TYPE getCladogramType() {
342 return _cladogram_type;
345 private int getClickToIndex( final String name ) {
347 if ( name.equals( "edit_info" ) ) {
348 index = Configuration.display_node_data;
350 .printWarningMessage( Constants.PRG_NAME,
351 "configuration key [edit_info] is deprecated, use [display node data] instead" );
353 else if ( name.equals( "display_node_data" ) ) {
354 index = Configuration.display_node_data;
356 else if ( name.equals( "collapse_uncollapse" ) ) {
357 index = Configuration.collapse_uncollapse;
359 else if ( name.equals( "reroot" ) ) {
360 index = Configuration.reroot;
362 else if ( name.equals( "subtree" ) ) {
363 index = Configuration.subtree;
365 else if ( name.equals( "swap" ) ) {
366 index = Configuration.swap;
368 else if ( name.equals( "display_sequences" ) ) {
370 .printWarningMessage( Constants.PRG_NAME, "configuration key [display_sequences] is deprecated" );
373 else if ( name.equals( "open_seq_web" ) ) {
374 index = Configuration.open_seq_web;
376 else if ( name.equals( "open_tax_web" ) ) {
377 index = Configuration.open_tax_web;
379 else if ( name.equals( "cut_subtree" ) ) {
380 index = Configuration.cut_subtree;
382 else if ( name.equals( "copy_subtree" ) ) {
383 index = Configuration.copy_subtree;
385 else if ( name.equals( "paste_subtree" ) ) {
386 index = Configuration.paste_subtree;
388 else if ( name.equals( "delete" ) ) {
389 index = Configuration.delete_subtree_or_node;
391 else if ( name.equals( "add_new_node" ) ) {
392 index = Configuration.add_new_node;
394 else if ( name.equals( "edit_node_data" ) ) {
395 index = Configuration.edit_node_data;
397 else if ( name.equals( "display_node_popup" ) ) {
398 ForesterUtil.printWarningMessage( Constants.PRG_NAME,
399 "configuration key [display_node_popup] is deprecated" );
402 else if ( name.equals( "custom_option" ) ) {
403 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "configuration key [custom_option] is deprecated" );
406 else if ( name.equals( "color_subtree" ) ) {
407 index = Configuration.color_subtree;
409 else if ( name.equals( "go_to_swiss_prot" ) ) {
410 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "configuration key [go_to_swiss_prot] is deprecated" );
416 int getClickToOptionsCount() {
417 return clickto_options.length;
420 String getClickToTitle( final int which ) {
421 return clickto_options[ which ][ 0 ];
424 public int getDefaultBootstrapSamples() {
425 return _default_bootstrap_samples;
428 int getDefaultDisplayClicktoOption() {
429 return default_clickto;
432 public NodeFill getDefaultNodeFill() {
433 return _default_node_fill;
436 public NodeShape getDefaultNodeShape() {
437 return _default_node_shape;
440 public short getDefaultNodeShapeSize() {
441 return _default_node_shape_size;
444 SortedMap<String, Color> getDisplayColors() {
445 return _display_colors;
448 String getDisplayTitle( final int which ) {
449 return display_options[ which ][ 0 ];
452 Map<String, Color> getDomainColors() {
453 if ( _domain_colors == null ) {
454 _domain_colors = new Hashtable<String, Color>();
456 return _domain_colors;
459 public Color getDomainStructureBaseColor() {
460 return _domain_structure_base_color;
463 public Color getDomainStructureFontColor() {
464 return _domain_structure_font_color;
467 int getGraphicsExportX() {
468 return _graphics_export_x;
471 int getGraphicsExportY() {
472 return _graphics_export_y;
475 Color getGuiBackgroundColor() {
476 return _gui_background_color;
479 Color getGuiButtonBackgroundColor() {
480 return _gui_button_background_color;
483 Color getGuiButtonBorderColor() {
484 return _gui_button_border_color;
487 Color getGuiButtonTextColor() {
488 return _gui_button_text_color;
491 Color getGuiCheckboxAndButtonActiveColor() {
492 return _gui_checkbox_and_button_active_color;
495 Color getGuiCheckboxTextColor() {
496 return _gui_checkbox_text_color;
499 Color getGuiMenuBackgroundColor() {
500 return _gui_menu_background_color;
503 Color getGuiMenuTextColor() {
504 return _gui_menu_text_color;
507 double getMinConfidenceValue() {
508 return _min_confidence_value;
511 NODE_LABEL_DIRECTION getNodeLabelDirection() {
512 return _node_label_direction;
515 short getNumberOfDigitsAfterCommaForBranchLengthValues() {
516 return _number_of_digits_after_comma_for_branch_length_values;
519 short getNumberOfDigitsAfterCommaForConfidenceValues() {
520 return _number_of_digits_after_comma_for_confidence_values;
523 short getOvMaxHeight() {
524 return _ov_max_height;
527 short getOvMaxWidth() {
528 return _ov_max_width;
531 OVERVIEW_PLACEMENT_TYPE getOvPlacement() {
532 return _ov_placement;
535 PHYLOGENY_GRAPHICS_TYPE getPhylogenyGraphicsType() {
536 return _phylogeny_graphics_type;
539 float getPrintLineWidth() {
540 return _print_line_width;
543 Hashtable<String, Color> getSpeciesColors() {
544 if ( _species_colors == null ) {
545 _species_colors = new Hashtable<String, Color>();
547 return _species_colors;
550 TreeColorSet getTreeColorSet() {
554 TreeFontSet getTreeFontSet() {
558 WebLink getWebLink( final String source ) {
559 return getWebLinks().get( source );
562 Map<String, WebLink> getWebLinks() {
566 public boolean isAbbreviateScientificTaxonNames() {
567 return _abbreviate_scientific_names;
570 boolean isAntialiasScreen() {
571 return _antialias_screen;
574 public boolean isBackgroundColorGradient() {
575 return _background_color_gradient;
578 public boolean isColorLabelsSameAsParentBranch() {
579 return _color_labels_same_as_parent_branch;
583 * Convenience method.
585 * @return true if value in configuration file was 'yes'
587 boolean isDrawAsPhylogram() {
588 return doCheckOption( display_as_phylogram );
591 boolean isEditable() {
595 boolean isExtractPfamTaxonomyCodesInNhParsing() {
596 return _nh_parsing_extract_pfam_taxonomy_codes;
599 boolean isHasWebLink( final String source ) {
600 return getWebLinks().containsKey( source );
604 * Only used by ArchaeoptryxE.
607 boolean isHideControlPanelAndMenubar() {
608 return _hide_controls_and_menus;
611 boolean isInternalNumberAreConfidenceForNhParsing() {
612 return _internal_number_are_confidence_for_nh_parsing;
615 boolean isReplaceUnderscoresInNhParsing() {
616 return _nh_parsing_replace_underscores;
619 boolean isShowBranchLengthValues() {
620 return _show_branch_length_values;
623 public boolean isShowDefaultNodeShapes() {
624 return _show_default_node_shapes;
627 public boolean isShowDomainLabels() {
628 return _show_domain_labels;
631 boolean isShowOverview() {
632 return _show_overview;
635 boolean isShowScale() {
639 public boolean isTaxonomyColorizeNodeShapes() {
640 return _taxonomy_colorize_node_shapes;
643 final boolean isUseNativeUI() {
644 if ( ( _ui == UI.UNKNOWN ) && AptxUtil.isMac() && AptxUtil.isJava15() ) {
647 return _ui == UI.NATIVE;
651 * Only used by ArchaeoptryxE.
654 boolean isUseTabbedDisplay() {
655 return _use_tabbed_display;
658 boolean isValidatePhyloXmlAgainstSchema() {
659 return _validate_against_phyloxml_xsd_schema;
662 private boolean parseBoolean( final String str ) {
663 final String my_str = str.trim().toLowerCase();
664 if ( my_str.equals( "yes" ) || my_str.equals( "true" ) ) {
667 else if ( my_str.equals( "no" ) || my_str.equals( "false" ) ) {
671 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "could not parse boolean value from [" + str + "]" );
676 private double parseDouble( final String str ) {
679 d = Double.parseDouble( str );
681 catch ( final Exception e ) {
682 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "could not parse double from [" + str + "]" );
688 private float parseFloat( final String str ) {
691 f = Float.parseFloat( str );
693 catch ( final Exception e ) {
694 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "could not parse float from [" + str + "]" );
700 private int parseInt( final String str ) {
703 i = Integer.parseInt( str );
705 catch ( final Exception e ) {
706 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "could not parse integer from [" + str + "]" );
712 private short parseShort( final String str ) {
715 i = Short.parseShort( str );
717 catch ( final Exception e ) {
718 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "could not parse short from [" + str + "]" );
724 private void processFontFamily( final StringTokenizer st ) {
725 setBaseFontFamilyName( "" );
726 final String font_str = ( ( String ) st.nextElement() ).trim();
727 final String[] fonts = font_str.split( ",+" );
728 for( String font : fonts ) {
729 font = font.replace( '_', ' ' ).trim();
730 if ( Arrays.binarySearch( AptxUtil.getAvailableFontFamiliesSorted(), font ) >= 0 ) {
731 setBaseFontFamilyName( font );
737 public void putDisplayColors( final String key, final Color color ) {
738 getDisplayColors().put( key, color );
742 * read each line of config file, process non-comment lines
743 * @throws IOException
745 private void readConfig( final BufferedReader conf_in ) throws IOException {
748 line = conf_in.readLine();
749 if ( line != null ) {
751 // skip comments and blank lines
752 if ( !line.startsWith( "#" ) && ( !ForesterUtil.isEmpty( line ) ) ) {
753 // convert runs of spaces to tabs
754 line = line.replaceAll( "\\s+", "\t" );
755 final StringTokenizer st = new StringTokenizer( line, "\t" );
759 } while ( line != null );
762 public void setAbbreviateScientificTaxonNames( final boolean abbreviate_scientific_names ) {
763 _abbreviate_scientific_names = abbreviate_scientific_names;
766 private void setAntialiasScreen( final boolean antialias_screen ) {
767 _antialias_screen = antialias_screen;
770 public void setBackgroundColorGradient( final boolean background_color_gradient ) {
771 _background_color_gradient = background_color_gradient;
774 public void setBaseFontFamilyName( final String base_font_family_name ) {
775 _base_font_family_name = base_font_family_name;
778 public void setBaseFontSize( final int base_font_size ) {
779 _base_font_size = base_font_size;
782 private void setCladogramType( final CLADOGRAM_TYPE cladogram_type ) {
783 _cladogram_type = cladogram_type;
786 public void setColorizeBranches( final boolean b ) {
787 display_options[ color_branches ][ 2 ] = b ? "yes" : "no";
790 public void setColorLabelsSameAsParentBranch( final boolean color_labels_same_as_parent_branch ) {
791 _color_labels_same_as_parent_branch = color_labels_same_as_parent_branch;
794 private void setDefaultBootstrapSamples( final int default_bootstrap_samples ) {
795 _default_bootstrap_samples = default_bootstrap_samples;
798 public void setDefaultNodeFill( final NodeFill default_node_fill ) {
799 _default_node_fill = default_node_fill;
802 public void setDefaultNodeShape( final NodeShape default_node_shape ) {
803 _default_node_shape = default_node_shape;
806 public void setDefaultNodeShapeSize( final short default_node_shape_size ) {
807 _default_node_shape_size = default_node_shape_size;
810 public void setDisplayAsPhylogram( final boolean b ) {
811 display_options[ display_as_phylogram ][ 2 ] = b ? "yes" : "no";
814 public void setDisplayColors( final SortedMap<String, Color> display_colors ) {
815 _display_colors = display_colors;
818 public void setDisplayConfidenceValues( final boolean b ) {
819 display_options[ write_confidence_values ][ 2 ] = b ? "yes" : "no";
822 public void setDisplayInternalData( final boolean b ) {
823 display_options[ display_internal_data ][ 2 ] = b ? "yes" : "no";
826 public void setDisplayNodeNames( final boolean b ) {
827 display_options[ show_node_names ][ 2 ] = b ? "yes" : "no";
830 public void setDisplaySequenceAcc( final boolean b ) {
831 display_options[ show_sequence_acc ][ 2 ] = b ? "yes" : "no";
834 public void setDisplaySequenceNames( final boolean b ) {
835 display_options[ show_gene_names ][ 2 ] = b ? "yes" : "no";
838 public void setDisplaySequenceRelations( final boolean display_sequence_relations ) {
839 _display_sequence_relations = display_sequence_relations;
842 public void setDisplaySequenceSymbols( final boolean b ) {
843 display_options[ show_gene_symbols ][ 2 ] = b ? "yes" : "no";
846 public void setDisplayTaxonomyCode( final boolean b ) {
847 display_options[ show_tax_code ][ 2 ] = b ? "yes" : "no";
850 public void setDisplayTaxonomyCommonNames( final boolean b ) {
851 display_options[ show_taxonomy_common_names ][ 2 ] = b ? "yes" : "no";
854 public void setDisplayTaxonomyImages( final boolean b ) {
855 display_options[ show_taxonomy_images ][ 2 ] = b ? "yes" : "no";
858 public void setDisplayTaxonomyScientificNames( final boolean b ) {
859 display_options[ show_taxonomy_scientific_names ][ 2 ] = b ? "yes" : "no";
862 public void setDynamicallyHideData( final boolean b ) {
863 display_options[ dynamically_hide_data ][ 2 ] = b ? "yes" : "no";
866 private void setEditable( final boolean editable ) {
867 _editable = editable;
870 public void setExtractPfamTaxonomyCodesInNhParsing( final boolean nh_parsing_extract_pfam_taxonomy_codes ) {
871 _nh_parsing_extract_pfam_taxonomy_codes = nh_parsing_extract_pfam_taxonomy_codes;
874 private void setGraphicsExportX( final int graphics_export_x ) {
875 _graphics_export_x = graphics_export_x;
878 private void setGraphicsExportY( final int graphics_export_y ) {
879 _graphics_export_y = graphics_export_y;
882 private void setInternalNumberAreConfidenceForNhParsing( final boolean internal_number_are_confidence_for_nh_parsing ) {
883 _internal_number_are_confidence_for_nh_parsing = internal_number_are_confidence_for_nh_parsing;
887 * Set a key-value(s) tuple
889 private void setKeyValue( final StringTokenizer st ) {
890 String key = ( String ) st.nextElement();
891 key = key.replace( ':', ' ' );
893 key = key.toLowerCase();
894 // Handle single value settings first:
895 if ( key.equals( "default_click_to" ) ) {
896 final String clickto_name = ( String ) st.nextElement();
897 default_clickto = getClickToIndex( clickto_name );
898 if ( default_clickto == -1 ) {
899 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "invalid value [" + clickto_name
900 + "] for [default_click_to]" );
903 else if ( default_clickto == DEPRECATED ) {
907 else if ( key.equals( "native_ui" ) ) {
908 final String my_str = ( ( String ) st.nextElement() ).trim().toLowerCase();
909 if ( my_str.equals( "yes" ) || my_str.equals( "true" ) ) {
912 else if ( my_str.equals( "no" ) || my_str.equals( "false" ) ) {
913 _ui = UI.CROSSPLATFORM;
915 else if ( my_str.equals( "?" ) ) {
919 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "could not parse yes/no/? value from [" + my_str
924 else if ( key.equals( VALIDATE_AGAINST_PHYLOXML_XSD_SCHEMA ) ) {
925 setValidatePhyloXmlAgainstSchema( parseBoolean( ( String ) st.nextElement() ) );
927 else if ( key.equals( "antialias_screen" ) ) {
928 setAntialiasScreen( parseBoolean( ( String ) st.nextElement() ) );
930 else if ( key.equals( "phylogeny_graphics_type" ) ) {
931 final String type_str = ( ( String ) st.nextElement() ).trim();
932 if ( type_str.equalsIgnoreCase( PHYLOGENY_GRAPHICS_TYPE.CONVEX.toString() ) ) {
933 setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CONVEX );
935 else if ( type_str.equalsIgnoreCase( PHYLOGENY_GRAPHICS_TYPE.CURVED.toString() ) ) {
936 setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CURVED );
938 else if ( type_str.equalsIgnoreCase( PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE.toString() ) ) {
939 setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE );
941 else if ( type_str.equalsIgnoreCase( PHYLOGENY_GRAPHICS_TYPE.ROUNDED.toString() ) ) {
942 setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.ROUNDED );
944 else if ( type_str.equalsIgnoreCase( PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR.toString() ) ) {
945 setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR );
947 else if ( type_str.equalsIgnoreCase( PHYLOGENY_GRAPHICS_TYPE.TRIANGULAR.toString() ) ) {
948 setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.TRIANGULAR );
950 else if ( type_str.equalsIgnoreCase( PHYLOGENY_GRAPHICS_TYPE.UNROOTED.toString() ) ) {
951 setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.UNROOTED );
953 else if ( type_str.equalsIgnoreCase( PHYLOGENY_GRAPHICS_TYPE.CIRCULAR.toString() ) ) {
954 setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CIRCULAR );
957 setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR );
958 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown value [" + type_str
959 + "] for [phylogeny_graphics_type]" );
962 else if ( key.equals( "min_confidence_value" ) ) {
963 final String mcv_str = ( ( String ) st.nextElement() ).trim();
964 final double d = parseDouble( mcv_str );
965 setMinConfidenceValue( d );
967 else if ( key.equals( "font_family" ) ) {
968 processFontFamily( st );
970 else if ( key.equals( "font_size" ) ) {
971 final String size_str = ( ( String ) st.nextElement() ).trim();
972 final int i = parseInt( size_str );
973 setBaseFontSize( i );
975 else if ( key.equals( "graphics_export_x" ) ) {
976 final String str = ( ( String ) st.nextElement() ).trim();
977 final int i = parseInt( str );
978 setGraphicsExportX( i );
980 else if ( key.equals( "graphics_export_y" ) ) {
981 final String str = ( ( String ) st.nextElement() ).trim();
982 final int i = parseInt( str );
983 setGraphicsExportY( i );
985 else if ( key.equals( "pdf_export_line_width" ) ) {
986 final String str = ( ( String ) st.nextElement() ).trim();
987 final float f = parseFloat( str );
989 setPrintLineWidth( f );
992 ForesterUtil.printWarningMessage( Constants.PRG_NAME,
993 "value for [pdf_export_line_width] cannot be zero or negative" );
996 else if ( key.equals( "default_number_of_bootstrap_resamples" ) ) {
997 final String str = ( ( String ) st.nextElement() ).trim();
998 final int i = parseInt( str );
1000 setDefaultBootstrapSamples( i );
1004 .printWarningMessage( Constants.PRG_NAME,
1005 "value for [default_number_of_bootstrap_resamples] cannot be negative" );
1008 else if ( key.equals( "show_scale" ) ) {
1009 setShowScale( parseBoolean( ( String ) st.nextElement() ) );
1011 else if ( key.equals( "show_overview" ) ) {
1012 setShowOverview( parseBoolean( ( String ) st.nextElement() ) );
1014 else if ( key.equals( "show_branch_length_values" ) ) {
1015 setShowBranchLengthValues( parseBoolean( ( String ) st.nextElement() ) );
1017 else if ( key.equals( "background_gradient" ) ) {
1018 setBackgroundColorGradient( parseBoolean( ( String ) st.nextElement() ) );
1020 else if ( key.equals( "color_labels_same_as_branch_length_values" ) ) {
1021 setColorLabelsSameAsParentBranch( parseBoolean( ( String ) st.nextElement() ) );
1023 else if ( key.equals( "show_domain_labels" ) ) {
1024 setShowDomainLabels( parseBoolean( ( String ) st.nextElement() ) );
1026 else if ( key.equals( "abbreviate_scientific_names" ) ) {
1027 setAbbreviateScientificTaxonNames( parseBoolean( ( String ) st.nextElement() ) );
1029 else if ( key.equals( "cladogram_type" ) ) {
1030 final String type_str = ( ( String ) st.nextElement() ).trim();
1031 if ( type_str.equalsIgnoreCase( Options.CLADOGRAM_TYPE.NON_LINED_UP.toString() ) ) {
1032 setCladogramType( Options.CLADOGRAM_TYPE.NON_LINED_UP );
1034 else if ( type_str.equalsIgnoreCase( Options.CLADOGRAM_TYPE.EXT_NODE_SUM_DEP.toString() ) ) {
1035 setCladogramType( Options.CLADOGRAM_TYPE.EXT_NODE_SUM_DEP );
1037 else if ( type_str.equalsIgnoreCase( Options.CLADOGRAM_TYPE.TOTAL_NODE_SUM_DEP.toString() ) ) {
1038 setCladogramType( Options.CLADOGRAM_TYPE.TOTAL_NODE_SUM_DEP );
1041 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown value [" + type_str
1042 + "] for [cladogram_type]" );
1045 else if ( key.equals( "non_lined_up_cladogram" ) ) {
1047 .printWarningMessage( Constants.PRG_NAME,
1048 "configuration key [non_lined_up_cladogram] is deprecated, use [cladogram_type] instead" );
1050 else if ( key.equals( "hide_controls_and_menus" ) ) {
1051 _hide_controls_and_menus = parseBoolean( ( String ) st.nextElement() );
1053 else if ( key.equals( "use_tabbed_display" ) ) {
1054 _use_tabbed_display = parseBoolean( ( String ) st.nextElement() );
1056 else if ( key.equals( "overview_width" ) ) {
1057 final short i = parseShort( ( ( String ) st.nextElement() ).trim() );
1060 else if ( key.equals( "overview_height" ) ) {
1061 final short i = parseShort( ( ( String ) st.nextElement() ).trim() );
1062 setOvMaxHeight( i );
1064 else if ( key.equals( "overview_placement_type" ) ) {
1065 final String type_str = ( ( String ) st.nextElement() ).trim();
1066 if ( type_str.equalsIgnoreCase( OVERVIEW_PLACEMENT_TYPE.UPPER_LEFT.toTag() ) ) {
1067 setOvPlacement( OVERVIEW_PLACEMENT_TYPE.UPPER_LEFT );
1069 else if ( type_str.equalsIgnoreCase( OVERVIEW_PLACEMENT_TYPE.UPPER_RIGHT.toTag() ) ) {
1070 setOvPlacement( OVERVIEW_PLACEMENT_TYPE.UPPER_RIGHT );
1072 else if ( type_str.equalsIgnoreCase( OVERVIEW_PLACEMENT_TYPE.LOWER_LEFT.toTag() ) ) {
1073 setOvPlacement( OVERVIEW_PLACEMENT_TYPE.LOWER_LEFT );
1075 else if ( type_str.equalsIgnoreCase( OVERVIEW_PLACEMENT_TYPE.LOWER_RIGHT.toTag() ) ) {
1076 setOvPlacement( OVERVIEW_PLACEMENT_TYPE.LOWER_RIGHT );
1079 setOvPlacement( OVERVIEW_PLACEMENT_TYPE.UPPER_LEFT );
1080 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown value [" + type_str
1081 + "] for [overview_placement_type]" );
1084 else if ( key.equals( "node_label_direction" ) ) {
1085 final String type_str = ( ( String ) st.nextElement() ).trim();
1086 if ( type_str.equalsIgnoreCase( NODE_LABEL_DIRECTION.HORIZONTAL.toString() ) ) {
1087 setNodeLabelDirection( NODE_LABEL_DIRECTION.HORIZONTAL );
1089 else if ( type_str.equalsIgnoreCase( NODE_LABEL_DIRECTION.RADIAL.toString() ) ) {
1090 setNodeLabelDirection( NODE_LABEL_DIRECTION.RADIAL );
1093 setNodeLabelDirection( NODE_LABEL_DIRECTION.HORIZONTAL );
1094 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown value [" + type_str
1095 + "] for [node_label_direction]" );
1098 else if ( key.equals( "branch_length_value_digits" ) ) {
1099 final short i = parseShort( ( ( String ) st.nextElement() ).trim() );
1101 setNumberOfDigitsAfterCommaForBranchLengthValue( i );
1104 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "illegal value [" + i
1105 + "] for [branch_length_value_digits]" );
1108 else if ( key.equals( "confidence_value_digits" ) ) {
1109 final short i = parseShort( ( ( String ) st.nextElement() ).trim() );
1111 setNumberOfDigitsAfterCommaForConfidenceValues( i );
1114 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "illegal value [" + i
1115 + "] for [confidence_value_digits]" );
1118 else if ( key.equals( "allow_editing" ) ) {
1119 setEditable( parseBoolean( ( String ) st.nextElement() ) );
1121 else if ( key.equals( "display_sequence_relations" ) ) {
1122 setDisplaySequenceRelations( parseBoolean( ( String ) st.nextElement() ) );
1124 else if ( key.equals( "replace_underscores_in_nh_parsing" ) ) {
1125 final boolean r = parseBoolean( ( String ) st.nextElement() );
1126 if ( r && isExtractPfamTaxonomyCodesInNhParsing() ) {
1128 .printWarningMessage( Constants.PRG_NAME,
1129 "attempt to extract taxonomies and replace underscores at the same time" );
1132 setReplaceUnderscoresInNhParsing( r );
1135 else if ( key.equals( "extract_taxonomy_codes_in_nh_parsing" ) ) {
1136 final boolean e = parseBoolean( ( String ) st.nextElement() );
1137 if ( e && isReplaceUnderscoresInNhParsing() ) {
1139 .printWarningMessage( Constants.PRG_NAME,
1140 "attempt to extract taxonomies and replace underscores at the same time" );
1143 setExtractPfamTaxonomyCodesInNhParsing( e );
1146 else if ( key.equals( "internal_labels_are_confidence_values" ) ) {
1147 setInternalNumberAreConfidenceForNhParsing( parseBoolean( ( String ) st.nextElement() ) );
1149 else if ( key.equals( "gui_background_color" ) ) {
1150 _gui_background_color = Color.decode( ( String ) st.nextElement() );
1152 else if ( key.equals( "gui_checkbox_text_color" ) ) {
1153 _gui_checkbox_text_color = Color.decode( ( String ) st.nextElement() );
1155 else if ( key.equals( "gui_checkbox_and_button_active_color" ) ) {
1156 _gui_checkbox_and_button_active_color = Color.decode( ( String ) st.nextElement() );
1158 else if ( key.equals( "gui_button_text_color" ) ) {
1159 _gui_button_text_color = Color.decode( ( String ) st.nextElement() );
1161 else if ( key.equals( "gui_button_background_color" ) ) {
1162 _gui_button_background_color = Color.decode( ( String ) st.nextElement() );
1164 else if ( key.equals( "gui_menu_background_color" ) ) {
1165 _gui_menu_background_color = Color.decode( ( String ) st.nextElement() );
1167 else if ( key.equals( "gui_menu_text_color" ) ) {
1168 _gui_menu_text_color = Color.decode( ( String ) st.nextElement() );
1170 else if ( key.equals( "gui_button_border_color" ) ) {
1171 _gui_button_border_color = Color.decode( ( String ) st.nextElement() );
1173 else if ( key.equals( "domain_structure_font_color" ) ) {
1174 _domain_structure_font_color = Color.decode( ( String ) st.nextElement() );
1176 else if ( key.equals( "domain_structure_base_color" ) ) {
1177 _domain_structure_base_color = Color.decode( ( String ) st.nextElement() );
1179 else if ( key.equals( "show_default_node_shapes" ) ) {
1180 setShowDefaultNodeShapes( parseBoolean( ( ( String ) st.nextElement() ).trim() ) );
1182 else if ( key.equals( "default_node_size" ) ) {
1183 final short i = parseShort( ( ( String ) st.nextElement() ).trim() );
1184 setDefaultNodeShapeSize( i );
1186 else if ( key.equals( "default_node_fill" ) ) {
1187 final String fill_str = ( ( String ) st.nextElement() ).trim();
1188 if ( fill_str.equalsIgnoreCase( NodeVisualization.NodeFill.NONE.toString() ) ) {
1189 setDefaultNodeFill( NodeFill.NONE );
1191 else if ( fill_str.equalsIgnoreCase( NodeVisualization.NodeFill.GRADIENT.toString() ) ) {
1192 setDefaultNodeFill( NodeFill.GRADIENT );
1194 else if ( fill_str.equalsIgnoreCase( NodeVisualization.NodeFill.SOLID.toString() ) ) {
1195 setDefaultNodeFill( NodeFill.SOLID );
1198 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown value [" + fill_str
1199 + "] for [default_node_fill]" );
1202 else if ( key.equals( "default_node_shape" ) ) {
1203 final String shape_str = ( ( String ) st.nextElement() ).trim();
1204 if ( shape_str.equalsIgnoreCase( NodeVisualization.NodeShape.CIRCLE.toString() ) ) {
1205 setDefaultNodeShape( NodeShape.CIRCLE );
1207 else if ( shape_str.equalsIgnoreCase( NodeVisualization.NodeShape.RECTANGLE.toString() ) ) {
1208 setDefaultNodeShape( NodeShape.RECTANGLE );
1211 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown value [" + shape_str
1212 + "] for [default_node_shape]" );
1215 else if ( key.equals( "taxonomy_colorize_node_shapes" ) ) {
1216 setTaxonomyColorizeNodeShapes( parseBoolean( ( String ) st.nextElement() ) );
1218 else if ( st.countTokens() >= 2 ) { // counts the tokens that are not
1221 if ( key.equals( "use_real_br_lengths" ) || key.equals( "phylogram" ) ) {
1222 key_index = Configuration.display_as_phylogram;
1223 if ( key.equals( "use_real_br_lengths" ) ) {
1225 .printWarningMessage( Constants.PRG_NAME,
1226 "configuration key [use_real_br_lengths] is deprecated, use [phylogram] instead" );
1229 else if ( key.equals( "rollover" ) ) {
1230 key_index = Configuration.node_data_popup;
1232 else if ( key.equals( "color_according_to_species" ) ) {
1233 key_index = Configuration.color_according_to_species;
1235 else if ( key.equals( "show_node_names" ) ) {
1236 key_index = Configuration.show_node_names;
1238 else if ( key.equals( "show_taxonomy" ) || key.equals( "show_taxonomy_code" ) ) {
1239 key_index = Configuration.show_tax_code;
1240 if ( key.equals( "show_taxonomy" ) ) {
1242 .printWarningMessage( Constants.PRG_NAME,
1243 "configuration key [show_taxonomy] is deprecated, use [show_taxonomy_code] instead" );
1246 else if ( key.equals( "write_br_length_values" ) ) {
1247 ForesterUtil.printWarningMessage( Constants.PRG_NAME,
1248 "configuration key [write_br_length_values] is deprecated" );
1249 key_index = DEPRECATED;
1251 else if ( key.equals( "write_bootstrap_values" ) || key.equals( "write_confidence_values" ) ) {
1252 key_index = Configuration.write_confidence_values;
1253 if ( key.equals( "write_bootstrap_values" ) ) {
1255 .printWarningMessage( Constants.PRG_NAME,
1256 "configuration key [write_bootstrap_values] is deprecated, use [write_confidence_values] instead" );
1259 else if ( key.equals( "write_events" ) || key.equals( "write_dup_spec" ) ) {
1260 key_index = Configuration.write_events;
1261 if ( key.equals( "write_dup_spec" ) ) {
1263 .printWarningMessage( Constants.PRG_NAME,
1264 "configuration key [write_dup_spec] is deprecated, use [write_events] instead" );
1267 else if ( key.equals( "color_branches" ) ) {
1268 key_index = Configuration.color_branches;
1270 else if ( key.equals( "width_branches" ) ) {
1271 key_index = Configuration.width_branches;
1273 else if ( key.equals( "color_orthologous" ) ) {
1274 ForesterUtil.printWarningMessage( Constants.PRG_NAME,
1275 "configuration key [color_orthologous] is deprecated" );
1277 else if ( key.equals( "color_subtree_neighbors" ) ) {
1278 ForesterUtil.printWarningMessage( Constants.PRG_NAME,
1279 "configuration key [color_subtree_neighbors] is deprecated" );
1281 else if ( key.equals( "color_super_orthologous" ) ) {
1282 ForesterUtil.printWarningMessage( Constants.PRG_NAME,
1283 "configuration key [color_super_orthologous] is deprecated" );
1285 else if ( key.equals( "mark_nodes_with_box" ) ) {
1286 ForesterUtil.printWarningMessage( Constants.PRG_NAME,
1287 "configuration key [mark_nodes_with_box] is deprecated" );
1288 key_index = DEPRECATED;
1290 else if ( key.equals( "show_domain_architectures" ) ) {
1291 key_index = Configuration.show_domain_architectures;
1293 else if ( key.equals( "show_annotations" ) ) {
1294 key_index = Configuration.show_annotation;
1296 else if ( key.equals( "show_binary_characters" ) ) {
1297 key_index = Configuration.show_binary_characters;
1299 else if ( key.equals( "show_binary_character_counts" ) ) {
1300 key_index = Configuration.show_binary_character_counts;
1302 else if ( key.equals( "show_gene_names" ) ) {
1303 key_index = Configuration.show_gene_names;
1305 else if ( key.equals( "show_gene_symbols" ) ) {
1306 key_index = Configuration.show_gene_symbols;
1308 else if ( key.equals( "show_sequence_acc" ) ) {
1309 key_index = Configuration.show_sequence_acc;
1311 else if ( key.equals( "show_node_ids" ) ) {
1313 .printWarningMessage( Constants.PRG_NAME, "configuration key [show_node_ids] is deprecated" );
1314 key_index = DEPRECATED;
1316 else if ( key.equals( "display_internal_data" ) ) {
1317 key_index = Configuration.display_internal_data;
1319 else if ( key.equals( "dynamically_hide_data" ) ) {
1320 key_index = Configuration.dynamically_hide_data;
1322 else if ( key.equals( "show_taxonomy_names" ) ) {
1323 ForesterUtil.printWarningMessage( Constants.PRG_NAME,
1324 "configuration key [show_taxonomy_names] is deprecated" );
1325 key_index = DEPRECATED;
1327 else if ( key.equals( "show_taxonomy_scientific_names" ) ) {
1328 key_index = Configuration.show_taxonomy_scientific_names;
1330 else if ( key.equals( "show_taxonomy_common_names" ) ) {
1331 key_index = Configuration.show_taxonomy_common_names;
1333 else if ( key.equals( "show_taxonomy_images" ) ) {
1334 key_index = Configuration.show_taxonomy_images;
1336 else if ( key.equals( "color_according_to_annotation" ) ) {
1337 key_index = Configuration.color_according_to_annotation;
1339 else if ( key.equals( "show_vector_data" ) ) {
1340 key_index = Configuration.show_vector_data;
1342 else if ( key.equals( "show_properties" ) ) {
1343 key_index = Configuration.show_properties;
1345 else if ( key.equals( "show_relation_confidence" ) ) {
1346 key_index = Configuration.show_relation_confidence;
1348 else if ( key.equals( "show_custom_node_shapes" ) ) {
1349 key_index = Configuration.show_custom_node_shapes;
1351 // If we've found the key, set the values
1352 if ( key_index >= 0 ) {
1353 display_options[ key_index ][ 1 ] = ( String ) st.nextElement();
1354 display_options[ key_index ][ 2 ] = ( String ) st.nextElement();
1355 // otherwise, keep looking
1358 if ( key_index == DEPRECATED ) {
1361 else if ( key.equals( "click_to" ) ) {
1362 final String click_to_name = ( String ) st.nextElement();
1363 key_index = getClickToIndex( click_to_name );
1364 if ( key_index >= 0 ) {
1365 clickto_options[ key_index ][ 1 ] = ( String ) st.nextElement();
1367 else if ( key_index == DEPRECATED ) {
1371 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown click-to option: "
1375 else if ( key.equals( "species_color" ) ) {
1376 getSpeciesColors().put( ( String ) st.nextElement(), Color.decode( ( String ) st.nextElement() ) );
1378 else if ( key.equals( "domain_color" ) ) {
1379 getDomainColors().put( ( String ) st.nextElement(), Color.decode( ( String ) st.nextElement() ) );
1381 else if ( key.equals( "annotation_color" ) ) {
1382 getAnnotationColors()
1383 .put( ( String ) st.nextElement(), Color.decode( ( String ) st.nextElement() ) );
1385 else if ( key.equals( "function_color" ) ) {
1386 ForesterUtil.printWarningMessage( Constants.PRG_NAME,
1387 "configuration key [function_color] is deprecated" );
1389 else if ( key.equals( DISPLAY_COLOR_KEY ) ) {
1390 putDisplayColors( ( String ) st.nextElement(), Color.decode( ( String ) st.nextElement() ) );
1392 else if ( key.equals( WEB_LINK_KEY ) ) {
1393 if ( st.countTokens() == 3 ) {
1394 createWebLink( ( String ) st.nextElement(),
1395 ( String ) st.nextElement(),
1396 ( String ) st.nextElement() );
1399 ForesterUtil.printWarningMessage( Constants.PRG_NAME,
1400 "illegal format in configuration file for key [" + key + "]" );
1404 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown configuration key [" + key
1405 + "] in: " + config_filename );
1410 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown configuration key [" + key + "] in: "
1411 + config_filename );
1415 public void setMinConfidenceValue( final double min_confidence_value ) {
1416 _min_confidence_value = min_confidence_value;
1419 public void setNodeLabelDirection( final NODE_LABEL_DIRECTION node_label_direction ) {
1420 _node_label_direction = node_label_direction;
1423 public void setNumberOfDigitsAfterCommaForBranchLengthValue( final short _number_of_digits_after_comma_for_branch_length_values ) {
1424 this._number_of_digits_after_comma_for_branch_length_values = _number_of_digits_after_comma_for_branch_length_values;
1427 public void setNumberOfDigitsAfterCommaForConfidenceValues( final short _number_of_digits_after_comma_for_confidence_values ) {
1428 this._number_of_digits_after_comma_for_confidence_values = _number_of_digits_after_comma_for_confidence_values;
1431 private void setOvMaxHeight( final short ov_max_height ) {
1432 _ov_max_height = ov_max_height;
1435 private void setOvMaxWidth( final short ov_max_width ) {
1436 _ov_max_width = ov_max_width;
1439 private void setOvPlacement( final OVERVIEW_PLACEMENT_TYPE ov_placement ) {
1440 _ov_placement = ov_placement;
1443 public void setPhylogenyGraphicsType( final PHYLOGENY_GRAPHICS_TYPE phylogeny_graphics_type ) {
1444 _phylogeny_graphics_type = phylogeny_graphics_type;
1447 public void setPrintLineWidth( final float print_line_width ) {
1448 _print_line_width = print_line_width;
1451 public void setReplaceUnderscoresInNhParsing( final boolean nh_parsing_replace_underscores ) {
1452 _nh_parsing_replace_underscores = nh_parsing_replace_underscores;
1455 public void setShowBranchLengthValues( final boolean show_branch_length_values ) {
1456 _show_branch_length_values = show_branch_length_values;
1459 public void setShowDefaultNodeShapes( final boolean show_default_node_shapes ) {
1460 _show_default_node_shapes = show_default_node_shapes;
1463 public void setShowDomainLabels( final boolean show_domain_labels ) {
1464 _show_domain_labels = show_domain_labels;
1467 private void setShowOverview( final boolean show_overview ) {
1468 _show_overview = show_overview;
1471 public void setShowScale( final boolean show_scale ) {
1472 _show_scale = show_scale;
1475 public void setTaxonomyColorize( final boolean b ) {
1476 display_options[ color_according_to_species ][ 2 ] = b ? "yes" : "no";
1479 public void setTaxonomyColorizeNodeShapes( final boolean taxonomy_colorize_node_shapes ) {
1480 _taxonomy_colorize_node_shapes = taxonomy_colorize_node_shapes;
1483 public void setUseBranchesWidths( final boolean b ) {
1484 display_options[ width_branches ][ 2 ] = b ? "yes" : "no";
1487 private void setValidatePhyloXmlAgainstSchema( final boolean validate_against_phyloxml_xsd_schema ) {
1488 _validate_against_phyloxml_xsd_schema = validate_against_phyloxml_xsd_schema;
1491 void setWebLinks( final SortedMap<String, WebLink> weblinks ) {
1492 _weblinks = weblinks;
1495 static String getDefaultFontFamilyName() {
1496 return DEFAULT_FONT_FAMILY;
1499 static enum TRIPLET {
1500 TRUE, FALSE, UNKNOWN
1504 NATIVE, CROSSPLATFORM, NIMBUS, UNKNOWN