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.NodeVisualization;
52 import org.forester.phylogeny.data.NodeVisualization.NodeFill;
53 import org.forester.phylogeny.data.NodeVisualization.NodeShape;
54 import org.forester.util.ForesterUtil;
56 public final class Configuration {
58 static final String VALIDATE_AGAINST_PHYLOXML_XSD_SCHEMA = "validate_against_phyloxml_xsd_schema";
59 private static final String DISPLAY_COLOR_KEY = "display_color";
60 private static final int DEPRECATED = -2;
61 private UI _ui = UI.UNKNOWN;
62 private boolean _use_tabbed_display = false;
63 private boolean _hide_controls_and_menus = false;
64 private CLADOGRAM_TYPE _cladogram_type = Constants.CLADOGRAM_TYPE_DEFAULT;
65 private SortedMap<String, Color> _display_colors = null;
66 private boolean _antialias_screen = true;
67 private PHYLOGENY_GRAPHICS_TYPE _phylogeny_graphics_type = PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR;
68 private String _base_font_family_name = "";
69 private int _base_font_size = -1;
70 private int _min_base_font_size = 2;
71 private int _max_base_font_size = 20;
72 private int _graphics_export_x = -1;
73 private int _graphics_export_y = -1;
74 private short _ov_max_width = 80;
75 private short _ov_max_height = 80;
76 private OVERVIEW_PLACEMENT_TYPE _ov_placement = OVERVIEW_PLACEMENT_TYPE.UPPER_LEFT;
77 private double _min_confidence_value = Options.MIN_CONFIDENCE_DEFAULT;
78 private float _print_line_width = Constants.PDF_LINE_WIDTH_DEFAULT;
79 private boolean _show_scale = false;
80 private boolean _show_branch_length_values = false;
81 private boolean _show_overview = true;
82 private short _number_of_digits_after_comma_for_confidence_values = Constants.NUMBER_OF_DIGITS_AFTER_COMMA_FOR_CONFIDENCE_VALUES_DEFAULT;
83 private short _number_of_digits_after_comma_for_branch_length_values = Constants.NUMBER_OF_DIGITS_AFTER_COMMA_FOR_BRANCH_LENGTH_VALUES_DEFAULT;
84 private boolean _editable = true;
85 private boolean _nh_parsing_replace_underscores = false;
86 private TAXONOMY_EXTRACTION _taxonomy_extraction = TAXONOMY_EXTRACTION.NO;
87 private boolean _internal_number_are_confidence_for_nh_parsing = false;
88 private boolean _display_sequence_relations = false;
89 private boolean _validate_against_phyloxml_xsd_schema = Constants.VALIDATE_AGAINST_PHYLOXML_XSD_SCJEMA_DEFAULT;
90 private boolean _background_color_gradient = false;
91 private boolean _show_domain_labels = true;
92 private boolean _show_annotation_ref_source = true;
93 private boolean _abbreviate_scientific_names = false;
94 private boolean _color_labels_same_as_parent_branch = false;
95 private boolean _show_default_node_shapes_internal = false;
96 private boolean _show_default_node_shapes_external = false;
97 private NodeShape _default_node_shape = NodeShape.RECTANGLE;
98 private NodeFill _default_node_fill = NodeFill.SOLID;
99 private short _default_node_shape_size = Constants.DEFAULT_NODE_SHAPE_SIZE_DEFAULT;
100 private boolean _taxonomy_colorize_node_shapes = false;
101 private int _default_bootstrap_samples = -1;
102 private File _path_to_local_mafft = null;
103 private File _path_to_local_fastme = null;
104 private File _path_to_local_raxml = null;
105 final static int display_as_phylogram = 0;
106 final static int show_node_names = 1;
107 final static int show_tax_code = 2;
108 final static int show_annotation = 3;
109 final static int write_confidence_values = 4;
110 final static int write_events = 5;
111 final static int color_according_to_species = 6;
112 final static int color_branches = 7;
113 final static int width_branches = 8;
114 final static int show_custom_node_shapes = 9;
115 final static int show_domain_architectures = 10;
116 final static int show_binary_characters = 11;
117 final static int show_binary_character_counts = 12;
118 final static int show_gene_names = 13;
119 final static int show_sequence_acc = 14;
120 final static int display_internal_data = 15;
121 final static int dynamically_hide_data = 16;
122 final static int show_taxonomy_scientific_names = 17;
123 final static int show_taxonomy_common_names = 18;
124 final static int color_according_to_annotation = 19;
125 final static int show_gene_symbols = 20;
126 final static int node_data_popup = 21;
127 final static int show_relation_confidence = 22;
128 final static int show_vector_data = 23;
129 final static int show_taxonomy_images = 24;
130 final static int show_properties = 25;
131 // ------------------
133 // ------------------
134 final static int display_node_data = 0;
135 final static int collapse_uncollapse = 1;
136 final static int reroot = 2;
137 final static int subtree = 3;
138 final static int swap = 4;
139 final static int color_subtree = 5;
140 final static int open_seq_web = 6;
141 final static int open_tax_web = 7;
142 final static int blast = 8;
143 final static int cut_subtree = 9;
144 final static int copy_subtree = 10;
145 final static int paste_subtree = 11;
146 final static int delete_subtree_or_node = 12;
147 final static int add_new_node = 13;
148 final static int edit_node_data = 14;
149 final static int sort_descendents = 15;
150 final static int get_ext_desc_data = 16;
151 final static int select_nodes = 17;
152 // ---------------------------
153 // Display options for trees
154 // ---------------------------
155 // ---------------------------------
156 // Pertaining to the config itself
157 // ---------------------------------
158 // Full path to config (may be URL)
159 String config_filename;
160 String default_config_filename = Constants.DEFAULT_CONFIGURATION_FILE_NAME;
161 final static String display_options[][] = {
162 { "Phylogram", "display", "?" }, { "Node Name", "display", "yes" }, { "Taxonomy Code", "display", "yes" },
163 { "Seq Annotations", "nodisplay", "no" }, { "Confidence Values", "display", "?" },
164 { "Node Events", "display", "?" }, { "Taxonomy Colorize", "display", "yes" },
165 { "Colorize Branches", "display", "no" }, { "Use Branch-Widths", "display", "no" },
166 { "Show Custom Nodes", "display", "yes" }, { "Domains", "nodisplay", "no" },
167 { "Binary Characters", "nodisplay", "no" }, { "Binary Char Counts", "nodisplay", "no" },
168 { "Seq Name", "display", "yes" }, { "Seq Acc", "display", "no" },
169 { "Show Internal Data", "display", "yes" }, { "Dyna Hide", "display", "yes" },
170 { "Taxonomy Scientific", "display", "yes" }, { "Taxonomy Common", "display", "no" },
171 { "Annotation Colorize", "nodisplay", "no" }, { "Seq Symbol", "display", "yes" },
172 { "Rollover", "display", "yes" }, { "Relation Confidence", "nodisplay", "no" },
173 { "Vector Data", "nodisplay", "no" }, { "Taxonomy Images", "display", "no" },
174 { "Properties", "nodisplay", "no" } };
175 final static String clickto_options[][] = {
176 { "Display Node Data", "display" }, { "Collapse/Uncollapse", "display" }, { "Root/Reroot", "display" },
177 { "Sub/Super Tree", "display" }, { "Swap Descendants", "display" }, { "Colorize Subtree", "display" },
178 { "Open Sequence Web", "display" }, { "Open Taxonomy Web", "display" }, { "Blast", "display" },
179 { "Cut Subtree", "display" }, { "Copy Subtree", "display" }, { "Paste Subtree", "display" },
180 { "Delete Subtree/Node", "display" }, { "Add New Node", "display" }, { "Edit Node Data", "display" },
181 { "Sort Descendants", "display" }, { "Return", "display" }, { "Select Node(s)", "display" } };
182 // This option is selected in the dropdown
183 int default_clickto = Configuration.display_node_data;
187 TreeColorSet tree_color_set;
191 TreeFontSet tree_font_set;
195 private static Hashtable<String, Color> _species_colors;
199 private static Hashtable<String, Color> _domain_colors;
203 private static Hashtable<String, Color> _annotation_colors;
204 boolean verbose = Constants.VERBOSE_DEFAULT;
205 private NODE_LABEL_DIRECTION _node_label_direction = NODE_LABEL_DIRECTION.HORIZONTAL;
206 private Color _gui_background_color = Constants.GUI_BACKGROUND_DEFAULT;
207 private Color _gui_checkbox_text_color = Constants.CHECKBOX_TEXT_COLOR_DEFAULT;
208 private Color _gui_checkbox_and_button_active_color = Constants.CHECKBOX_AND_BUTTON_ACTIVE_COLOR_DEFAULT;
209 private Color _gui_button_text_color = Constants.BUTTON_TEXT_COLOR_DEFAULT;
210 private Color _gui_button_background_color = Constants.BUTTON_BACKGROUND_COLOR_DEFAULT;
211 private Color _gui_menu_background_color = Constants.MENU_BACKGROUND_COLOR_DEFAULT;
212 private Color _gui_menu_text_color = Constants.MENU_TEXT_COLOR_DEFAULT;
213 private Color _gui_button_border_color = Constants.BUTTON_BORDER_COLOR_DEFAULT;
214 private Color _domain_structure_font_color = Constants.DOMAIN_STRUCTURE_FONT_COLOR_DEFAULT;
215 private Color _domain_structure_base_color = Constants.DOMAIN_STRUCTURE_BASE_COLOR_DEFAULT;
216 private NODE_DATA _ext_desc_data_to_return = NODE_DATA.UNKNOWN;
217 private String _label_for_get_ext_descendents_data = "";
218 private EXT_NODE_DATA_RETURN_ON _ext_node_data_return_on = EXT_NODE_DATA_RETURN_ON.WINODW;
219 private int _frame_x_size;
220 private int _frame_y_size;
221 private boolean _midpoint_root = false;
222 private static String DEFAULT_FONT_FAMILY = "";
224 for( final String font_name : Constants.DEFAULT_FONT_CHOICES ) {
225 if ( Arrays.binarySearch( AptxUtil.getAvailableFontFamiliesSorted(), font_name ) >= 0 ) {
226 DEFAULT_FONT_FAMILY = font_name;
230 if ( ForesterUtil.isEmpty( DEFAULT_FONT_FAMILY ) ) {
231 DEFAULT_FONT_FAMILY = Constants.DEFAULT_FONT_CHOICES[ Constants.DEFAULT_FONT_CHOICES.length - 1 ];
235 public Configuration() {
236 this( null, false, false, false );
239 public Configuration( final String cf, final boolean is_url, final boolean is_applet, final boolean verbose ) {
240 if ( ForesterUtil.isEmpty( cf ) ) {
241 config_filename = default_config_filename;
244 config_filename = cf;
246 setDisplayColors( new TreeMap<String, Color>() );
247 config_filename = config_filename.trim();
250 // If URL, open accordingly
252 u = new URL( config_filename );
254 final InputStreamReader isr = new InputStreamReader( u.openStream() );
255 final BufferedReader bf = new BufferedReader( isr );
258 ForesterUtil.programMessage( Constants.PRG_NAME, "successfully read from configuration url ["
259 + config_filename + "]" );
261 catch ( final Exception e ) {
262 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "failed to read configuration from ["
263 + config_filename + "]: " + e.getLocalizedMessage() );
266 catch ( final Exception e ) {
267 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "cannot find or open configuration url ["
268 + config_filename + "]" );
272 // Otherwise, open as a file
273 File f = new File( config_filename );
275 f = new File( config_filename + ".txt" );
277 if ( f.exists() && f.canRead() ) {
279 final BufferedReader bf = new BufferedReader( new FileReader( f ) );
283 catch ( final Exception e ) {
285 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "failed to read configuration from ["
286 + config_filename + "]: " + e );
292 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "cannot find or open configuration file ["
293 + config_filename + "]" );
299 public String getBaseFontFamilyName() {
300 return _base_font_family_name;
303 public int getDefaultBootstrapSamples() {
304 return _default_bootstrap_samples;
307 public NodeFill getDefaultNodeFill() {
308 return _default_node_fill;
311 public NodeShape getDefaultNodeShape() {
312 return _default_node_shape;
315 public short getDefaultNodeShapeSize() {
316 return _default_node_shape_size;
319 public Color getDomainStructureBaseColor() {
320 return _domain_structure_base_color;
323 public Color getDomainStructureFontColor() {
324 return _domain_structure_font_color;
327 public NODE_DATA getExtDescNodeDataToReturn() {
328 return _ext_desc_data_to_return;
331 public EXT_NODE_DATA_RETURN_ON getExtNodeDataReturnOn() {
332 return _ext_node_data_return_on;
335 public int getFrameXSize() {
336 return _frame_x_size;
339 public int getFrameYSize() {
340 return _frame_y_size;
343 public String getLabelForGetExtDescendentsData() {
344 return _label_for_get_ext_descendents_data;
347 public File getPathToLocalFastme() {
348 return _path_to_local_fastme;
351 public File getpathToLocalMafft() {
352 return _path_to_local_mafft;
355 public File getPathToLocalRaxml() {
356 return _path_to_local_raxml;
359 public boolean isAbbreviateScientificTaxonNames() {
360 return _abbreviate_scientific_names;
363 public boolean isBackgroundColorGradient() {
364 return _background_color_gradient;
367 public boolean isColorLabelsSameAsParentBranch() {
368 return _color_labels_same_as_parent_branch;
371 public boolean isShowDefaultNodeShapesExternal() {
372 return _show_default_node_shapes_external;
375 public boolean isShowDefaultNodeShapesInternal() {
376 return _show_default_node_shapes_internal;
379 public boolean isShowDomainLabels() {
380 return _show_domain_labels;
383 public boolean isTaxonomyColorizeNodeShapes() {
384 return _taxonomy_colorize_node_shapes;
387 public void putDisplayColors( final String key, final Color color ) {
388 getDisplayColors().put( key, color );
391 public void setAbbreviateScientificTaxonNames( final boolean abbreviate_scientific_names ) {
392 _abbreviate_scientific_names = abbreviate_scientific_names;
395 public void setBackgroundColorGradient( final boolean background_color_gradient ) {
396 _background_color_gradient = background_color_gradient;
399 public void setBaseFontFamilyName( final String base_font_family_name ) {
400 _base_font_family_name = base_font_family_name;
403 public void setBaseFontSize( final int base_font_size ) {
404 _base_font_size = base_font_size;
407 private void setMaxBaseFontSize( final int max_base_font_size ) {
408 _max_base_font_size = max_base_font_size;
411 private void setMinBaseFontSize( final int min_base_font_size ) {
412 _min_base_font_size = min_base_font_size;
415 public void setColorizeBranches( final boolean b ) {
416 display_options[ color_branches ][ 2 ] = b ? "yes" : "no";
419 public void setColorLabelsSameAsParentBranch( final boolean color_labels_same_as_parent_branch ) {
420 _color_labels_same_as_parent_branch = color_labels_same_as_parent_branch;
423 public void setDefaultNodeFill( final NodeFill default_node_fill ) {
424 _default_node_fill = default_node_fill;
427 public void setDefaultNodeShape( final NodeShape default_node_shape ) {
428 _default_node_shape = default_node_shape;
431 public void setDefaultNodeShapeSize( final short default_node_shape_size ) {
432 _default_node_shape_size = default_node_shape_size;
435 public void setDisplayAsPhylogram( final boolean b ) {
436 display_options[ display_as_phylogram ][ 2 ] = b ? "yes" : "no";
439 public void setDisplayColors( final SortedMap<String, Color> display_colors ) {
440 _display_colors = display_colors;
443 public void setDisplayConfidenceValues( final boolean b ) {
444 display_options[ write_confidence_values ][ 2 ] = b ? "yes" : "no";
447 public void setDisplayInternalData( final boolean b ) {
448 display_options[ display_internal_data ][ 2 ] = b ? "yes" : "no";
451 public void setDisplayNodeNames( final boolean b ) {
452 display_options[ show_node_names ][ 2 ] = b ? "yes" : "no";
455 public void setDisplaySequenceAcc( final boolean b ) {
456 display_options[ show_sequence_acc ][ 2 ] = b ? "yes" : "no";
459 public void setDisplaySequenceNames( final boolean b ) {
460 display_options[ show_gene_names ][ 2 ] = b ? "yes" : "no";
463 public void setDisplaySequenceRelations( final boolean display_sequence_relations ) {
464 _display_sequence_relations = display_sequence_relations;
467 public void setDisplaySequenceSymbols( final boolean b ) {
468 display_options[ show_gene_symbols ][ 2 ] = b ? "yes" : "no";
471 public void setDisplayTaxonomyCode( final boolean b ) {
472 display_options[ show_tax_code ][ 2 ] = b ? "yes" : "no";
475 public void setDisplayTaxonomyCommonNames( final boolean b ) {
476 display_options[ show_taxonomy_common_names ][ 2 ] = b ? "yes" : "no";
479 public void setDisplayTaxonomyImages( final boolean b ) {
480 display_options[ show_taxonomy_images ][ 2 ] = b ? "yes" : "no";
483 public void setDisplayTaxonomyScientificNames( final boolean b ) {
484 display_options[ show_taxonomy_scientific_names ][ 2 ] = b ? "yes" : "no";
487 public void setDynamicallyHideData( final boolean b ) {
488 display_options[ dynamically_hide_data ][ 2 ] = b ? "yes" : "no";
491 public void setExtDescNodeDataToReturn( final NODE_DATA ext_desc_data_to_return ) {
492 _ext_desc_data_to_return = ext_desc_data_to_return;
495 public void setFrameXSize( final int frame_x_size ) {
496 _frame_x_size = frame_x_size;
499 public void setFrameYSize( final int frame_y_size ) {
500 _frame_y_size = frame_y_size;
503 public void setMinConfidenceValue( final double min_confidence_value ) {
504 _min_confidence_value = min_confidence_value;
507 public void setNodeLabelDirection( final NODE_LABEL_DIRECTION node_label_direction ) {
508 _node_label_direction = node_label_direction;
511 public void setNumberOfDigitsAfterCommaForBranchLengthValue( final short number_of_digits_after_comma_for_branch_length_values ) {
512 _number_of_digits_after_comma_for_branch_length_values = number_of_digits_after_comma_for_branch_length_values;
515 public void setNumberOfDigitsAfterCommaForConfidenceValues( final short number_of_digits_after_comma_for_confidence_values ) {
516 _number_of_digits_after_comma_for_confidence_values = number_of_digits_after_comma_for_confidence_values;
519 public void setPhylogenyGraphicsType( final PHYLOGENY_GRAPHICS_TYPE phylogeny_graphics_type ) {
520 _phylogeny_graphics_type = phylogeny_graphics_type;
523 public void setPrintLineWidth( final float print_line_width ) {
524 _print_line_width = print_line_width;
527 public void setReplaceUnderscoresInNhParsing( final boolean nh_parsing_replace_underscores ) {
528 _nh_parsing_replace_underscores = nh_parsing_replace_underscores;
531 public void setShowBranchLengthValues( final boolean show_branch_length_values ) {
532 _show_branch_length_values = show_branch_length_values;
535 public void setShowDefaultNodeShapesExternal( final boolean show_default_node_shapes_external ) {
536 _show_default_node_shapes_external = show_default_node_shapes_external;
539 public void setShowDefaultNodeShapesInternal( final boolean show_default_node_shapes_internal ) {
540 _show_default_node_shapes_internal = show_default_node_shapes_internal;
543 public void setShowDomainLabels( final boolean show_domain_labels ) {
544 _show_domain_labels = show_domain_labels;
547 public void setShowScale( final boolean show_scale ) {
548 _show_scale = show_scale;
551 public void setTaxonomyColorize( final boolean b ) {
552 display_options[ color_according_to_species ][ 2 ] = b ? "yes" : "no";
555 public void setTaxonomyColorizeNodeShapes( final boolean taxonomy_colorize_node_shapes ) {
556 _taxonomy_colorize_node_shapes = taxonomy_colorize_node_shapes;
559 public void setUseBranchesWidths( final boolean b ) {
560 display_options[ width_branches ][ 2 ] = b ? "yes" : "no";
563 boolean displaySequenceRelations() {
564 return _display_sequence_relations;
567 boolean doCheckOption( final int which ) {
568 return ( display_options[ which ][ 2 ].equalsIgnoreCase( "yes" ) )
569 || ( display_options[ which ][ 2 ].equalsIgnoreCase( "true" ) );
572 boolean doDisplayClickToOption( final int which ) {
573 return clickto_options[ which ][ 1 ].equalsIgnoreCase( "display" );
576 boolean doDisplayOption( final int which ) {
577 return display_options[ which ][ 1 ].equalsIgnoreCase( "display" );
581 * Will attempt to use the phylogeny to determine whether to check
582 * this or not (e.g. phylogram)
585 boolean doGuessCheckOption( final int which ) {
586 return display_options[ which ][ 2 ].equals( "?" );
589 Map<String, Color> getAnnotationColors() {
590 if ( _annotation_colors == null ) {
591 _annotation_colors = new Hashtable<String, Color>();
593 return _annotation_colors;
596 int getBaseFontSize() {
597 return _base_font_size;
600 int getMinBaseFontSize() {
601 return _min_base_font_size;
604 int getMaxBaseFontSize() {
605 return _max_base_font_size;
608 CLADOGRAM_TYPE getCladogramType() {
609 return _cladogram_type;
612 int getClickToOptionsCount() {
613 return clickto_options.length;
616 String getClickToTitle( final int which ) {
617 return clickto_options[ which ][ 0 ];
620 int getDefaultDisplayClicktoOption() {
621 return default_clickto;
624 SortedMap<String, Color> getDisplayColors() {
625 return _display_colors;
628 String getDisplayTitle( final int which ) {
629 return display_options[ which ][ 0 ];
632 Map<String, Color> getDomainColors() {
633 if ( _domain_colors == null ) {
634 _domain_colors = new Hashtable<String, Color>();
636 return _domain_colors;
639 int getGraphicsExportX() {
640 return _graphics_export_x;
643 int getGraphicsExportY() {
644 return _graphics_export_y;
647 Color getGuiBackgroundColor() {
648 return _gui_background_color;
651 Color getGuiButtonBackgroundColor() {
652 return _gui_button_background_color;
655 Color getGuiButtonBorderColor() {
656 return _gui_button_border_color;
659 Color getGuiButtonTextColor() {
660 return _gui_button_text_color;
663 Color getGuiCheckboxAndButtonActiveColor() {
664 return _gui_checkbox_and_button_active_color;
667 Color getGuiCheckboxTextColor() {
668 return _gui_checkbox_text_color;
671 Color getGuiMenuBackgroundColor() {
672 return _gui_menu_background_color;
675 Color getGuiMenuTextColor() {
676 return _gui_menu_text_color;
679 double getMinConfidenceValue() {
680 return _min_confidence_value;
683 NODE_LABEL_DIRECTION getNodeLabelDirection() {
684 return _node_label_direction;
687 short getNumberOfDigitsAfterCommaForBranchLengthValues() {
688 return _number_of_digits_after_comma_for_branch_length_values;
691 short getNumberOfDigitsAfterCommaForConfidenceValues() {
692 return _number_of_digits_after_comma_for_confidence_values;
695 short getOvMaxHeight() {
696 return _ov_max_height;
699 short getOvMaxWidth() {
700 return _ov_max_width;
703 OVERVIEW_PLACEMENT_TYPE getOvPlacement() {
704 return _ov_placement;
707 PHYLOGENY_GRAPHICS_TYPE getPhylogenyGraphicsType() {
708 return _phylogeny_graphics_type;
711 float getPrintLineWidth() {
712 return _print_line_width;
715 Hashtable<String, Color> getSpeciesColors() {
716 if ( _species_colors == null ) {
717 _species_colors = new Hashtable<String, Color>();
719 return _species_colors;
722 final TAXONOMY_EXTRACTION getTaxonomyExtraction() {
723 return _taxonomy_extraction;
726 boolean isAntialiasScreen() {
727 if ( ForesterUtil.isMac() ) {
728 //Apple Macintosh graphics are slow, turn off anti-alias.
731 return _antialias_screen;
735 * Convenience method.
737 * @return true if value in configuration file was 'yes'
739 boolean isDrawAsPhylogram() {
740 return doCheckOption( display_as_phylogram );
743 boolean isEditable() {
748 * Only used by ArchaeoptryxE.
751 boolean isHideControlPanelAndMenubar() {
752 return _hide_controls_and_menus;
755 boolean isInternalNumberAreConfidenceForNhParsing() {
756 return _internal_number_are_confidence_for_nh_parsing;
759 boolean isReplaceUnderscoresInNhParsing() {
760 return _nh_parsing_replace_underscores;
763 boolean isShowBranchLengthValues() {
764 return _show_branch_length_values;
767 boolean isShowOverview() {
768 return _show_overview;
771 boolean isShowScale() {
775 final boolean isUseNativeUI() {
776 if ( ( _ui == UI.UNKNOWN ) && ForesterUtil.isMac() ) {
779 return _ui == UI.NATIVE;
783 * Only used by ArchaeoptryxE.
786 boolean isUseTabbedDisplay() {
787 return _use_tabbed_display;
790 boolean isValidatePhyloXmlAgainstSchema() {
791 return _validate_against_phyloxml_xsd_schema;
794 final void setTaxonomyExtraction( final TAXONOMY_EXTRACTION taxonomy_extraction ) {
795 _taxonomy_extraction = taxonomy_extraction;
798 private int getClickToIndex( final String name ) {
800 if ( name.equals( "edit_info" ) ) {
801 index = Configuration.display_node_data;
803 .printWarningMessage( Constants.PRG_NAME,
804 "configuration key [edit_info] is deprecated, use [display node data] instead" );
806 else if ( name.equals( "display_node_data" ) ) {
807 index = Configuration.display_node_data;
809 else if ( name.equals( "collapse_uncollapse" ) ) {
810 index = Configuration.collapse_uncollapse;
812 else if ( name.equals( "reroot" ) ) {
813 index = Configuration.reroot;
815 else if ( name.equals( "subtree" ) ) {
816 index = Configuration.subtree;
818 else if ( name.equals( "swap" ) ) {
819 index = Configuration.swap;
821 else if ( name.equals( "sort_descendants" ) ) {
822 index = Configuration.sort_descendents;
824 else if ( name.equals( "get_ext_descendents_data" ) ) {
825 index = Configuration.get_ext_desc_data;
827 else if ( name.equals( "display_sequences" ) ) {
829 .printWarningMessage( Constants.PRG_NAME, "configuration key [display_sequences] is deprecated" );
832 else if ( name.equals( "open_seq_web" ) ) {
833 index = Configuration.open_seq_web;
835 else if ( name.equals( "open_tax_web" ) ) {
836 index = Configuration.open_tax_web;
838 else if ( name.equals( "blast" ) ) {
839 index = Configuration.blast;
841 else if ( name.equals( "cut_subtree" ) ) {
842 index = Configuration.cut_subtree;
844 else if ( name.equals( "copy_subtree" ) ) {
845 index = Configuration.copy_subtree;
847 else if ( name.equals( "paste_subtree" ) ) {
848 index = Configuration.paste_subtree;
850 else if ( name.equals( "delete" ) ) {
851 index = Configuration.delete_subtree_or_node;
853 else if ( name.equals( "add_new_node" ) ) {
854 index = Configuration.add_new_node;
856 else if ( name.equals( "edit_node_data" ) ) {
857 index = Configuration.edit_node_data;
859 else if ( name.equals( "select_nodes" ) ) {
860 index = Configuration.select_nodes;
862 else if ( name.equals( "display_node_popup" ) ) {
863 ForesterUtil.printWarningMessage( Constants.PRG_NAME,
864 "configuration key [display_node_popup] is deprecated" );
867 else if ( name.equals( "custom_option" ) ) {
868 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "configuration key [custom_option] is deprecated" );
871 else if ( name.equals( "color_subtree" ) ) {
872 index = Configuration.color_subtree;
877 private boolean parseBoolean( final String str ) {
878 final String my_str = str.trim().toLowerCase();
879 if ( my_str.equals( "yes" ) || my_str.equals( "true" ) ) {
882 else if ( my_str.equals( "no" ) || my_str.equals( "false" ) ) {
886 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "could not parse boolean value from [" + str + "]" );
891 private double parseDouble( final String str ) {
894 d = Double.parseDouble( str.trim() );
896 catch ( final Exception e ) {
897 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "could not parse double from [" + str + "]" );
903 private float parseFloat( final String str ) {
906 f = Float.parseFloat( str.trim() );
908 catch ( final Exception e ) {
909 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "could not parse float from [" + str + "]" );
915 private int parseInt( final String str ) {
918 i = Integer.parseInt( str.trim() );
920 catch ( final Exception e ) {
921 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "could not parse integer from [" + str + "]" );
927 private short parseShort( final String str ) {
930 i = Short.parseShort( str.trim() );
932 catch ( final Exception e ) {
933 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "could not parse short from [" + str + "]" );
939 private void processFontFamily( final StringTokenizer st ) {
940 setBaseFontFamilyName( "" );
941 final String font_str = ( ( String ) st.nextElement() ).trim();
942 final String[] fonts = font_str.split( ",+" );
943 for( String font : fonts ) {
944 font = font.replace( '_', ' ' ).trim();
945 if ( Arrays.binarySearch( AptxUtil.getAvailableFontFamiliesSorted(), font ) >= 0 ) {
946 setBaseFontFamilyName( font );
953 * read each line of config file, process non-comment lines
954 * @throws IOException
956 private void readConfig( final BufferedReader conf_in ) throws IOException {
959 line = conf_in.readLine();
960 if ( line != null ) {
962 // skip comments and blank lines
963 if ( !line.startsWith( "#" ) && ( !ForesterUtil.isEmpty( line ) ) ) {
964 // convert runs of spaces to tabs
965 line = line.replaceAll( "\\s+", "\t" );
966 final StringTokenizer st = new StringTokenizer( line, "\t" );
970 } while ( line != null );
973 private void setAntialiasScreen( final boolean antialias_screen ) {
974 _antialias_screen = antialias_screen;
977 private void setCladogramType( final CLADOGRAM_TYPE cladogram_type ) {
978 _cladogram_type = cladogram_type;
981 private void setDefaultBootstrapSamples( final int default_bootstrap_samples ) {
982 _default_bootstrap_samples = default_bootstrap_samples;
985 private void setEditable( final boolean editable ) {
986 _editable = editable;
989 private void setExtNodeDataReturnOn( final EXT_NODE_DATA_RETURN_ON ext_node_data_return_on ) {
990 _ext_node_data_return_on = ext_node_data_return_on;
993 private void setGraphicsExportX( final int graphics_export_x ) {
994 _graphics_export_x = graphics_export_x;
997 private void setGraphicsExportY( final int graphics_export_y ) {
998 _graphics_export_y = graphics_export_y;
1001 private void setInternalNumberAreConfidenceForNhParsing( final boolean internal_number_are_confidence_for_nh_parsing ) {
1002 _internal_number_are_confidence_for_nh_parsing = internal_number_are_confidence_for_nh_parsing;
1006 * Set a key-value(s) tuple
1008 private void setKeyValue( final StringTokenizer st ) {
1009 final String key = ( ( String ) st.nextElement() ).replace( ':', ' ' ).trim().toLowerCase();
1010 if ( !st.hasMoreElements() ) {
1013 // Handle single value settings first:
1014 if ( key.equals( "default_click_to" ) ) {
1015 final String clickto_name = ( String ) st.nextElement();
1016 default_clickto = getClickToIndex( clickto_name );
1017 if ( default_clickto == -1 ) {
1018 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "invalid value [" + clickto_name
1019 + "] for [default_click_to]" );
1020 default_clickto = 0;
1022 else if ( default_clickto == DEPRECATED ) {
1026 else if ( key.equals( "native_ui" ) ) {
1027 final String my_str = ( ( String ) st.nextElement() ).trim().toLowerCase();
1028 if ( my_str.equals( "yes" ) || my_str.equals( "true" ) ) {
1031 else if ( my_str.equals( "no" ) || my_str.equals( "false" ) ) {
1032 _ui = UI.CROSSPLATFORM;
1034 else if ( my_str.equals( "?" ) ) {
1038 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "could not parse yes/no/? value from [" + my_str
1043 else if ( key.equals( VALIDATE_AGAINST_PHYLOXML_XSD_SCHEMA ) ) {
1044 setValidatePhyloXmlAgainstSchema( parseBoolean( ( String ) st.nextElement() ) );
1046 else if ( key.equals( "antialias_screen" ) ) {
1047 setAntialiasScreen( parseBoolean( ( String ) st.nextElement() ) );
1049 else if ( key.equals( "phylogeny_graphics_type" ) ) {
1050 final String type_str = ( ( String ) st.nextElement() ).trim();
1051 if ( type_str.equalsIgnoreCase( PHYLOGENY_GRAPHICS_TYPE.CONVEX.toString() ) ) {
1052 setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CONVEX );
1054 else if ( type_str.equalsIgnoreCase( PHYLOGENY_GRAPHICS_TYPE.CURVED.toString() ) ) {
1055 setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CURVED );
1057 else if ( type_str.equalsIgnoreCase( PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE.toString() ) ) {
1058 setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE );
1060 else if ( type_str.equalsIgnoreCase( PHYLOGENY_GRAPHICS_TYPE.ROUNDED.toString() ) ) {
1061 setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.ROUNDED );
1063 else if ( type_str.equalsIgnoreCase( PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR.toString() ) ) {
1064 setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR );
1066 else if ( type_str.equalsIgnoreCase( PHYLOGENY_GRAPHICS_TYPE.TRIANGULAR.toString() ) ) {
1067 setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.TRIANGULAR );
1069 else if ( type_str.equalsIgnoreCase( PHYLOGENY_GRAPHICS_TYPE.UNROOTED.toString() ) ) {
1070 setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.UNROOTED );
1072 else if ( type_str.equalsIgnoreCase( PHYLOGENY_GRAPHICS_TYPE.CIRCULAR.toString() ) ) {
1073 setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CIRCULAR );
1076 setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR );
1077 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown value [" + type_str
1078 + "] for [phylogeny_graphics_type]" );
1081 else if ( key.equals( "min_confidence_value" ) ) {
1082 final String mcv_str = ( ( String ) st.nextElement() ).trim();
1083 final double d = parseDouble( mcv_str );
1084 setMinConfidenceValue( d );
1086 else if ( key.equals( "font_family" ) ) {
1087 processFontFamily( st );
1089 else if ( key.equals( "font_size" ) ) {
1090 final String size_str = ( ( String ) st.nextElement() ).trim();
1091 final int i = parseInt( size_str );
1093 setBaseFontSize( i );
1096 else if ( key.equals( "font_size_min" ) ) {
1097 final String size_str = ( ( String ) st.nextElement() ).trim();
1098 final int i = parseInt( size_str );
1100 setMinBaseFontSize( i );
1103 else if ( key.equals( "font_size_max" ) ) {
1104 final String size_str = ( ( String ) st.nextElement() ).trim();
1105 final int i = parseInt( size_str );
1107 setMaxBaseFontSize( i );
1110 else if ( key.equals( "graphics_export_x" ) ) {
1111 final String str = ( ( String ) st.nextElement() ).trim();
1112 final int i = parseInt( str );
1114 setGraphicsExportX( i );
1117 else if ( key.equals( "graphics_export_y" ) ) {
1118 final String str = ( ( String ) st.nextElement() ).trim();
1119 final int i = parseInt( str );
1121 setGraphicsExportY( i );
1124 else if ( key.equals( "pdf_export_line_width" ) ) {
1125 final String str = ( ( String ) st.nextElement() ).trim();
1126 final float f = parseFloat( str );
1128 setPrintLineWidth( f );
1131 ForesterUtil.printWarningMessage( Constants.PRG_NAME,
1132 "value for [pdf_export_line_width] cannot be zero or negative" );
1135 else if ( key.equals( "window_initial_size_x" ) ) {
1136 final String str = ( ( String ) st.nextElement() ).trim();
1137 final int i = parseInt( str );
1142 else if ( key.equals( "window_initial_size_y" ) ) {
1143 final String str = ( ( String ) st.nextElement() ).trim();
1144 final int i = parseInt( str );
1149 else if ( key.equals( "default_number_of_bootstrap_resamples" ) ) {
1150 final String str = ( ( String ) st.nextElement() ).trim();
1151 final int i = parseInt( str );
1153 setDefaultBootstrapSamples( i );
1157 .printWarningMessage( Constants.PRG_NAME,
1158 "value for [default_number_of_bootstrap_resamples] cannot be negative" );
1161 else if ( key.equals( "mafft_local" ) ) {
1162 final String str = ( ( String ) st.nextElement() ).trim();
1163 if ( !ForesterUtil.isEmpty( str ) ) {
1164 setPathToLocalMafft( new File( str ) );
1167 else if ( key.equals( "fastme_local" ) ) {
1168 final String str = ( ( String ) st.nextElement() ).trim();
1169 if ( !ForesterUtil.isEmpty( str ) ) {
1170 setPathToLocalFastme( new File( str ) );
1173 else if ( key.equals( "raxml_local" ) ) {
1174 final String str = ( ( String ) st.nextElement() ).trim();
1175 if ( !ForesterUtil.isEmpty( str ) ) {
1176 setPathToLocalRaxml( new File( str ) );
1179 else if ( key.equals( "show_scale" ) ) {
1180 setShowScale( parseBoolean( ( String ) st.nextElement() ) );
1182 else if ( key.equals( "show_overview" ) ) {
1183 setShowOverview( parseBoolean( ( String ) st.nextElement() ) );
1185 else if ( key.equals( "show_branch_length_values" ) ) {
1186 setShowBranchLengthValues( parseBoolean( ( String ) st.nextElement() ) );
1188 else if ( key.equals( "background_gradient" ) ) {
1189 setBackgroundColorGradient( parseBoolean( ( String ) st.nextElement() ) );
1191 else if ( key.equals( "color_labels_same_as_branch_length_values" ) ) {
1192 setColorLabelsSameAsParentBranch( parseBoolean( ( String ) st.nextElement() ) );
1194 else if ( key.equals( "show_domain_labels" ) ) {
1195 setShowDomainLabels( parseBoolean( ( String ) st.nextElement() ) );
1197 else if ( key.equals( "show_seq_annotation_ref_sources" ) ) {
1198 setShowAnnotationRefSource( parseBoolean( ( String ) st.nextElement() ) );
1200 else if ( key.equals( "abbreviate_scientific_names" ) ) {
1201 setAbbreviateScientificTaxonNames( parseBoolean( ( String ) st.nextElement() ) );
1203 else if ( key.equals( "cladogram_type" ) ) {
1204 final String type_str = ( ( String ) st.nextElement() ).trim();
1205 if ( type_str.equalsIgnoreCase( Options.CLADOGRAM_TYPE.NON_LINED_UP.toString() ) ) {
1206 setCladogramType( Options.CLADOGRAM_TYPE.NON_LINED_UP );
1208 else if ( type_str.equalsIgnoreCase( Options.CLADOGRAM_TYPE.EXT_NODE_SUM_DEP.toString() ) ) {
1209 setCladogramType( Options.CLADOGRAM_TYPE.EXT_NODE_SUM_DEP );
1211 else if ( type_str.equalsIgnoreCase( Options.CLADOGRAM_TYPE.TOTAL_NODE_SUM_DEP.toString() ) ) {
1212 setCladogramType( Options.CLADOGRAM_TYPE.TOTAL_NODE_SUM_DEP );
1215 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown value [" + type_str
1216 + "] for [cladogram_type]" );
1219 else if ( key.equals( "non_lined_up_cladogram" ) ) {
1221 .printWarningMessage( Constants.PRG_NAME,
1222 "configuration key [non_lined_up_cladogram] is deprecated, use [cladogram_type] instead" );
1224 else if ( key.equals( "hide_controls_and_menus" ) ) {
1225 _hide_controls_and_menus = parseBoolean( ( String ) st.nextElement() );
1227 else if ( key.equals( "use_tabbed_display" ) ) {
1228 _use_tabbed_display = parseBoolean( ( String ) st.nextElement() );
1230 else if ( key.equals( "overview_width" ) ) {
1231 final short i = parseShort( ( ( String ) st.nextElement() ) );
1234 else if ( key.equals( "overview_height" ) ) {
1235 final short i = parseShort( ( ( String ) st.nextElement() ) );
1236 setOvMaxHeight( i );
1238 else if ( key.equals( "overview_placement_type" ) ) {
1239 final String type_str = ( ( String ) st.nextElement() ).trim();
1240 if ( type_str.equalsIgnoreCase( OVERVIEW_PLACEMENT_TYPE.UPPER_LEFT.toTag() ) ) {
1241 setOvPlacement( OVERVIEW_PLACEMENT_TYPE.UPPER_LEFT );
1243 else if ( type_str.equalsIgnoreCase( OVERVIEW_PLACEMENT_TYPE.UPPER_RIGHT.toTag() ) ) {
1244 setOvPlacement( OVERVIEW_PLACEMENT_TYPE.UPPER_RIGHT );
1246 else if ( type_str.equalsIgnoreCase( OVERVIEW_PLACEMENT_TYPE.LOWER_LEFT.toTag() ) ) {
1247 setOvPlacement( OVERVIEW_PLACEMENT_TYPE.LOWER_LEFT );
1249 else if ( type_str.equalsIgnoreCase( OVERVIEW_PLACEMENT_TYPE.LOWER_RIGHT.toTag() ) ) {
1250 setOvPlacement( OVERVIEW_PLACEMENT_TYPE.LOWER_RIGHT );
1253 setOvPlacement( OVERVIEW_PLACEMENT_TYPE.UPPER_LEFT );
1254 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown value [" + type_str
1255 + "] for [overview_placement_type]" );
1258 else if ( key.equals( "node_label_direction" ) ) {
1259 final String type_str = ( ( String ) st.nextElement() ).trim();
1260 if ( type_str.equalsIgnoreCase( NODE_LABEL_DIRECTION.HORIZONTAL.toString() ) ) {
1261 setNodeLabelDirection( NODE_LABEL_DIRECTION.HORIZONTAL );
1263 else if ( type_str.equalsIgnoreCase( NODE_LABEL_DIRECTION.RADIAL.toString() ) ) {
1264 setNodeLabelDirection( NODE_LABEL_DIRECTION.RADIAL );
1267 setNodeLabelDirection( NODE_LABEL_DIRECTION.HORIZONTAL );
1268 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown value [" + type_str
1269 + "] for [node_label_direction]" );
1272 else if ( key.equals( "branch_length_value_digits" ) ) {
1273 final short i = parseShort( ( ( String ) st.nextElement() ).trim() );
1275 setNumberOfDigitsAfterCommaForBranchLengthValue( i );
1278 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "illegal value [" + i
1279 + "] for [branch_length_value_digits]" );
1282 else if ( key.equals( "confidence_value_digits" ) ) {
1283 final short i = parseShort( ( ( String ) st.nextElement() ).trim() );
1285 setNumberOfDigitsAfterCommaForConfidenceValues( i );
1288 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "illegal value [" + i
1289 + "] for [confidence_value_digits]" );
1292 else if ( key.equals( "allow_editing" ) ) {
1293 setEditable( parseBoolean( ( String ) st.nextElement() ) );
1295 else if ( key.equals( "display_sequence_relations" ) ) {
1296 setDisplaySequenceRelations( parseBoolean( ( String ) st.nextElement() ) );
1298 else if ( key.equals( "replace_underscores_in_nh_parsing" ) ) {
1299 final boolean r = parseBoolean( ( String ) st.nextElement() );
1300 if ( r && ( getTaxonomyExtraction() != TAXONOMY_EXTRACTION.NO ) ) {
1302 .printWarningMessage( Constants.PRG_NAME,
1303 "attempt to extract taxonomies and replace underscores at the same time" );
1306 setReplaceUnderscoresInNhParsing( r );
1309 else if ( key.equals( "taxonomy_extraction_in_nh_parsing" ) ) {
1310 final String s = ( String ) st.nextElement();
1311 if ( s.equalsIgnoreCase( "no" ) ) {
1312 setTaxonomyExtraction( TAXONOMY_EXTRACTION.NO );
1314 else if ( s.equalsIgnoreCase( "pfam_relaxed" ) ) {
1315 setTaxonomyExtraction( TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
1317 else if ( s.equalsIgnoreCase( "pfam_strict" ) ) {
1318 setTaxonomyExtraction( TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1320 else if ( s.equalsIgnoreCase( "aggressive" ) ) {
1321 setTaxonomyExtraction( TAXONOMY_EXTRACTION.AGGRESSIVE );
1325 .printWarningMessage( Constants.PRG_NAME,
1326 "unknown value for \"taxonomy_extraction_in_nh_parsing\": "
1328 + " (must be either: no, pfam_relaxed, pfam_strict, or aggressive)" );
1330 if ( ( getTaxonomyExtraction() != TAXONOMY_EXTRACTION.NO ) && isReplaceUnderscoresInNhParsing() ) {
1332 .printWarningMessage( Constants.PRG_NAME,
1333 "attempt to extract taxonomies and replace underscores at the same time" );
1336 else if ( key.equals( "internal_labels_are_confidence_values" ) ) {
1337 setInternalNumberAreConfidenceForNhParsing( parseBoolean( ( String ) st.nextElement() ) );
1339 else if ( key.equals( "gui_background_color" ) ) {
1340 _gui_background_color = Color.decode( ( String ) st.nextElement() );
1342 else if ( key.equals( "gui_checkbox_text_color" ) ) {
1343 _gui_checkbox_text_color = Color.decode( ( String ) st.nextElement() );
1345 else if ( key.equals( "gui_checkbox_and_button_active_color" ) ) {
1346 _gui_checkbox_and_button_active_color = Color.decode( ( String ) st.nextElement() );
1348 else if ( key.equals( "gui_button_text_color" ) ) {
1349 _gui_button_text_color = Color.decode( ( String ) st.nextElement() );
1351 else if ( key.equals( "gui_button_background_color" ) ) {
1352 _gui_button_background_color = Color.decode( ( String ) st.nextElement() );
1354 else if ( key.equals( "gui_menu_background_color" ) ) {
1355 _gui_menu_background_color = Color.decode( ( String ) st.nextElement() );
1357 else if ( key.equals( "gui_menu_text_color" ) ) {
1358 _gui_menu_text_color = Color.decode( ( String ) st.nextElement() );
1360 else if ( key.equals( "gui_button_border_color" ) ) {
1361 _gui_button_border_color = Color.decode( ( String ) st.nextElement() );
1363 else if ( key.equals( "domain_structure_font_color" ) ) {
1364 _domain_structure_font_color = Color.decode( ( String ) st.nextElement() );
1366 else if ( key.equals( "domain_structure_base_color" ) ) {
1367 _domain_structure_base_color = Color.decode( ( String ) st.nextElement() );
1369 else if ( key.equals( "show_default_node_shapes" ) ) {
1371 .printWarningMessage( Constants.PRG_NAME,
1372 "configuration key [show_default_node_shapes] is deprecated, use [show_default_node_shapes_internal] and [show_default_node_shapes_external] instead" );
1373 final boolean b = parseBoolean( ( ( String ) st.nextElement() ).trim() );
1374 setShowDefaultNodeShapesInternal( b );
1375 setShowDefaultNodeShapesExternal( b );
1377 else if ( key.equals( "show_default_node_shapes_internal" ) ) {
1378 setShowDefaultNodeShapesInternal( parseBoolean( ( ( String ) st.nextElement() ).trim() ) );
1380 else if ( key.equals( "show_default_node_shapes_external" ) ) {
1381 setShowDefaultNodeShapesExternal( parseBoolean( ( ( String ) st.nextElement() ).trim() ) );
1383 else if ( key.equals( "default_node_size" ) ) {
1384 final short i = parseShort( ( ( String ) st.nextElement() ).trim() );
1385 setDefaultNodeShapeSize( i );
1387 else if ( key.equals( "default_node_fill" ) ) {
1388 final String fill_str = ( ( String ) st.nextElement() ).trim();
1389 if ( fill_str.equalsIgnoreCase( NodeVisualization.NodeFill.NONE.toString() ) ) {
1390 setDefaultNodeFill( NodeFill.NONE );
1392 else if ( fill_str.equalsIgnoreCase( NodeVisualization.NodeFill.GRADIENT.toString() ) ) {
1393 setDefaultNodeFill( NodeFill.GRADIENT );
1395 else if ( fill_str.equalsIgnoreCase( NodeVisualization.NodeFill.SOLID.toString() ) ) {
1396 setDefaultNodeFill( NodeFill.SOLID );
1399 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown value [" + fill_str
1400 + "] for [default_node_fill]" );
1403 else if ( key.equals( "default_node_shape" ) ) {
1404 final String shape_str = ( ( String ) st.nextElement() ).trim();
1405 if ( shape_str.equalsIgnoreCase( NodeVisualization.NodeShape.CIRCLE.toString() ) ) {
1406 setDefaultNodeShape( NodeShape.CIRCLE );
1408 else if ( shape_str.equalsIgnoreCase( NodeVisualization.NodeShape.RECTANGLE.toString() ) ) {
1409 setDefaultNodeShape( NodeShape.RECTANGLE );
1412 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown value [" + shape_str
1413 + "] for [default_node_shape]" );
1416 else if ( key.equals( "taxonomy_colorize_node_shapes" ) ) {
1417 setTaxonomyColorizeNodeShapes( parseBoolean( ( String ) st.nextElement() ) );
1419 else if ( key.equals( "midpoint_reroot" ) ) {
1420 setMidpointReroot( parseBoolean( ( String ) st.nextElement() ) );
1422 else if ( key.equals( "ext_descendents_data_to_return" ) ) {
1423 final String s = ( ( String ) st.nextElement() ).trim();
1424 if ( s.equalsIgnoreCase( "node_name" ) ) {
1425 setExtDescNodeDataToReturn( NODE_DATA.NODE_NAME );
1427 else if ( s.equalsIgnoreCase( "sequence_acc" ) ) {
1428 setExtDescNodeDataToReturn( NODE_DATA.SEQUENCE_ACC );
1430 else if ( s.equalsIgnoreCase( "sequence_mol_seq_fasta" ) ) {
1431 setExtDescNodeDataToReturn( NODE_DATA.SEQUENCE_MOL_SEQ_FASTA );
1433 else if ( s.equalsIgnoreCase( "sequence_mol_seq" ) ) {
1434 setExtDescNodeDataToReturn( NODE_DATA.SEQUENCE_MOL_SEQ );
1436 else if ( s.equalsIgnoreCase( "sequence_name" ) ) {
1437 setExtDescNodeDataToReturn( NODE_DATA.SEQUENCE_NAME );
1439 else if ( s.equalsIgnoreCase( "sequence_symbol" ) ) {
1440 setExtDescNodeDataToReturn( NODE_DATA.SEQUENCE_SYMBOL );
1442 else if ( s.equalsIgnoreCase( "taxonomy_scientific_name" ) ) {
1443 setExtDescNodeDataToReturn( NODE_DATA.TAXONOMY_SCIENTIFIC_NAME );
1445 else if ( s.equalsIgnoreCase( "taxonomy_code" ) ) {
1446 setExtDescNodeDataToReturn( NODE_DATA.TAXONOMY_CODE );
1448 else if ( s.equalsIgnoreCase( "taxonomy_common_name" ) ) {
1449 setExtDescNodeDataToReturn( NODE_DATA.TAXONOMY_COMM0N_NAME );
1451 else if ( s.equalsIgnoreCase( "user_selected" ) ) {
1452 setExtDescNodeDataToReturn( NODE_DATA.UNKNOWN );
1455 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown value [" + s
1456 + "] for [ext_descendents_data_to_return]" );
1459 else if ( key.equals( "label_for_get_ext_descendents_data" ) ) {
1460 final String s = ( ( String ) st.nextElement() ).trim();
1461 if ( ForesterUtil.isEmpty( s ) || ( s.length() < 2 ) ) {
1462 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "illegal value [" + s
1463 + "] for [label_for_get_ext_descendents_data]" );
1466 setLabelForGetExtDescendentsData( s.replaceAll( "_", " " ) );
1469 else if ( key.equals( "ext_descendents_data_to_return_on" ) ) {
1470 final String s = ( ( String ) st.nextElement() ).trim().toLowerCase();
1471 if ( s.equals( "console" ) ) {
1472 setExtNodeDataReturnOn( EXT_NODE_DATA_RETURN_ON.CONSOLE );
1474 else if ( s.equals( "window" ) ) {
1475 setExtNodeDataReturnOn( EXT_NODE_DATA_RETURN_ON.WINODW );
1477 else if ( s.equals( "buffer_only" ) ) {
1478 setExtNodeDataReturnOn( EXT_NODE_DATA_RETURN_ON.BUFFER_ONLY );
1481 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown value [" + s
1482 + "] for [ext_descendents_data_to_return_on]" );
1485 else if ( st.countTokens() >= 2 ) { // counts the tokens that are not
1488 if ( key.equals( "use_real_br_lengths" ) || key.equals( "phylogram" ) ) {
1489 key_index = Configuration.display_as_phylogram;
1490 if ( key.equals( "use_real_br_lengths" ) ) {
1492 .printWarningMessage( Constants.PRG_NAME,
1493 "configuration key [use_real_br_lengths] is deprecated, use [phylogram] instead" );
1496 else if ( key.equals( "rollover" ) ) {
1497 key_index = Configuration.node_data_popup;
1499 else if ( key.equals( "color_according_to_species" ) ) {
1500 key_index = Configuration.color_according_to_species;
1502 else if ( key.equals( "show_node_names" ) ) {
1503 key_index = Configuration.show_node_names;
1505 else if ( key.equals( "show_taxonomy" ) || key.equals( "show_taxonomy_code" ) ) {
1506 key_index = Configuration.show_tax_code;
1507 if ( key.equals( "show_taxonomy" ) ) {
1509 .printWarningMessage( Constants.PRG_NAME,
1510 "configuration key [show_taxonomy] is deprecated, use [show_taxonomy_code] instead" );
1513 else if ( key.equals( "write_br_length_values" ) ) {
1514 ForesterUtil.printWarningMessage( Constants.PRG_NAME,
1515 "configuration key [write_br_length_values] is deprecated" );
1516 key_index = DEPRECATED;
1518 else if ( key.equals( "write_bootstrap_values" ) || key.equals( "write_confidence_values" ) ) {
1519 key_index = Configuration.write_confidence_values;
1520 if ( key.equals( "write_bootstrap_values" ) ) {
1522 .printWarningMessage( Constants.PRG_NAME,
1523 "configuration key [write_bootstrap_values] is deprecated, use [write_confidence_values] instead" );
1526 else if ( key.equals( "write_events" ) || key.equals( "write_dup_spec" ) ) {
1527 key_index = Configuration.write_events;
1528 if ( key.equals( "write_dup_spec" ) ) {
1530 .printWarningMessage( Constants.PRG_NAME,
1531 "configuration key [write_dup_spec] is deprecated, use [write_events] instead" );
1534 else if ( key.equals( "color_branches" ) ) {
1535 key_index = Configuration.color_branches;
1537 else if ( key.equals( "width_branches" ) ) {
1538 key_index = Configuration.width_branches;
1540 else if ( key.equals( "mark_nodes_with_box" ) ) {
1541 ForesterUtil.printWarningMessage( Constants.PRG_NAME,
1542 "configuration key [mark_nodes_with_box] is deprecated" );
1543 key_index = DEPRECATED;
1545 else if ( key.equals( "show_domain_architectures" ) ) {
1546 key_index = Configuration.show_domain_architectures;
1548 else if ( key.equals( "show_annotations" ) ) {
1549 key_index = Configuration.show_annotation;
1551 else if ( key.equals( "show_binary_characters" ) ) {
1552 key_index = Configuration.show_binary_characters;
1554 else if ( key.equals( "show_binary_character_counts" ) ) {
1555 key_index = Configuration.show_binary_character_counts;
1557 else if ( key.equals( "show_gene_names" ) ) {
1558 key_index = Configuration.show_gene_names;
1560 else if ( key.equals( "show_gene_symbols" ) ) {
1561 key_index = Configuration.show_gene_symbols;
1563 else if ( key.equals( "show_sequence_acc" ) ) {
1564 key_index = Configuration.show_sequence_acc;
1566 else if ( key.equals( "show_node_ids" ) ) {
1568 .printWarningMessage( Constants.PRG_NAME, "configuration key [show_node_ids] is deprecated" );
1569 key_index = DEPRECATED;
1571 else if ( key.equals( "display_internal_data" ) ) {
1572 key_index = Configuration.display_internal_data;
1574 else if ( key.equals( "dynamically_hide_data" ) ) {
1575 key_index = Configuration.dynamically_hide_data;
1577 else if ( key.equals( "show_taxonomy_names" ) ) {
1578 ForesterUtil.printWarningMessage( Constants.PRG_NAME,
1579 "configuration key [show_taxonomy_names] is deprecated" );
1580 key_index = DEPRECATED;
1582 else if ( key.equals( "show_taxonomy_scientific_names" ) ) {
1583 key_index = Configuration.show_taxonomy_scientific_names;
1585 else if ( key.equals( "show_taxonomy_common_names" ) ) {
1586 key_index = Configuration.show_taxonomy_common_names;
1588 else if ( key.equals( "show_taxonomy_images" ) ) {
1589 key_index = Configuration.show_taxonomy_images;
1591 else if ( key.equals( "color_according_to_annotation" ) ) {
1592 key_index = Configuration.color_according_to_annotation;
1594 else if ( key.equals( "show_vector_data" ) ) {
1595 key_index = Configuration.show_vector_data;
1597 else if ( key.equals( "show_properties" ) ) {
1598 key_index = Configuration.show_properties;
1600 else if ( key.equals( "show_relation_confidence" ) ) {
1601 key_index = Configuration.show_relation_confidence;
1603 else if ( key.equals( "show_custom_node_shapes" ) ) {
1604 key_index = Configuration.show_custom_node_shapes;
1606 // If we've found the key, set the values
1607 if ( key_index >= 0 ) {
1608 display_options[ key_index ][ 1 ] = ( String ) st.nextElement();
1609 display_options[ key_index ][ 2 ] = ( String ) st.nextElement();
1610 // otherwise, keep looking
1613 if ( key_index == DEPRECATED ) {
1616 else if ( key.equals( "click_to" ) ) {
1617 final String click_to_name = ( String ) st.nextElement();
1618 key_index = getClickToIndex( click_to_name );
1619 if ( key_index >= 0 ) {
1620 clickto_options[ key_index ][ 1 ] = ( String ) st.nextElement();
1622 else if ( key_index == DEPRECATED ) {
1626 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown click-to option: "
1630 else if ( key.equals( "species_color" ) ) {
1631 getSpeciesColors().put( ( ( String ) st.nextElement() ).replace( '_', ' ' ),
1632 Color.decode( ( String ) st.nextElement() ) );
1634 else if ( key.equals( "domain_color" ) ) {
1635 getDomainColors().put( ( String ) st.nextElement(), Color.decode( ( String ) st.nextElement() ) );
1637 else if ( key.equals( "annotation_color" ) ) {
1638 getAnnotationColors()
1639 .put( ( String ) st.nextElement(), Color.decode( ( String ) st.nextElement() ) );
1641 else if ( key.equals( "function_color" ) ) {
1642 ForesterUtil.printWarningMessage( Constants.PRG_NAME,
1643 "configuration key [function_color] is deprecated" );
1645 else if ( key.equals( DISPLAY_COLOR_KEY ) ) {
1646 putDisplayColors( ( String ) st.nextElement(), Color.decode( ( String ) st.nextElement() ) );
1649 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown configuration key [" + key
1650 + "] in: " + config_filename );
1655 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown configuration key [" + key + "] in: "
1656 + config_filename );
1660 private void setShowAnnotationRefSource( final boolean b ) {
1661 _show_annotation_ref_source = b;
1664 private void setLabelForGetExtDescendentsData( final String label_for_get_ext_descendents_data ) {
1665 _label_for_get_ext_descendents_data = label_for_get_ext_descendents_data;
1668 private void setOvMaxHeight( final short ov_max_height ) {
1669 _ov_max_height = ov_max_height;
1672 private void setOvMaxWidth( final short ov_max_width ) {
1673 _ov_max_width = ov_max_width;
1676 private void setOvPlacement( final OVERVIEW_PLACEMENT_TYPE ov_placement ) {
1677 _ov_placement = ov_placement;
1680 private void setPathToLocalFastme( final File path_to_local_fastme ) {
1681 _path_to_local_fastme = path_to_local_fastme;
1684 private void setPathToLocalMafft( final File path_to_local_mafft ) {
1685 _path_to_local_mafft = path_to_local_mafft;
1688 private void setPathToLocalRaxml( final File path_to_local_raxml ) {
1689 _path_to_local_raxml = path_to_local_raxml;
1692 private void setShowOverview( final boolean show_overview ) {
1693 _show_overview = show_overview;
1696 private void setValidatePhyloXmlAgainstSchema( final boolean validate_against_phyloxml_xsd_schema ) {
1697 _validate_against_phyloxml_xsd_schema = validate_against_phyloxml_xsd_schema;
1700 static String getDefaultFontFamilyName() {
1701 return DEFAULT_FONT_FAMILY;
1704 public enum EXT_NODE_DATA_RETURN_ON {
1705 CONSOLE, WINODW, BUFFER_ONLY;
1709 NATIVE, CROSSPLATFORM, NIMBUS, UNKNOWN
1712 static enum TRIPLET {
1713 TRUE, FALSE, UNKNOWN
1716 public boolean isMidpointReroot() {
1717 return _midpoint_root;
1720 public void setMidpointReroot( final boolean midpoint_root ) {
1721 _midpoint_root = midpoint_root;
1724 public boolean isShowAnnotationRefSource() {
1725 return _show_annotation_ref_source;