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;
38 import java.util.Arrays;
39 import java.util.Hashtable;
41 import java.util.SortedMap;
42 import java.util.StringTokenizer;
43 import java.util.TreeMap;
45 import org.forester.archaeopteryx.Options.CLADOGRAM_TYPE;
46 import org.forester.archaeopteryx.Options.NODE_LABEL_DIRECTION;
47 import org.forester.archaeopteryx.Options.OVERVIEW_PLACEMENT_TYPE;
48 import org.forester.archaeopteryx.Options.PHYLOGENY_GRAPHICS_TYPE;
49 import org.forester.io.parsers.nhx.NHXParser.TAXONOMY_EXTRACTION;
50 import org.forester.phylogeny.data.NodeData.NODE_DATA;
51 import org.forester.phylogeny.data.NodeVisualData;
52 import org.forester.phylogeny.data.NodeVisualData.NodeFill;
53 import org.forester.phylogeny.data.NodeVisualData.NodeShape;
54 import org.forester.util.ForesterUtil;
56 public final class Configuration {
58 final static String clickto_options[][] = {
59 { "Display Node Data", "display" }, { "Collapse/Uncollapse", "display" }, { "Root/Reroot", "display" },
60 { "Sub/Super Tree", "display" }, { "Swap Descendants", "display" }, { "Colorize Subtree(s)", "display" },
61 { "Colorize Node Font", "display" }, { "Open Sequence DB", "display" }, { "Open PDB", "display" },
62 { "Open Taxonomy DB", "display" }, { "Blast", "display" }, { "Cut Subtree", "display" },
63 { "Copy Subtree", "display" }, { "Paste Subtree", "display" }, { "Delete Subtree/Node", "display" },
64 { "Add New Node", "display" }, { "Edit Node Data", "display" }, { "Sort Descendants", "display" },
65 { "Return", "display" }, { "Select Node(s)", "display" } };
66 final static int display_node_data = 0;
67 final static int collapse_uncollapse = 1;
68 final static int reroot = 2;
69 final static int subtree = 3;
70 final static int swap = 4;
71 final static int color_subtree = 5;
72 final static int color_node_font = 6;
73 final static int open_seq_web = 7;
74 final static int open_pdb_web = 8;
75 final static int open_tax_web = 9;
76 final static int blast = 10;
77 final static int cut_subtree = 11;
78 final static int copy_subtree = 12;
79 final static int paste_subtree = 13;
80 final static int delete_subtree_or_node = 14;
81 final static int add_new_node = 15;
82 final static int edit_node_data = 16;
83 final static int sort_descendents = 17;
84 final static int get_ext_desc_data = 18;
85 final static int select_nodes = 19;
89 final static String display_options[][] = {
90 { "Phylogram", "display", "?" }, { "Node Name", "display", "yes" }, { "Taxonomy Code", "display", "yes" },
91 { "Seq Annotations", "nodisplay", "no" }, { "Confidence Values", "display", "?" },
92 { "Node Events", "display", "?" }, { "Colorize by Taxonomy", "display", "no" },
93 { "Use Branch Colors", "display", "no" }, { "Use Branch Widths", "display", "no" },
94 { "Show Custom Nodes", "display", "yes" }, { "Protein Domains", "nodisplay", "no" },
95 { "Binary Characters", "nodisplay", "no" }, { "Binary Char Counts", "nodisplay", "no" },
96 { "Seq Name", "display", "yes" }, { "Seq Accession", "display", "no" },
97 { "Show Internal Data", "display", "yes" }, { "Dyna Hide", "display", "yes" },
98 { "Taxonomy Scientific", "display", "yes" }, { "Taxonomy Common", "display", "no" },
99 { "Colorize by Annotation", "nodisplay", "no" }, { "Seq Symbol", "display", "yes" },
100 { "Rollover", "display", "yes" }, { "Relation Confidence", "nodisplay", "no" },
101 { "Vector Data", "nodisplay", "no" }, { "Taxonomy Images", "display", "no" },
102 { "Properties", "nodisplay", "no" }, { "Gene Name", "display", "yes" } };
103 final static int display_as_phylogram = 0;
104 final static int show_node_names = 1;
105 final static int show_tax_code = 2;
106 final static int show_annotation = 3;
107 final static int write_confidence_values = 4;
108 final static int write_events = 5;
109 final static int color_according_to_species = 6;
110 final static int color_branches = 7;
111 final static int width_branches = 8;
112 final static int show_custom_node_shapes = 9;
113 final static int show_domain_architectures = 10;
114 final static int show_binary_characters = 11;
115 final static int show_binary_character_counts = 12;
116 final static int show_seq_names = 13;
117 final static int show_sequence_acc = 14;
118 final static int display_internal_data = 15;
119 final static int dynamically_hide_data = 16;
120 final static int show_taxonomy_scientific_names = 17;
121 final static int show_taxonomy_common_names = 18;
122 final static int color_according_to_annotation = 19;
123 final static int show_seq_symbols = 20;
124 final static int node_data_popup = 21;
125 final static int show_relation_confidence = 22;
126 final static int show_vector_data = 23;
127 final static int show_taxonomy_images = 24;
128 final static int show_properties = 25;
129 final static int show_gene_names = 26;
130 static final String VALIDATE_AGAINST_PHYLOXML_XSD_SCHEMA = "validate_against_phyloxml_xsd_schema";
134 private static Hashtable<String, Color> _annotation_colors;
138 private static Hashtable<String, Color> _domain_colors;
142 private static Hashtable<String, Color> _species_colors;
143 private static String DEFAULT_FONT_FAMILY = "";
144 private static final int DEPRECATED = -2;
145 private static final String DISPLAY_COLOR_KEY = "display_color";
146 // ---------------------------
147 // Display options for trees
148 // ---------------------------
149 // ---------------------------------
150 // Pertaining to the config itself
151 // ---------------------------------
152 // Full path to config (may be URL)
153 String config_filename;
154 // This option is selected in the dropdown
155 int default_clickto = Configuration.display_node_data;
156 String default_config_filename = Constants.DEFAULT_CONFIGURATION_FILE_NAME;
160 TreeColorSet tree_color_set;
164 TreeFontSet tree_font_set;
165 boolean verbose = Constants.VERBOSE_DEFAULT;
166 private boolean _abbreviate_scientific_names = false;
167 private boolean _antialias_screen = true;
168 private boolean _background_color_gradient = false;
169 private String _base_font_family_name = "";
170 private int _base_font_size = -1;
171 private CLADOGRAM_TYPE _cladogram_type = Constants.CLADOGRAM_TYPE_DEFAULT;
172 private boolean _color_labels_same_as_parent_branch = false;
173 private int _default_bootstrap_samples = -1;
174 private NodeFill _default_node_fill = NodeFill.SOLID;
175 private NodeShape _default_node_shape = NodeShape.RECTANGLE;
176 private short _default_node_shape_size = Constants.DEFAULT_NODE_SHAPE_SIZE_DEFAULT;
177 private SortedMap<String, Color> _display_colors = null;
178 private boolean _display_sequence_relations = false;
179 private Color _domain_structure_base_color = Constants.DOMAIN_STRUCTURE_BASE_COLOR_DEFAULT;
180 private Color _domain_structure_font_color = Constants.DOMAIN_STRUCTURE_FONT_COLOR_DEFAULT;
181 private boolean _editable = true;
182 private NODE_DATA _ext_desc_data_to_return = NODE_DATA.UNKNOWN;
183 private EXT_NODE_DATA_RETURN_ON _ext_node_data_return_on = EXT_NODE_DATA_RETURN_ON.WINODW;
184 private int _frame_x_size;
185 private int _frame_y_size;
186 private int _graphics_export_x = -1;
187 private int _graphics_export_y = -1;
188 private Color _gui_background_color = Constants.GUI_BACKGROUND_DEFAULT;
189 private Color _gui_button_background_color = Constants.BUTTON_BACKGROUND_COLOR_DEFAULT;
190 private Color _gui_button_border_color = Constants.BUTTON_BORDER_COLOR_DEFAULT;
191 private Color _gui_button_text_color = Constants.BUTTON_TEXT_COLOR_DEFAULT;
192 private Color _gui_checkbox_and_button_active_color = Constants.CHECKBOX_AND_BUTTON_ACTIVE_COLOR_DEFAULT;
193 private Color _gui_checkbox_text_color = Constants.CHECKBOX_TEXT_COLOR_DEFAULT;
194 private Color _gui_menu_background_color = Constants.MENU_BACKGROUND_COLOR_DEFAULT;
195 private Color _gui_menu_text_color = Constants.MENU_TEXT_COLOR_DEFAULT;
196 private boolean _hide_controls_and_menus = false;
197 private boolean _internal_number_are_confidence_for_nh_parsing = false;
198 private String _label_for_get_ext_descendents_data = "";
199 private int _max_base_font_size = 20;
200 private boolean _midpoint_root = false;
201 private int _min_base_font_size = 2;
202 private double _min_confidence_value = Options.MIN_CONFIDENCE_DEFAULT;
203 private boolean _nh_parsing_replace_underscores = false;
204 private NODE_LABEL_DIRECTION _node_label_direction = NODE_LABEL_DIRECTION.HORIZONTAL;
205 private short _number_of_digits_after_comma_for_branch_length_values = Constants.NUMBER_OF_DIGITS_AFTER_COMMA_FOR_BRANCH_LENGTH_VALUES_DEFAULT;
206 private short _number_of_digits_after_comma_for_confidence_values = Constants.NUMBER_OF_DIGITS_AFTER_COMMA_FOR_CONFIDENCE_VALUES_DEFAULT;
207 private short _ov_max_height = 80;
208 private short _ov_max_width = 80;
209 private OVERVIEW_PLACEMENT_TYPE _ov_placement = OVERVIEW_PLACEMENT_TYPE.UPPER_LEFT;
210 private File _path_to_local_fastme = null;
211 private File _path_to_local_mafft = null;
212 private File _path_to_local_raxml = null;
213 private PHYLOGENY_GRAPHICS_TYPE _phylogeny_graphics_type = PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR;
214 private float _print_line_width = Constants.PDF_LINE_WIDTH_DEFAULT;
215 private boolean _show_annotation_ref_source = true;
216 private boolean _show_branch_length_values = false;
217 private boolean _show_default_node_shapes_external = false;
218 private boolean _show_default_node_shapes_internal = false;
219 private boolean _show_domain_labels = true;
220 private boolean _show_overview = true;
221 private boolean _show_scale = false;
222 private TAXONOMY_EXTRACTION _taxonomy_extraction = TAXONOMY_EXTRACTION.NO;
223 private UI _ui = UI.UNKNOWN;
224 private boolean _use_tabbed_display = false;
225 private boolean _validate_against_phyloxml_xsd_schema = Constants.VALIDATE_AGAINST_PHYLOXML_XSD_SCJEMA_DEFAULT;
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 setDisplayColors( new TreeMap<String, Color>() );
250 config_filename = config_filename.trim();
253 // If URL, open accordingly
255 u = new URL( config_filename );
257 final InputStreamReader isr = new InputStreamReader( u.openStream() );
258 final BufferedReader bf = new BufferedReader( isr );
261 ForesterUtil.programMessage( Constants.PRG_NAME, "successfully read from configuration url ["
262 + config_filename + "]" );
264 catch ( final Exception e ) {
265 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "failed to read configuration from ["
266 + config_filename + "]: " + e.getLocalizedMessage() );
269 catch ( final Exception e ) {
270 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "cannot find or open configuration url ["
271 + config_filename + "]" );
275 // Otherwise, open as a file
276 File f = new File( config_filename );
278 f = new File( config_filename + ".txt" );
280 if ( f.exists() && f.canRead() ) {
282 final BufferedReader bf = new BufferedReader( new FileReader( f ) );
286 catch ( final Exception e ) {
288 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "failed to read configuration from ["
289 + config_filename + "]: " + e );
295 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "cannot find or open configuration file ["
296 + config_filename + "]" );
302 public String getBaseFontFamilyName() {
303 return _base_font_family_name;
306 public int getDefaultBootstrapSamples() {
307 return _default_bootstrap_samples;
310 public NodeFill getDefaultNodeFill() {
311 return _default_node_fill;
314 public NodeShape getDefaultNodeShape() {
315 return _default_node_shape;
318 public short getDefaultNodeShapeSize() {
319 return _default_node_shape_size;
322 public Color getDomainStructureBaseColor() {
323 return _domain_structure_base_color;
326 public Color getDomainStructureFontColor() {
327 return _domain_structure_font_color;
330 public NODE_DATA getExtDescNodeDataToReturn() {
331 return _ext_desc_data_to_return;
334 public EXT_NODE_DATA_RETURN_ON getExtNodeDataReturnOn() {
335 return _ext_node_data_return_on;
338 public int getFrameXSize() {
339 return _frame_x_size;
342 public int getFrameYSize() {
343 return _frame_y_size;
346 public String getLabelForGetExtDescendentsData() {
347 return _label_for_get_ext_descendents_data;
350 public File getPathToLocalFastme() {
351 return _path_to_local_fastme;
354 public File getpathToLocalMafft() {
355 return _path_to_local_mafft;
358 public File getPathToLocalRaxml() {
359 return _path_to_local_raxml;
362 public boolean isAbbreviateScientificTaxonNames() {
363 return _abbreviate_scientific_names;
366 public boolean isBackgroundColorGradient() {
367 return _background_color_gradient;
370 public boolean isColorByTaxonomicGroup() {
374 public boolean isColorLabelsSameAsParentBranch() {
375 return _color_labels_same_as_parent_branch;
378 public boolean isMidpointReroot() {
379 return _midpoint_root;
382 public boolean isShowAnnotationRefSource() {
383 return _show_annotation_ref_source;
386 public boolean isShowDefaultNodeShapesExternal() {
387 return _show_default_node_shapes_external;
390 public boolean isShowDefaultNodeShapesInternal() {
391 return _show_default_node_shapes_internal;
394 public boolean isShowDomainLabels() {
395 return _show_domain_labels;
398 public void putDisplayColors( final String key, final Color color ) {
399 getDisplayColors().put( key, color );
402 public void setAbbreviateScientificTaxonNames( final boolean abbreviate_scientific_names ) {
403 _abbreviate_scientific_names = abbreviate_scientific_names;
406 public void setBackgroundColorGradient( final boolean background_color_gradient ) {
407 _background_color_gradient = background_color_gradient;
410 public void setBaseFontFamilyName( final String base_font_family_name ) {
411 _base_font_family_name = base_font_family_name;
414 public void setBaseFontSize( final int base_font_size ) {
415 _base_font_size = base_font_size;
418 public void setColorizeBranches( final boolean b ) {
419 display_options[ color_branches ][ 2 ] = b ? "yes" : "no";
422 public void setColorLabelsSameAsParentBranch( final boolean color_labels_same_as_parent_branch ) {
423 _color_labels_same_as_parent_branch = color_labels_same_as_parent_branch;
426 public void setDefaultNodeFill( final NodeFill default_node_fill ) {
427 _default_node_fill = default_node_fill;
430 public void setDefaultNodeShape( final NodeShape default_node_shape ) {
431 _default_node_shape = default_node_shape;
434 public void setDefaultNodeShapeSize( final short default_node_shape_size ) {
435 _default_node_shape_size = default_node_shape_size;
438 public void setDisplayAsPhylogram( final boolean b ) {
439 display_options[ display_as_phylogram ][ 2 ] = b ? "yes" : "no";
442 public void setDisplayColors( final SortedMap<String, Color> display_colors ) {
443 _display_colors = display_colors;
446 public void setDisplayConfidenceValues( final boolean b ) {
447 display_options[ write_confidence_values ][ 2 ] = b ? "yes" : "no";
450 public void setDisplayInternalData( final boolean b ) {
451 display_options[ display_internal_data ][ 2 ] = b ? "yes" : "no";
454 public void setDisplayNodeNames( final boolean b ) {
455 display_options[ show_node_names ][ 2 ] = b ? "yes" : "no";
458 public void setDisplaySequenceAcc( final boolean b ) {
459 display_options[ show_sequence_acc ][ 2 ] = b ? "yes" : "no";
462 public void setDisplaySequenceNames( final boolean b ) {
463 display_options[ show_seq_names ][ 2 ] = b ? "yes" : "no";
466 public void setDisplaySequenceRelations( final boolean display_sequence_relations ) {
467 _display_sequence_relations = display_sequence_relations;
470 public void setDisplaySequenceSymbols( final boolean b ) {
471 display_options[ show_seq_symbols ][ 2 ] = b ? "yes" : "no";
474 public void setDisplayTaxonomyCode( final boolean b ) {
475 display_options[ show_tax_code ][ 2 ] = b ? "yes" : "no";
478 public void setDisplayTaxonomyCommonNames( final boolean b ) {
479 display_options[ show_taxonomy_common_names ][ 2 ] = b ? "yes" : "no";
482 public void setDisplayTaxonomyImages( final boolean b ) {
483 display_options[ show_taxonomy_images ][ 2 ] = b ? "yes" : "no";
486 public void setDisplayTaxonomyScientificNames( final boolean b ) {
487 display_options[ show_taxonomy_scientific_names ][ 2 ] = b ? "yes" : "no";
490 public void setDynamicallyHideData( final boolean b ) {
491 display_options[ dynamically_hide_data ][ 2 ] = b ? "yes" : "no";
494 public void setExtDescNodeDataToReturn( final NODE_DATA ext_desc_data_to_return ) {
495 _ext_desc_data_to_return = ext_desc_data_to_return;
498 public void setFrameXSize( final int frame_x_size ) {
499 _frame_x_size = frame_x_size;
502 public void setFrameYSize( final int frame_y_size ) {
503 _frame_y_size = frame_y_size;
506 public void setMidpointReroot( final boolean midpoint_root ) {
507 _midpoint_root = midpoint_root;
510 public void setMinConfidenceValue( final double min_confidence_value ) {
511 _min_confidence_value = min_confidence_value;
514 public void setNodeLabelDirection( final NODE_LABEL_DIRECTION node_label_direction ) {
515 _node_label_direction = node_label_direction;
518 public void setNumberOfDigitsAfterCommaForBranchLengthValue( final short number_of_digits_after_comma_for_branch_length_values ) {
519 _number_of_digits_after_comma_for_branch_length_values = number_of_digits_after_comma_for_branch_length_values;
522 public void setNumberOfDigitsAfterCommaForConfidenceValues( final short number_of_digits_after_comma_for_confidence_values ) {
523 _number_of_digits_after_comma_for_confidence_values = number_of_digits_after_comma_for_confidence_values;
526 public void setPhylogenyGraphicsType( final PHYLOGENY_GRAPHICS_TYPE phylogeny_graphics_type ) {
527 _phylogeny_graphics_type = phylogeny_graphics_type;
530 public void setPrintLineWidth( final float print_line_width ) {
531 _print_line_width = print_line_width;
534 public void setReplaceUnderscoresInNhParsing( final boolean nh_parsing_replace_underscores ) {
535 _nh_parsing_replace_underscores = nh_parsing_replace_underscores;
538 public void setShowBranchLengthValues( final boolean show_branch_length_values ) {
539 _show_branch_length_values = show_branch_length_values;
542 public void setShowDefaultNodeShapesExternal( final boolean show_default_node_shapes_external ) {
543 _show_default_node_shapes_external = show_default_node_shapes_external;
546 public void setShowDefaultNodeShapesInternal( final boolean show_default_node_shapes_internal ) {
547 _show_default_node_shapes_internal = show_default_node_shapes_internal;
550 public void setShowDomainLabels( final boolean show_domain_labels ) {
551 _show_domain_labels = show_domain_labels;
554 public void setShowScale( final boolean show_scale ) {
555 _show_scale = show_scale;
558 public void setTaxonomyColorize( final boolean b ) {
559 display_options[ color_according_to_species ][ 2 ] = b ? "yes" : "no";
562 public void setUseBranchesWidths( final boolean b ) {
563 display_options[ width_branches ][ 2 ] = b ? "yes" : "no";
566 boolean displaySequenceRelations() {
567 return _display_sequence_relations;
570 boolean doCheckOption( final int which ) {
571 return ( display_options[ which ][ 2 ].equalsIgnoreCase( "yes" ) )
572 || ( display_options[ which ][ 2 ].equalsIgnoreCase( "true" ) );
575 boolean doDisplayClickToOption( final int which ) {
576 return clickto_options[ which ][ 1 ].equalsIgnoreCase( "display" );
579 boolean doDisplayOption( final int which ) {
580 return display_options[ which ][ 1 ].equalsIgnoreCase( "display" );
584 * Will attempt to use the phylogeny to determine whether to check
585 * this or not (e.g. phylogram)
588 boolean doGuessCheckOption( final int which ) {
589 return display_options[ which ][ 2 ].equals( "?" );
592 Map<String, Color> getAnnotationColors() {
593 if ( _annotation_colors == null ) {
594 _annotation_colors = new Hashtable<String, Color>();
596 return _annotation_colors;
599 int getBaseFontSize() {
600 return _base_font_size;
603 CLADOGRAM_TYPE getCladogramType() {
604 return _cladogram_type;
607 int getClickToOptionsCount() {
608 return clickto_options.length;
611 String getClickToTitle( final int which ) {
612 return clickto_options[ which ][ 0 ];
615 int getDefaultDisplayClicktoOption() {
616 return default_clickto;
619 SortedMap<String, Color> getDisplayColors() {
620 return _display_colors;
623 String getDisplayTitle( final int which ) {
624 return display_options[ which ][ 0 ];
627 Map<String, Color> getDomainColors() {
628 if ( _domain_colors == null ) {
629 _domain_colors = new Hashtable<String, Color>();
631 return _domain_colors;
634 int getGraphicsExportX() {
635 return _graphics_export_x;
638 int getGraphicsExportY() {
639 return _graphics_export_y;
642 Color getGuiBackgroundColor() {
643 return _gui_background_color;
646 Color getGuiButtonBackgroundColor() {
647 return _gui_button_background_color;
650 Color getGuiButtonBorderColor() {
651 return _gui_button_border_color;
654 Color getGuiButtonTextColor() {
655 return _gui_button_text_color;
658 Color getGuiCheckboxAndButtonActiveColor() {
659 return _gui_checkbox_and_button_active_color;
662 Color getGuiCheckboxTextColor() {
663 return _gui_checkbox_text_color;
666 Color getGuiMenuBackgroundColor() {
667 return _gui_menu_background_color;
670 Color getGuiMenuTextColor() {
671 return _gui_menu_text_color;
674 int getMaxBaseFontSize() {
675 return _max_base_font_size;
678 int getMinBaseFontSize() {
679 return _min_base_font_size;
682 double getMinConfidenceValue() {
683 return _min_confidence_value;
686 NODE_LABEL_DIRECTION getNodeLabelDirection() {
687 return _node_label_direction;
690 short getNumberOfDigitsAfterCommaForBranchLengthValues() {
691 return _number_of_digits_after_comma_for_branch_length_values;
694 short getNumberOfDigitsAfterCommaForConfidenceValues() {
695 return _number_of_digits_after_comma_for_confidence_values;
698 short getOvMaxHeight() {
699 return _ov_max_height;
702 short getOvMaxWidth() {
703 return _ov_max_width;
706 OVERVIEW_PLACEMENT_TYPE getOvPlacement() {
707 return _ov_placement;
710 PHYLOGENY_GRAPHICS_TYPE getPhylogenyGraphicsType() {
711 return _phylogeny_graphics_type;
714 float getPrintLineWidth() {
715 return _print_line_width;
718 Hashtable<String, Color> getSpeciesColors() {
719 if ( _species_colors == null ) {
720 _species_colors = new Hashtable<String, Color>();
722 return _species_colors;
725 final TAXONOMY_EXTRACTION getTaxonomyExtraction() {
726 return _taxonomy_extraction;
729 boolean isAntialiasScreen() {
730 if ( ForesterUtil.isMac() ) {
731 //Apple Macintosh graphics are slow, turn off anti-alias.
734 return _antialias_screen;
738 * Convenience method.
740 * @return true if value in configuration file was 'yes'
742 boolean isDrawAsPhylogram() {
743 return doCheckOption( display_as_phylogram );
746 boolean isEditable() {
751 * Only used by ArchaeoptryxE.
754 boolean isHideControlPanelAndMenubar() {
755 return _hide_controls_and_menus;
758 boolean isInternalNumberAreConfidenceForNhParsing() {
759 return _internal_number_are_confidence_for_nh_parsing;
762 boolean isReplaceUnderscoresInNhParsing() {
763 return _nh_parsing_replace_underscores;
766 boolean isShowBranchLengthValues() {
767 return _show_branch_length_values;
770 boolean isShowOverview() {
771 return _show_overview;
774 boolean isShowScale() {
778 final boolean isUseNativeUI() {
779 if ( ( _ui == UI.UNKNOWN ) && ForesterUtil.isMac() ) {
782 return _ui == UI.NATIVE;
786 * Only used by ArchaeoptryxE.
789 boolean isUseTabbedDisplay() {
790 return _use_tabbed_display;
793 boolean isValidatePhyloXmlAgainstSchema() {
794 return _validate_against_phyloxml_xsd_schema;
797 final void setTaxonomyExtraction( final TAXONOMY_EXTRACTION taxonomy_extraction ) {
798 _taxonomy_extraction = taxonomy_extraction;
801 private int getClickToIndex( final String name ) {
803 if ( name.equals( "edit_info" ) ) {
804 index = Configuration.display_node_data;
806 .printWarningMessage( Constants.PRG_NAME,
807 "configuration key [edit_info] is deprecated, use [display node data] instead" );
809 else if ( name.equals( "display_node_data" ) ) {
810 index = Configuration.display_node_data;
812 else if ( name.equals( "collapse_uncollapse" ) ) {
813 index = Configuration.collapse_uncollapse;
815 else if ( name.equals( "reroot" ) ) {
816 index = Configuration.reroot;
818 else if ( name.equals( "subtree" ) ) {
819 index = Configuration.subtree;
821 else if ( name.equals( "swap" ) ) {
822 index = Configuration.swap;
824 else if ( name.equals( "sort_descendants" ) ) {
825 index = Configuration.sort_descendents;
827 else if ( name.equals( "get_ext_descendents_data" ) ) {
828 index = Configuration.get_ext_desc_data;
830 else if ( name.equals( "display_sequences" ) ) {
832 .printWarningMessage( Constants.PRG_NAME, "configuration key [display_sequences] is deprecated" );
835 else if ( name.equals( "open_seq_web" ) ) {
836 index = Configuration.open_seq_web;
838 else if ( name.equals( "open_pdb_web" ) ) {
839 index = Configuration.open_pdb_web;
841 else if ( name.equals( "open_tax_web" ) ) {
842 index = Configuration.open_tax_web;
844 else if ( name.equals( "blast" ) ) {
845 index = Configuration.blast;
847 else if ( name.equals( "cut_subtree" ) ) {
848 index = Configuration.cut_subtree;
850 else if ( name.equals( "copy_subtree" ) ) {
851 index = Configuration.copy_subtree;
853 else if ( name.equals( "paste_subtree" ) ) {
854 index = Configuration.paste_subtree;
856 else if ( name.equals( "delete" ) ) {
857 index = Configuration.delete_subtree_or_node;
859 else if ( name.equals( "add_new_node" ) ) {
860 index = Configuration.add_new_node;
862 else if ( name.equals( "edit_node_data" ) ) {
863 index = Configuration.edit_node_data;
865 else if ( name.equals( "select_nodes" ) ) {
866 index = Configuration.select_nodes;
868 else if ( name.equals( "display_node_popup" ) ) {
869 ForesterUtil.printWarningMessage( Constants.PRG_NAME,
870 "configuration key [display_node_popup] is deprecated" );
873 else if ( name.equals( "custom_option" ) ) {
874 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "configuration key [custom_option] is deprecated" );
877 else if ( name.equals( "color_subtree" ) ) {
878 index = Configuration.color_subtree;
883 private boolean parseBoolean( final String str ) {
884 final String my_str = str.trim().toLowerCase();
885 if ( my_str.equals( "yes" ) || my_str.equals( "true" ) ) {
888 else if ( my_str.equals( "no" ) || my_str.equals( "false" ) ) {
892 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "could not parse boolean value from [" + str + "]" );
897 private double parseDouble( final String str ) {
900 d = Double.parseDouble( str.trim() );
902 catch ( final Exception e ) {
903 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "could not parse double from [" + str + "]" );
909 private float parseFloat( final String str ) {
912 f = Float.parseFloat( str.trim() );
914 catch ( final Exception e ) {
915 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "could not parse float from [" + str + "]" );
921 private int parseInt( final String str ) {
924 i = Integer.parseInt( str.trim() );
926 catch ( final Exception e ) {
927 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "could not parse integer from [" + str + "]" );
933 private short parseShort( final String str ) {
936 i = Short.parseShort( str.trim() );
938 catch ( final Exception e ) {
939 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "could not parse short from [" + str + "]" );
945 private void processFontFamily( final StringTokenizer st ) {
946 setBaseFontFamilyName( "" );
947 final String font_str = ( ( String ) st.nextElement() ).trim();
948 final String[] fonts = font_str.split( ",+" );
949 for( String font : fonts ) {
950 font = font.replace( '_', ' ' ).trim();
951 if ( Arrays.binarySearch( AptxUtil.getAvailableFontFamiliesSorted(), font ) >= 0 ) {
952 setBaseFontFamilyName( font );
959 * read each line of config file, process non-comment lines
960 * @throws IOException
962 private void readConfig( final BufferedReader conf_in ) throws IOException {
965 line = conf_in.readLine();
966 if ( line != null ) {
968 // skip comments and blank lines
969 if ( !line.startsWith( "#" ) && ( !ForesterUtil.isEmpty( line ) ) ) {
970 // convert runs of spaces to tabs
971 line = line.replaceAll( "\\s+", "\t" );
972 final StringTokenizer st = new StringTokenizer( line, "\t" );
976 } while ( line != null );
979 private void setAntialiasScreen( final boolean antialias_screen ) {
980 _antialias_screen = antialias_screen;
983 private void setCladogramType( final CLADOGRAM_TYPE cladogram_type ) {
984 _cladogram_type = cladogram_type;
987 private void setDefaultBootstrapSamples( final int default_bootstrap_samples ) {
988 _default_bootstrap_samples = default_bootstrap_samples;
991 private void setEditable( final boolean editable ) {
992 _editable = editable;
995 private void setExtNodeDataReturnOn( final EXT_NODE_DATA_RETURN_ON ext_node_data_return_on ) {
996 _ext_node_data_return_on = ext_node_data_return_on;
999 private void setGraphicsExportX( final int graphics_export_x ) {
1000 _graphics_export_x = graphics_export_x;
1003 private void setGraphicsExportY( final int graphics_export_y ) {
1004 _graphics_export_y = graphics_export_y;
1007 private void setInternalNumberAreConfidenceForNhParsing( final boolean internal_number_are_confidence_for_nh_parsing ) {
1008 _internal_number_are_confidence_for_nh_parsing = internal_number_are_confidence_for_nh_parsing;
1012 * Set a key-value(s) tuple
1014 private void setKeyValue( final StringTokenizer st ) {
1015 final String key = ( ( String ) st.nextElement() ).replace( ':', ' ' ).trim().toLowerCase();
1016 if ( !st.hasMoreElements() ) {
1019 // Handle single value settings first:
1020 if ( key.equals( "default_click_to" ) ) {
1021 final String clickto_name = ( String ) st.nextElement();
1022 default_clickto = getClickToIndex( clickto_name );
1023 if ( default_clickto == -1 ) {
1024 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "invalid value [" + clickto_name
1025 + "] for [default_click_to]" );
1026 default_clickto = 0;
1028 else if ( default_clickto == DEPRECATED ) {
1032 else if ( key.equals( "native_ui" ) ) {
1033 final String my_str = ( ( String ) st.nextElement() ).trim().toLowerCase();
1034 if ( my_str.equals( "yes" ) || my_str.equals( "true" ) ) {
1037 else if ( my_str.equals( "no" ) || my_str.equals( "false" ) ) {
1038 _ui = UI.CROSSPLATFORM;
1040 else if ( my_str.equals( "?" ) ) {
1044 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "could not parse yes/no/? value from [" + my_str
1049 else if ( key.equals( VALIDATE_AGAINST_PHYLOXML_XSD_SCHEMA ) ) {
1050 setValidatePhyloXmlAgainstSchema( parseBoolean( ( String ) st.nextElement() ) );
1052 else if ( key.equals( "antialias_screen" ) ) {
1053 setAntialiasScreen( parseBoolean( ( String ) st.nextElement() ) );
1055 else if ( key.equals( "phylogeny_graphics_type" ) ) {
1056 final String type_str = ( ( String ) st.nextElement() ).trim();
1057 if ( type_str.equalsIgnoreCase( PHYLOGENY_GRAPHICS_TYPE.CONVEX.toString() ) ) {
1058 setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CONVEX );
1060 else if ( type_str.equalsIgnoreCase( PHYLOGENY_GRAPHICS_TYPE.CURVED.toString() ) ) {
1061 setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CURVED );
1063 else if ( type_str.equalsIgnoreCase( PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE.toString() ) ) {
1064 setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE );
1066 else if ( type_str.equalsIgnoreCase( PHYLOGENY_GRAPHICS_TYPE.ROUNDED.toString() ) ) {
1067 setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.ROUNDED );
1069 else if ( type_str.equalsIgnoreCase( PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR.toString() ) ) {
1070 setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR );
1072 else if ( type_str.equalsIgnoreCase( PHYLOGENY_GRAPHICS_TYPE.TRIANGULAR.toString() ) ) {
1073 setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.TRIANGULAR );
1075 else if ( type_str.equalsIgnoreCase( PHYLOGENY_GRAPHICS_TYPE.UNROOTED.toString() ) ) {
1076 setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.UNROOTED );
1078 else if ( type_str.equalsIgnoreCase( PHYLOGENY_GRAPHICS_TYPE.CIRCULAR.toString() ) ) {
1079 setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CIRCULAR );
1082 setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR );
1083 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown value [" + type_str
1084 + "] for [phylogeny_graphics_type]" );
1087 else if ( key.equals( "min_confidence_value" ) ) {
1088 final String mcv_str = ( ( String ) st.nextElement() ).trim();
1089 final double d = parseDouble( mcv_str );
1090 setMinConfidenceValue( d );
1092 else if ( key.equals( "font_family" ) ) {
1093 processFontFamily( st );
1095 else if ( key.equals( "font_size" ) ) {
1096 final String size_str = ( ( String ) st.nextElement() ).trim();
1097 final int i = parseInt( size_str );
1099 setBaseFontSize( i );
1102 else if ( key.equals( "font_size_min" ) ) {
1103 final String size_str = ( ( String ) st.nextElement() ).trim();
1104 final int i = parseInt( size_str );
1106 setMinBaseFontSize( i );
1109 else if ( key.equals( "font_size_max" ) ) {
1110 final String size_str = ( ( String ) st.nextElement() ).trim();
1111 final int i = parseInt( size_str );
1113 setMaxBaseFontSize( i );
1116 else if ( key.equals( "graphics_export_x" ) ) {
1117 final String str = ( ( String ) st.nextElement() ).trim();
1118 final int i = parseInt( str );
1120 setGraphicsExportX( i );
1123 else if ( key.equals( "graphics_export_y" ) ) {
1124 final String str = ( ( String ) st.nextElement() ).trim();
1125 final int i = parseInt( str );
1127 setGraphicsExportY( i );
1130 else if ( key.equals( "pdf_export_line_width" ) ) {
1131 final String str = ( ( String ) st.nextElement() ).trim();
1132 final float f = parseFloat( str );
1134 setPrintLineWidth( f );
1137 ForesterUtil.printWarningMessage( Constants.PRG_NAME,
1138 "value for [pdf_export_line_width] cannot be zero or negative" );
1141 else if ( key.equals( "window_initial_size_x" ) ) {
1142 final String str = ( ( String ) st.nextElement() ).trim();
1143 final int i = parseInt( str );
1148 else if ( key.equals( "window_initial_size_y" ) ) {
1149 final String str = ( ( String ) st.nextElement() ).trim();
1150 final int i = parseInt( str );
1155 else if ( key.equals( "default_number_of_bootstrap_resamples" ) ) {
1156 final String str = ( ( String ) st.nextElement() ).trim();
1157 final int i = parseInt( str );
1159 setDefaultBootstrapSamples( i );
1163 .printWarningMessage( Constants.PRG_NAME,
1164 "value for [default_number_of_bootstrap_resamples] cannot be negative" );
1167 else if ( key.equals( "mafft_local" ) ) {
1168 final String str = ( ( String ) st.nextElement() ).trim();
1169 if ( !ForesterUtil.isEmpty( str ) ) {
1170 setPathToLocalMafft( new File( str ) );
1173 else if ( key.equals( "fastme_local" ) ) {
1174 final String str = ( ( String ) st.nextElement() ).trim();
1175 if ( !ForesterUtil.isEmpty( str ) ) {
1176 setPathToLocalFastme( new File( str ) );
1179 else if ( key.equals( "raxml_local" ) ) {
1180 final String str = ( ( String ) st.nextElement() ).trim();
1181 if ( !ForesterUtil.isEmpty( str ) ) {
1182 setPathToLocalRaxml( new File( str ) );
1185 else if ( key.equals( "show_scale" ) ) {
1186 setShowScale( parseBoolean( ( String ) st.nextElement() ) );
1188 else if ( key.equals( "show_overview" ) ) {
1189 setShowOverview( parseBoolean( ( String ) st.nextElement() ) );
1191 else if ( key.equals( "show_branch_length_values" ) ) {
1192 setShowBranchLengthValues( parseBoolean( ( String ) st.nextElement() ) );
1194 else if ( key.equals( "background_gradient" ) ) {
1195 setBackgroundColorGradient( parseBoolean( ( String ) st.nextElement() ) );
1197 else if ( key.equals( "color_labels_same_as_branch_length_values" ) ) {
1198 setColorLabelsSameAsParentBranch( parseBoolean( ( String ) st.nextElement() ) );
1200 else if ( key.equals( "show_domain_labels" ) ) {
1201 setShowDomainLabels( parseBoolean( ( String ) st.nextElement() ) );
1203 else if ( key.equals( "show_seq_annotation_ref_sources" ) ) {
1204 setShowAnnotationRefSource( parseBoolean( ( String ) st.nextElement() ) );
1206 else if ( key.equals( "abbreviate_scientific_names" ) ) {
1207 setAbbreviateScientificTaxonNames( parseBoolean( ( String ) st.nextElement() ) );
1209 else if ( key.equals( "cladogram_type" ) ) {
1210 final String type_str = ( ( String ) st.nextElement() ).trim();
1211 if ( type_str.equalsIgnoreCase( Options.CLADOGRAM_TYPE.NON_LINED_UP.toString() ) ) {
1212 setCladogramType( Options.CLADOGRAM_TYPE.NON_LINED_UP );
1214 else if ( type_str.equalsIgnoreCase( Options.CLADOGRAM_TYPE.EXT_NODE_SUM_DEP.toString() ) ) {
1215 setCladogramType( Options.CLADOGRAM_TYPE.EXT_NODE_SUM_DEP );
1217 else if ( type_str.equalsIgnoreCase( Options.CLADOGRAM_TYPE.TOTAL_NODE_SUM_DEP.toString() ) ) {
1218 setCladogramType( Options.CLADOGRAM_TYPE.TOTAL_NODE_SUM_DEP );
1221 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown value [" + type_str
1222 + "] for [cladogram_type]" );
1225 else if ( key.equals( "non_lined_up_cladogram" ) ) {
1227 .printWarningMessage( Constants.PRG_NAME,
1228 "configuration key [non_lined_up_cladogram] is deprecated, use [cladogram_type] instead" );
1230 else if ( key.equals( "hide_controls_and_menus" ) ) {
1231 _hide_controls_and_menus = parseBoolean( ( String ) st.nextElement() );
1233 else if ( key.equals( "use_tabbed_display" ) ) {
1234 _use_tabbed_display = parseBoolean( ( String ) st.nextElement() );
1236 else if ( key.equals( "overview_width" ) ) {
1237 final short i = parseShort( ( ( String ) st.nextElement() ) );
1240 else if ( key.equals( "overview_height" ) ) {
1241 final short i = parseShort( ( ( String ) st.nextElement() ) );
1242 setOvMaxHeight( i );
1244 else if ( key.equals( "overview_placement_type" ) ) {
1245 final String type_str = ( ( String ) st.nextElement() ).trim();
1246 if ( type_str.equalsIgnoreCase( OVERVIEW_PLACEMENT_TYPE.UPPER_LEFT.toTag() ) ) {
1247 setOvPlacement( OVERVIEW_PLACEMENT_TYPE.UPPER_LEFT );
1249 else if ( type_str.equalsIgnoreCase( OVERVIEW_PLACEMENT_TYPE.UPPER_RIGHT.toTag() ) ) {
1250 setOvPlacement( OVERVIEW_PLACEMENT_TYPE.UPPER_RIGHT );
1252 else if ( type_str.equalsIgnoreCase( OVERVIEW_PLACEMENT_TYPE.LOWER_LEFT.toTag() ) ) {
1253 setOvPlacement( OVERVIEW_PLACEMENT_TYPE.LOWER_LEFT );
1255 else if ( type_str.equalsIgnoreCase( OVERVIEW_PLACEMENT_TYPE.LOWER_RIGHT.toTag() ) ) {
1256 setOvPlacement( OVERVIEW_PLACEMENT_TYPE.LOWER_RIGHT );
1259 setOvPlacement( OVERVIEW_PLACEMENT_TYPE.UPPER_LEFT );
1260 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown value [" + type_str
1261 + "] for [overview_placement_type]" );
1264 else if ( key.equals( "node_label_direction" ) ) {
1265 final String type_str = ( ( String ) st.nextElement() ).trim();
1266 if ( type_str.equalsIgnoreCase( NODE_LABEL_DIRECTION.HORIZONTAL.toString() ) ) {
1267 setNodeLabelDirection( NODE_LABEL_DIRECTION.HORIZONTAL );
1269 else if ( type_str.equalsIgnoreCase( NODE_LABEL_DIRECTION.RADIAL.toString() ) ) {
1270 setNodeLabelDirection( NODE_LABEL_DIRECTION.RADIAL );
1273 setNodeLabelDirection( NODE_LABEL_DIRECTION.HORIZONTAL );
1274 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown value [" + type_str
1275 + "] for [node_label_direction]" );
1278 else if ( key.equals( "branch_length_value_digits" ) ) {
1279 final short i = parseShort( ( ( String ) st.nextElement() ).trim() );
1281 setNumberOfDigitsAfterCommaForBranchLengthValue( i );
1284 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "illegal value [" + i
1285 + "] for [branch_length_value_digits]" );
1288 else if ( key.equals( "confidence_value_digits" ) ) {
1289 final short i = parseShort( ( ( String ) st.nextElement() ).trim() );
1291 setNumberOfDigitsAfterCommaForConfidenceValues( i );
1294 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "illegal value [" + i
1295 + "] for [confidence_value_digits]" );
1298 else if ( key.equals( "allow_editing" ) ) {
1299 setEditable( parseBoolean( ( String ) st.nextElement() ) );
1301 else if ( key.equals( "display_sequence_relations" ) ) {
1302 setDisplaySequenceRelations( parseBoolean( ( String ) st.nextElement() ) );
1304 else if ( key.equals( "replace_underscores_in_nh_parsing" ) ) {
1305 final boolean r = parseBoolean( ( String ) st.nextElement() );
1306 if ( r && ( getTaxonomyExtraction() != TAXONOMY_EXTRACTION.NO ) ) {
1308 .printWarningMessage( Constants.PRG_NAME,
1309 "attempt to extract taxonomies and replace underscores at the same time" );
1312 setReplaceUnderscoresInNhParsing( r );
1315 else if ( key.equals( "taxonomy_extraction_in_nh_parsing" ) ) {
1316 final String s = ( String ) st.nextElement();
1317 if ( s.equalsIgnoreCase( "no" ) ) {
1318 setTaxonomyExtraction( TAXONOMY_EXTRACTION.NO );
1320 else if ( s.equalsIgnoreCase( "pfam_relaxed" ) ) {
1321 setTaxonomyExtraction( TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
1323 else if ( s.equalsIgnoreCase( "pfam_strict" ) ) {
1324 setTaxonomyExtraction( TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1326 else if ( s.equalsIgnoreCase( "aggressive" ) ) {
1327 setTaxonomyExtraction( TAXONOMY_EXTRACTION.AGGRESSIVE );
1331 .printWarningMessage( Constants.PRG_NAME,
1332 "unknown value for \"taxonomy_extraction_in_nh_parsing\": "
1334 + " (must be either: no, pfam_relaxed, pfam_strict, or aggressive)" );
1336 if ( ( getTaxonomyExtraction() != TAXONOMY_EXTRACTION.NO ) && isReplaceUnderscoresInNhParsing() ) {
1338 .printWarningMessage( Constants.PRG_NAME,
1339 "attempt to extract taxonomies and replace underscores at the same time" );
1342 else if ( key.equals( "internal_labels_are_confidence_values" ) ) {
1343 setInternalNumberAreConfidenceForNhParsing( parseBoolean( ( String ) st.nextElement() ) );
1345 else if ( key.equals( "gui_background_color" ) ) {
1346 _gui_background_color = Color.decode( ( String ) st.nextElement() );
1348 else if ( key.equals( "gui_checkbox_text_color" ) ) {
1349 _gui_checkbox_text_color = Color.decode( ( String ) st.nextElement() );
1351 else if ( key.equals( "gui_checkbox_and_button_active_color" ) ) {
1352 _gui_checkbox_and_button_active_color = Color.decode( ( String ) st.nextElement() );
1354 else if ( key.equals( "gui_button_text_color" ) ) {
1355 _gui_button_text_color = Color.decode( ( String ) st.nextElement() );
1357 else if ( key.equals( "gui_button_background_color" ) ) {
1358 _gui_button_background_color = Color.decode( ( String ) st.nextElement() );
1360 else if ( key.equals( "gui_menu_background_color" ) ) {
1361 _gui_menu_background_color = Color.decode( ( String ) st.nextElement() );
1363 else if ( key.equals( "gui_menu_text_color" ) ) {
1364 _gui_menu_text_color = Color.decode( ( String ) st.nextElement() );
1366 else if ( key.equals( "gui_button_border_color" ) ) {
1367 _gui_button_border_color = Color.decode( ( String ) st.nextElement() );
1369 else if ( key.equals( "domain_structure_font_color" ) ) {
1370 _domain_structure_font_color = Color.decode( ( String ) st.nextElement() );
1372 else if ( key.equals( "domain_structure_base_color" ) ) {
1373 _domain_structure_base_color = Color.decode( ( String ) st.nextElement() );
1375 else if ( key.equals( "show_default_node_shapes" ) ) {
1377 .printWarningMessage( Constants.PRG_NAME,
1378 "configuration key [show_default_node_shapes] is deprecated, use [show_default_node_shapes_internal] and [show_default_node_shapes_external] instead" );
1379 final boolean b = parseBoolean( ( ( String ) st.nextElement() ).trim() );
1380 setShowDefaultNodeShapesInternal( b );
1381 setShowDefaultNodeShapesExternal( b );
1383 else if ( key.equals( "show_default_node_shapes_internal" ) ) {
1384 setShowDefaultNodeShapesInternal( parseBoolean( ( ( String ) st.nextElement() ).trim() ) );
1386 else if ( key.equals( "show_default_node_shapes_external" ) ) {
1387 setShowDefaultNodeShapesExternal( parseBoolean( ( ( String ) st.nextElement() ).trim() ) );
1389 else if ( key.equals( "default_node_size" ) ) {
1390 final short i = parseShort( ( ( String ) st.nextElement() ).trim() );
1391 setDefaultNodeShapeSize( i );
1393 else if ( key.equals( "default_node_fill" ) ) {
1394 final String fill_str = ( ( String ) st.nextElement() ).trim();
1395 if ( fill_str.equalsIgnoreCase( NodeVisualData.NodeFill.NONE.toString() ) ) {
1396 setDefaultNodeFill( NodeFill.NONE );
1398 else if ( fill_str.equalsIgnoreCase( NodeVisualData.NodeFill.GRADIENT.toString() ) ) {
1399 setDefaultNodeFill( NodeFill.GRADIENT );
1401 else if ( fill_str.equalsIgnoreCase( NodeVisualData.NodeFill.SOLID.toString() ) ) {
1402 setDefaultNodeFill( NodeFill.SOLID );
1405 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown value [" + fill_str
1406 + "] for [default_node_fill]" );
1409 else if ( key.equals( "default_node_shape" ) ) {
1410 final String shape_str = ( ( String ) st.nextElement() ).trim();
1411 if ( shape_str.equalsIgnoreCase( NodeVisualData.NodeShape.CIRCLE.toString() ) ) {
1412 setDefaultNodeShape( NodeShape.CIRCLE );
1414 else if ( shape_str.equalsIgnoreCase( NodeVisualData.NodeShape.RECTANGLE.toString() ) ) {
1415 setDefaultNodeShape( NodeShape.RECTANGLE );
1418 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown value [" + shape_str
1419 + "] for [default_node_shape]" );
1422 else if ( key.equals( "midpoint_reroot" ) ) {
1423 setMidpointReroot( parseBoolean( ( String ) st.nextElement() ) );
1425 else if ( key.equals( "ext_descendents_data_to_return" ) ) {
1426 final String s = ( ( String ) st.nextElement() ).trim();
1427 if ( s.equalsIgnoreCase( "node_name" ) ) {
1428 setExtDescNodeDataToReturn( NODE_DATA.NODE_NAME );
1430 else if ( s.equalsIgnoreCase( "sequence_acc" ) ) {
1431 setExtDescNodeDataToReturn( NODE_DATA.SEQUENCE_ACC );
1433 else if ( s.equalsIgnoreCase( "sequence_mol_seq_fasta" ) ) {
1434 setExtDescNodeDataToReturn( NODE_DATA.SEQUENCE_MOL_SEQ_FASTA );
1436 else if ( s.equalsIgnoreCase( "sequence_mol_seq" ) ) {
1437 setExtDescNodeDataToReturn( NODE_DATA.SEQUENCE_MOL_SEQ );
1439 else if ( s.equalsIgnoreCase( "sequence_name" ) ) {
1440 setExtDescNodeDataToReturn( NODE_DATA.SEQUENCE_NAME );
1442 else if ( s.equalsIgnoreCase( "gene_name" ) ) {
1443 setExtDescNodeDataToReturn( NODE_DATA.GENE_NAME );
1445 else if ( s.equalsIgnoreCase( "sequence_symbol" ) ) {
1446 setExtDescNodeDataToReturn( NODE_DATA.SEQUENCE_SYMBOL );
1448 else if ( s.equalsIgnoreCase( "taxonomy_scientific_name" ) ) {
1449 setExtDescNodeDataToReturn( NODE_DATA.TAXONOMY_SCIENTIFIC_NAME );
1451 else if ( s.equalsIgnoreCase( "taxonomy_code" ) ) {
1452 setExtDescNodeDataToReturn( NODE_DATA.TAXONOMY_CODE );
1454 else if ( s.equalsIgnoreCase( "taxonomy_common_name" ) ) {
1455 setExtDescNodeDataToReturn( NODE_DATA.TAXONOMY_COMM0N_NAME );
1457 else if ( s.equalsIgnoreCase( "user_selected" ) ) {
1458 setExtDescNodeDataToReturn( NODE_DATA.UNKNOWN );
1461 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown value [" + s
1462 + "] for [ext_descendents_data_to_return]" );
1465 else if ( key.equals( "label_for_get_ext_descendents_data" ) ) {
1466 final String s = ( ( String ) st.nextElement() ).trim();
1467 if ( ForesterUtil.isEmpty( s ) || ( s.length() < 2 ) ) {
1468 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "illegal value [" + s
1469 + "] for [label_for_get_ext_descendents_data]" );
1472 setLabelForGetExtDescendentsData( s.replaceAll( "_", " " ) );
1475 else if ( key.equals( "ext_descendents_data_to_return_on" ) ) {
1476 final String s = ( ( String ) st.nextElement() ).trim().toLowerCase();
1477 if ( s.equals( "console" ) ) {
1478 setExtNodeDataReturnOn( EXT_NODE_DATA_RETURN_ON.CONSOLE );
1480 else if ( s.equals( "window" ) ) {
1481 setExtNodeDataReturnOn( EXT_NODE_DATA_RETURN_ON.WINODW );
1483 else if ( s.equals( "buffer_only" ) ) {
1484 setExtNodeDataReturnOn( EXT_NODE_DATA_RETURN_ON.BUFFER_ONLY );
1487 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown value [" + s
1488 + "] for [ext_descendents_data_to_return_on]" );
1491 else if ( st.countTokens() >= 2 ) { // counts the tokens that are not
1494 if ( key.equals( "phylogram" ) ) {
1495 key_index = Configuration.display_as_phylogram;
1497 else if ( key.equals( "rollover" ) ) {
1498 key_index = Configuration.node_data_popup;
1500 else if ( key.equals( "color_according_to_species" ) ) {
1501 key_index = Configuration.color_according_to_species;
1503 else if ( key.equals( "show_node_names" ) ) {
1504 key_index = Configuration.show_node_names;
1506 else if ( key.equals( "show_taxonomy_code" ) ) {
1507 key_index = Configuration.show_tax_code;
1509 else if ( key.equals( "write_confidence_values" ) ) {
1510 key_index = Configuration.write_confidence_values;
1512 else if ( key.equals( "write_events" ) ) {
1513 key_index = Configuration.write_events;
1515 else if ( key.equals( "color_branches" ) ) {
1516 key_index = Configuration.color_branches;
1518 else if ( key.equals( "width_branches" ) ) {
1519 key_index = Configuration.width_branches;
1521 else if ( key.equals( "show_domain_architectures" ) ) {
1522 key_index = Configuration.show_domain_architectures;
1524 else if ( key.equals( "show_annotations" ) ) {
1525 key_index = Configuration.show_annotation;
1527 else if ( key.equals( "show_binary_characters" ) ) {
1528 key_index = Configuration.show_binary_characters;
1530 else if ( key.equals( "show_binary_character_counts" ) ) {
1531 key_index = Configuration.show_binary_character_counts;
1533 else if ( key.equals( "show_seq_names" ) ) {
1534 key_index = Configuration.show_seq_names;
1536 else if ( key.equals( "show_gene_names" ) ) {
1537 key_index = Configuration.show_gene_names;
1539 else if ( key.equals( "show_seq_symbols" ) ) {
1540 key_index = Configuration.show_seq_symbols;
1542 else if ( key.equals( "show_seq_acc" ) ) {
1543 key_index = Configuration.show_sequence_acc;
1545 else if ( key.equals( "display_internal_data" ) ) {
1546 key_index = Configuration.display_internal_data;
1548 else if ( key.equals( "dynamically_hide_data" ) ) {
1549 key_index = Configuration.dynamically_hide_data;
1551 else if ( key.equals( "show_taxonomy_scientific_names" ) ) {
1552 key_index = Configuration.show_taxonomy_scientific_names;
1554 else if ( key.equals( "show_taxonomy_common_names" ) ) {
1555 key_index = Configuration.show_taxonomy_common_names;
1557 else if ( key.equals( "show_taxonomy_images" ) ) {
1558 key_index = Configuration.show_taxonomy_images;
1560 else if ( key.equals( "color_according_to_annotation" ) ) {
1561 key_index = Configuration.color_according_to_annotation;
1563 else if ( key.equals( "show_vector_data" ) ) {
1564 key_index = Configuration.show_vector_data;
1566 else if ( key.equals( "show_properties" ) ) {
1567 key_index = Configuration.show_properties;
1569 else if ( key.equals( "show_relation_confidence" ) ) {
1570 key_index = Configuration.show_relation_confidence;
1572 else if ( key.equals( "show_custom_node_shapes" ) ) {
1573 key_index = Configuration.show_custom_node_shapes;
1575 // If we've found the key, set the values
1576 if ( key_index >= 0 ) {
1577 display_options[ key_index ][ 1 ] = ( String ) st.nextElement();
1578 display_options[ key_index ][ 2 ] = ( String ) st.nextElement();
1579 // otherwise, keep looking
1582 if ( key_index == DEPRECATED ) {
1585 else if ( key.equals( "click_to" ) ) {
1586 final String click_to_name = ( String ) st.nextElement();
1587 key_index = getClickToIndex( click_to_name );
1588 if ( key_index >= 0 ) {
1589 clickto_options[ key_index ][ 1 ] = ( String ) st.nextElement();
1591 else if ( key_index == DEPRECATED ) {
1595 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown click-to option: "
1599 else if ( key.equals( "species_color" ) ) {
1600 getSpeciesColors().put( ( ( String ) st.nextElement() ).replace( '_', ' ' ),
1601 Color.decode( ( String ) st.nextElement() ) );
1603 else if ( key.equals( "domain_color" ) ) {
1604 getDomainColors().put( ( String ) st.nextElement(), Color.decode( ( String ) st.nextElement() ) );
1606 else if ( key.equals( "annotation_color" ) ) {
1607 getAnnotationColors()
1608 .put( ( String ) st.nextElement(), Color.decode( ( String ) st.nextElement() ) );
1610 else if ( key.equals( "function_color" ) ) {
1611 ForesterUtil.printWarningMessage( Constants.PRG_NAME,
1612 "configuration key [function_color] is deprecated" );
1614 else if ( key.equals( DISPLAY_COLOR_KEY ) ) {
1615 putDisplayColors( ( String ) st.nextElement(), Color.decode( ( String ) st.nextElement() ) );
1618 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown configuration key [" + key
1619 + "] in: " + config_filename );
1624 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown configuration key [" + key + "] in: "
1625 + config_filename );
1629 private void setLabelForGetExtDescendentsData( final String label_for_get_ext_descendents_data ) {
1630 _label_for_get_ext_descendents_data = label_for_get_ext_descendents_data;
1633 private void setMaxBaseFontSize( final int max_base_font_size ) {
1634 _max_base_font_size = max_base_font_size;
1637 private void setMinBaseFontSize( final int min_base_font_size ) {
1638 _min_base_font_size = min_base_font_size;
1641 private void setOvMaxHeight( final short ov_max_height ) {
1642 _ov_max_height = ov_max_height;
1645 private void setOvMaxWidth( final short ov_max_width ) {
1646 _ov_max_width = ov_max_width;
1649 private void setOvPlacement( final OVERVIEW_PLACEMENT_TYPE ov_placement ) {
1650 _ov_placement = ov_placement;
1653 private void setPathToLocalFastme( final File path_to_local_fastme ) {
1654 _path_to_local_fastme = path_to_local_fastme;
1657 private void setPathToLocalMafft( final File path_to_local_mafft ) {
1658 _path_to_local_mafft = path_to_local_mafft;
1661 private void setPathToLocalRaxml( final File path_to_local_raxml ) {
1662 _path_to_local_raxml = path_to_local_raxml;
1665 private void setShowAnnotationRefSource( final boolean b ) {
1666 _show_annotation_ref_source = b;
1669 private void setShowOverview( final boolean show_overview ) {
1670 _show_overview = show_overview;
1673 private void setValidatePhyloXmlAgainstSchema( final boolean validate_against_phyloxml_xsd_schema ) {
1674 _validate_against_phyloxml_xsd_schema = validate_against_phyloxml_xsd_schema;
1677 static String getDefaultFontFamilyName() {
1678 return DEFAULT_FONT_FAMILY;
1681 public enum EXT_NODE_DATA_RETURN_ON {
1682 BUFFER_ONLY, CONSOLE, WINODW;
1686 CROSSPLATFORM, NATIVE, NIMBUS, UNKNOWN
1689 static enum TRIPLET {
1690 FALSE, TRUE, UNKNOWN