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", "?" }, { "Colorize by Taxonomy", "display", "yes" },
165 { "Use Branch Colors", "display", "no" }, { "Use Branch Widths", "display", "no" },
166 { "Show Custom Nodes", "display", "yes" }, { "Protein 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 { "Colorize by Annotation", "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" },
178 { "Colorize Subtree/Node(s)", "display" }, { "Open Sequence DB", "display" },
179 { "Open Taxonomy DB", "display" }, { "Blast", "display" }, { "Cut Subtree", "display" },
180 { "Copy Subtree", "display" }, { "Paste Subtree", "display" }, { "Delete Subtree/Node", "display" },
181 { "Add New Node", "display" }, { "Edit Node Data", "display" }, { "Sort Descendants", "display" },
182 { "Return", "display" }, { "Select Node(s)", "display" } };
183 // This option is selected in the dropdown
184 int default_clickto = Configuration.display_node_data;
188 TreeColorSet tree_color_set;
192 TreeFontSet tree_font_set;
196 private static Hashtable<String, Color> _species_colors;
200 private static Hashtable<String, Color> _domain_colors;
204 private static Hashtable<String, Color> _annotation_colors;
205 boolean verbose = Constants.VERBOSE_DEFAULT;
206 private NODE_LABEL_DIRECTION _node_label_direction = NODE_LABEL_DIRECTION.HORIZONTAL;
207 private Color _gui_background_color = Constants.GUI_BACKGROUND_DEFAULT;
208 private Color _gui_checkbox_text_color = Constants.CHECKBOX_TEXT_COLOR_DEFAULT;
209 private Color _gui_checkbox_and_button_active_color = Constants.CHECKBOX_AND_BUTTON_ACTIVE_COLOR_DEFAULT;
210 private Color _gui_button_text_color = Constants.BUTTON_TEXT_COLOR_DEFAULT;
211 private Color _gui_button_background_color = Constants.BUTTON_BACKGROUND_COLOR_DEFAULT;
212 private Color _gui_menu_background_color = Constants.MENU_BACKGROUND_COLOR_DEFAULT;
213 private Color _gui_menu_text_color = Constants.MENU_TEXT_COLOR_DEFAULT;
214 private Color _gui_button_border_color = Constants.BUTTON_BORDER_COLOR_DEFAULT;
215 private Color _domain_structure_font_color = Constants.DOMAIN_STRUCTURE_FONT_COLOR_DEFAULT;
216 private Color _domain_structure_base_color = Constants.DOMAIN_STRUCTURE_BASE_COLOR_DEFAULT;
217 private NODE_DATA _ext_desc_data_to_return = NODE_DATA.UNKNOWN;
218 private String _label_for_get_ext_descendents_data = "";
219 private EXT_NODE_DATA_RETURN_ON _ext_node_data_return_on = EXT_NODE_DATA_RETURN_ON.WINODW;
220 private int _frame_x_size;
221 private int _frame_y_size;
222 private boolean _midpoint_root = false;
223 private static String DEFAULT_FONT_FAMILY = "";
225 for( final String font_name : Constants.DEFAULT_FONT_CHOICES ) {
226 if ( Arrays.binarySearch( AptxUtil.getAvailableFontFamiliesSorted(), font_name ) >= 0 ) {
227 DEFAULT_FONT_FAMILY = font_name;
231 if ( ForesterUtil.isEmpty( DEFAULT_FONT_FAMILY ) ) {
232 DEFAULT_FONT_FAMILY = Constants.DEFAULT_FONT_CHOICES[ Constants.DEFAULT_FONT_CHOICES.length - 1 ];
236 public Configuration() {
237 this( null, false, false, false );
240 public Configuration( final String cf, final boolean is_url, final boolean is_applet, final boolean verbose ) {
241 if ( ForesterUtil.isEmpty( cf ) ) {
242 config_filename = default_config_filename;
245 config_filename = cf;
247 setDisplayColors( new TreeMap<String, Color>() );
248 config_filename = config_filename.trim();
251 // If URL, open accordingly
253 u = new URL( config_filename );
255 final InputStreamReader isr = new InputStreamReader( u.openStream() );
256 final BufferedReader bf = new BufferedReader( isr );
259 ForesterUtil.programMessage( Constants.PRG_NAME, "successfully read from configuration url ["
260 + config_filename + "]" );
262 catch ( final Exception e ) {
263 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "failed to read configuration from ["
264 + config_filename + "]: " + e.getLocalizedMessage() );
267 catch ( final Exception e ) {
268 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "cannot find or open configuration url ["
269 + config_filename + "]" );
273 // Otherwise, open as a file
274 File f = new File( config_filename );
276 f = new File( config_filename + ".txt" );
278 if ( f.exists() && f.canRead() ) {
280 final BufferedReader bf = new BufferedReader( new FileReader( f ) );
284 catch ( final Exception e ) {
286 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "failed to read configuration from ["
287 + config_filename + "]: " + e );
293 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "cannot find or open configuration file ["
294 + config_filename + "]" );
300 public String getBaseFontFamilyName() {
301 return _base_font_family_name;
304 public int getDefaultBootstrapSamples() {
305 return _default_bootstrap_samples;
308 public NodeFill getDefaultNodeFill() {
309 return _default_node_fill;
312 public NodeShape getDefaultNodeShape() {
313 return _default_node_shape;
316 public short getDefaultNodeShapeSize() {
317 return _default_node_shape_size;
320 public Color getDomainStructureBaseColor() {
321 return _domain_structure_base_color;
324 public Color getDomainStructureFontColor() {
325 return _domain_structure_font_color;
328 public NODE_DATA getExtDescNodeDataToReturn() {
329 return _ext_desc_data_to_return;
332 public EXT_NODE_DATA_RETURN_ON getExtNodeDataReturnOn() {
333 return _ext_node_data_return_on;
336 public int getFrameXSize() {
337 return _frame_x_size;
340 public int getFrameYSize() {
341 return _frame_y_size;
344 public String getLabelForGetExtDescendentsData() {
345 return _label_for_get_ext_descendents_data;
348 public File getPathToLocalFastme() {
349 return _path_to_local_fastme;
352 public File getpathToLocalMafft() {
353 return _path_to_local_mafft;
356 public File getPathToLocalRaxml() {
357 return _path_to_local_raxml;
360 public boolean isAbbreviateScientificTaxonNames() {
361 return _abbreviate_scientific_names;
364 public boolean isBackgroundColorGradient() {
365 return _background_color_gradient;
368 public boolean isColorLabelsSameAsParentBranch() {
369 return _color_labels_same_as_parent_branch;
372 public boolean isShowDefaultNodeShapesExternal() {
373 return _show_default_node_shapes_external;
376 public boolean isShowDefaultNodeShapesInternal() {
377 return _show_default_node_shapes_internal;
380 public boolean isShowDomainLabels() {
381 return _show_domain_labels;
384 public boolean isTaxonomyColorizeNodeShapes() {
385 return _taxonomy_colorize_node_shapes;
388 public void putDisplayColors( final String key, final Color color ) {
389 getDisplayColors().put( key, color );
392 public void setAbbreviateScientificTaxonNames( final boolean abbreviate_scientific_names ) {
393 _abbreviate_scientific_names = abbreviate_scientific_names;
396 public void setBackgroundColorGradient( final boolean background_color_gradient ) {
397 _background_color_gradient = background_color_gradient;
400 public void setBaseFontFamilyName( final String base_font_family_name ) {
401 _base_font_family_name = base_font_family_name;
404 public void setBaseFontSize( final int base_font_size ) {
405 _base_font_size = base_font_size;
408 private void setMaxBaseFontSize( final int max_base_font_size ) {
409 _max_base_font_size = max_base_font_size;
412 private void setMinBaseFontSize( final int min_base_font_size ) {
413 _min_base_font_size = min_base_font_size;
416 public void setColorizeBranches( final boolean b ) {
417 display_options[ color_branches ][ 2 ] = b ? "yes" : "no";
420 public void setColorLabelsSameAsParentBranch( final boolean color_labels_same_as_parent_branch ) {
421 _color_labels_same_as_parent_branch = color_labels_same_as_parent_branch;
424 public void setDefaultNodeFill( final NodeFill default_node_fill ) {
425 _default_node_fill = default_node_fill;
428 public void setDefaultNodeShape( final NodeShape default_node_shape ) {
429 _default_node_shape = default_node_shape;
432 public void setDefaultNodeShapeSize( final short default_node_shape_size ) {
433 _default_node_shape_size = default_node_shape_size;
436 public void setDisplayAsPhylogram( final boolean b ) {
437 display_options[ display_as_phylogram ][ 2 ] = b ? "yes" : "no";
440 public void setDisplayColors( final SortedMap<String, Color> display_colors ) {
441 _display_colors = display_colors;
444 public void setDisplayConfidenceValues( final boolean b ) {
445 display_options[ write_confidence_values ][ 2 ] = b ? "yes" : "no";
448 public void setDisplayInternalData( final boolean b ) {
449 display_options[ display_internal_data ][ 2 ] = b ? "yes" : "no";
452 public void setDisplayNodeNames( final boolean b ) {
453 display_options[ show_node_names ][ 2 ] = b ? "yes" : "no";
456 public void setDisplaySequenceAcc( final boolean b ) {
457 display_options[ show_sequence_acc ][ 2 ] = b ? "yes" : "no";
460 public void setDisplaySequenceNames( final boolean b ) {
461 display_options[ show_gene_names ][ 2 ] = b ? "yes" : "no";
464 public void setDisplaySequenceRelations( final boolean display_sequence_relations ) {
465 _display_sequence_relations = display_sequence_relations;
468 public void setDisplaySequenceSymbols( final boolean b ) {
469 display_options[ show_gene_symbols ][ 2 ] = b ? "yes" : "no";
472 public void setDisplayTaxonomyCode( final boolean b ) {
473 display_options[ show_tax_code ][ 2 ] = b ? "yes" : "no";
476 public void setDisplayTaxonomyCommonNames( final boolean b ) {
477 display_options[ show_taxonomy_common_names ][ 2 ] = b ? "yes" : "no";
480 public void setDisplayTaxonomyImages( final boolean b ) {
481 display_options[ show_taxonomy_images ][ 2 ] = b ? "yes" : "no";
484 public void setDisplayTaxonomyScientificNames( final boolean b ) {
485 display_options[ show_taxonomy_scientific_names ][ 2 ] = b ? "yes" : "no";
488 public void setDynamicallyHideData( final boolean b ) {
489 display_options[ dynamically_hide_data ][ 2 ] = b ? "yes" : "no";
492 public void setExtDescNodeDataToReturn( final NODE_DATA ext_desc_data_to_return ) {
493 _ext_desc_data_to_return = ext_desc_data_to_return;
496 public void setFrameXSize( final int frame_x_size ) {
497 _frame_x_size = frame_x_size;
500 public void setFrameYSize( final int frame_y_size ) {
501 _frame_y_size = frame_y_size;
504 public void setMinConfidenceValue( final double min_confidence_value ) {
505 _min_confidence_value = min_confidence_value;
508 public void setNodeLabelDirection( final NODE_LABEL_DIRECTION node_label_direction ) {
509 _node_label_direction = node_label_direction;
512 public void setNumberOfDigitsAfterCommaForBranchLengthValue( final short number_of_digits_after_comma_for_branch_length_values ) {
513 _number_of_digits_after_comma_for_branch_length_values = number_of_digits_after_comma_for_branch_length_values;
516 public void setNumberOfDigitsAfterCommaForConfidenceValues( final short number_of_digits_after_comma_for_confidence_values ) {
517 _number_of_digits_after_comma_for_confidence_values = number_of_digits_after_comma_for_confidence_values;
520 public void setPhylogenyGraphicsType( final PHYLOGENY_GRAPHICS_TYPE phylogeny_graphics_type ) {
521 _phylogeny_graphics_type = phylogeny_graphics_type;
524 public void setPrintLineWidth( final float print_line_width ) {
525 _print_line_width = print_line_width;
528 public void setReplaceUnderscoresInNhParsing( final boolean nh_parsing_replace_underscores ) {
529 _nh_parsing_replace_underscores = nh_parsing_replace_underscores;
532 public void setShowBranchLengthValues( final boolean show_branch_length_values ) {
533 _show_branch_length_values = show_branch_length_values;
536 public void setShowDefaultNodeShapesExternal( final boolean show_default_node_shapes_external ) {
537 _show_default_node_shapes_external = show_default_node_shapes_external;
540 public void setShowDefaultNodeShapesInternal( final boolean show_default_node_shapes_internal ) {
541 _show_default_node_shapes_internal = show_default_node_shapes_internal;
544 public void setShowDomainLabels( final boolean show_domain_labels ) {
545 _show_domain_labels = show_domain_labels;
548 public void setShowScale( final boolean show_scale ) {
549 _show_scale = show_scale;
552 public void setTaxonomyColorize( final boolean b ) {
553 display_options[ color_according_to_species ][ 2 ] = b ? "yes" : "no";
556 public void setTaxonomyColorizeNodeShapes( final boolean taxonomy_colorize_node_shapes ) {
557 _taxonomy_colorize_node_shapes = taxonomy_colorize_node_shapes;
560 public void setUseBranchesWidths( final boolean b ) {
561 display_options[ width_branches ][ 2 ] = b ? "yes" : "no";
564 boolean displaySequenceRelations() {
565 return _display_sequence_relations;
568 boolean doCheckOption( final int which ) {
569 return ( display_options[ which ][ 2 ].equalsIgnoreCase( "yes" ) )
570 || ( display_options[ which ][ 2 ].equalsIgnoreCase( "true" ) );
573 boolean doDisplayClickToOption( final int which ) {
574 return clickto_options[ which ][ 1 ].equalsIgnoreCase( "display" );
577 boolean doDisplayOption( final int which ) {
578 return display_options[ which ][ 1 ].equalsIgnoreCase( "display" );
582 * Will attempt to use the phylogeny to determine whether to check
583 * this or not (e.g. phylogram)
586 boolean doGuessCheckOption( final int which ) {
587 return display_options[ which ][ 2 ].equals( "?" );
590 Map<String, Color> getAnnotationColors() {
591 if ( _annotation_colors == null ) {
592 _annotation_colors = new Hashtable<String, Color>();
594 return _annotation_colors;
597 int getBaseFontSize() {
598 return _base_font_size;
601 int getMinBaseFontSize() {
602 return _min_base_font_size;
605 int getMaxBaseFontSize() {
606 return _max_base_font_size;
609 CLADOGRAM_TYPE getCladogramType() {
610 return _cladogram_type;
613 int getClickToOptionsCount() {
614 return clickto_options.length;
617 String getClickToTitle( final int which ) {
618 return clickto_options[ which ][ 0 ];
621 int getDefaultDisplayClicktoOption() {
622 return default_clickto;
625 SortedMap<String, Color> getDisplayColors() {
626 return _display_colors;
629 String getDisplayTitle( final int which ) {
630 return display_options[ which ][ 0 ];
633 Map<String, Color> getDomainColors() {
634 if ( _domain_colors == null ) {
635 _domain_colors = new Hashtable<String, Color>();
637 return _domain_colors;
640 int getGraphicsExportX() {
641 return _graphics_export_x;
644 int getGraphicsExportY() {
645 return _graphics_export_y;
648 Color getGuiBackgroundColor() {
649 return _gui_background_color;
652 Color getGuiButtonBackgroundColor() {
653 return _gui_button_background_color;
656 Color getGuiButtonBorderColor() {
657 return _gui_button_border_color;
660 Color getGuiButtonTextColor() {
661 return _gui_button_text_color;
664 Color getGuiCheckboxAndButtonActiveColor() {
665 return _gui_checkbox_and_button_active_color;
668 Color getGuiCheckboxTextColor() {
669 return _gui_checkbox_text_color;
672 Color getGuiMenuBackgroundColor() {
673 return _gui_menu_background_color;
676 Color getGuiMenuTextColor() {
677 return _gui_menu_text_color;
680 double getMinConfidenceValue() {
681 return _min_confidence_value;
684 NODE_LABEL_DIRECTION getNodeLabelDirection() {
685 return _node_label_direction;
688 short getNumberOfDigitsAfterCommaForBranchLengthValues() {
689 return _number_of_digits_after_comma_for_branch_length_values;
692 short getNumberOfDigitsAfterCommaForConfidenceValues() {
693 return _number_of_digits_after_comma_for_confidence_values;
696 short getOvMaxHeight() {
697 return _ov_max_height;
700 short getOvMaxWidth() {
701 return _ov_max_width;
704 OVERVIEW_PLACEMENT_TYPE getOvPlacement() {
705 return _ov_placement;
708 PHYLOGENY_GRAPHICS_TYPE getPhylogenyGraphicsType() {
709 return _phylogeny_graphics_type;
712 float getPrintLineWidth() {
713 return _print_line_width;
716 Hashtable<String, Color> getSpeciesColors() {
717 if ( _species_colors == null ) {
718 _species_colors = new Hashtable<String, Color>();
720 return _species_colors;
723 final TAXONOMY_EXTRACTION getTaxonomyExtraction() {
724 return _taxonomy_extraction;
727 boolean isAntialiasScreen() {
728 if ( ForesterUtil.isMac() ) {
729 //Apple Macintosh graphics are slow, turn off anti-alias.
732 return _antialias_screen;
736 * Convenience method.
738 * @return true if value in configuration file was 'yes'
740 boolean isDrawAsPhylogram() {
741 return doCheckOption( display_as_phylogram );
744 boolean isEditable() {
749 * Only used by ArchaeoptryxE.
752 boolean isHideControlPanelAndMenubar() {
753 return _hide_controls_and_menus;
756 boolean isInternalNumberAreConfidenceForNhParsing() {
757 return _internal_number_are_confidence_for_nh_parsing;
760 boolean isReplaceUnderscoresInNhParsing() {
761 return _nh_parsing_replace_underscores;
764 boolean isShowBranchLengthValues() {
765 return _show_branch_length_values;
768 boolean isShowOverview() {
769 return _show_overview;
772 boolean isShowScale() {
776 final boolean isUseNativeUI() {
777 if ( ( _ui == UI.UNKNOWN ) && ForesterUtil.isMac() ) {
780 return _ui == UI.NATIVE;
784 * Only used by ArchaeoptryxE.
787 boolean isUseTabbedDisplay() {
788 return _use_tabbed_display;
791 boolean isValidatePhyloXmlAgainstSchema() {
792 return _validate_against_phyloxml_xsd_schema;
795 final void setTaxonomyExtraction( final TAXONOMY_EXTRACTION taxonomy_extraction ) {
796 _taxonomy_extraction = taxonomy_extraction;
799 private int getClickToIndex( final String name ) {
801 if ( name.equals( "edit_info" ) ) {
802 index = Configuration.display_node_data;
804 .printWarningMessage( Constants.PRG_NAME,
805 "configuration key [edit_info] is deprecated, use [display node data] instead" );
807 else if ( name.equals( "display_node_data" ) ) {
808 index = Configuration.display_node_data;
810 else if ( name.equals( "collapse_uncollapse" ) ) {
811 index = Configuration.collapse_uncollapse;
813 else if ( name.equals( "reroot" ) ) {
814 index = Configuration.reroot;
816 else if ( name.equals( "subtree" ) ) {
817 index = Configuration.subtree;
819 else if ( name.equals( "swap" ) ) {
820 index = Configuration.swap;
822 else if ( name.equals( "sort_descendants" ) ) {
823 index = Configuration.sort_descendents;
825 else if ( name.equals( "get_ext_descendents_data" ) ) {
826 index = Configuration.get_ext_desc_data;
828 else if ( name.equals( "display_sequences" ) ) {
830 .printWarningMessage( Constants.PRG_NAME, "configuration key [display_sequences] is deprecated" );
833 else if ( name.equals( "open_seq_web" ) ) {
834 index = Configuration.open_seq_web;
836 else if ( name.equals( "open_tax_web" ) ) {
837 index = Configuration.open_tax_web;
839 else if ( name.equals( "blast" ) ) {
840 index = Configuration.blast;
842 else if ( name.equals( "cut_subtree" ) ) {
843 index = Configuration.cut_subtree;
845 else if ( name.equals( "copy_subtree" ) ) {
846 index = Configuration.copy_subtree;
848 else if ( name.equals( "paste_subtree" ) ) {
849 index = Configuration.paste_subtree;
851 else if ( name.equals( "delete" ) ) {
852 index = Configuration.delete_subtree_or_node;
854 else if ( name.equals( "add_new_node" ) ) {
855 index = Configuration.add_new_node;
857 else if ( name.equals( "edit_node_data" ) ) {
858 index = Configuration.edit_node_data;
860 else if ( name.equals( "select_nodes" ) ) {
861 index = Configuration.select_nodes;
863 else if ( name.equals( "display_node_popup" ) ) {
864 ForesterUtil.printWarningMessage( Constants.PRG_NAME,
865 "configuration key [display_node_popup] is deprecated" );
868 else if ( name.equals( "custom_option" ) ) {
869 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "configuration key [custom_option] is deprecated" );
872 else if ( name.equals( "color_subtree" ) ) {
873 index = Configuration.color_subtree;
878 private boolean parseBoolean( final String str ) {
879 final String my_str = str.trim().toLowerCase();
880 if ( my_str.equals( "yes" ) || my_str.equals( "true" ) ) {
883 else if ( my_str.equals( "no" ) || my_str.equals( "false" ) ) {
887 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "could not parse boolean value from [" + str + "]" );
892 private double parseDouble( final String str ) {
895 d = Double.parseDouble( str.trim() );
897 catch ( final Exception e ) {
898 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "could not parse double from [" + str + "]" );
904 private float parseFloat( final String str ) {
907 f = Float.parseFloat( str.trim() );
909 catch ( final Exception e ) {
910 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "could not parse float from [" + str + "]" );
916 private int parseInt( final String str ) {
919 i = Integer.parseInt( str.trim() );
921 catch ( final Exception e ) {
922 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "could not parse integer from [" + str + "]" );
928 private short parseShort( final String str ) {
931 i = Short.parseShort( str.trim() );
933 catch ( final Exception e ) {
934 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "could not parse short from [" + str + "]" );
940 private void processFontFamily( final StringTokenizer st ) {
941 setBaseFontFamilyName( "" );
942 final String font_str = ( ( String ) st.nextElement() ).trim();
943 final String[] fonts = font_str.split( ",+" );
944 for( String font : fonts ) {
945 font = font.replace( '_', ' ' ).trim();
946 if ( Arrays.binarySearch( AptxUtil.getAvailableFontFamiliesSorted(), font ) >= 0 ) {
947 setBaseFontFamilyName( font );
954 * read each line of config file, process non-comment lines
955 * @throws IOException
957 private void readConfig( final BufferedReader conf_in ) throws IOException {
960 line = conf_in.readLine();
961 if ( line != null ) {
963 // skip comments and blank lines
964 if ( !line.startsWith( "#" ) && ( !ForesterUtil.isEmpty( line ) ) ) {
965 // convert runs of spaces to tabs
966 line = line.replaceAll( "\\s+", "\t" );
967 final StringTokenizer st = new StringTokenizer( line, "\t" );
971 } while ( line != null );
974 private void setAntialiasScreen( final boolean antialias_screen ) {
975 _antialias_screen = antialias_screen;
978 private void setCladogramType( final CLADOGRAM_TYPE cladogram_type ) {
979 _cladogram_type = cladogram_type;
982 private void setDefaultBootstrapSamples( final int default_bootstrap_samples ) {
983 _default_bootstrap_samples = default_bootstrap_samples;
986 private void setEditable( final boolean editable ) {
987 _editable = editable;
990 private void setExtNodeDataReturnOn( final EXT_NODE_DATA_RETURN_ON ext_node_data_return_on ) {
991 _ext_node_data_return_on = ext_node_data_return_on;
994 private void setGraphicsExportX( final int graphics_export_x ) {
995 _graphics_export_x = graphics_export_x;
998 private void setGraphicsExportY( final int graphics_export_y ) {
999 _graphics_export_y = graphics_export_y;
1002 private void setInternalNumberAreConfidenceForNhParsing( final boolean internal_number_are_confidence_for_nh_parsing ) {
1003 _internal_number_are_confidence_for_nh_parsing = internal_number_are_confidence_for_nh_parsing;
1007 * Set a key-value(s) tuple
1009 private void setKeyValue( final StringTokenizer st ) {
1010 final String key = ( ( String ) st.nextElement() ).replace( ':', ' ' ).trim().toLowerCase();
1011 if ( !st.hasMoreElements() ) {
1014 // Handle single value settings first:
1015 if ( key.equals( "default_click_to" ) ) {
1016 final String clickto_name = ( String ) st.nextElement();
1017 default_clickto = getClickToIndex( clickto_name );
1018 if ( default_clickto == -1 ) {
1019 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "invalid value [" + clickto_name
1020 + "] for [default_click_to]" );
1021 default_clickto = 0;
1023 else if ( default_clickto == DEPRECATED ) {
1027 else if ( key.equals( "native_ui" ) ) {
1028 final String my_str = ( ( String ) st.nextElement() ).trim().toLowerCase();
1029 if ( my_str.equals( "yes" ) || my_str.equals( "true" ) ) {
1032 else if ( my_str.equals( "no" ) || my_str.equals( "false" ) ) {
1033 _ui = UI.CROSSPLATFORM;
1035 else if ( my_str.equals( "?" ) ) {
1039 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "could not parse yes/no/? value from [" + my_str
1044 else if ( key.equals( VALIDATE_AGAINST_PHYLOXML_XSD_SCHEMA ) ) {
1045 setValidatePhyloXmlAgainstSchema( parseBoolean( ( String ) st.nextElement() ) );
1047 else if ( key.equals( "antialias_screen" ) ) {
1048 setAntialiasScreen( parseBoolean( ( String ) st.nextElement() ) );
1050 else if ( key.equals( "phylogeny_graphics_type" ) ) {
1051 final String type_str = ( ( String ) st.nextElement() ).trim();
1052 if ( type_str.equalsIgnoreCase( PHYLOGENY_GRAPHICS_TYPE.CONVEX.toString() ) ) {
1053 setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CONVEX );
1055 else if ( type_str.equalsIgnoreCase( PHYLOGENY_GRAPHICS_TYPE.CURVED.toString() ) ) {
1056 setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CURVED );
1058 else if ( type_str.equalsIgnoreCase( PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE.toString() ) ) {
1059 setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE );
1061 else if ( type_str.equalsIgnoreCase( PHYLOGENY_GRAPHICS_TYPE.ROUNDED.toString() ) ) {
1062 setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.ROUNDED );
1064 else if ( type_str.equalsIgnoreCase( PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR.toString() ) ) {
1065 setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR );
1067 else if ( type_str.equalsIgnoreCase( PHYLOGENY_GRAPHICS_TYPE.TRIANGULAR.toString() ) ) {
1068 setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.TRIANGULAR );
1070 else if ( type_str.equalsIgnoreCase( PHYLOGENY_GRAPHICS_TYPE.UNROOTED.toString() ) ) {
1071 setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.UNROOTED );
1073 else if ( type_str.equalsIgnoreCase( PHYLOGENY_GRAPHICS_TYPE.CIRCULAR.toString() ) ) {
1074 setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CIRCULAR );
1077 setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR );
1078 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown value [" + type_str
1079 + "] for [phylogeny_graphics_type]" );
1082 else if ( key.equals( "min_confidence_value" ) ) {
1083 final String mcv_str = ( ( String ) st.nextElement() ).trim();
1084 final double d = parseDouble( mcv_str );
1085 setMinConfidenceValue( d );
1087 else if ( key.equals( "font_family" ) ) {
1088 processFontFamily( st );
1090 else if ( key.equals( "font_size" ) ) {
1091 final String size_str = ( ( String ) st.nextElement() ).trim();
1092 final int i = parseInt( size_str );
1094 setBaseFontSize( i );
1097 else if ( key.equals( "font_size_min" ) ) {
1098 final String size_str = ( ( String ) st.nextElement() ).trim();
1099 final int i = parseInt( size_str );
1101 setMinBaseFontSize( i );
1104 else if ( key.equals( "font_size_max" ) ) {
1105 final String size_str = ( ( String ) st.nextElement() ).trim();
1106 final int i = parseInt( size_str );
1108 setMaxBaseFontSize( i );
1111 else if ( key.equals( "graphics_export_x" ) ) {
1112 final String str = ( ( String ) st.nextElement() ).trim();
1113 final int i = parseInt( str );
1115 setGraphicsExportX( i );
1118 else if ( key.equals( "graphics_export_y" ) ) {
1119 final String str = ( ( String ) st.nextElement() ).trim();
1120 final int i = parseInt( str );
1122 setGraphicsExportY( i );
1125 else if ( key.equals( "pdf_export_line_width" ) ) {
1126 final String str = ( ( String ) st.nextElement() ).trim();
1127 final float f = parseFloat( str );
1129 setPrintLineWidth( f );
1132 ForesterUtil.printWarningMessage( Constants.PRG_NAME,
1133 "value for [pdf_export_line_width] cannot be zero or negative" );
1136 else if ( key.equals( "window_initial_size_x" ) ) {
1137 final String str = ( ( String ) st.nextElement() ).trim();
1138 final int i = parseInt( str );
1143 else if ( key.equals( "window_initial_size_y" ) ) {
1144 final String str = ( ( String ) st.nextElement() ).trim();
1145 final int i = parseInt( str );
1150 else if ( key.equals( "default_number_of_bootstrap_resamples" ) ) {
1151 final String str = ( ( String ) st.nextElement() ).trim();
1152 final int i = parseInt( str );
1154 setDefaultBootstrapSamples( i );
1158 .printWarningMessage( Constants.PRG_NAME,
1159 "value for [default_number_of_bootstrap_resamples] cannot be negative" );
1162 else if ( key.equals( "mafft_local" ) ) {
1163 final String str = ( ( String ) st.nextElement() ).trim();
1164 if ( !ForesterUtil.isEmpty( str ) ) {
1165 setPathToLocalMafft( new File( str ) );
1168 else if ( key.equals( "fastme_local" ) ) {
1169 final String str = ( ( String ) st.nextElement() ).trim();
1170 if ( !ForesterUtil.isEmpty( str ) ) {
1171 setPathToLocalFastme( new File( str ) );
1174 else if ( key.equals( "raxml_local" ) ) {
1175 final String str = ( ( String ) st.nextElement() ).trim();
1176 if ( !ForesterUtil.isEmpty( str ) ) {
1177 setPathToLocalRaxml( new File( str ) );
1180 else if ( key.equals( "show_scale" ) ) {
1181 setShowScale( parseBoolean( ( String ) st.nextElement() ) );
1183 else if ( key.equals( "show_overview" ) ) {
1184 setShowOverview( parseBoolean( ( String ) st.nextElement() ) );
1186 else if ( key.equals( "show_branch_length_values" ) ) {
1187 setShowBranchLengthValues( parseBoolean( ( String ) st.nextElement() ) );
1189 else if ( key.equals( "background_gradient" ) ) {
1190 setBackgroundColorGradient( parseBoolean( ( String ) st.nextElement() ) );
1192 else if ( key.equals( "color_labels_same_as_branch_length_values" ) ) {
1193 setColorLabelsSameAsParentBranch( parseBoolean( ( String ) st.nextElement() ) );
1195 else if ( key.equals( "show_domain_labels" ) ) {
1196 setShowDomainLabels( parseBoolean( ( String ) st.nextElement() ) );
1198 else if ( key.equals( "show_seq_annotation_ref_sources" ) ) {
1199 setShowAnnotationRefSource( parseBoolean( ( String ) st.nextElement() ) );
1201 else if ( key.equals( "abbreviate_scientific_names" ) ) {
1202 setAbbreviateScientificTaxonNames( parseBoolean( ( String ) st.nextElement() ) );
1204 else if ( key.equals( "cladogram_type" ) ) {
1205 final String type_str = ( ( String ) st.nextElement() ).trim();
1206 if ( type_str.equalsIgnoreCase( Options.CLADOGRAM_TYPE.NON_LINED_UP.toString() ) ) {
1207 setCladogramType( Options.CLADOGRAM_TYPE.NON_LINED_UP );
1209 else if ( type_str.equalsIgnoreCase( Options.CLADOGRAM_TYPE.EXT_NODE_SUM_DEP.toString() ) ) {
1210 setCladogramType( Options.CLADOGRAM_TYPE.EXT_NODE_SUM_DEP );
1212 else if ( type_str.equalsIgnoreCase( Options.CLADOGRAM_TYPE.TOTAL_NODE_SUM_DEP.toString() ) ) {
1213 setCladogramType( Options.CLADOGRAM_TYPE.TOTAL_NODE_SUM_DEP );
1216 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown value [" + type_str
1217 + "] for [cladogram_type]" );
1220 else if ( key.equals( "non_lined_up_cladogram" ) ) {
1222 .printWarningMessage( Constants.PRG_NAME,
1223 "configuration key [non_lined_up_cladogram] is deprecated, use [cladogram_type] instead" );
1225 else if ( key.equals( "hide_controls_and_menus" ) ) {
1226 _hide_controls_and_menus = parseBoolean( ( String ) st.nextElement() );
1228 else if ( key.equals( "use_tabbed_display" ) ) {
1229 _use_tabbed_display = parseBoolean( ( String ) st.nextElement() );
1231 else if ( key.equals( "overview_width" ) ) {
1232 final short i = parseShort( ( ( String ) st.nextElement() ) );
1235 else if ( key.equals( "overview_height" ) ) {
1236 final short i = parseShort( ( ( String ) st.nextElement() ) );
1237 setOvMaxHeight( i );
1239 else if ( key.equals( "overview_placement_type" ) ) {
1240 final String type_str = ( ( String ) st.nextElement() ).trim();
1241 if ( type_str.equalsIgnoreCase( OVERVIEW_PLACEMENT_TYPE.UPPER_LEFT.toTag() ) ) {
1242 setOvPlacement( OVERVIEW_PLACEMENT_TYPE.UPPER_LEFT );
1244 else if ( type_str.equalsIgnoreCase( OVERVIEW_PLACEMENT_TYPE.UPPER_RIGHT.toTag() ) ) {
1245 setOvPlacement( OVERVIEW_PLACEMENT_TYPE.UPPER_RIGHT );
1247 else if ( type_str.equalsIgnoreCase( OVERVIEW_PLACEMENT_TYPE.LOWER_LEFT.toTag() ) ) {
1248 setOvPlacement( OVERVIEW_PLACEMENT_TYPE.LOWER_LEFT );
1250 else if ( type_str.equalsIgnoreCase( OVERVIEW_PLACEMENT_TYPE.LOWER_RIGHT.toTag() ) ) {
1251 setOvPlacement( OVERVIEW_PLACEMENT_TYPE.LOWER_RIGHT );
1254 setOvPlacement( OVERVIEW_PLACEMENT_TYPE.UPPER_LEFT );
1255 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown value [" + type_str
1256 + "] for [overview_placement_type]" );
1259 else if ( key.equals( "node_label_direction" ) ) {
1260 final String type_str = ( ( String ) st.nextElement() ).trim();
1261 if ( type_str.equalsIgnoreCase( NODE_LABEL_DIRECTION.HORIZONTAL.toString() ) ) {
1262 setNodeLabelDirection( NODE_LABEL_DIRECTION.HORIZONTAL );
1264 else if ( type_str.equalsIgnoreCase( NODE_LABEL_DIRECTION.RADIAL.toString() ) ) {
1265 setNodeLabelDirection( NODE_LABEL_DIRECTION.RADIAL );
1268 setNodeLabelDirection( NODE_LABEL_DIRECTION.HORIZONTAL );
1269 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown value [" + type_str
1270 + "] for [node_label_direction]" );
1273 else if ( key.equals( "branch_length_value_digits" ) ) {
1274 final short i = parseShort( ( ( String ) st.nextElement() ).trim() );
1276 setNumberOfDigitsAfterCommaForBranchLengthValue( i );
1279 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "illegal value [" + i
1280 + "] for [branch_length_value_digits]" );
1283 else if ( key.equals( "confidence_value_digits" ) ) {
1284 final short i = parseShort( ( ( String ) st.nextElement() ).trim() );
1286 setNumberOfDigitsAfterCommaForConfidenceValues( i );
1289 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "illegal value [" + i
1290 + "] for [confidence_value_digits]" );
1293 else if ( key.equals( "allow_editing" ) ) {
1294 setEditable( parseBoolean( ( String ) st.nextElement() ) );
1296 else if ( key.equals( "display_sequence_relations" ) ) {
1297 setDisplaySequenceRelations( parseBoolean( ( String ) st.nextElement() ) );
1299 else if ( key.equals( "replace_underscores_in_nh_parsing" ) ) {
1300 final boolean r = parseBoolean( ( String ) st.nextElement() );
1301 if ( r && ( getTaxonomyExtraction() != TAXONOMY_EXTRACTION.NO ) ) {
1303 .printWarningMessage( Constants.PRG_NAME,
1304 "attempt to extract taxonomies and replace underscores at the same time" );
1307 setReplaceUnderscoresInNhParsing( r );
1310 else if ( key.equals( "taxonomy_extraction_in_nh_parsing" ) ) {
1311 final String s = ( String ) st.nextElement();
1312 if ( s.equalsIgnoreCase( "no" ) ) {
1313 setTaxonomyExtraction( TAXONOMY_EXTRACTION.NO );
1315 else if ( s.equalsIgnoreCase( "pfam_relaxed" ) ) {
1316 setTaxonomyExtraction( TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
1318 else if ( s.equalsIgnoreCase( "pfam_strict" ) ) {
1319 setTaxonomyExtraction( TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1321 else if ( s.equalsIgnoreCase( "aggressive" ) ) {
1322 setTaxonomyExtraction( TAXONOMY_EXTRACTION.AGGRESSIVE );
1326 .printWarningMessage( Constants.PRG_NAME,
1327 "unknown value for \"taxonomy_extraction_in_nh_parsing\": "
1329 + " (must be either: no, pfam_relaxed, pfam_strict, or aggressive)" );
1331 if ( ( getTaxonomyExtraction() != TAXONOMY_EXTRACTION.NO ) && isReplaceUnderscoresInNhParsing() ) {
1333 .printWarningMessage( Constants.PRG_NAME,
1334 "attempt to extract taxonomies and replace underscores at the same time" );
1337 else if ( key.equals( "internal_labels_are_confidence_values" ) ) {
1338 setInternalNumberAreConfidenceForNhParsing( parseBoolean( ( String ) st.nextElement() ) );
1340 else if ( key.equals( "gui_background_color" ) ) {
1341 _gui_background_color = Color.decode( ( String ) st.nextElement() );
1343 else if ( key.equals( "gui_checkbox_text_color" ) ) {
1344 _gui_checkbox_text_color = Color.decode( ( String ) st.nextElement() );
1346 else if ( key.equals( "gui_checkbox_and_button_active_color" ) ) {
1347 _gui_checkbox_and_button_active_color = Color.decode( ( String ) st.nextElement() );
1349 else if ( key.equals( "gui_button_text_color" ) ) {
1350 _gui_button_text_color = Color.decode( ( String ) st.nextElement() );
1352 else if ( key.equals( "gui_button_background_color" ) ) {
1353 _gui_button_background_color = Color.decode( ( String ) st.nextElement() );
1355 else if ( key.equals( "gui_menu_background_color" ) ) {
1356 _gui_menu_background_color = Color.decode( ( String ) st.nextElement() );
1358 else if ( key.equals( "gui_menu_text_color" ) ) {
1359 _gui_menu_text_color = Color.decode( ( String ) st.nextElement() );
1361 else if ( key.equals( "gui_button_border_color" ) ) {
1362 _gui_button_border_color = Color.decode( ( String ) st.nextElement() );
1364 else if ( key.equals( "domain_structure_font_color" ) ) {
1365 _domain_structure_font_color = Color.decode( ( String ) st.nextElement() );
1367 else if ( key.equals( "domain_structure_base_color" ) ) {
1368 _domain_structure_base_color = Color.decode( ( String ) st.nextElement() );
1370 else if ( key.equals( "show_default_node_shapes" ) ) {
1372 .printWarningMessage( Constants.PRG_NAME,
1373 "configuration key [show_default_node_shapes] is deprecated, use [show_default_node_shapes_internal] and [show_default_node_shapes_external] instead" );
1374 final boolean b = parseBoolean( ( ( String ) st.nextElement() ).trim() );
1375 setShowDefaultNodeShapesInternal( b );
1376 setShowDefaultNodeShapesExternal( b );
1378 else if ( key.equals( "show_default_node_shapes_internal" ) ) {
1379 setShowDefaultNodeShapesInternal( parseBoolean( ( ( String ) st.nextElement() ).trim() ) );
1381 else if ( key.equals( "show_default_node_shapes_external" ) ) {
1382 setShowDefaultNodeShapesExternal( parseBoolean( ( ( String ) st.nextElement() ).trim() ) );
1384 else if ( key.equals( "default_node_size" ) ) {
1385 final short i = parseShort( ( ( String ) st.nextElement() ).trim() );
1386 setDefaultNodeShapeSize( i );
1388 else if ( key.equals( "default_node_fill" ) ) {
1389 final String fill_str = ( ( String ) st.nextElement() ).trim();
1390 if ( fill_str.equalsIgnoreCase( NodeVisualization.NodeFill.NONE.toString() ) ) {
1391 setDefaultNodeFill( NodeFill.NONE );
1393 else if ( fill_str.equalsIgnoreCase( NodeVisualization.NodeFill.GRADIENT.toString() ) ) {
1394 setDefaultNodeFill( NodeFill.GRADIENT );
1396 else if ( fill_str.equalsIgnoreCase( NodeVisualization.NodeFill.SOLID.toString() ) ) {
1397 setDefaultNodeFill( NodeFill.SOLID );
1400 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown value [" + fill_str
1401 + "] for [default_node_fill]" );
1404 else if ( key.equals( "default_node_shape" ) ) {
1405 final String shape_str = ( ( String ) st.nextElement() ).trim();
1406 if ( shape_str.equalsIgnoreCase( NodeVisualization.NodeShape.CIRCLE.toString() ) ) {
1407 setDefaultNodeShape( NodeShape.CIRCLE );
1409 else if ( shape_str.equalsIgnoreCase( NodeVisualization.NodeShape.RECTANGLE.toString() ) ) {
1410 setDefaultNodeShape( NodeShape.RECTANGLE );
1413 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown value [" + shape_str
1414 + "] for [default_node_shape]" );
1417 else if ( key.equals( "taxonomy_colorize_node_shapes" ) ) {
1418 setTaxonomyColorizeNodeShapes( parseBoolean( ( String ) st.nextElement() ) );
1420 else if ( key.equals( "midpoint_reroot" ) ) {
1421 setMidpointReroot( parseBoolean( ( String ) st.nextElement() ) );
1423 else if ( key.equals( "ext_descendents_data_to_return" ) ) {
1424 final String s = ( ( String ) st.nextElement() ).trim();
1425 if ( s.equalsIgnoreCase( "node_name" ) ) {
1426 setExtDescNodeDataToReturn( NODE_DATA.NODE_NAME );
1428 else if ( s.equalsIgnoreCase( "sequence_acc" ) ) {
1429 setExtDescNodeDataToReturn( NODE_DATA.SEQUENCE_ACC );
1431 else if ( s.equalsIgnoreCase( "sequence_mol_seq_fasta" ) ) {
1432 setExtDescNodeDataToReturn( NODE_DATA.SEQUENCE_MOL_SEQ_FASTA );
1434 else if ( s.equalsIgnoreCase( "sequence_mol_seq" ) ) {
1435 setExtDescNodeDataToReturn( NODE_DATA.SEQUENCE_MOL_SEQ );
1437 else if ( s.equalsIgnoreCase( "sequence_name" ) ) {
1438 setExtDescNodeDataToReturn( NODE_DATA.SEQUENCE_NAME );
1440 else if ( s.equalsIgnoreCase( "sequence_symbol" ) ) {
1441 setExtDescNodeDataToReturn( NODE_DATA.SEQUENCE_SYMBOL );
1443 else if ( s.equalsIgnoreCase( "taxonomy_scientific_name" ) ) {
1444 setExtDescNodeDataToReturn( NODE_DATA.TAXONOMY_SCIENTIFIC_NAME );
1446 else if ( s.equalsIgnoreCase( "taxonomy_code" ) ) {
1447 setExtDescNodeDataToReturn( NODE_DATA.TAXONOMY_CODE );
1449 else if ( s.equalsIgnoreCase( "taxonomy_common_name" ) ) {
1450 setExtDescNodeDataToReturn( NODE_DATA.TAXONOMY_COMM0N_NAME );
1452 else if ( s.equalsIgnoreCase( "user_selected" ) ) {
1453 setExtDescNodeDataToReturn( NODE_DATA.UNKNOWN );
1456 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown value [" + s
1457 + "] for [ext_descendents_data_to_return]" );
1460 else if ( key.equals( "label_for_get_ext_descendents_data" ) ) {
1461 final String s = ( ( String ) st.nextElement() ).trim();
1462 if ( ForesterUtil.isEmpty( s ) || ( s.length() < 2 ) ) {
1463 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "illegal value [" + s
1464 + "] for [label_for_get_ext_descendents_data]" );
1467 setLabelForGetExtDescendentsData( s.replaceAll( "_", " " ) );
1470 else if ( key.equals( "ext_descendents_data_to_return_on" ) ) {
1471 final String s = ( ( String ) st.nextElement() ).trim().toLowerCase();
1472 if ( s.equals( "console" ) ) {
1473 setExtNodeDataReturnOn( EXT_NODE_DATA_RETURN_ON.CONSOLE );
1475 else if ( s.equals( "window" ) ) {
1476 setExtNodeDataReturnOn( EXT_NODE_DATA_RETURN_ON.WINODW );
1478 else if ( s.equals( "buffer_only" ) ) {
1479 setExtNodeDataReturnOn( EXT_NODE_DATA_RETURN_ON.BUFFER_ONLY );
1482 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown value [" + s
1483 + "] for [ext_descendents_data_to_return_on]" );
1486 else if ( st.countTokens() >= 2 ) { // counts the tokens that are not
1489 if ( key.equals( "use_real_br_lengths" ) || key.equals( "phylogram" ) ) {
1490 key_index = Configuration.display_as_phylogram;
1491 if ( key.equals( "use_real_br_lengths" ) ) {
1493 .printWarningMessage( Constants.PRG_NAME,
1494 "configuration key [use_real_br_lengths] is deprecated, use [phylogram] instead" );
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" ) || key.equals( "show_taxonomy_code" ) ) {
1507 key_index = Configuration.show_tax_code;
1508 if ( key.equals( "show_taxonomy" ) ) {
1510 .printWarningMessage( Constants.PRG_NAME,
1511 "configuration key [show_taxonomy] is deprecated, use [show_taxonomy_code] instead" );
1514 else if ( key.equals( "write_br_length_values" ) ) {
1515 ForesterUtil.printWarningMessage( Constants.PRG_NAME,
1516 "configuration key [write_br_length_values] is deprecated" );
1517 key_index = DEPRECATED;
1519 else if ( key.equals( "write_bootstrap_values" ) || key.equals( "write_confidence_values" ) ) {
1520 key_index = Configuration.write_confidence_values;
1521 if ( key.equals( "write_bootstrap_values" ) ) {
1523 .printWarningMessage( Constants.PRG_NAME,
1524 "configuration key [write_bootstrap_values] is deprecated, use [write_confidence_values] instead" );
1527 else if ( key.equals( "write_events" ) || key.equals( "write_dup_spec" ) ) {
1528 key_index = Configuration.write_events;
1529 if ( key.equals( "write_dup_spec" ) ) {
1531 .printWarningMessage( Constants.PRG_NAME,
1532 "configuration key [write_dup_spec] is deprecated, use [write_events] instead" );
1535 else if ( key.equals( "color_branches" ) ) {
1536 key_index = Configuration.color_branches;
1538 else if ( key.equals( "width_branches" ) ) {
1539 key_index = Configuration.width_branches;
1541 else if ( key.equals( "mark_nodes_with_box" ) ) {
1542 ForesterUtil.printWarningMessage( Constants.PRG_NAME,
1543 "configuration key [mark_nodes_with_box] is deprecated" );
1544 key_index = DEPRECATED;
1546 else if ( key.equals( "show_domain_architectures" ) ) {
1547 key_index = Configuration.show_domain_architectures;
1549 else if ( key.equals( "show_annotations" ) ) {
1550 key_index = Configuration.show_annotation;
1552 else if ( key.equals( "show_binary_characters" ) ) {
1553 key_index = Configuration.show_binary_characters;
1555 else if ( key.equals( "show_binary_character_counts" ) ) {
1556 key_index = Configuration.show_binary_character_counts;
1558 else if ( key.equals( "show_gene_names" ) ) {
1559 key_index = Configuration.show_gene_names;
1561 else if ( key.equals( "show_gene_symbols" ) ) {
1562 key_index = Configuration.show_gene_symbols;
1564 else if ( key.equals( "show_sequence_acc" ) ) {
1565 key_index = Configuration.show_sequence_acc;
1567 else if ( key.equals( "show_node_ids" ) ) {
1569 .printWarningMessage( Constants.PRG_NAME, "configuration key [show_node_ids] is deprecated" );
1570 key_index = DEPRECATED;
1572 else if ( key.equals( "display_internal_data" ) ) {
1573 key_index = Configuration.display_internal_data;
1575 else if ( key.equals( "dynamically_hide_data" ) ) {
1576 key_index = Configuration.dynamically_hide_data;
1578 else if ( key.equals( "show_taxonomy_names" ) ) {
1579 ForesterUtil.printWarningMessage( Constants.PRG_NAME,
1580 "configuration key [show_taxonomy_names] is deprecated" );
1581 key_index = DEPRECATED;
1583 else if ( key.equals( "show_taxonomy_scientific_names" ) ) {
1584 key_index = Configuration.show_taxonomy_scientific_names;
1586 else if ( key.equals( "show_taxonomy_common_names" ) ) {
1587 key_index = Configuration.show_taxonomy_common_names;
1589 else if ( key.equals( "show_taxonomy_images" ) ) {
1590 key_index = Configuration.show_taxonomy_images;
1592 else if ( key.equals( "color_according_to_annotation" ) ) {
1593 key_index = Configuration.color_according_to_annotation;
1595 else if ( key.equals( "show_vector_data" ) ) {
1596 key_index = Configuration.show_vector_data;
1598 else if ( key.equals( "show_properties" ) ) {
1599 key_index = Configuration.show_properties;
1601 else if ( key.equals( "show_relation_confidence" ) ) {
1602 key_index = Configuration.show_relation_confidence;
1604 else if ( key.equals( "show_custom_node_shapes" ) ) {
1605 key_index = Configuration.show_custom_node_shapes;
1607 // If we've found the key, set the values
1608 if ( key_index >= 0 ) {
1609 display_options[ key_index ][ 1 ] = ( String ) st.nextElement();
1610 display_options[ key_index ][ 2 ] = ( String ) st.nextElement();
1611 // otherwise, keep looking
1614 if ( key_index == DEPRECATED ) {
1617 else if ( key.equals( "click_to" ) ) {
1618 final String click_to_name = ( String ) st.nextElement();
1619 key_index = getClickToIndex( click_to_name );
1620 if ( key_index >= 0 ) {
1621 clickto_options[ key_index ][ 1 ] = ( String ) st.nextElement();
1623 else if ( key_index == DEPRECATED ) {
1627 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown click-to option: "
1631 else if ( key.equals( "species_color" ) ) {
1632 getSpeciesColors().put( ( ( String ) st.nextElement() ).replace( '_', ' ' ),
1633 Color.decode( ( String ) st.nextElement() ) );
1635 else if ( key.equals( "domain_color" ) ) {
1636 getDomainColors().put( ( String ) st.nextElement(), Color.decode( ( String ) st.nextElement() ) );
1638 else if ( key.equals( "annotation_color" ) ) {
1639 getAnnotationColors()
1640 .put( ( String ) st.nextElement(), Color.decode( ( String ) st.nextElement() ) );
1642 else if ( key.equals( "function_color" ) ) {
1643 ForesterUtil.printWarningMessage( Constants.PRG_NAME,
1644 "configuration key [function_color] is deprecated" );
1646 else if ( key.equals( DISPLAY_COLOR_KEY ) ) {
1647 putDisplayColors( ( String ) st.nextElement(), Color.decode( ( String ) st.nextElement() ) );
1650 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown configuration key [" + key
1651 + "] in: " + config_filename );
1656 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown configuration key [" + key + "] in: "
1657 + config_filename );
1661 private void setShowAnnotationRefSource( final boolean b ) {
1662 _show_annotation_ref_source = b;
1665 private void setLabelForGetExtDescendentsData( final String label_for_get_ext_descendents_data ) {
1666 _label_for_get_ext_descendents_data = label_for_get_ext_descendents_data;
1669 private void setOvMaxHeight( final short ov_max_height ) {
1670 _ov_max_height = ov_max_height;
1673 private void setOvMaxWidth( final short ov_max_width ) {
1674 _ov_max_width = ov_max_width;
1677 private void setOvPlacement( final OVERVIEW_PLACEMENT_TYPE ov_placement ) {
1678 _ov_placement = ov_placement;
1681 private void setPathToLocalFastme( final File path_to_local_fastme ) {
1682 _path_to_local_fastme = path_to_local_fastme;
1685 private void setPathToLocalMafft( final File path_to_local_mafft ) {
1686 _path_to_local_mafft = path_to_local_mafft;
1689 private void setPathToLocalRaxml( final File path_to_local_raxml ) {
1690 _path_to_local_raxml = path_to_local_raxml;
1693 private void setShowOverview( final boolean show_overview ) {
1694 _show_overview = show_overview;
1697 private void setValidatePhyloXmlAgainstSchema( final boolean validate_against_phyloxml_xsd_schema ) {
1698 _validate_against_phyloxml_xsd_schema = validate_against_phyloxml_xsd_schema;
1701 static String getDefaultFontFamilyName() {
1702 return DEFAULT_FONT_FAMILY;
1705 public enum EXT_NODE_DATA_RETURN_ON {
1706 CONSOLE, WINODW, BUFFER_ONLY;
1710 NATIVE, CROSSPLATFORM, NIMBUS, UNKNOWN
1713 static enum TRIPLET {
1714 TRUE, FALSE, UNKNOWN
1717 public boolean isMidpointReroot() {
1718 return _midpoint_root;
1721 public void setMidpointReroot( final boolean midpoint_root ) {
1722 _midpoint_root = midpoint_root;
1725 public boolean isShowAnnotationRefSource() {
1726 return _show_annotation_ref_source;