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