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: https://sites.google.com/site/cmzmasek/home/software/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.io.parsers.nhx.NHXParser.TAXONOMY_EXTRACTION;
51 import org.forester.phylogeny.data.NodeData.NODE_DATA;
52 import org.forester.phylogeny.data.NodeVisualization;
53 import org.forester.phylogeny.data.NodeVisualization.NodeFill;
54 import org.forester.phylogeny.data.NodeVisualization.NodeShape;
55 import org.forester.util.ForesterUtil;
57 public final class Configuration {
59 public enum EXT_NODE_DATA_RETURN_ON {
60 CONSOLE, WINODW, BUFFER_ONLY;
62 static final String VALIDATE_AGAINST_PHYLOXML_XSD_SCHEMA = "validate_against_phyloxml_xsd_schema";
63 private static final String WEB_LINK_KEY = "web_link";
64 private static final String DISPLAY_COLOR_KEY = "display_color";
65 private static final int DEPRECATED = -2;
66 private UI _ui = UI.UNKNOWN;
67 private boolean _use_tabbed_display = false;
68 private boolean _hide_controls_and_menus = false;
69 private CLADOGRAM_TYPE _cladogram_type = Constants.CLADOGRAM_TYPE_DEFAULT;
70 private SortedMap<String, WebLink> _weblinks = null;
71 private SortedMap<String, Color> _display_colors = null;
72 private boolean _antialias_screen = true;
73 private PHYLOGENY_GRAPHICS_TYPE _phylogeny_graphics_type = PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR;
74 private String _base_font_family_name = "";
75 private int _base_font_size = -1;
76 private int _graphics_export_x = -1;
77 private int _graphics_export_y = -1;
78 private short _ov_max_width = 80;
79 private short _ov_max_height = 80;
80 private OVERVIEW_PLACEMENT_TYPE _ov_placement = OVERVIEW_PLACEMENT_TYPE.UPPER_LEFT;
81 private double _min_confidence_value = Options.MIN_CONFIDENCE_DEFAULT;
82 private float _print_line_width = Constants.PDF_LINE_WIDTH_DEFAULT;
83 private boolean _show_scale = false;
84 private boolean _show_branch_length_values = false;
85 private boolean _show_overview = true;
86 private short _number_of_digits_after_comma_for_confidence_values = Constants.NUMBER_OF_DIGITS_AFTER_COMMA_FOR_CONFIDENCE_VALUES_DEFAULT;
87 private short _number_of_digits_after_comma_for_branch_length_values = Constants.NUMBER_OF_DIGITS_AFTER_COMMA_FOR_BRANCH_LENGTH_VALUES_DEFAULT;
88 private boolean _editable = true;
89 private boolean _nh_parsing_replace_underscores = false;
90 private TAXONOMY_EXTRACTION _taxonomy_extraction = TAXONOMY_EXTRACTION.PFAM_STYLE_ONLY;
91 private boolean _internal_number_are_confidence_for_nh_parsing = false;
92 private boolean _display_sequence_relations = false;
93 private boolean _validate_against_phyloxml_xsd_schema = Constants.VALIDATE_AGAINST_PHYLOXML_XSD_SCJEMA_DEFAULT;
94 private boolean _background_color_gradient = false;
95 private boolean _show_domain_labels = true;
96 private boolean _abbreviate_scientific_names = false;
97 private boolean _color_labels_same_as_parent_branch = false;
98 private boolean _show_default_node_shapes_internal = false;
99 private boolean _show_default_node_shapes_external = false;
100 private NodeShape _default_node_shape = NodeShape.CIRCLE;
101 private NodeFill _default_node_fill = NodeFill.GRADIENT;
102 private short _default_node_shape_size = Constants.DEFAULT_NODE_SHAPE_SIZE_DEFAULT;
103 private boolean _taxonomy_colorize_node_shapes = false;
104 private int _default_bootstrap_samples = -1;
105 private File _path_to_local_mafft = null;
106 private File _path_to_local_fastme = null;
107 private File _path_to_local_raxml = null;
108 private File _path_to_local_clustalo = null;
109 final static int display_as_phylogram = 0;
110 final static int show_node_names = 1;
111 final static int show_tax_code = 2;
112 final static int show_annotation = 3;
113 final static int write_confidence_values = 4;
114 final static int write_events = 5;
115 final static int color_according_to_species = 6;
116 final static int color_branches = 7;
117 final static int width_branches = 8;
118 final static int show_custom_node_shapes = 9;
119 final static int show_domain_architectures = 10;
120 final static int show_binary_characters = 11;
121 final static int show_binary_character_counts = 12;
122 final static int show_gene_names = 13;
123 final static int show_sequence_acc = 14;
124 final static int display_internal_data = 15;
125 final static int dynamically_hide_data = 16;
126 final static int show_taxonomy_scientific_names = 17;
127 final static int show_taxonomy_common_names = 18;
128 final static int color_according_to_annotation = 19;
129 final static int show_gene_symbols = 20;
130 final static int node_data_popup = 21;
131 final static int show_relation_confidence = 22;
132 final static int show_vector_data = 23;
133 final static int show_taxonomy_images = 24;
134 final static int show_properties = 25;
135 // ------------------
137 // ------------------
138 final static int display_node_data = 0;
139 final static int collapse_uncollapse = 1;
140 final static int reroot = 2;
141 final static int subtree = 3;
142 final static int swap = 4;
143 final static int color_subtree = 5;
144 final static int open_seq_web = 6;
145 final static int open_tax_web = 7;
146 final static int blast = 8;
147 final static int cut_subtree = 9;
148 final static int copy_subtree = 10;
149 final static int paste_subtree = 11;
150 final static int delete_subtree_or_node = 12;
151 final static int add_new_node = 13;
152 final static int edit_node_data = 14;
153 final static int sort_descendents = 15;
154 final static int get_ext_desc_data = 16;
155 final static int select_nodes = 17;
156 // ---------------------------
157 // Display options for trees
158 // ---------------------------
159 // ---------------------------------
160 // Pertaining to the config itself
161 // ---------------------------------
162 // Full path to config (may be URL)
163 String config_filename;
164 String default_config_filename = Constants.DEFAULT_CONFIGURATION_FILE_NAME;
165 final static String display_options[][] = {
166 { "Phylogram", "display", "?" }, { "Node Name", "display", "yes" }, { "Taxonomy Code", "display", "yes" },
167 { "Annotation", "nodisplay", "no" }, { "Confidence Values", "display", "?" },
168 { "Node Events", "display", "?" }, { "Taxonomy Colorize", "display", "yes" },
169 { "Colorize Branches", "display", "no" }, { "Use Branch-Widths", "display", "no" },
170 { "Show Custom Nodes", "display", "yes" }, { "Domains", "nodisplay", "no" },
171 { "Binary Characters", "nodisplay", "no" }, { "Binary Char Counts", "nodisplay", "no" },
172 { "Seq Name", "display", "yes" }, { "Seq Acc", "display", "no" },
173 { "Show Internal Data", "display", "yes" }, { "Dyna Hide", "display", "yes" },
174 { "Taxonomy Scientific", "display", "yes" }, { "Taxonomy Common", "display", "no" },
175 { "Annotation Colorize", "nodisplay", "no" }, { "Seq Symbol", "display", "yes" },
176 { "Rollover", "display", "yes" }, { "Relation Confidence", "nodisplay", "no" },
177 { "Vector Data", "nodisplay", "no" }, { "Taxonomy Images", "display", "no" },
178 { "Properties", "nodisplay", "no" } };
179 final static String clickto_options[][] = {
180 { "Display Node Data", "display" }, { "Collapse/Uncollapse", "display" }, { "Root/Reroot", "display" },
181 { "Sub/Super Tree", "display" }, { "Swap Descendants", "display" }, { "Colorize Subtree", "display" },
182 { "Open Sequence Web", "display" }, { "Open Taxonomy Web", "display" }, { "Blast", "display" },
183 { "Cut Subtree", "display" }, { "Copy Subtree", "display" }, { "Paste Subtree", "display" },
184 { "Delete Subtree/Node", "display" }, { "Add New Node", "display" }, { "Edit Node Data", "display" },
185 { "Sort Descendants", "display" }, { "Return", "display" }, { "Select Node(s)", "display" } };
186 // This option is selected in the dropdown
187 int default_clickto = Configuration.display_node_data;
191 TreeColorSet tree_color_set;
195 TreeFontSet tree_font_set;
199 private static Hashtable<String, Color> _species_colors;
203 private static Hashtable<String, Color> _domain_colors;
207 private static Hashtable<String, Color> _annotation_colors;
208 boolean verbose = Constants.VERBOSE_DEFAULT;
209 private NODE_LABEL_DIRECTION _node_label_direction = NODE_LABEL_DIRECTION.HORIZONTAL;
210 private Color _gui_background_color = Constants.GUI_BACKGROUND_DEFAULT;
211 private Color _gui_checkbox_text_color = Constants.CHECKBOX_TEXT_COLOR_DEFAULT;
212 private Color _gui_checkbox_and_button_active_color = Constants.CHECKBOX_AND_BUTTON_ACTIVE_COLOR_DEFAULT;
213 private Color _gui_button_text_color = Constants.BUTTON_TEXT_COLOR_DEFAULT;
214 private Color _gui_button_background_color = Constants.BUTTON_BACKGROUND_COLOR_DEFAULT;
215 private Color _gui_menu_background_color = Constants.MENU_BACKGROUND_COLOR_DEFAULT;
216 private Color _gui_menu_text_color = Constants.MENU_TEXT_COLOR_DEFAULT;
217 private Color _gui_button_border_color = Constants.BUTTON_BORDER_COLOR_DEFAULT;
218 private Color _domain_structure_font_color = Constants.DOMAIN_STRUCTURE_FONT_COLOR_DEFAULT;
219 private Color _domain_structure_base_color = Constants.DOMAIN_STRUCTURE_BASE_COLOR_DEFAULT;
220 private NODE_DATA _ext_desc_data_to_return = NODE_DATA.UNKNOWN;
221 private String _label_for_get_ext_descendents_data = "";
222 private EXT_NODE_DATA_RETURN_ON _ext_node_data_return_on = EXT_NODE_DATA_RETURN_ON.WINODW;
223 private int _frame_x_size;
224 private int _frame_y_size;
225 private static String DEFAULT_FONT_FAMILY = "";
227 for( final String font_name : Constants.DEFAULT_FONT_CHOICES ) {
228 if ( Arrays.binarySearch( AptxUtil.getAvailableFontFamiliesSorted(), font_name ) >= 0 ) {
229 DEFAULT_FONT_FAMILY = font_name;
233 if ( ForesterUtil.isEmpty( DEFAULT_FONT_FAMILY ) ) {
234 DEFAULT_FONT_FAMILY = Constants.DEFAULT_FONT_CHOICES[ Constants.DEFAULT_FONT_CHOICES.length - 1 ];
238 public Configuration() {
239 this( null, false, false, false );
242 public Configuration( final String cf, final boolean is_url, final boolean is_applet, final boolean verbose ) {
243 if ( ForesterUtil.isEmpty( cf ) ) {
244 config_filename = default_config_filename;
247 config_filename = cf;
249 setWebLinks( new TreeMap<String, WebLink>() );
250 setDisplayColors( new TreeMap<String, Color>() );
251 config_filename = config_filename.trim();
254 // If URL, open accordingly
256 u = new URL( config_filename );
258 final InputStreamReader isr = new InputStreamReader( u.openStream() );
259 final BufferedReader bf = new BufferedReader( isr );
262 ForesterUtil.programMessage( Constants.PRG_NAME, "successfully read from configuration url ["
263 + config_filename + "]" );
265 catch ( final Exception e ) {
266 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "failed to read configuration from ["
267 + config_filename + "]: " + e.getLocalizedMessage() );
270 catch ( final Exception e ) {
271 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "cannot find or open configuration url ["
272 + config_filename + "]" );
276 // Otherwise, open as a file
277 File f = new File( config_filename );
279 f = new File( config_filename + ".txt" );
281 if ( f.exists() && f.canRead() ) {
283 final BufferedReader bf = new BufferedReader( new FileReader( f ) );
287 catch ( final Exception e ) {
289 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "failed to read configuration from ["
290 + config_filename + "]: " + e );
296 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "cannot find or open configuration file ["
297 + config_filename + "]" );
303 private void createWebLink( final String url_str, final String desc, final String source_identifier ) {
304 WebLink weblink = null;
307 weblink = new WebLink( new URL( url_str.trim() ), desc.trim(), source_identifier.trim() );
309 catch ( final MalformedURLException e ) {
310 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "could not create URL from [" + url_str + "]" );
313 if ( !ex && ( weblink != null ) ) {
314 getWebLinks().put( weblink.getSourceIdentifier().toLowerCase(), weblink );
318 boolean displaySequenceRelations() {
319 return _display_sequence_relations;
322 boolean doCheckOption( final int which ) {
323 return ( display_options[ which ][ 2 ].equalsIgnoreCase( "yes" ) )
324 || ( display_options[ which ][ 2 ].equalsIgnoreCase( "true" ) );
327 boolean doDisplayClickToOption( final int which ) {
328 return clickto_options[ which ][ 1 ].equalsIgnoreCase( "display" );
331 boolean doDisplayOption( final int which ) {
332 return display_options[ which ][ 1 ].equalsIgnoreCase( "display" );
336 * Will attempt to use the phylogeny to determine whether to check
337 * this or not (e.g. phylogram)
340 boolean doGuessCheckOption( final int which ) {
341 return display_options[ which ][ 2 ].equals( "?" );
344 Map<String, Color> getAnnotationColors() {
345 if ( _annotation_colors == null ) {
346 _annotation_colors = new Hashtable<String, Color>();
348 return _annotation_colors;
351 public String getBaseFontFamilyName() {
352 return _base_font_family_name;
355 int getBaseFontSize() {
356 return _base_font_size;
359 CLADOGRAM_TYPE getCladogramType() {
360 return _cladogram_type;
363 private int getClickToIndex( final String name ) {
365 if ( name.equals( "edit_info" ) ) {
366 index = Configuration.display_node_data;
368 .printWarningMessage( Constants.PRG_NAME,
369 "configuration key [edit_info] is deprecated, use [display node data] instead" );
371 else if ( name.equals( "display_node_data" ) ) {
372 index = Configuration.display_node_data;
374 else if ( name.equals( "collapse_uncollapse" ) ) {
375 index = Configuration.collapse_uncollapse;
377 else if ( name.equals( "reroot" ) ) {
378 index = Configuration.reroot;
380 else if ( name.equals( "subtree" ) ) {
381 index = Configuration.subtree;
383 else if ( name.equals( "swap" ) ) {
384 index = Configuration.swap;
386 else if ( name.equals( "sort_descendants" ) ) {
387 index = Configuration.sort_descendents;
389 else if ( name.equals( "get_ext_descendents_data" ) ) {
390 index = Configuration.get_ext_desc_data;
392 else if ( name.equals( "display_sequences" ) ) {
394 .printWarningMessage( Constants.PRG_NAME, "configuration key [display_sequences] is deprecated" );
397 else if ( name.equals( "open_seq_web" ) ) {
398 index = Configuration.open_seq_web;
400 else if ( name.equals( "open_tax_web" ) ) {
401 index = Configuration.open_tax_web;
403 else if ( name.equals( "blast" ) ) {
404 index = Configuration.blast;
406 else if ( name.equals( "cut_subtree" ) ) {
407 index = Configuration.cut_subtree;
409 else if ( name.equals( "copy_subtree" ) ) {
410 index = Configuration.copy_subtree;
412 else if ( name.equals( "paste_subtree" ) ) {
413 index = Configuration.paste_subtree;
415 else if ( name.equals( "delete" ) ) {
416 index = Configuration.delete_subtree_or_node;
418 else if ( name.equals( "add_new_node" ) ) {
419 index = Configuration.add_new_node;
421 else if ( name.equals( "edit_node_data" ) ) {
422 index = Configuration.edit_node_data;
424 else if ( name.equals( "select_nodes" ) ) {
425 index = Configuration.select_nodes;
427 else if ( name.equals( "display_node_popup" ) ) {
428 ForesterUtil.printWarningMessage( Constants.PRG_NAME,
429 "configuration key [display_node_popup] is deprecated" );
432 else if ( name.equals( "custom_option" ) ) {
433 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "configuration key [custom_option] is deprecated" );
436 else if ( name.equals( "color_subtree" ) ) {
437 index = Configuration.color_subtree;
439 else if ( name.equals( "go_to_swiss_prot" ) ) {
440 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "configuration key [go_to_swiss_prot] is deprecated" );
446 int getClickToOptionsCount() {
447 return clickto_options.length;
450 String getClickToTitle( final int which ) {
451 return clickto_options[ which ][ 0 ];
454 public int getDefaultBootstrapSamples() {
455 return _default_bootstrap_samples;
458 public File getpathToLocalMafft() {
459 return _path_to_local_mafft;
462 public File getPathToLocalFastme() {
463 return _path_to_local_fastme;
466 public File getPathToLocalRaxml() {
467 return _path_to_local_raxml;
470 int getDefaultDisplayClicktoOption() {
471 return default_clickto;
474 public NodeFill getDefaultNodeFill() {
475 return _default_node_fill;
478 public NodeShape getDefaultNodeShape() {
479 return _default_node_shape;
482 public short getDefaultNodeShapeSize() {
483 return _default_node_shape_size;
486 SortedMap<String, Color> getDisplayColors() {
487 return _display_colors;
490 String getDisplayTitle( final int which ) {
491 return display_options[ which ][ 0 ];
494 Map<String, Color> getDomainColors() {
495 if ( _domain_colors == null ) {
496 _domain_colors = new Hashtable<String, Color>();
498 return _domain_colors;
501 public Color getDomainStructureBaseColor() {
502 return _domain_structure_base_color;
505 public Color getDomainStructureFontColor() {
506 return _domain_structure_font_color;
509 int getGraphicsExportX() {
510 return _graphics_export_x;
513 int getGraphicsExportY() {
514 return _graphics_export_y;
517 Color getGuiBackgroundColor() {
518 return _gui_background_color;
521 Color getGuiButtonBackgroundColor() {
522 return _gui_button_background_color;
525 Color getGuiButtonBorderColor() {
526 return _gui_button_border_color;
529 Color getGuiButtonTextColor() {
530 return _gui_button_text_color;
533 Color getGuiCheckboxAndButtonActiveColor() {
534 return _gui_checkbox_and_button_active_color;
537 Color getGuiCheckboxTextColor() {
538 return _gui_checkbox_text_color;
541 Color getGuiMenuBackgroundColor() {
542 return _gui_menu_background_color;
545 Color getGuiMenuTextColor() {
546 return _gui_menu_text_color;
549 double getMinConfidenceValue() {
550 return _min_confidence_value;
553 NODE_LABEL_DIRECTION getNodeLabelDirection() {
554 return _node_label_direction;
557 short getNumberOfDigitsAfterCommaForBranchLengthValues() {
558 return _number_of_digits_after_comma_for_branch_length_values;
561 short getNumberOfDigitsAfterCommaForConfidenceValues() {
562 return _number_of_digits_after_comma_for_confidence_values;
565 short getOvMaxHeight() {
566 return _ov_max_height;
569 short getOvMaxWidth() {
570 return _ov_max_width;
573 OVERVIEW_PLACEMENT_TYPE getOvPlacement() {
574 return _ov_placement;
577 PHYLOGENY_GRAPHICS_TYPE getPhylogenyGraphicsType() {
578 return _phylogeny_graphics_type;
581 float getPrintLineWidth() {
582 return _print_line_width;
585 Hashtable<String, Color> getSpeciesColors() {
586 if ( _species_colors == null ) {
587 _species_colors = new Hashtable<String, Color>();
589 return _species_colors;
592 TreeColorSet getTreeColorSet() {
596 TreeFontSet getTreeFontSet() {
600 WebLink getWebLink( final String source ) {
601 return getWebLinks().get( source );
604 Map<String, WebLink> getWebLinks() {
608 public boolean isAbbreviateScientificTaxonNames() {
609 return _abbreviate_scientific_names;
612 boolean isAntialiasScreen() {
613 return _antialias_screen;
616 public boolean isBackgroundColorGradient() {
617 return _background_color_gradient;
620 public boolean isColorLabelsSameAsParentBranch() {
621 return _color_labels_same_as_parent_branch;
625 * Convenience method.
627 * @return true if value in configuration file was 'yes'
629 boolean isDrawAsPhylogram() {
630 return doCheckOption( display_as_phylogram );
633 boolean isEditable() {
637 final TAXONOMY_EXTRACTION getTaxonomyExtraction() {
638 return _taxonomy_extraction;
641 boolean isHasWebLink( final String source ) {
642 return getWebLinks().containsKey( source );
646 * Only used by ArchaeoptryxE.
649 boolean isHideControlPanelAndMenubar() {
650 return _hide_controls_and_menus;
653 boolean isInternalNumberAreConfidenceForNhParsing() {
654 return _internal_number_are_confidence_for_nh_parsing;
657 boolean isReplaceUnderscoresInNhParsing() {
658 return _nh_parsing_replace_underscores;
661 boolean isShowBranchLengthValues() {
662 return _show_branch_length_values;
665 public boolean isShowDefaultNodeShapesExternal() {
666 return _show_default_node_shapes_external;
669 public boolean isShowDefaultNodeShapesInternal() {
670 return _show_default_node_shapes_internal;
673 public boolean isShowDomainLabels() {
674 return _show_domain_labels;
677 boolean isShowOverview() {
678 return _show_overview;
681 boolean isShowScale() {
685 public boolean isTaxonomyColorizeNodeShapes() {
686 return _taxonomy_colorize_node_shapes;
689 final boolean isUseNativeUI() {
690 if ( ( _ui == UI.UNKNOWN ) && AptxUtil.isMac() && AptxUtil.isJava15() ) {
693 return _ui == UI.NATIVE;
697 * Only used by ArchaeoptryxE.
700 boolean isUseTabbedDisplay() {
701 return _use_tabbed_display;
704 boolean isValidatePhyloXmlAgainstSchema() {
705 return _validate_against_phyloxml_xsd_schema;
708 private boolean parseBoolean( final String str ) {
709 final String my_str = str.trim().toLowerCase();
710 if ( my_str.equals( "yes" ) || my_str.equals( "true" ) ) {
713 else if ( my_str.equals( "no" ) || my_str.equals( "false" ) ) {
717 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "could not parse boolean value from [" + str + "]" );
722 private double parseDouble( final String str ) {
725 d = Double.parseDouble( str.trim() );
727 catch ( final Exception e ) {
728 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "could not parse double from [" + str + "]" );
734 private float parseFloat( final String str ) {
737 f = Float.parseFloat( str.trim() );
739 catch ( final Exception e ) {
740 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "could not parse float from [" + str + "]" );
746 private int parseInt( final String str ) {
749 i = Integer.parseInt( str.trim() );
751 catch ( final Exception e ) {
752 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "could not parse integer from [" + str + "]" );
758 private short parseShort( final String str ) {
761 i = Short.parseShort( str.trim() );
763 catch ( final Exception e ) {
764 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "could not parse short from [" + str + "]" );
770 private void processFontFamily( final StringTokenizer st ) {
771 setBaseFontFamilyName( "" );
772 final String font_str = ( ( String ) st.nextElement() ).trim();
773 final String[] fonts = font_str.split( ",+" );
774 for( String font : fonts ) {
775 font = font.replace( '_', ' ' ).trim();
776 if ( Arrays.binarySearch( AptxUtil.getAvailableFontFamiliesSorted(), font ) >= 0 ) {
777 setBaseFontFamilyName( font );
783 public void putDisplayColors( final String key, final Color color ) {
784 getDisplayColors().put( key, color );
788 * read each line of config file, process non-comment lines
789 * @throws IOException
791 private void readConfig( final BufferedReader conf_in ) throws IOException {
794 line = conf_in.readLine();
795 if ( line != null ) {
797 // skip comments and blank lines
798 if ( !line.startsWith( "#" ) && ( !ForesterUtil.isEmpty( line ) ) ) {
799 // convert runs of spaces to tabs
800 line = line.replaceAll( "\\s+", "\t" );
801 final StringTokenizer st = new StringTokenizer( line, "\t" );
805 } while ( line != null );
808 public void setAbbreviateScientificTaxonNames( final boolean abbreviate_scientific_names ) {
809 _abbreviate_scientific_names = abbreviate_scientific_names;
812 private void setAntialiasScreen( final boolean antialias_screen ) {
813 _antialias_screen = antialias_screen;
816 public void setBackgroundColorGradient( final boolean background_color_gradient ) {
817 _background_color_gradient = background_color_gradient;
820 public void setBaseFontFamilyName( final String base_font_family_name ) {
821 _base_font_family_name = base_font_family_name;
824 public void setBaseFontSize( final int base_font_size ) {
825 _base_font_size = base_font_size;
828 private void setCladogramType( final CLADOGRAM_TYPE cladogram_type ) {
829 _cladogram_type = cladogram_type;
832 public void setColorizeBranches( final boolean b ) {
833 display_options[ color_branches ][ 2 ] = b ? "yes" : "no";
836 public void setColorLabelsSameAsParentBranch( final boolean color_labels_same_as_parent_branch ) {
837 _color_labels_same_as_parent_branch = color_labels_same_as_parent_branch;
840 private void setDefaultBootstrapSamples( final int default_bootstrap_samples ) {
841 _default_bootstrap_samples = default_bootstrap_samples;
844 private void setPathToLocalMafft( final File path_to_local_mafft ) {
845 _path_to_local_mafft = path_to_local_mafft;
848 private void setPathToLocalFastme( final File path_to_local_fastme ) {
849 _path_to_local_fastme = path_to_local_fastme;
852 private void setPathToLocalRaxml( final File path_to_local_raxml ) {
853 _path_to_local_raxml = path_to_local_raxml;
856 public File getPathToLocalClustalOmega() {
857 return _path_to_local_clustalo;
860 public void setPathToLocalClustalOmega( final File path_to_local_clustalo ) {
861 _path_to_local_clustalo = path_to_local_clustalo;
864 public void setDefaultNodeFill( final NodeFill default_node_fill ) {
865 _default_node_fill = default_node_fill;
868 public void setDefaultNodeShape( final NodeShape default_node_shape ) {
869 _default_node_shape = default_node_shape;
872 public void setDefaultNodeShapeSize( final short default_node_shape_size ) {
873 _default_node_shape_size = default_node_shape_size;
876 public void setDisplayAsPhylogram( final boolean b ) {
877 display_options[ display_as_phylogram ][ 2 ] = b ? "yes" : "no";
880 public void setDisplayColors( final SortedMap<String, Color> display_colors ) {
881 _display_colors = display_colors;
884 public void setDisplayConfidenceValues( final boolean b ) {
885 display_options[ write_confidence_values ][ 2 ] = b ? "yes" : "no";
888 public void setDisplayInternalData( final boolean b ) {
889 display_options[ display_internal_data ][ 2 ] = b ? "yes" : "no";
892 public void setDisplayNodeNames( final boolean b ) {
893 display_options[ show_node_names ][ 2 ] = b ? "yes" : "no";
896 public void setDisplaySequenceAcc( final boolean b ) {
897 display_options[ show_sequence_acc ][ 2 ] = b ? "yes" : "no";
900 public void setDisplaySequenceNames( final boolean b ) {
901 display_options[ show_gene_names ][ 2 ] = b ? "yes" : "no";
904 public void setDisplaySequenceRelations( final boolean display_sequence_relations ) {
905 _display_sequence_relations = display_sequence_relations;
908 public void setDisplaySequenceSymbols( final boolean b ) {
909 display_options[ show_gene_symbols ][ 2 ] = b ? "yes" : "no";
912 public void setDisplayTaxonomyCode( final boolean b ) {
913 display_options[ show_tax_code ][ 2 ] = b ? "yes" : "no";
916 public void setDisplayTaxonomyCommonNames( final boolean b ) {
917 display_options[ show_taxonomy_common_names ][ 2 ] = b ? "yes" : "no";
920 public void setDisplayTaxonomyImages( final boolean b ) {
921 display_options[ show_taxonomy_images ][ 2 ] = b ? "yes" : "no";
924 public void setDisplayTaxonomyScientificNames( final boolean b ) {
925 display_options[ show_taxonomy_scientific_names ][ 2 ] = b ? "yes" : "no";
928 public void setDynamicallyHideData( final boolean b ) {
929 display_options[ dynamically_hide_data ][ 2 ] = b ? "yes" : "no";
932 private void setEditable( final boolean editable ) {
933 _editable = editable;
936 final void setTaxonomyExtraction( final TAXONOMY_EXTRACTION taxonomy_extraction ) {
937 _taxonomy_extraction = taxonomy_extraction;
940 private void setGraphicsExportX( final int graphics_export_x ) {
941 _graphics_export_x = graphics_export_x;
944 private void setGraphicsExportY( final int graphics_export_y ) {
945 _graphics_export_y = graphics_export_y;
948 private void setInternalNumberAreConfidenceForNhParsing( final boolean internal_number_are_confidence_for_nh_parsing ) {
949 _internal_number_are_confidence_for_nh_parsing = internal_number_are_confidence_for_nh_parsing;
953 * Set a key-value(s) tuple
955 private void setKeyValue( final StringTokenizer st ) {
956 final String key = ( ( String ) st.nextElement() ).replace( ':', ' ' ).trim().toLowerCase();
957 if ( !st.hasMoreElements() ) {
960 // Handle single value settings first:
961 if ( key.equals( "default_click_to" ) ) {
962 final String clickto_name = ( String ) st.nextElement();
963 default_clickto = getClickToIndex( clickto_name );
964 if ( default_clickto == -1 ) {
965 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "invalid value [" + clickto_name
966 + "] for [default_click_to]" );
969 else if ( default_clickto == DEPRECATED ) {
973 else if ( key.equals( "native_ui" ) ) {
974 final String my_str = ( ( String ) st.nextElement() ).trim().toLowerCase();
975 if ( my_str.equals( "yes" ) || my_str.equals( "true" ) ) {
978 else if ( my_str.equals( "no" ) || my_str.equals( "false" ) ) {
979 _ui = UI.CROSSPLATFORM;
981 else if ( my_str.equals( "?" ) ) {
985 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "could not parse yes/no/? value from [" + my_str
990 else if ( key.equals( VALIDATE_AGAINST_PHYLOXML_XSD_SCHEMA ) ) {
991 setValidatePhyloXmlAgainstSchema( parseBoolean( ( String ) st.nextElement() ) );
993 else if ( key.equals( "antialias_screen" ) ) {
994 setAntialiasScreen( parseBoolean( ( String ) st.nextElement() ) );
996 else if ( key.equals( "phylogeny_graphics_type" ) ) {
997 final String type_str = ( ( String ) st.nextElement() ).trim();
998 if ( type_str.equalsIgnoreCase( PHYLOGENY_GRAPHICS_TYPE.CONVEX.toString() ) ) {
999 setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CONVEX );
1001 else if ( type_str.equalsIgnoreCase( PHYLOGENY_GRAPHICS_TYPE.CURVED.toString() ) ) {
1002 setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CURVED );
1004 else if ( type_str.equalsIgnoreCase( PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE.toString() ) ) {
1005 setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE );
1007 else if ( type_str.equalsIgnoreCase( PHYLOGENY_GRAPHICS_TYPE.ROUNDED.toString() ) ) {
1008 setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.ROUNDED );
1010 else if ( type_str.equalsIgnoreCase( PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR.toString() ) ) {
1011 setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR );
1013 else if ( type_str.equalsIgnoreCase( PHYLOGENY_GRAPHICS_TYPE.TRIANGULAR.toString() ) ) {
1014 setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.TRIANGULAR );
1016 else if ( type_str.equalsIgnoreCase( PHYLOGENY_GRAPHICS_TYPE.UNROOTED.toString() ) ) {
1017 setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.UNROOTED );
1019 else if ( type_str.equalsIgnoreCase( PHYLOGENY_GRAPHICS_TYPE.CIRCULAR.toString() ) ) {
1020 setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CIRCULAR );
1023 setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR );
1024 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown value [" + type_str
1025 + "] for [phylogeny_graphics_type]" );
1028 else if ( key.equals( "min_confidence_value" ) ) {
1029 final String mcv_str = ( ( String ) st.nextElement() ).trim();
1030 final double d = parseDouble( mcv_str );
1031 setMinConfidenceValue( d );
1033 else if ( key.equals( "font_family" ) ) {
1034 processFontFamily( st );
1036 else if ( key.equals( "font_size" ) ) {
1037 final String size_str = ( ( String ) st.nextElement() ).trim();
1038 final int i = parseInt( size_str );
1040 setBaseFontSize( i );
1043 else if ( key.equals( "graphics_export_x" ) ) {
1044 final String str = ( ( String ) st.nextElement() ).trim();
1045 final int i = parseInt( str );
1047 setGraphicsExportX( i );
1050 else if ( key.equals( "graphics_export_y" ) ) {
1051 final String str = ( ( String ) st.nextElement() ).trim();
1052 final int i = parseInt( str );
1054 setGraphicsExportY( i );
1057 else if ( key.equals( "pdf_export_line_width" ) ) {
1058 final String str = ( ( String ) st.nextElement() ).trim();
1059 final float f = parseFloat( str );
1061 setPrintLineWidth( f );
1064 ForesterUtil.printWarningMessage( Constants.PRG_NAME,
1065 "value for [pdf_export_line_width] cannot be zero or negative" );
1068 else if ( key.equals( "window_initial_size_x" ) ) {
1069 final String str = ( ( String ) st.nextElement() ).trim();
1070 final int i = parseInt( str );
1075 else if ( key.equals( "window_initial_size_y" ) ) {
1076 final String str = ( ( String ) st.nextElement() ).trim();
1077 final int i = parseInt( str );
1082 else if ( key.equals( "default_number_of_bootstrap_resamples" ) ) {
1083 final String str = ( ( String ) st.nextElement() ).trim();
1084 final int i = parseInt( str );
1086 setDefaultBootstrapSamples( i );
1090 .printWarningMessage( Constants.PRG_NAME,
1091 "value for [default_number_of_bootstrap_resamples] cannot be negative" );
1094 else if ( key.equals( "clustalo_local" ) ) {
1095 final String str = ( ( String ) st.nextElement() ).trim();
1096 if ( !ForesterUtil.isEmpty( str ) ) {
1097 setPathToLocalClustalOmega( new File( str ) );
1100 else if ( key.equals( "mafft_local" ) ) {
1101 final String str = ( ( String ) st.nextElement() ).trim();
1102 if ( !ForesterUtil.isEmpty( str ) ) {
1103 setPathToLocalMafft( new File( str ) );
1106 else if ( key.equals( "fastme_local" ) ) {
1107 final String str = ( ( String ) st.nextElement() ).trim();
1108 if ( !ForesterUtil.isEmpty( str ) ) {
1109 setPathToLocalFastme( new File( str ) );
1112 else if ( key.equals( "raxml_local" ) ) {
1113 final String str = ( ( String ) st.nextElement() ).trim();
1114 if ( !ForesterUtil.isEmpty( str ) ) {
1115 setPathToLocalRaxml( new File( str ) );
1118 else if ( key.equals( "show_scale" ) ) {
1119 setShowScale( parseBoolean( ( String ) st.nextElement() ) );
1121 else if ( key.equals( "show_overview" ) ) {
1122 setShowOverview( parseBoolean( ( String ) st.nextElement() ) );
1124 else if ( key.equals( "show_branch_length_values" ) ) {
1125 setShowBranchLengthValues( parseBoolean( ( String ) st.nextElement() ) );
1127 else if ( key.equals( "background_gradient" ) ) {
1128 setBackgroundColorGradient( parseBoolean( ( String ) st.nextElement() ) );
1130 else if ( key.equals( "color_labels_same_as_branch_length_values" ) ) {
1131 setColorLabelsSameAsParentBranch( parseBoolean( ( String ) st.nextElement() ) );
1133 else if ( key.equals( "show_domain_labels" ) ) {
1134 setShowDomainLabels( parseBoolean( ( String ) st.nextElement() ) );
1136 else if ( key.equals( "abbreviate_scientific_names" ) ) {
1137 setAbbreviateScientificTaxonNames( parseBoolean( ( String ) st.nextElement() ) );
1139 else if ( key.equals( "cladogram_type" ) ) {
1140 final String type_str = ( ( String ) st.nextElement() ).trim();
1141 if ( type_str.equalsIgnoreCase( Options.CLADOGRAM_TYPE.NON_LINED_UP.toString() ) ) {
1142 setCladogramType( Options.CLADOGRAM_TYPE.NON_LINED_UP );
1144 else if ( type_str.equalsIgnoreCase( Options.CLADOGRAM_TYPE.EXT_NODE_SUM_DEP.toString() ) ) {
1145 setCladogramType( Options.CLADOGRAM_TYPE.EXT_NODE_SUM_DEP );
1147 else if ( type_str.equalsIgnoreCase( Options.CLADOGRAM_TYPE.TOTAL_NODE_SUM_DEP.toString() ) ) {
1148 setCladogramType( Options.CLADOGRAM_TYPE.TOTAL_NODE_SUM_DEP );
1151 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown value [" + type_str
1152 + "] for [cladogram_type]" );
1155 else if ( key.equals( "non_lined_up_cladogram" ) ) {
1157 .printWarningMessage( Constants.PRG_NAME,
1158 "configuration key [non_lined_up_cladogram] is deprecated, use [cladogram_type] instead" );
1160 else if ( key.equals( "hide_controls_and_menus" ) ) {
1161 _hide_controls_and_menus = parseBoolean( ( String ) st.nextElement() );
1163 else if ( key.equals( "use_tabbed_display" ) ) {
1164 _use_tabbed_display = parseBoolean( ( String ) st.nextElement() );
1166 else if ( key.equals( "overview_width" ) ) {
1167 final short i = parseShort( ( ( String ) st.nextElement() ) );
1170 else if ( key.equals( "overview_height" ) ) {
1171 final short i = parseShort( ( ( String ) st.nextElement() ) );
1172 setOvMaxHeight( i );
1174 else if ( key.equals( "overview_placement_type" ) ) {
1175 final String type_str = ( ( String ) st.nextElement() ).trim();
1176 if ( type_str.equalsIgnoreCase( OVERVIEW_PLACEMENT_TYPE.UPPER_LEFT.toTag() ) ) {
1177 setOvPlacement( OVERVIEW_PLACEMENT_TYPE.UPPER_LEFT );
1179 else if ( type_str.equalsIgnoreCase( OVERVIEW_PLACEMENT_TYPE.UPPER_RIGHT.toTag() ) ) {
1180 setOvPlacement( OVERVIEW_PLACEMENT_TYPE.UPPER_RIGHT );
1182 else if ( type_str.equalsIgnoreCase( OVERVIEW_PLACEMENT_TYPE.LOWER_LEFT.toTag() ) ) {
1183 setOvPlacement( OVERVIEW_PLACEMENT_TYPE.LOWER_LEFT );
1185 else if ( type_str.equalsIgnoreCase( OVERVIEW_PLACEMENT_TYPE.LOWER_RIGHT.toTag() ) ) {
1186 setOvPlacement( OVERVIEW_PLACEMENT_TYPE.LOWER_RIGHT );
1189 setOvPlacement( OVERVIEW_PLACEMENT_TYPE.UPPER_LEFT );
1190 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown value [" + type_str
1191 + "] for [overview_placement_type]" );
1194 else if ( key.equals( "node_label_direction" ) ) {
1195 final String type_str = ( ( String ) st.nextElement() ).trim();
1196 if ( type_str.equalsIgnoreCase( NODE_LABEL_DIRECTION.HORIZONTAL.toString() ) ) {
1197 setNodeLabelDirection( NODE_LABEL_DIRECTION.HORIZONTAL );
1199 else if ( type_str.equalsIgnoreCase( NODE_LABEL_DIRECTION.RADIAL.toString() ) ) {
1200 setNodeLabelDirection( NODE_LABEL_DIRECTION.RADIAL );
1203 setNodeLabelDirection( NODE_LABEL_DIRECTION.HORIZONTAL );
1204 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown value [" + type_str
1205 + "] for [node_label_direction]" );
1208 else if ( key.equals( "branch_length_value_digits" ) ) {
1209 final short i = parseShort( ( ( String ) st.nextElement() ).trim() );
1211 setNumberOfDigitsAfterCommaForBranchLengthValue( i );
1214 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "illegal value [" + i
1215 + "] for [branch_length_value_digits]" );
1218 else if ( key.equals( "confidence_value_digits" ) ) {
1219 final short i = parseShort( ( ( String ) st.nextElement() ).trim() );
1221 setNumberOfDigitsAfterCommaForConfidenceValues( i );
1224 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "illegal value [" + i
1225 + "] for [confidence_value_digits]" );
1228 else if ( key.equals( "allow_editing" ) ) {
1229 setEditable( parseBoolean( ( String ) st.nextElement() ) );
1231 else if ( key.equals( "display_sequence_relations" ) ) {
1232 setDisplaySequenceRelations( parseBoolean( ( String ) st.nextElement() ) );
1234 else if ( key.equals( "replace_underscores_in_nh_parsing" ) ) {
1235 final boolean r = parseBoolean( ( String ) st.nextElement() );
1236 if ( r && ( getTaxonomyExtraction() != TAXONOMY_EXTRACTION.NO ) ) {
1238 .printWarningMessage( Constants.PRG_NAME,
1239 "attempt to extract taxonomies and replace underscores at the same time" );
1242 setReplaceUnderscoresInNhParsing( r );
1245 else if ( key.equals( "taxonomy_extraction_in_nh_parsing" ) ) {
1246 final String s = ( String ) st.nextElement();
1247 if ( s.equalsIgnoreCase( "no" ) ) {
1248 setTaxonomyExtraction( TAXONOMY_EXTRACTION.NO );
1250 else if ( s.equalsIgnoreCase( "yes" ) ) {
1251 setTaxonomyExtraction( TAXONOMY_EXTRACTION.YES );
1253 else if ( s.equalsIgnoreCase( "pfam" ) ) {
1254 setTaxonomyExtraction( TAXONOMY_EXTRACTION.PFAM_STYLE_ONLY );
1257 ForesterUtil.printWarningMessage( Constants.PRG_NAME,
1258 "unknown value for \"taxonomy_extraction_in_nh_parsing\": " + s );
1260 if ( ( getTaxonomyExtraction() != TAXONOMY_EXTRACTION.NO ) && isReplaceUnderscoresInNhParsing() ) {
1262 .printWarningMessage( Constants.PRG_NAME,
1263 "attempt to extract taxonomies and replace underscores at the same time" );
1266 else if ( key.equals( "internal_labels_are_confidence_values" ) ) {
1267 setInternalNumberAreConfidenceForNhParsing( parseBoolean( ( String ) st.nextElement() ) );
1269 else if ( key.equals( "gui_background_color" ) ) {
1270 _gui_background_color = Color.decode( ( String ) st.nextElement() );
1272 else if ( key.equals( "gui_checkbox_text_color" ) ) {
1273 _gui_checkbox_text_color = Color.decode( ( String ) st.nextElement() );
1275 else if ( key.equals( "gui_checkbox_and_button_active_color" ) ) {
1276 _gui_checkbox_and_button_active_color = Color.decode( ( String ) st.nextElement() );
1278 else if ( key.equals( "gui_button_text_color" ) ) {
1279 _gui_button_text_color = Color.decode( ( String ) st.nextElement() );
1281 else if ( key.equals( "gui_button_background_color" ) ) {
1282 _gui_button_background_color = Color.decode( ( String ) st.nextElement() );
1284 else if ( key.equals( "gui_menu_background_color" ) ) {
1285 _gui_menu_background_color = Color.decode( ( String ) st.nextElement() );
1287 else if ( key.equals( "gui_menu_text_color" ) ) {
1288 _gui_menu_text_color = Color.decode( ( String ) st.nextElement() );
1290 else if ( key.equals( "gui_button_border_color" ) ) {
1291 _gui_button_border_color = Color.decode( ( String ) st.nextElement() );
1293 else if ( key.equals( "domain_structure_font_color" ) ) {
1294 _domain_structure_font_color = Color.decode( ( String ) st.nextElement() );
1296 else if ( key.equals( "domain_structure_base_color" ) ) {
1297 _domain_structure_base_color = Color.decode( ( String ) st.nextElement() );
1299 else if ( key.equals( "show_default_node_shapes" ) ) {
1301 .printWarningMessage( Constants.PRG_NAME,
1302 "configuration key [show_default_node_shapes] is deprecated, use [show_default_node_shapes_internal] and [show_default_node_shapes_external] instead" );
1303 final boolean b = parseBoolean( ( ( String ) st.nextElement() ).trim() );
1304 setShowDefaultNodeShapesInternal( b );
1305 setShowDefaultNodeShapesExternal( b );
1307 else if ( key.equals( "show_default_node_shapes_internal" ) ) {
1308 setShowDefaultNodeShapesInternal( parseBoolean( ( ( String ) st.nextElement() ).trim() ) );
1310 else if ( key.equals( "show_default_node_shapes_external" ) ) {
1311 setShowDefaultNodeShapesExternal( parseBoolean( ( ( String ) st.nextElement() ).trim() ) );
1313 else if ( key.equals( "default_node_size" ) ) {
1314 final short i = parseShort( ( ( String ) st.nextElement() ).trim() );
1315 setDefaultNodeShapeSize( i );
1317 else if ( key.equals( "default_node_fill" ) ) {
1318 final String fill_str = ( ( String ) st.nextElement() ).trim();
1319 if ( fill_str.equalsIgnoreCase( NodeVisualization.NodeFill.NONE.toString() ) ) {
1320 setDefaultNodeFill( NodeFill.NONE );
1322 else if ( fill_str.equalsIgnoreCase( NodeVisualization.NodeFill.GRADIENT.toString() ) ) {
1323 setDefaultNodeFill( NodeFill.GRADIENT );
1325 else if ( fill_str.equalsIgnoreCase( NodeVisualization.NodeFill.SOLID.toString() ) ) {
1326 setDefaultNodeFill( NodeFill.SOLID );
1329 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown value [" + fill_str
1330 + "] for [default_node_fill]" );
1333 else if ( key.equals( "default_node_shape" ) ) {
1334 final String shape_str = ( ( String ) st.nextElement() ).trim();
1335 if ( shape_str.equalsIgnoreCase( NodeVisualization.NodeShape.CIRCLE.toString() ) ) {
1336 setDefaultNodeShape( NodeShape.CIRCLE );
1338 else if ( shape_str.equalsIgnoreCase( NodeVisualization.NodeShape.RECTANGLE.toString() ) ) {
1339 setDefaultNodeShape( NodeShape.RECTANGLE );
1342 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown value [" + shape_str
1343 + "] for [default_node_shape]" );
1346 else if ( key.equals( "taxonomy_colorize_node_shapes" ) ) {
1347 setTaxonomyColorizeNodeShapes( parseBoolean( ( String ) st.nextElement() ) );
1349 else if ( key.equals( "ext_descendents_data_to_return" ) ) {
1350 final String s = ( ( String ) st.nextElement() ).trim();
1351 if ( s.equalsIgnoreCase( "node_name" ) ) {
1352 setExtDescNodeDataToReturn( NODE_DATA.NODE_NAME );
1354 else if ( s.equalsIgnoreCase( "sequence_acc" ) ) {
1355 setExtDescNodeDataToReturn( NODE_DATA.SEQUENCE_ACC );
1357 else if ( s.equalsIgnoreCase( "sequence_mol_seq" ) ) {
1358 setExtDescNodeDataToReturn( NODE_DATA.SEQUENCE_MOL_SEQ );
1360 else if ( s.equalsIgnoreCase( "sequence_name" ) ) {
1361 setExtDescNodeDataToReturn( NODE_DATA.SEQUENCE_NAME );
1363 else if ( s.equalsIgnoreCase( "sequence_symbol" ) ) {
1364 setExtDescNodeDataToReturn( NODE_DATA.SEQUENCE_SYMBOL );
1366 else if ( s.equalsIgnoreCase( "taxonomy_scientific_name" ) ) {
1367 setExtDescNodeDataToReturn( NODE_DATA.TAXONOMY_SCIENTIFIC_NAME );
1369 else if ( s.equalsIgnoreCase( "taxonomy_code" ) ) {
1370 setExtDescNodeDataToReturn( NODE_DATA.TAXONOMY_CODE );
1372 else if ( s.equalsIgnoreCase( "user_selected" ) ) {
1373 setExtDescNodeDataToReturn( NODE_DATA.UNKNOWN );
1376 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown value [" + s
1377 + "] for [ext_descendents_data_to_return]" );
1380 else if ( key.equals( "label_for_get_ext_descendents_data" ) ) {
1381 final String s = ( ( String ) st.nextElement() ).trim();
1382 if ( ForesterUtil.isEmpty( s ) || ( s.length() < 2 ) ) {
1383 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "illegal value [" + s
1384 + "] for [label_for_get_ext_descendents_data]" );
1387 setLabelForGetExtDescendentsData( s.replaceAll( "_", " " ) );
1390 else if ( key.equals( "ext_descendents_data_to_return_on" ) ) {
1391 final String s = ( ( String ) st.nextElement() ).trim().toLowerCase();
1392 if ( s.equals( "console" ) ) {
1393 setExtNodeDataReturnOn( EXT_NODE_DATA_RETURN_ON.CONSOLE );
1395 else if ( s.equals( "window" ) ) {
1396 setExtNodeDataReturnOn( EXT_NODE_DATA_RETURN_ON.WINODW );
1398 else if ( s.equals( "buffer_only" ) ) {
1399 setExtNodeDataReturnOn( EXT_NODE_DATA_RETURN_ON.BUFFER_ONLY );
1402 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown value [" + s
1403 + "] for [ext_descendents_data_to_return_on]" );
1406 else if ( st.countTokens() >= 2 ) { // counts the tokens that are not
1409 if ( key.equals( "use_real_br_lengths" ) || key.equals( "phylogram" ) ) {
1410 key_index = Configuration.display_as_phylogram;
1411 if ( key.equals( "use_real_br_lengths" ) ) {
1413 .printWarningMessage( Constants.PRG_NAME,
1414 "configuration key [use_real_br_lengths] is deprecated, use [phylogram] instead" );
1417 else if ( key.equals( "rollover" ) ) {
1418 key_index = Configuration.node_data_popup;
1420 else if ( key.equals( "color_according_to_species" ) ) {
1421 key_index = Configuration.color_according_to_species;
1423 else if ( key.equals( "show_node_names" ) ) {
1424 key_index = Configuration.show_node_names;
1426 else if ( key.equals( "show_taxonomy" ) || key.equals( "show_taxonomy_code" ) ) {
1427 key_index = Configuration.show_tax_code;
1428 if ( key.equals( "show_taxonomy" ) ) {
1430 .printWarningMessage( Constants.PRG_NAME,
1431 "configuration key [show_taxonomy] is deprecated, use [show_taxonomy_code] instead" );
1434 else if ( key.equals( "write_br_length_values" ) ) {
1435 ForesterUtil.printWarningMessage( Constants.PRG_NAME,
1436 "configuration key [write_br_length_values] is deprecated" );
1437 key_index = DEPRECATED;
1439 else if ( key.equals( "write_bootstrap_values" ) || key.equals( "write_confidence_values" ) ) {
1440 key_index = Configuration.write_confidence_values;
1441 if ( key.equals( "write_bootstrap_values" ) ) {
1443 .printWarningMessage( Constants.PRG_NAME,
1444 "configuration key [write_bootstrap_values] is deprecated, use [write_confidence_values] instead" );
1447 else if ( key.equals( "write_events" ) || key.equals( "write_dup_spec" ) ) {
1448 key_index = Configuration.write_events;
1449 if ( key.equals( "write_dup_spec" ) ) {
1451 .printWarningMessage( Constants.PRG_NAME,
1452 "configuration key [write_dup_spec] is deprecated, use [write_events] instead" );
1455 else if ( key.equals( "color_branches" ) ) {
1456 key_index = Configuration.color_branches;
1458 else if ( key.equals( "width_branches" ) ) {
1459 key_index = Configuration.width_branches;
1461 else if ( key.equals( "color_orthologous" ) ) {
1462 ForesterUtil.printWarningMessage( Constants.PRG_NAME,
1463 "configuration key [color_orthologous] is deprecated" );
1465 else if ( key.equals( "color_subtree_neighbors" ) ) {
1466 ForesterUtil.printWarningMessage( Constants.PRG_NAME,
1467 "configuration key [color_subtree_neighbors] is deprecated" );
1469 else if ( key.equals( "color_super_orthologous" ) ) {
1470 ForesterUtil.printWarningMessage( Constants.PRG_NAME,
1471 "configuration key [color_super_orthologous] is deprecated" );
1473 else if ( key.equals( "mark_nodes_with_box" ) ) {
1474 ForesterUtil.printWarningMessage( Constants.PRG_NAME,
1475 "configuration key [mark_nodes_with_box] is deprecated" );
1476 key_index = DEPRECATED;
1478 else if ( key.equals( "show_domain_architectures" ) ) {
1479 key_index = Configuration.show_domain_architectures;
1481 else if ( key.equals( "show_annotations" ) ) {
1482 key_index = Configuration.show_annotation;
1484 else if ( key.equals( "show_binary_characters" ) ) {
1485 key_index = Configuration.show_binary_characters;
1487 else if ( key.equals( "show_binary_character_counts" ) ) {
1488 key_index = Configuration.show_binary_character_counts;
1490 else if ( key.equals( "show_gene_names" ) ) {
1491 key_index = Configuration.show_gene_names;
1493 else if ( key.equals( "show_gene_symbols" ) ) {
1494 key_index = Configuration.show_gene_symbols;
1496 else if ( key.equals( "show_sequence_acc" ) ) {
1497 key_index = Configuration.show_sequence_acc;
1499 else if ( key.equals( "show_node_ids" ) ) {
1501 .printWarningMessage( Constants.PRG_NAME, "configuration key [show_node_ids] is deprecated" );
1502 key_index = DEPRECATED;
1504 else if ( key.equals( "display_internal_data" ) ) {
1505 key_index = Configuration.display_internal_data;
1507 else if ( key.equals( "dynamically_hide_data" ) ) {
1508 key_index = Configuration.dynamically_hide_data;
1510 else if ( key.equals( "show_taxonomy_names" ) ) {
1511 ForesterUtil.printWarningMessage( Constants.PRG_NAME,
1512 "configuration key [show_taxonomy_names] is deprecated" );
1513 key_index = DEPRECATED;
1515 else if ( key.equals( "show_taxonomy_scientific_names" ) ) {
1516 key_index = Configuration.show_taxonomy_scientific_names;
1518 else if ( key.equals( "show_taxonomy_common_names" ) ) {
1519 key_index = Configuration.show_taxonomy_common_names;
1521 else if ( key.equals( "show_taxonomy_images" ) ) {
1522 key_index = Configuration.show_taxonomy_images;
1524 else if ( key.equals( "color_according_to_annotation" ) ) {
1525 key_index = Configuration.color_according_to_annotation;
1527 else if ( key.equals( "show_vector_data" ) ) {
1528 key_index = Configuration.show_vector_data;
1530 else if ( key.equals( "show_properties" ) ) {
1531 key_index = Configuration.show_properties;
1533 else if ( key.equals( "show_relation_confidence" ) ) {
1534 key_index = Configuration.show_relation_confidence;
1536 else if ( key.equals( "show_custom_node_shapes" ) ) {
1537 key_index = Configuration.show_custom_node_shapes;
1539 // If we've found the key, set the values
1540 if ( key_index >= 0 ) {
1541 display_options[ key_index ][ 1 ] = ( String ) st.nextElement();
1542 display_options[ key_index ][ 2 ] = ( String ) st.nextElement();
1543 // otherwise, keep looking
1546 if ( key_index == DEPRECATED ) {
1549 else if ( key.equals( "click_to" ) ) {
1550 final String click_to_name = ( String ) st.nextElement();
1551 key_index = getClickToIndex( click_to_name );
1552 if ( key_index >= 0 ) {
1553 clickto_options[ key_index ][ 1 ] = ( String ) st.nextElement();
1555 else if ( key_index == DEPRECATED ) {
1559 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown click-to option: "
1563 else if ( key.equals( "species_color" ) ) {
1564 getSpeciesColors().put( ( String ) st.nextElement(), Color.decode( ( String ) st.nextElement() ) );
1566 else if ( key.equals( "domain_color" ) ) {
1567 getDomainColors().put( ( String ) st.nextElement(), Color.decode( ( String ) st.nextElement() ) );
1569 else if ( key.equals( "annotation_color" ) ) {
1570 getAnnotationColors()
1571 .put( ( String ) st.nextElement(), Color.decode( ( String ) st.nextElement() ) );
1573 else if ( key.equals( "function_color" ) ) {
1574 ForesterUtil.printWarningMessage( Constants.PRG_NAME,
1575 "configuration key [function_color] is deprecated" );
1577 else if ( key.equals( DISPLAY_COLOR_KEY ) ) {
1578 putDisplayColors( ( String ) st.nextElement(), Color.decode( ( String ) st.nextElement() ) );
1580 else if ( key.equals( WEB_LINK_KEY ) ) {
1581 if ( st.countTokens() == 3 ) {
1582 createWebLink( ( String ) st.nextElement(),
1583 ( String ) st.nextElement(),
1584 ( String ) st.nextElement() );
1587 ForesterUtil.printWarningMessage( Constants.PRG_NAME,
1588 "illegal format in configuration file for key [" + key + "]" );
1592 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown configuration key [" + key
1593 + "] in: " + config_filename );
1598 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown configuration key [" + key + "] in: "
1599 + config_filename );
1603 private void setLabelForGetExtDescendentsData( final String label_for_get_ext_descendents_data ) {
1604 _label_for_get_ext_descendents_data = label_for_get_ext_descendents_data;
1607 public String getLabelForGetExtDescendentsData() {
1608 return _label_for_get_ext_descendents_data;
1611 public void setMinConfidenceValue( final double min_confidence_value ) {
1612 _min_confidence_value = min_confidence_value;
1615 public void setNodeLabelDirection( final NODE_LABEL_DIRECTION node_label_direction ) {
1616 _node_label_direction = node_label_direction;
1619 public void setNumberOfDigitsAfterCommaForBranchLengthValue( final short number_of_digits_after_comma_for_branch_length_values ) {
1620 _number_of_digits_after_comma_for_branch_length_values = number_of_digits_after_comma_for_branch_length_values;
1623 public void setNumberOfDigitsAfterCommaForConfidenceValues( final short number_of_digits_after_comma_for_confidence_values ) {
1624 _number_of_digits_after_comma_for_confidence_values = number_of_digits_after_comma_for_confidence_values;
1627 private void setOvMaxHeight( final short ov_max_height ) {
1628 _ov_max_height = ov_max_height;
1631 private void setOvMaxWidth( final short ov_max_width ) {
1632 _ov_max_width = ov_max_width;
1635 private void setOvPlacement( final OVERVIEW_PLACEMENT_TYPE ov_placement ) {
1636 _ov_placement = ov_placement;
1639 public void setPhylogenyGraphicsType( final PHYLOGENY_GRAPHICS_TYPE phylogeny_graphics_type ) {
1640 _phylogeny_graphics_type = phylogeny_graphics_type;
1643 public void setPrintLineWidth( final float print_line_width ) {
1644 _print_line_width = print_line_width;
1647 public void setReplaceUnderscoresInNhParsing( final boolean nh_parsing_replace_underscores ) {
1648 _nh_parsing_replace_underscores = nh_parsing_replace_underscores;
1651 public void setShowBranchLengthValues( final boolean show_branch_length_values ) {
1652 _show_branch_length_values = show_branch_length_values;
1655 public void setShowDefaultNodeShapesInternal( final boolean show_default_node_shapes_internal ) {
1656 _show_default_node_shapes_internal = show_default_node_shapes_internal;
1659 public void setShowDefaultNodeShapesExternal( final boolean show_default_node_shapes_external ) {
1660 _show_default_node_shapes_external = show_default_node_shapes_external;
1663 public void setShowDomainLabels( final boolean show_domain_labels ) {
1664 _show_domain_labels = show_domain_labels;
1667 private void setShowOverview( final boolean show_overview ) {
1668 _show_overview = show_overview;
1671 public void setShowScale( final boolean show_scale ) {
1672 _show_scale = show_scale;
1675 public void setTaxonomyColorize( final boolean b ) {
1676 display_options[ color_according_to_species ][ 2 ] = b ? "yes" : "no";
1679 public void setTaxonomyColorizeNodeShapes( final boolean taxonomy_colorize_node_shapes ) {
1680 _taxonomy_colorize_node_shapes = taxonomy_colorize_node_shapes;
1683 public void setUseBranchesWidths( final boolean b ) {
1684 display_options[ width_branches ][ 2 ] = b ? "yes" : "no";
1687 private void setValidatePhyloXmlAgainstSchema( final boolean validate_against_phyloxml_xsd_schema ) {
1688 _validate_against_phyloxml_xsd_schema = validate_against_phyloxml_xsd_schema;
1691 void setWebLinks( final SortedMap<String, WebLink> weblinks ) {
1692 _weblinks = weblinks;
1695 static String getDefaultFontFamilyName() {
1696 return DEFAULT_FONT_FAMILY;
1699 static enum TRIPLET {
1700 TRUE, FALSE, UNKNOWN
1704 NATIVE, CROSSPLATFORM, NIMBUS, UNKNOWN
1707 public NODE_DATA getExtDescNodeDataToReturn() {
1708 return _ext_desc_data_to_return;
1711 public void setExtDescNodeDataToReturn( final NODE_DATA ext_desc_data_to_return ) {
1712 _ext_desc_data_to_return = ext_desc_data_to_return;
1715 public EXT_NODE_DATA_RETURN_ON getExtNodeDataReturnOn() {
1716 return _ext_node_data_return_on;
1719 private void setExtNodeDataReturnOn( final EXT_NODE_DATA_RETURN_ON ext_node_data_return_on ) {
1720 _ext_node_data_return_on = ext_node_data_return_on;
1723 public int getFrameXSize() {
1724 return _frame_x_size;
1727 public int getFrameYSize() {
1728 return _frame_y_size;
1731 public void setFrameXSize( final int frame_x_size ) {
1732 _frame_x_size = frame_x_size;
1735 public void setFrameYSize( final int frame_y_size ) {
1736 _frame_y_size = frame_y_size;