2 // FORESTER -- software libraries and applications
3 // for evolutionary biology research and applications.
5 // Copyright (C) 2008-2009 Christian M. Zmasek
6 // Copyright (C) 2008-2009 Burnham Institute for Medical Research
7 // Copyright (C) 2000-2001 Washington University School of Medicine
8 // and Howard Hughes Medical Institute
9 // Copyright (C) 2003-2007 Ethalinda K.S. Cannon
10 // All rights reserved
12 // This library is free software; you can redistribute it and/or
13 // modify it under the terms of the GNU Lesser General Public
14 // License as published by the Free Software Foundation; either
15 // version 2.1 of the License, or (at your option) any later version.
17 // This library is distributed in the hope that it will be useful,
18 // but WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 // Lesser General Public License for more details.
22 // You should have received a copy of the GNU Lesser General Public
23 // License along with this library; if not, write to the Free Software
24 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
26 // Contact: phylosoft @ gmail . com
27 // WWW: https://sites.google.com/site/cmzmasek/home/software/forester
29 package org.forester.archaeopteryx;
31 import java.awt.Color;
32 import java.io.BufferedReader;
34 import java.io.FileReader;
35 import java.io.IOException;
36 import java.io.InputStreamReader;
38 import java.util.Arrays;
39 import java.util.Hashtable;
41 import java.util.SortedMap;
42 import java.util.StringTokenizer;
43 import java.util.TreeMap;
45 import org.forester.archaeopteryx.Options.CLADOGRAM_TYPE;
46 import org.forester.archaeopteryx.Options.NODE_LABEL_DIRECTION;
47 import org.forester.archaeopteryx.Options.OVERVIEW_PLACEMENT_TYPE;
48 import org.forester.archaeopteryx.Options.PHYLOGENY_GRAPHICS_TYPE;
49 import org.forester.io.parsers.nhx.NHXParser.TAXONOMY_EXTRACTION;
50 import org.forester.phylogeny.data.NodeData.NODE_DATA;
51 import org.forester.phylogeny.data.NodeVisualData;
52 import org.forester.phylogeny.data.NodeVisualData.NodeFill;
53 import org.forester.phylogeny.data.NodeVisualData.NodeShape;
54 import org.forester.util.ForesterUtil;
56 public final class Configuration {
58 final static String clickto_options[][] = {
59 { "Display Node Data", "display" }, { "Collapse/Uncollapse", "display" }, { "Root/Reroot", "display" },
60 { "Go to Sub-/Super-Tree", "display" }, { "Swap Descendants", "display" },
61 { "Colorize Node(s)", "display" }, { "Change Node Font(s)", "display" },
62 { "Colorize Subtree(s)", "display" }, { "Open Sequence DB", "display" }, { "Open PDB", "display" },
63 { "Open Taxonomy DB", "display" }, { "Launch BLAST", "display" }, { "Cut Subtree", "display" },
64 { "Copy Subtree", "display" }, { "Paste Subtree", "display" }, { "Delete Subtree/Node", "display" },
65 { "Add New Node", "display" }, { "Edit Node Data", "display" }, { "Sort Descendants", "display" },
66 { "Return", "display" }, { "Select Node(s)", "display" } };
67 final static int display_node_data = 0;
68 final static int collapse_uncollapse = 1;
69 final static int reroot = 2;
70 final static int subtree = 3;
71 final static int swap = 4;
72 final static int color_node_font = 5;
73 final static int change_node_font = 6;
74 final static int color_subtree = 7;
75 final static int open_seq_web = 8;
76 final static int open_pdb_web = 9;
77 final static int open_tax_web = 10;
78 final static int blast = 11;
79 final static int cut_subtree = 12;
80 final static int copy_subtree = 13;
81 final static int paste_subtree = 14;
82 final static int delete_subtree_or_node = 15;
83 final static int add_new_node = 16;
84 final static int edit_node_data = 17;
85 final static int sort_descendents = 18;
86 final static int get_ext_desc_data = 19;
87 final static int select_nodes = 20;
91 final static String display_options[][] = {
92 { "Phylogram", "display", "?" }, { "Node Name", "display", "yes" }, { "Taxonomy Code", "display", "yes" },
93 { "Seq Annotations", "display", "no" }, { "Confidence Values", "display", "?" },
94 { "Node Events", "display", "?" }, { "Colorize by Taxonomy", "display", "no" },
95 { "Colorize by Sequence", "display", "no" }, { "Visual Styles/Branch Colors", "display", "no" },
96 { "Branch Widths", "display", "no" }, { "Protein Domains", "display", "no" },
97 { "Binary Characters", "nodisplay", "no" }, { "Binary Char Counts", "nodisplay", "no" },
98 { "Seq Name", "display", "yes" }, { "Seq Accession", "display", "no" },
99 { "Show Internal Data", "display", "yes" }, { "Dyna Hide", "display", "yes" },
100 { "Taxonomy Scientific", "display", "yes" }, { "Taxonomy Common", "display", "no" },
101 { "Colorize by Annotation", "display", "no" }, { "Seq Symbol", "display", "yes" },
102 { "Rollover", "display", "yes" }, { "Relation Confidence", "nodisplay", "no" },
103 { "Vector Data", "nodisplay", "no" }, { "Taxonomy Images", "display", "no" },
104 { "Properties", "display", "no" }, { "Gene Name", "display", "yes" } };
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_according_to_sequence = 7;
113 final static int use_style = 8;
114 final static int width_branches = 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 static final String VALIDATE_AGAINST_PHYLOXML_XSD_SCHEMA = "validate_against_phyloxml_xsd_schema";
133 private static Hashtable<String, Color> _sequence_colors;
134 private static Hashtable<String, Color> _annotation_colors;
135 private static Hashtable<String, Color> _domain_colors;
136 private static Hashtable<String, Color> _species_colors;
137 private static String DEFAULT_FONT_FAMILY = "";
138 private static final int DEPRECATED = -2;
139 private static final String DISPLAY_COLOR_KEY = "display_color";
140 // ---------------------------
141 // Display options for trees
142 // ---------------------------
143 // ---------------------------------
144 // Pertaining to the config itself
145 // ---------------------------------
146 // Full path to config (may be URL)
147 String config_filename;
148 // This option is selected in the dropdown
149 int default_clickto = Configuration.display_node_data;
150 String default_config_filename = Constants.DEFAULT_CONFIGURATION_FILE_NAME;
154 TreeColorSet tree_color_set;
158 TreeFontSet tree_font_set;
159 boolean verbose = Constants.VERBOSE_DEFAULT;
160 private boolean _abbreviate_scientific_names = false;
161 private boolean _antialias_screen = true;
162 private boolean _background_color_gradient = false;
163 private String _base_font_family_name = "";
164 private int _base_font_size = -1;
165 private CLADOGRAM_TYPE _cladogram_type = Constants.CLADOGRAM_TYPE_DEFAULT;
166 private boolean _color_labels_same_as_parent_branch = false;
167 private int _default_bootstrap_samples = -1;
168 private NodeFill _default_node_fill = NodeFill.SOLID;
169 private NodeShape _default_node_shape = NodeShape.RECTANGLE;
170 private short _default_node_shape_size = Constants.DEFAULT_NODE_SHAPE_SIZE_DEFAULT;
171 private SortedMap<String, Color> _display_colors = null;
172 private boolean _display_sequence_relations = false;
173 private boolean _editable = true;
174 private NODE_DATA _ext_desc_data_to_return = NODE_DATA.UNKNOWN;
175 private EXT_NODE_DATA_RETURN_ON _ext_node_data_return_on = EXT_NODE_DATA_RETURN_ON.WINODW;
176 private int _frame_x_size;
177 private int _frame_y_size;
178 private int _graphics_export_x = -1;
179 private int _graphics_export_y = -1;
180 private Color _gui_background_color = Constants.GUI_BACKGROUND_DEFAULT;
181 private Color _gui_button_background_color = Constants.BUTTON_BACKGROUND_COLOR_DEFAULT;
182 private Color _gui_button_border_color = Constants.BUTTON_BORDER_COLOR_DEFAULT;
183 private Color _gui_button_text_color = Constants.BUTTON_TEXT_COLOR_DEFAULT;
184 private Color _gui_checkbox_and_button_active_color = Constants.CHECKBOX_AND_BUTTON_ACTIVE_COLOR_DEFAULT;
185 private Color _gui_checkbox_text_color = Constants.CHECKBOX_TEXT_COLOR_DEFAULT;
186 private Color _gui_menu_background_color = Constants.MENU_BACKGROUND_COLOR_DEFAULT;
187 private Color _gui_menu_text_color = Constants.MENU_TEXT_COLOR_DEFAULT;
188 private boolean _hide_controls_and_menus = false;
189 private boolean _internal_number_are_confidence_for_nh_parsing = false;
190 private String _label_for_get_ext_descendents_data = "";
191 private int _max_base_font_size = 20;
192 private boolean _midpoint_root = false;
193 private int _min_base_font_size = 2;
194 private double _min_confidence_value = Options.MIN_CONFIDENCE_DEFAULT;
195 private boolean _nh_parsing_replace_underscores = false;
196 private NODE_LABEL_DIRECTION _node_label_direction = NODE_LABEL_DIRECTION.HORIZONTAL;
197 private short _number_of_digits_after_comma_for_branch_length_values = Constants.NUMBER_OF_DIGITS_AFTER_COMMA_FOR_BRANCH_LENGTH_VALUES_DEFAULT;
198 private short _number_of_digits_after_comma_for_confidence_values = Constants.NUMBER_OF_DIGITS_AFTER_COMMA_FOR_CONFIDENCE_VALUES_DEFAULT;
199 private short _ov_max_height = 80;
200 private short _ov_max_width = 80;
201 private OVERVIEW_PLACEMENT_TYPE _ov_placement = OVERVIEW_PLACEMENT_TYPE.UPPER_LEFT;
202 private File _path_to_local_fastme = null;
203 private File _path_to_local_mafft = null;
204 private File _path_to_local_raxml = null;
205 private PHYLOGENY_GRAPHICS_TYPE _phylogeny_graphics_type = PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR;
206 private float _print_line_width = Constants.PDF_LINE_WIDTH_DEFAULT;
207 private boolean _show_annotation_ref_source = true;
208 private boolean _show_branch_length_values = false;
209 private boolean _show_default_node_shapes_external = false;
210 private boolean _show_default_node_shapes_internal = false;
211 private boolean _show_domain_labels = true;
212 private boolean _show_overview = true;
213 private boolean _show_scale = false;
214 private TAXONOMY_EXTRACTION _taxonomy_extraction = TAXONOMY_EXTRACTION.NO;
215 private UI _ui = UI.UNKNOWN;
216 private boolean _use_tabbed_display = false;
217 private boolean _validate_against_phyloxml_xsd_schema = Constants.VALIDATE_AGAINST_PHYLOXML_XSD_SCJEMA_DEFAULT;
218 private Color _vector_data_min_color = Color.BLUE;
219 private Color _vector_data_max_color = Color.YELLOW;
220 private Color _vector_data_mean_color = Color.WHITE;
221 private double _vector_data_height = 12;
222 private int _vector_data_width = 120;
224 for( final String font_name : Constants.DEFAULT_FONT_CHOICES ) {
225 if ( Arrays.binarySearch( AptxUtil.getAvailableFontFamiliesSorted(), font_name ) >= 0 ) {
226 DEFAULT_FONT_FAMILY = font_name;
230 if ( ForesterUtil.isEmpty( DEFAULT_FONT_FAMILY ) ) {
231 DEFAULT_FONT_FAMILY = Constants.DEFAULT_FONT_CHOICES[ Constants.DEFAULT_FONT_CHOICES.length - 1 ];
235 public Configuration() {
236 this( null, false, false, false );
239 public Configuration( final String cf, final boolean is_url, final boolean is_applet, final boolean verbose ) {
240 if ( ForesterUtil.isEmpty( cf ) ) {
241 config_filename = default_config_filename;
244 config_filename = cf;
246 setDisplayColors( new TreeMap<String, Color>() );
247 config_filename = config_filename.trim();
250 // If URL, open accordingly
252 u = new URL( config_filename );
254 final InputStreamReader isr = new InputStreamReader( u.openStream() );
255 final BufferedReader bf = new BufferedReader( isr );
258 ForesterUtil.programMessage( Constants.PRG_NAME, "successfully read from configuration url ["
259 + config_filename + "]" );
261 catch ( final Exception e ) {
262 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "failed to read configuration from ["
263 + config_filename + "]: " + e.getLocalizedMessage() );
266 catch ( final Exception e ) {
267 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "cannot find or open configuration url ["
268 + config_filename + "]" );
272 // Otherwise, open as a file
273 File f = new File( config_filename );
275 f = new File( config_filename + ".txt" );
277 if ( f.exists() && f.canRead() ) {
279 final BufferedReader bf = new BufferedReader( new FileReader( f ) );
283 catch ( final Exception e ) {
285 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "failed to read configuration from ["
286 + config_filename + "]: " + e );
292 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "cannot find or open configuration file ["
293 + config_filename + "]" );
299 public String getBaseFontFamilyName() {
300 return _base_font_family_name;
303 public int getDefaultBootstrapSamples() {
304 return _default_bootstrap_samples;
307 public NodeFill getDefaultNodeFill() {
308 return _default_node_fill;
311 public NodeShape getDefaultNodeShape() {
312 return _default_node_shape;
315 public short getDefaultNodeShapeSize() {
316 return _default_node_shape_size;
319 public NODE_DATA getExtDescNodeDataToReturn() {
320 return _ext_desc_data_to_return;
323 public EXT_NODE_DATA_RETURN_ON getExtNodeDataReturnOn() {
324 return _ext_node_data_return_on;
327 public int getFrameXSize() {
328 return _frame_x_size;
331 public int getFrameYSize() {
332 return _frame_y_size;
335 public String getLabelForGetExtDescendentsData() {
336 return _label_for_get_ext_descendents_data;
339 public File getPathToLocalFastme() {
340 return _path_to_local_fastme;
343 public File getPathToLocalMafft() {
344 return _path_to_local_mafft;
347 public File getPathToLocalRaxml() {
348 return _path_to_local_raxml;
351 public boolean isAbbreviateScientificTaxonNames() {
352 return _abbreviate_scientific_names;
355 public boolean isBackgroundColorGradient() {
356 return _background_color_gradient;
359 public boolean isColorByTaxonomicGroup() {
363 public boolean isColorLabelsSameAsParentBranch() {
364 return _color_labels_same_as_parent_branch;
367 public boolean isMidpointReroot() {
368 return _midpoint_root;
371 public boolean isShowAnnotationRefSource() {
372 return _show_annotation_ref_source;
375 public boolean isShowDefaultNodeShapesExternal() {
376 return _show_default_node_shapes_external;
379 public boolean isShowDefaultNodeShapesInternal() {
380 return _show_default_node_shapes_internal;
383 public boolean isShowDomainLabels() {
384 return _show_domain_labels;
387 public void putDisplayColors( final String key, final Color color ) {
388 getDisplayColors().put( key, color );
391 public void setAddTaxonomyImagesCB( final boolean b ) {
392 display_options[ show_taxonomy_images ][ 1 ] = b ? "yes" : "no";
395 public void setAbbreviateScientificTaxonNames( final boolean abbreviate_scientific_names ) {
396 _abbreviate_scientific_names = abbreviate_scientific_names;
399 public void setBackgroundColorGradient( final boolean background_color_gradient ) {
400 _background_color_gradient = background_color_gradient;
403 public void setBaseFontFamilyName( final String base_font_family_name ) {
404 _base_font_family_name = base_font_family_name;
407 public void setBaseFontSize( final int base_font_size ) {
408 _base_font_size = base_font_size;
411 public void setColorizeBranches( final boolean b ) {
412 display_options[ use_style ][ 2 ] = b ? "yes" : "no";
415 public void setColorLabelsSameAsParentBranch( final boolean color_labels_same_as_parent_branch ) {
416 _color_labels_same_as_parent_branch = color_labels_same_as_parent_branch;
419 public void setDefaultNodeFill( final NodeFill default_node_fill ) {
420 _default_node_fill = default_node_fill;
423 public void setDefaultNodeShape( final NodeShape default_node_shape ) {
424 _default_node_shape = default_node_shape;
427 public void setDefaultNodeShapeSize( final short default_node_shape_size ) {
428 _default_node_shape_size = default_node_shape_size;
431 public void setDisplayAsPhylogram( final boolean b ) {
432 display_options[ display_as_phylogram ][ 2 ] = b ? "yes" : "no";
435 public void setUseStyle( final boolean b ) {
436 display_options[ use_style ][ 2 ] = b ? "yes" : "no";
439 public void setDisplayColors( final SortedMap<String, Color> display_colors ) {
440 _display_colors = display_colors;
443 public void setDisplayConfidenceValues( final boolean b ) {
444 display_options[ write_confidence_values ][ 2 ] = b ? "yes" : "no";
447 public void setDisplayInternalData( final boolean b ) {
448 display_options[ display_internal_data ][ 2 ] = b ? "yes" : "no";
451 public void setDisplayNodeNames( final boolean b ) {
452 display_options[ show_node_names ][ 2 ] = b ? "yes" : "no";
455 public void setDisplaySequenceAcc( final boolean b ) {
456 display_options[ show_sequence_acc ][ 2 ] = b ? "yes" : "no";
459 public void setDisplaySequenceNames( final boolean b ) {
460 display_options[ show_seq_names ][ 2 ] = b ? "yes" : "no";
463 public void setDisplayGeneNames( final boolean b ) {
464 display_options[ show_gene_names ][ 2 ] = b ? "yes" : "no";
467 public void setDisplaySequenceRelations( final boolean display_sequence_relations ) {
468 _display_sequence_relations = display_sequence_relations;
471 public void setDisplaySequenceSymbols( final boolean b ) {
472 display_options[ show_seq_symbols ][ 2 ] = b ? "yes" : "no";
475 public void setDisplayTaxonomyCode( final boolean b ) {
476 display_options[ show_tax_code ][ 2 ] = b ? "yes" : "no";
479 public void setDisplayTaxonomyCommonNames( final boolean b ) {
480 display_options[ show_taxonomy_common_names ][ 2 ] = b ? "yes" : "no";
483 public void setDisplayTaxonomyImages( final boolean b ) {
484 display_options[ show_taxonomy_images ][ 2 ] = b ? "yes" : "no";
487 public void setDisplayTaxonomyScientificNames( final boolean b ) {
488 display_options[ show_taxonomy_scientific_names ][ 2 ] = b ? "yes" : "no";
491 public void setDynamicallyHideData( final boolean b ) {
492 display_options[ dynamically_hide_data ][ 2 ] = b ? "yes" : "no";
495 public void setExtDescNodeDataToReturn( final NODE_DATA ext_desc_data_to_return ) {
496 _ext_desc_data_to_return = ext_desc_data_to_return;
499 public void setFrameXSize( final int frame_x_size ) {
500 _frame_x_size = frame_x_size;
503 public void setFrameYSize( final int frame_y_size ) {
504 _frame_y_size = frame_y_size;
507 public void setMidpointReroot( final boolean midpoint_root ) {
508 _midpoint_root = midpoint_root;
511 public void setMinConfidenceValue( final double min_confidence_value ) {
512 _min_confidence_value = min_confidence_value;
515 public void setNodeLabelDirection( final NODE_LABEL_DIRECTION node_label_direction ) {
516 _node_label_direction = node_label_direction;
519 public void setNumberOfDigitsAfterCommaForBranchLengthValue( final short number_of_digits_after_comma_for_branch_length_values ) {
520 _number_of_digits_after_comma_for_branch_length_values = number_of_digits_after_comma_for_branch_length_values;
523 public void setNumberOfDigitsAfterCommaForConfidenceValues( final short number_of_digits_after_comma_for_confidence_values ) {
524 _number_of_digits_after_comma_for_confidence_values = number_of_digits_after_comma_for_confidence_values;
527 public void setPhylogenyGraphicsType( final PHYLOGENY_GRAPHICS_TYPE phylogeny_graphics_type ) {
528 _phylogeny_graphics_type = phylogeny_graphics_type;
531 public void setPrintLineWidth( final float print_line_width ) {
532 _print_line_width = print_line_width;
535 public void setReplaceUnderscoresInNhParsing( final boolean nh_parsing_replace_underscores ) {
536 _nh_parsing_replace_underscores = nh_parsing_replace_underscores;
539 public void setShowBranchLengthValues( final boolean show_branch_length_values ) {
540 _show_branch_length_values = show_branch_length_values;
543 public void setShowDefaultNodeShapesExternal( final boolean show_default_node_shapes_external ) {
544 _show_default_node_shapes_external = show_default_node_shapes_external;
547 public void setShowDefaultNodeShapesInternal( final boolean show_default_node_shapes_internal ) {
548 _show_default_node_shapes_internal = show_default_node_shapes_internal;
551 public void setShowDomainLabels( final boolean show_domain_labels ) {
552 _show_domain_labels = show_domain_labels;
555 public void setShowScale( final boolean show_scale ) {
556 _show_scale = show_scale;
559 boolean displaySequenceRelations() {
560 return _display_sequence_relations;
563 boolean doCheckOption( final int which ) {
564 return ( display_options[ which ][ 2 ].equalsIgnoreCase( "yes" ) )
565 || ( display_options[ which ][ 2 ].equalsIgnoreCase( "true" ) );
568 boolean doDisplayClickToOption( final int which ) {
569 return clickto_options[ which ][ 1 ].equalsIgnoreCase( "display" );
572 boolean doDisplayOption( final int which ) {
573 return display_options[ which ][ 1 ].equalsIgnoreCase( "display" );
577 * Will attempt to use the phylogeny to determine whether to check
578 * this or not (e.g. phylogram)
581 boolean doGuessCheckOption( final int which ) {
582 return display_options[ which ][ 2 ].equals( "?" );
585 Map<String, Color> getAnnotationColors() {
586 if ( _annotation_colors == null ) {
587 _annotation_colors = new Hashtable<String, Color>();
589 return _annotation_colors;
592 int getBaseFontSize() {
593 return _base_font_size;
596 CLADOGRAM_TYPE getCladogramType() {
597 return _cladogram_type;
600 int getClickToOptionsCount() {
601 return clickto_options.length;
604 String getClickToTitle( final int which ) {
605 return clickto_options[ which ][ 0 ];
608 int getDefaultDisplayClicktoOption() {
609 return default_clickto;
612 SortedMap<String, Color> getDisplayColors() {
613 return _display_colors;
616 String getDisplayTitle( final int which ) {
617 return display_options[ which ][ 0 ];
620 Map<String, Color> getDomainColors() {
621 if ( _domain_colors == null ) {
622 _domain_colors = new Hashtable<String, Color>();
624 return _domain_colors;
627 int getGraphicsExportX() {
628 return _graphics_export_x;
631 int getGraphicsExportY() {
632 return _graphics_export_y;
635 Color getGuiBackgroundColor() {
636 return _gui_background_color;
639 Color getGuiButtonBackgroundColor() {
640 return _gui_button_background_color;
643 Color getGuiButtonBorderColor() {
644 return _gui_button_border_color;
647 Color getGuiButtonTextColor() {
648 return _gui_button_text_color;
651 Color getGuiCheckboxAndButtonActiveColor() {
652 return _gui_checkbox_and_button_active_color;
655 Color getGuiCheckboxTextColor() {
656 return _gui_checkbox_text_color;
659 Color getGuiMenuBackgroundColor() {
660 return _gui_menu_background_color;
663 Color getGuiMenuTextColor() {
664 return _gui_menu_text_color;
667 int getMaxBaseFontSize() {
668 return _max_base_font_size;
671 int getMinBaseFontSize() {
672 return _min_base_font_size;
675 double getMinConfidenceValue() {
676 return _min_confidence_value;
679 NODE_LABEL_DIRECTION getNodeLabelDirection() {
680 return _node_label_direction;
683 short getNumberOfDigitsAfterCommaForBranchLengthValues() {
684 return _number_of_digits_after_comma_for_branch_length_values;
687 short getNumberOfDigitsAfterCommaForConfidenceValues() {
688 return _number_of_digits_after_comma_for_confidence_values;
691 short getOvMaxHeight() {
692 return _ov_max_height;
695 short getOvMaxWidth() {
696 return _ov_max_width;
699 OVERVIEW_PLACEMENT_TYPE getOvPlacement() {
700 return _ov_placement;
703 PHYLOGENY_GRAPHICS_TYPE getPhylogenyGraphicsType() {
704 return _phylogeny_graphics_type;
707 float getPrintLineWidth() {
708 return _print_line_width;
711 Hashtable<String, Color> getSpeciesColors() {
712 if ( _species_colors == null ) {
713 _species_colors = new Hashtable<String, Color>();
715 return _species_colors;
718 Hashtable<String, Color> getSequenceColors() {
719 if ( _sequence_colors == null ) {
720 _sequence_colors = new Hashtable<String, Color>();
722 return _sequence_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;
880 else if ( name.equals( "change_node_font" ) ) {
881 index = Configuration.change_node_font;
883 else if ( name.equals( "color_node_font" ) ) {
884 index = Configuration.color_node_font;
886 else if ( name.equals( "color_subtree" ) ) {
887 index = Configuration.color_subtree;
892 private boolean parseBoolean( final String str ) {
893 final String my_str = str.trim().toLowerCase();
894 if ( my_str.equals( "yes" ) || my_str.equals( "true" ) ) {
897 else if ( my_str.equals( "no" ) || my_str.equals( "false" ) ) {
901 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "could not parse boolean value from [" + str + "]" );
906 private double parseDouble( final String str ) {
909 d = Double.parseDouble( str.trim() );
911 catch ( final Exception e ) {
912 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "could not parse double from [" + str + "]" );
918 private float parseFloat( final String str ) {
921 f = Float.parseFloat( str.trim() );
923 catch ( final Exception e ) {
924 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "could not parse float from [" + str + "]" );
930 private int parseInt( final String str ) {
933 i = Integer.parseInt( str.trim() );
935 catch ( final Exception e ) {
936 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "could not parse integer from [" + str + "]" );
942 private short parseShort( final String str ) {
945 i = Short.parseShort( str.trim() );
947 catch ( final Exception e ) {
948 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "could not parse short from [" + str + "]" );
954 private void processFontFamily( final StringTokenizer st ) {
955 setBaseFontFamilyName( "" );
956 final String font_str = ( ( String ) st.nextElement() ).trim();
957 final String[] fonts = font_str.split( ",+" );
958 for( String font : fonts ) {
959 font = font.replace( '_', ' ' ).trim();
960 if ( Arrays.binarySearch( AptxUtil.getAvailableFontFamiliesSorted(), font ) >= 0 ) {
961 setBaseFontFamilyName( font );
968 * read each line of config file, process non-comment lines
969 * @throws IOException
971 private void readConfig( final BufferedReader conf_in ) throws IOException {
974 line = conf_in.readLine();
975 if ( line != null ) {
977 // skip comments and blank lines
978 if ( !line.startsWith( "#" ) && ( !ForesterUtil.isEmpty( line ) ) ) {
979 // convert runs of spaces to tabs
980 line = line.replaceAll( "\\s+", "\t" );
981 final StringTokenizer st = new StringTokenizer( line, "\t" );
985 } while ( line != null );
988 private void setAntialiasScreen( final boolean antialias_screen ) {
989 _antialias_screen = antialias_screen;
992 private void setCladogramType( final CLADOGRAM_TYPE cladogram_type ) {
993 _cladogram_type = cladogram_type;
996 private void setDefaultBootstrapSamples( final int default_bootstrap_samples ) {
997 _default_bootstrap_samples = default_bootstrap_samples;
1000 private void setEditable( final boolean editable ) {
1001 _editable = editable;
1004 private void setExtNodeDataReturnOn( final EXT_NODE_DATA_RETURN_ON ext_node_data_return_on ) {
1005 _ext_node_data_return_on = ext_node_data_return_on;
1008 private void setGraphicsExportX( final int graphics_export_x ) {
1009 _graphics_export_x = graphics_export_x;
1012 private void setGraphicsExportY( final int graphics_export_y ) {
1013 _graphics_export_y = graphics_export_y;
1016 private void setInternalNumberAreConfidenceForNhParsing( final boolean internal_number_are_confidence_for_nh_parsing ) {
1017 _internal_number_are_confidence_for_nh_parsing = internal_number_are_confidence_for_nh_parsing;
1021 * Set a key-value(s) tuple
1023 private void setKeyValue( final StringTokenizer st ) {
1024 final String key = ( ( String ) st.nextElement() ).replace( ':', ' ' ).trim().toLowerCase();
1025 if ( !st.hasMoreElements() ) {
1028 // Handle single value settings first:
1029 if ( key.equals( "default_click_to" ) ) {
1030 final String clickto_name = ( String ) st.nextElement();
1031 default_clickto = getClickToIndex( clickto_name );
1032 if ( default_clickto == -1 ) {
1033 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "invalid value [" + clickto_name
1034 + "] for [default_click_to]" );
1035 default_clickto = 0;
1037 else if ( default_clickto == DEPRECATED ) {
1041 else if ( key.equals( "native_ui" ) ) {
1042 final String my_str = ( ( String ) st.nextElement() ).trim().toLowerCase();
1043 if ( my_str.equals( "yes" ) || my_str.equals( "true" ) ) {
1046 else if ( my_str.equals( "no" ) || my_str.equals( "false" ) ) {
1047 _ui = UI.CROSSPLATFORM;
1049 else if ( my_str.equals( "?" ) ) {
1053 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "could not parse yes/no/? value from [" + my_str
1058 else if ( key.equals( VALIDATE_AGAINST_PHYLOXML_XSD_SCHEMA ) ) {
1059 setValidatePhyloXmlAgainstSchema( parseBoolean( ( String ) st.nextElement() ) );
1061 else if ( key.equals( "antialias_screen" ) ) {
1062 setAntialiasScreen( parseBoolean( ( String ) st.nextElement() ) );
1064 else if ( key.equals( "phylogeny_graphics_type" ) ) {
1065 final String type_str = ( ( String ) st.nextElement() ).trim();
1066 if ( type_str.equalsIgnoreCase( PHYLOGENY_GRAPHICS_TYPE.CONVEX.toString() ) ) {
1067 setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CONVEX );
1069 else if ( type_str.equalsIgnoreCase( PHYLOGENY_GRAPHICS_TYPE.CURVED.toString() ) ) {
1070 setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CURVED );
1072 else if ( type_str.equalsIgnoreCase( PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE.toString() ) ) {
1073 setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE );
1075 else if ( type_str.equalsIgnoreCase( PHYLOGENY_GRAPHICS_TYPE.ROUNDED.toString() ) ) {
1076 setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.ROUNDED );
1078 else if ( type_str.equalsIgnoreCase( PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR.toString() ) ) {
1079 setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR );
1081 else if ( type_str.equalsIgnoreCase( PHYLOGENY_GRAPHICS_TYPE.TRIANGULAR.toString() ) ) {
1082 setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.TRIANGULAR );
1084 else if ( type_str.equalsIgnoreCase( PHYLOGENY_GRAPHICS_TYPE.UNROOTED.toString() ) ) {
1085 setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.UNROOTED );
1087 else if ( type_str.equalsIgnoreCase( PHYLOGENY_GRAPHICS_TYPE.CIRCULAR.toString() ) ) {
1088 setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CIRCULAR );
1091 setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR );
1092 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown value [" + type_str
1093 + "] for [phylogeny_graphics_type]" );
1096 else if ( key.equals( "min_confidence_value" ) ) {
1097 final String mcv_str = ( ( String ) st.nextElement() ).trim();
1098 final double d = parseDouble( mcv_str );
1099 setMinConfidenceValue( d );
1101 else if ( key.equals( "font_family" ) ) {
1102 processFontFamily( st );
1104 else if ( key.equals( "font_size" ) ) {
1105 final String size_str = ( ( String ) st.nextElement() ).trim();
1106 final int i = parseInt( size_str );
1108 setBaseFontSize( i );
1111 else if ( key.equals( "font_size_min" ) ) {
1112 final String size_str = ( ( String ) st.nextElement() ).trim();
1113 final int i = parseInt( size_str );
1115 setMinBaseFontSize( i );
1118 else if ( key.equals( "font_size_max" ) ) {
1119 final String size_str = ( ( String ) st.nextElement() ).trim();
1120 final int i = parseInt( size_str );
1122 setMaxBaseFontSize( i );
1125 else if ( key.equals( "graphics_export_x" ) ) {
1126 final String str = ( ( String ) st.nextElement() ).trim();
1127 final int i = parseInt( str );
1129 setGraphicsExportX( i );
1132 else if ( key.equals( "graphics_export_y" ) ) {
1133 final String str = ( ( String ) st.nextElement() ).trim();
1134 final int i = parseInt( str );
1136 setGraphicsExportY( i );
1139 else if ( key.equals( "pdf_export_line_width" ) ) {
1140 final String str = ( ( String ) st.nextElement() ).trim();
1141 final float f = parseFloat( str );
1143 setPrintLineWidth( f );
1146 ForesterUtil.printWarningMessage( Constants.PRG_NAME,
1147 "value for [pdf_export_line_width] cannot be zero or negative" );
1150 else if ( key.equals( "window_initial_size_x" ) ) {
1151 final String str = ( ( String ) st.nextElement() ).trim();
1152 final int i = parseInt( str );
1157 else if ( key.equals( "window_initial_size_y" ) ) {
1158 final String str = ( ( String ) st.nextElement() ).trim();
1159 final int i = parseInt( str );
1164 else if ( key.equals( "default_number_of_bootstrap_resamples" ) ) {
1165 final String str = ( ( String ) st.nextElement() ).trim();
1166 final int i = parseInt( str );
1168 setDefaultBootstrapSamples( i );
1172 .printWarningMessage( Constants.PRG_NAME,
1173 "value for [default_number_of_bootstrap_resamples] cannot be negative" );
1176 else if ( key.equals( "mafft_local" ) ) {
1177 final String str = ( ( String ) st.nextElement() ).trim();
1178 if ( !ForesterUtil.isEmpty( str ) ) {
1179 setPathToLocalMafft( new File( str ) );
1182 else if ( key.equals( "fastme_local" ) ) {
1183 final String str = ( ( String ) st.nextElement() ).trim();
1184 if ( !ForesterUtil.isEmpty( str ) ) {
1185 setPathToLocalFastme( new File( str ) );
1188 else if ( key.equals( "raxml_local" ) ) {
1189 final String str = ( ( String ) st.nextElement() ).trim();
1190 if ( !ForesterUtil.isEmpty( str ) ) {
1191 setPathToLocalRaxml( new File( str ) );
1194 else if ( key.equals( "show_scale" ) ) {
1195 setShowScale( parseBoolean( ( String ) st.nextElement() ) );
1197 else if ( key.equals( "show_overview" ) ) {
1198 setShowOverview( parseBoolean( ( String ) st.nextElement() ) );
1200 else if ( key.equals( "show_branch_length_values" ) ) {
1201 setShowBranchLengthValues( parseBoolean( ( String ) st.nextElement() ) );
1203 else if ( key.equals( "background_gradient" ) ) {
1204 setBackgroundColorGradient( parseBoolean( ( String ) st.nextElement() ) );
1206 else if ( key.equals( "color_labels_same_as_branch_length_values" ) ) {
1207 setColorLabelsSameAsParentBranch( parseBoolean( ( String ) st.nextElement() ) );
1209 else if ( key.equals( "show_domain_labels" ) ) {
1210 setShowDomainLabels( parseBoolean( ( String ) st.nextElement() ) );
1212 else if ( key.equals( "show_seq_annotation_ref_sources" ) ) {
1213 setShowAnnotationRefSource( parseBoolean( ( String ) st.nextElement() ) );
1215 else if ( key.equals( "abbreviate_scientific_names" ) ) {
1216 setAbbreviateScientificTaxonNames( parseBoolean( ( String ) st.nextElement() ) );
1218 else if ( key.equals( "cladogram_type" ) ) {
1219 final String type_str = ( ( String ) st.nextElement() ).trim();
1220 if ( type_str.equalsIgnoreCase( Options.CLADOGRAM_TYPE.NON_LINED_UP.toString() ) ) {
1221 setCladogramType( Options.CLADOGRAM_TYPE.NON_LINED_UP );
1223 else if ( type_str.equalsIgnoreCase( Options.CLADOGRAM_TYPE.EXT_NODE_SUM_DEP.toString() ) ) {
1224 setCladogramType( Options.CLADOGRAM_TYPE.EXT_NODE_SUM_DEP );
1226 else if ( type_str.equalsIgnoreCase( Options.CLADOGRAM_TYPE.TOTAL_NODE_SUM_DEP.toString() ) ) {
1227 setCladogramType( Options.CLADOGRAM_TYPE.TOTAL_NODE_SUM_DEP );
1230 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown value [" + type_str
1231 + "] for [cladogram_type]" );
1234 else if ( key.equals( "non_lined_up_cladogram" ) ) {
1236 .printWarningMessage( Constants.PRG_NAME,
1237 "configuration key [non_lined_up_cladogram] is deprecated, use [cladogram_type] instead" );
1239 else if ( key.equals( "hide_controls_and_menus" ) ) {
1240 _hide_controls_and_menus = parseBoolean( ( String ) st.nextElement() );
1242 else if ( key.equals( "use_tabbed_display" ) ) {
1243 _use_tabbed_display = parseBoolean( ( String ) st.nextElement() );
1245 else if ( key.equals( "overview_width" ) ) {
1246 final short i = parseShort( ( ( String ) st.nextElement() ) );
1249 else if ( key.equals( "overview_height" ) ) {
1250 final short i = parseShort( ( ( String ) st.nextElement() ) );
1251 setOvMaxHeight( i );
1253 else if ( key.equals( "overview_placement_type" ) ) {
1254 final String type_str = ( ( String ) st.nextElement() ).trim();
1255 if ( type_str.equalsIgnoreCase( OVERVIEW_PLACEMENT_TYPE.UPPER_LEFT.toTag() ) ) {
1256 setOvPlacement( OVERVIEW_PLACEMENT_TYPE.UPPER_LEFT );
1258 else if ( type_str.equalsIgnoreCase( OVERVIEW_PLACEMENT_TYPE.UPPER_RIGHT.toTag() ) ) {
1259 setOvPlacement( OVERVIEW_PLACEMENT_TYPE.UPPER_RIGHT );
1261 else if ( type_str.equalsIgnoreCase( OVERVIEW_PLACEMENT_TYPE.LOWER_LEFT.toTag() ) ) {
1262 setOvPlacement( OVERVIEW_PLACEMENT_TYPE.LOWER_LEFT );
1264 else if ( type_str.equalsIgnoreCase( OVERVIEW_PLACEMENT_TYPE.LOWER_RIGHT.toTag() ) ) {
1265 setOvPlacement( OVERVIEW_PLACEMENT_TYPE.LOWER_RIGHT );
1268 setOvPlacement( OVERVIEW_PLACEMENT_TYPE.UPPER_LEFT );
1269 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown value [" + type_str
1270 + "] for [overview_placement_type]" );
1273 else if ( key.equals( "node_label_direction" ) ) {
1274 final String type_str = ( ( String ) st.nextElement() ).trim();
1275 if ( type_str.equalsIgnoreCase( NODE_LABEL_DIRECTION.HORIZONTAL.toString() ) ) {
1276 setNodeLabelDirection( NODE_LABEL_DIRECTION.HORIZONTAL );
1278 else if ( type_str.equalsIgnoreCase( NODE_LABEL_DIRECTION.RADIAL.toString() ) ) {
1279 setNodeLabelDirection( NODE_LABEL_DIRECTION.RADIAL );
1282 setNodeLabelDirection( NODE_LABEL_DIRECTION.HORIZONTAL );
1283 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown value [" + type_str
1284 + "] for [node_label_direction]" );
1287 else if ( key.equals( "branch_length_value_digits" ) ) {
1288 final short i = parseShort( ( ( String ) st.nextElement() ).trim() );
1290 setNumberOfDigitsAfterCommaForBranchLengthValue( i );
1293 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "illegal value [" + i
1294 + "] for [branch_length_value_digits]" );
1297 else if ( key.equals( "confidence_value_digits" ) ) {
1298 final short i = parseShort( ( ( String ) st.nextElement() ).trim() );
1300 setNumberOfDigitsAfterCommaForConfidenceValues( i );
1303 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "illegal value [" + i
1304 + "] for [confidence_value_digits]" );
1307 else if ( key.equals( "allow_editing" ) ) {
1308 setEditable( parseBoolean( ( String ) st.nextElement() ) );
1310 else if ( key.equals( "display_sequence_relations" ) ) {
1311 setDisplaySequenceRelations( parseBoolean( ( String ) st.nextElement() ) );
1313 else if ( key.equals( "replace_underscores_in_nh_parsing" ) ) {
1314 final boolean r = parseBoolean( ( String ) st.nextElement() );
1315 if ( r && ( getTaxonomyExtraction() != TAXONOMY_EXTRACTION.NO ) ) {
1317 .printWarningMessage( Constants.PRG_NAME,
1318 "attempt to extract taxonomies and replace underscores at the same time" );
1321 setReplaceUnderscoresInNhParsing( r );
1324 else if ( key.equals( "taxonomy_extraction_in_nh_parsing" ) ) {
1325 final String s = ( String ) st.nextElement();
1326 if ( s.equalsIgnoreCase( "no" ) ) {
1327 setTaxonomyExtraction( TAXONOMY_EXTRACTION.NO );
1329 else if ( s.equalsIgnoreCase( "pfam_relaxed" ) ) {
1330 setTaxonomyExtraction( TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
1332 else if ( s.equalsIgnoreCase( "pfam_strict" ) ) {
1333 setTaxonomyExtraction( TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1335 else if ( s.equalsIgnoreCase( "aggressive" ) ) {
1336 setTaxonomyExtraction( TAXONOMY_EXTRACTION.AGGRESSIVE );
1340 .printWarningMessage( Constants.PRG_NAME,
1341 "unknown value for \"taxonomy_extraction_in_nh_parsing\": "
1343 + " (must be either: no, pfam_relaxed, pfam_strict, or aggressive)" );
1345 if ( ( getTaxonomyExtraction() != TAXONOMY_EXTRACTION.NO ) && isReplaceUnderscoresInNhParsing() ) {
1347 .printWarningMessage( Constants.PRG_NAME,
1348 "attempt to extract taxonomies and replace underscores at the same time" );
1351 else if ( key.equals( "internal_labels_are_confidence_values" ) ) {
1352 setInternalNumberAreConfidenceForNhParsing( parseBoolean( ( String ) st.nextElement() ) );
1354 else if ( key.equals( "gui_background_color" ) ) {
1355 _gui_background_color = Color.decode( ( String ) st.nextElement() );
1357 else if ( key.equals( "gui_checkbox_text_color" ) ) {
1358 _gui_checkbox_text_color = Color.decode( ( String ) st.nextElement() );
1360 else if ( key.equals( "gui_checkbox_and_button_active_color" ) ) {
1361 _gui_checkbox_and_button_active_color = Color.decode( ( String ) st.nextElement() );
1363 else if ( key.equals( "gui_button_text_color" ) ) {
1364 _gui_button_text_color = Color.decode( ( String ) st.nextElement() );
1366 else if ( key.equals( "gui_button_background_color" ) ) {
1367 _gui_button_background_color = Color.decode( ( String ) st.nextElement() );
1369 else if ( key.equals( "gui_menu_background_color" ) ) {
1370 _gui_menu_background_color = Color.decode( ( String ) st.nextElement() );
1372 else if ( key.equals( "gui_menu_text_color" ) ) {
1373 _gui_menu_text_color = Color.decode( ( String ) st.nextElement() );
1375 else if ( key.equals( "gui_button_border_color" ) ) {
1376 _gui_button_border_color = Color.decode( ( String ) st.nextElement() );
1379 else if ( key.equals( "show_default_node_shapes" ) ) {
1381 .printWarningMessage( Constants.PRG_NAME,
1382 "configuration key [show_default_node_shapes] is deprecated, use [show_default_node_shapes_internal] and [show_default_node_shapes_external] instead" );
1383 final boolean b = parseBoolean( ( ( String ) st.nextElement() ).trim() );
1384 setShowDefaultNodeShapesInternal( b );
1385 setShowDefaultNodeShapesExternal( b );
1387 else if ( key.equals( "show_default_node_shapes_internal" ) ) {
1388 setShowDefaultNodeShapesInternal( parseBoolean( ( ( String ) st.nextElement() ).trim() ) );
1390 else if ( key.equals( "show_default_node_shapes_external" ) ) {
1391 setShowDefaultNodeShapesExternal( parseBoolean( ( ( String ) st.nextElement() ).trim() ) );
1393 else if ( key.equals( "default_node_size" ) ) {
1394 final short i = parseShort( ( ( String ) st.nextElement() ).trim() );
1395 setDefaultNodeShapeSize( i );
1397 else if ( key.equals( "default_node_fill" ) ) {
1398 final String fill_str = ( ( String ) st.nextElement() ).trim();
1399 if ( fill_str.equalsIgnoreCase( NodeVisualData.NodeFill.NONE.toString() ) ) {
1400 setDefaultNodeFill( NodeFill.NONE );
1402 else if ( fill_str.equalsIgnoreCase( NodeVisualData.NodeFill.GRADIENT.toString() ) ) {
1403 setDefaultNodeFill( NodeFill.GRADIENT );
1405 else if ( fill_str.equalsIgnoreCase( NodeVisualData.NodeFill.SOLID.toString() ) ) {
1406 setDefaultNodeFill( NodeFill.SOLID );
1409 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown value [" + fill_str
1410 + "] for [default_node_fill]" );
1413 else if ( key.equals( "default_node_shape" ) ) {
1414 final String shape_str = ( ( String ) st.nextElement() ).trim();
1415 if ( shape_str.equalsIgnoreCase( NodeVisualData.NodeShape.CIRCLE.toString() ) ) {
1416 setDefaultNodeShape( NodeShape.CIRCLE );
1418 else if ( shape_str.equalsIgnoreCase( NodeVisualData.NodeShape.RECTANGLE.toString() ) ) {
1419 setDefaultNodeShape( NodeShape.RECTANGLE );
1422 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown value [" + shape_str
1423 + "] for [default_node_shape]" );
1426 else if ( key.equals( "midpoint_reroot" ) ) {
1427 setMidpointReroot( parseBoolean( ( String ) st.nextElement() ) );
1429 else if ( key.equals( "ext_descendents_data_to_return" ) ) {
1430 final String s = ( ( String ) st.nextElement() ).trim();
1431 if ( s.equalsIgnoreCase( "node_name" ) ) {
1432 setExtDescNodeDataToReturn( NODE_DATA.NODE_NAME );
1434 else if ( s.equalsIgnoreCase( "sequence_acc" ) ) {
1435 setExtDescNodeDataToReturn( NODE_DATA.SEQUENCE_ACC );
1437 else if ( s.equalsIgnoreCase( "sequence_mol_seq_fasta" ) ) {
1438 setExtDescNodeDataToReturn( NODE_DATA.SEQUENCE_MOL_SEQ_FASTA );
1440 else if ( s.equalsIgnoreCase( "sequence_mol_seq" ) ) {
1441 setExtDescNodeDataToReturn( NODE_DATA.SEQUENCE_MOL_SEQ );
1443 else if ( s.equalsIgnoreCase( "sequence_name" ) ) {
1444 setExtDescNodeDataToReturn( NODE_DATA.SEQUENCE_NAME );
1446 else if ( s.equalsIgnoreCase( "gene_name" ) ) {
1447 setExtDescNodeDataToReturn( NODE_DATA.GENE_NAME );
1449 else if ( s.equalsIgnoreCase( "sequence_symbol" ) ) {
1450 setExtDescNodeDataToReturn( NODE_DATA.SEQUENCE_SYMBOL );
1452 else if ( s.equalsIgnoreCase( "taxonomy_scientific_name" ) ) {
1453 setExtDescNodeDataToReturn( NODE_DATA.TAXONOMY_SCIENTIFIC_NAME );
1455 else if ( s.equalsIgnoreCase( "taxonomy_code" ) ) {
1456 setExtDescNodeDataToReturn( NODE_DATA.TAXONOMY_CODE );
1458 else if ( s.equalsIgnoreCase( "taxonomy_common_name" ) ) {
1459 setExtDescNodeDataToReturn( NODE_DATA.TAXONOMY_COMM0N_NAME );
1461 else if ( s.equalsIgnoreCase( "user_selected" ) ) {
1462 setExtDescNodeDataToReturn( NODE_DATA.UNKNOWN );
1465 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown value [" + s
1466 + "] for [ext_descendents_data_to_return]" );
1469 else if ( key.equals( "label_for_get_ext_descendents_data" ) ) {
1470 final String s = ( ( String ) st.nextElement() ).trim();
1471 if ( ForesterUtil.isEmpty( s ) || ( s.length() < 2 ) ) {
1472 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "illegal value [" + s
1473 + "] for [label_for_get_ext_descendents_data]" );
1476 setLabelForGetExtDescendentsData( s.replaceAll( "_", " " ) );
1479 else if ( key.equals( "ext_descendents_data_to_return_on" ) ) {
1480 final String s = ( ( String ) st.nextElement() ).trim().toLowerCase();
1481 if ( s.equals( "console" ) ) {
1482 setExtNodeDataReturnOn( EXT_NODE_DATA_RETURN_ON.CONSOLE );
1484 else if ( s.equals( "window" ) ) {
1485 setExtNodeDataReturnOn( EXT_NODE_DATA_RETURN_ON.WINODW );
1487 else if ( s.equals( "buffer_only" ) ) {
1488 setExtNodeDataReturnOn( EXT_NODE_DATA_RETURN_ON.BUFFER_ONLY );
1491 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown value [" + s
1492 + "] for [ext_descendents_data_to_return_on]" );
1496 else if ( key.equals( "vector_data_min_color" ) ) {
1497 _vector_data_min_color = Color.decode( ( String ) st.nextElement() );
1499 else if ( key.equals( "vector_data_max_color" ) ) {
1500 _vector_data_max_color = Color.decode( ( String ) st.nextElement() );
1502 else if ( key.equals( "vector_data_mean_color" ) ) {
1503 _vector_data_mean_color = Color.decode( ( String ) st.nextElement() );
1506 else if ( key.equals( "vector_data_width" ) ) {
1507 _vector_data_width = parseShort( ( String ) st.nextElement() );
1508 if ( _vector_data_width < 1 ) {
1509 _vector_data_width = 120;
1512 else if ( key.equals( "vector_data_height" ) ) {
1513 _vector_data_height = parseShort( ( String ) st.nextElement() );
1514 if ( _vector_data_height < 1 ) {
1515 _vector_data_height = 12;
1519 else if ( st.countTokens() >= 2 ) { // counts the tokens that are not
1522 if ( key.equals( "phylogram" ) ) {
1523 key_index = Configuration.display_as_phylogram;
1525 else if ( key.equals( "rollover" ) ) {
1526 key_index = Configuration.node_data_popup;
1528 else if ( key.equals( "color_according_to_species" ) ) {
1529 key_index = Configuration.color_according_to_species;
1531 else if ( key.equals( "color_according_to_sequence" ) ) {
1532 key_index = Configuration.color_according_to_sequence;
1534 else if ( key.equals( "show_node_names" ) ) {
1535 key_index = Configuration.show_node_names;
1537 else if ( key.equals( "show_taxonomy_code" ) ) {
1538 key_index = Configuration.show_tax_code;
1540 else if ( key.equals( "write_confidence_values" ) ) {
1541 key_index = Configuration.write_confidence_values;
1543 else if ( key.equals( "write_events" ) ) {
1544 key_index = Configuration.write_events;
1546 else if ( key.equals( "use_visual_styles" ) ) {
1547 key_index = Configuration.use_style;
1549 else if ( key.equals( "color_branches" ) ) {
1550 key_index = Configuration.use_style;
1552 .printWarningMessage( Constants.PRG_NAME,
1553 "configuration key [color_branches] is deprecated, use [use_visual_styles] instead" );
1555 else if ( key.equals( "width_branches" ) ) {
1556 key_index = Configuration.width_branches;
1558 else if ( key.equals( "show_domain_architectures" ) ) {
1559 key_index = Configuration.show_domain_architectures;
1561 else if ( key.equals( "show_annotations" ) ) {
1562 key_index = Configuration.show_annotation;
1564 else if ( key.equals( "show_binary_characters" ) ) {
1565 key_index = Configuration.show_binary_characters;
1567 else if ( key.equals( "show_binary_character_counts" ) ) {
1568 key_index = Configuration.show_binary_character_counts;
1570 else if ( key.equals( "show_seq_names" ) ) {
1571 key_index = Configuration.show_seq_names;
1573 else if ( key.equals( "show_gene_names" ) ) {
1574 key_index = Configuration.show_gene_names;
1576 else if ( key.equals( "show_seq_symbols" ) ) {
1577 key_index = Configuration.show_seq_symbols;
1579 else if ( key.equals( "show_seq_acc" ) ) {
1580 key_index = Configuration.show_sequence_acc;
1582 else if ( key.equals( "display_internal_data" ) ) {
1583 key_index = Configuration.display_internal_data;
1585 else if ( key.equals( "dynamically_hide_data" ) ) {
1586 key_index = Configuration.dynamically_hide_data;
1588 else if ( key.equals( "show_taxonomy_scientific_names" ) ) {
1589 key_index = Configuration.show_taxonomy_scientific_names;
1591 else if ( key.equals( "show_taxonomy_common_names" ) ) {
1592 key_index = Configuration.show_taxonomy_common_names;
1594 else if ( key.equals( "show_taxonomy_images" ) ) {
1595 key_index = Configuration.show_taxonomy_images;
1597 else if ( key.equals( "color_according_to_annotation" ) ) {
1598 key_index = Configuration.color_according_to_annotation;
1600 else if ( key.equals( "show_vector_data" ) ) {
1601 key_index = Configuration.show_vector_data;
1603 else if ( key.equals( "show_properties" ) ) {
1604 key_index = Configuration.show_properties;
1606 else if ( key.equals( "show_relation_confidence" ) ) {
1607 key_index = Configuration.show_relation_confidence;
1609 // If we've found the key, set the values
1610 if ( key_index >= 0 ) {
1611 display_options[ key_index ][ 1 ] = ( String ) st.nextElement();
1612 display_options[ key_index ][ 2 ] = ( String ) st.nextElement();
1613 // otherwise, keep looking
1616 if ( key_index == DEPRECATED ) {
1619 else if ( key.equals( "click_to" ) ) {
1620 final String click_to_name = ( String ) st.nextElement();
1621 key_index = getClickToIndex( click_to_name );
1622 if ( key_index >= 0 ) {
1623 clickto_options[ key_index ][ 1 ] = ( String ) st.nextElement();
1625 else if ( key_index == DEPRECATED ) {
1629 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown click-to option: "
1633 else if ( key.equals( "species_color" ) ) {
1634 getSpeciesColors().put( ( ( String ) st.nextElement() ).replace( '_', ' ' ),
1635 Color.decode( ( String ) st.nextElement() ) );
1637 else if ( key.equals( "sequence_color" ) ) {
1638 getSequenceColors().put( ( ( String ) st.nextElement() ).replace( '_', ' ' ),
1639 Color.decode( ( String ) st.nextElement() ) );
1641 else if ( key.equals( "domain_color" ) ) {
1642 getDomainColors().put( ( String ) st.nextElement(), Color.decode( ( String ) st.nextElement() ) );
1644 else if ( key.equals( "annotation_color" ) ) {
1645 getAnnotationColors()
1646 .put( ( String ) st.nextElement(), Color.decode( ( String ) st.nextElement() ) );
1648 else if ( key.equals( "function_color" ) ) {
1649 ForesterUtil.printWarningMessage( Constants.PRG_NAME,
1650 "configuration key [function_color] is deprecated" );
1652 else if ( key.equals( DISPLAY_COLOR_KEY ) ) {
1653 putDisplayColors( ( String ) st.nextElement(), Color.decode( ( String ) st.nextElement() ) );
1656 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown configuration key [" + key
1657 + "] in: " + config_filename );
1662 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown configuration key [" + key + "] in: "
1663 + config_filename );
1667 private void setLabelForGetExtDescendentsData( final String label_for_get_ext_descendents_data ) {
1668 _label_for_get_ext_descendents_data = label_for_get_ext_descendents_data;
1671 private void setMaxBaseFontSize( final int max_base_font_size ) {
1672 _max_base_font_size = max_base_font_size;
1675 private void setMinBaseFontSize( final int min_base_font_size ) {
1676 _min_base_font_size = min_base_font_size;
1679 private void setOvMaxHeight( final short ov_max_height ) {
1680 _ov_max_height = ov_max_height;
1683 private void setOvMaxWidth( final short ov_max_width ) {
1684 _ov_max_width = ov_max_width;
1687 private void setOvPlacement( final OVERVIEW_PLACEMENT_TYPE ov_placement ) {
1688 _ov_placement = ov_placement;
1691 private void setPathToLocalFastme( final File path_to_local_fastme ) {
1692 _path_to_local_fastme = path_to_local_fastme;
1695 private void setPathToLocalMafft( final File path_to_local_mafft ) {
1696 _path_to_local_mafft = path_to_local_mafft;
1699 private void setPathToLocalRaxml( final File path_to_local_raxml ) {
1700 _path_to_local_raxml = path_to_local_raxml;
1703 private void setShowAnnotationRefSource( final boolean b ) {
1704 _show_annotation_ref_source = b;
1707 private void setShowOverview( final boolean show_overview ) {
1708 _show_overview = show_overview;
1711 private void setValidatePhyloXmlAgainstSchema( final boolean validate_against_phyloxml_xsd_schema ) {
1712 _validate_against_phyloxml_xsd_schema = validate_against_phyloxml_xsd_schema;
1715 static String getDefaultFontFamilyName() {
1716 return DEFAULT_FONT_FAMILY;
1719 public enum EXT_NODE_DATA_RETURN_ON {
1720 BUFFER_ONLY, CONSOLE, WINODW;
1724 CROSSPLATFORM, NATIVE, NIMBUS, UNKNOWN
1727 static enum TRIPLET {
1728 FALSE, TRUE, UNKNOWN
1731 public Color getVectorDataMinColor() {
1732 return _vector_data_min_color;
1735 public Color getVectorDataMaxColor() {
1736 return _vector_data_max_color;
1739 public Color getVectorDataMeanColor() {
1740 return _vector_data_mean_color;
1743 public double getVectorDataHeight() {
1744 return _vector_data_height;
1747 public int getVectorDataWidth() {
1748 return _vector_data_width;