diff --git resources/lang/Messages.properties resources/lang/Messages.properties index 6736791..0aadffc 100644 --- resources/lang/Messages.properties +++ resources/lang/Messages.properties @@ -1,740 +1,741 @@ action.refresh_services = Refresh Services action.reset_services = Reset Services action.merge_results = Merge Results action.load_scheme = Load scheme action.save_scheme = Save scheme action.save_image = Save Image action.paste = Paste action.show_html_source = Show HTML Source action.print = Print action.web_service = Web Service action.cancel_job = Cancel Job action.start_job = Start Job action.revert = Revert action.move_down = Move Down action.move_up = Move Up action.remove_return_datatype = Remove return datatype action.add_return_datatype = Add return datatype action.remove_input_parameter = Remove selected input parameter action.add_input_parameter = Add input parameter action.edit = Edit action.new = New action.open_file = Open file action.show_unconserved = Show Unconserved action.open_new_aligmnent = Open new alignment action.raise_associated_windows = Raise Associated Windows action.minimize_associated_windows = Minimize Associated Windows action.close_all = Close all action.load_project = Load Project action.save_project = Save Project action.quit = Quit action.expand_views = Expand Views action.gather_views = Gather Views action.page_setup = Page Setup action.reload = Reload action.load = Load action.open = Open action.cancel = Cancel action.create = Create action.update = Update action.delete = Delete action.snapshot = Snapshot action.clear = Clear action.accept = Accept action.select_ddbb = --- Select Database --- action.undo = Undo action.redo = Redo action.reset = Reset action.remove_left = Remove left action.remove_right = Remove right action.remove_empty_columns = Remove Empty Columns action.remove_all_gaps = Remove All Gaps action.left_justify_alignment = Left Justify Alignment action.right_justify_alignment = Right Justify Alignment action.boxes = Boxes action.text = Text action.by_pairwise_id = by Pairwise Identity action.by_id = by Id action.by_length = by Length action.by_group = by Group action.remove = Remove action.remove_redundancy = Remove Redundancy... action.pairwise_alignment = Pairwise Alignments... action.by_rna_helixes = by RNA Helices action.user_defined = User Defined... action.by_conservation = By Conservation action.wrap = Wrap action.show_gaps = Show Gaps action.show_hidden_markers = Show Hidden Markers action.find = Find action.undefine_groups = Undefine Groups action.create_groups = Create Groups action.make_groups_selection = Make Groups For Selection action.copy = Copy action.cut = Cut action.font = Font... action.scale_above = Scale Above action.scale_left = Scale Left action.scale_right = Scale Right action.by_tree_order = By Tree Order action.sort = Sort action.calculate_tree = Calculate Tree action.help = Help action.by_annotation = by Annotation... action.invert_sequence_selection = Invert Sequence Selection action.invert_column_selection = Invert Column Selection action.show = Show action.hide = Hide action.ok = OK action.set_defaults = Defaults action.create_group = Create Group action.remove_group = Remove Group action.edit_group = Edit Group action.border_colour = Border colour action.edit_new_group = Edit New Group action.hide_sequences = Hide Sequences action.sequences = Sequences action.ids = IDS action.ids_sequences = IDS and sequences action.reveal_all = Reveal All action.reveal_sequences = Reveal Sequences action.find_all = Find all action.find_next = Find next action.file = File action.view = View action.change_params = Change Parameters action.apply = Apply action.apply_threshold_all_groups = Apply threshold to all groups action.apply_all_groups = Apply to all Groups action.by_chain = By chain action.by_sequence = By Sequence action.paste_annotations = Paste Annotations action.format = Format action.select = Select action.new_view = New View action.close = Close action.add = Add action.save_as_default = Save as default action.save_as = Save as action.save = Save action.cancel_fetch = Cancel Fetch action.save_omit_hidden_columns = Save / Omit Hidden Columns action.change_font = Change Font action.change_font_tree_panel = Change Font (Tree Panel) action.colour = Colour action.calculate = Calculate action.select_all = Select all action.deselect_all = Deselect all action.invert_selection = Invert selection action.using_jmol = Using Jmol action.link = Link action.group_link = Group Links action.show_chain = Show Chain action.show_group = Show Group action.fetch_db_references = Fetch DB References -action.edit = Edit action.view_flanking_regions = Show flanking regions label.view_flanking_regions = Show sequence data either side of the subsequences involved in this alignment label.str = Str: label.seq = Seq: label.structures_manager = Structures Manager label.nickname = Nickname: label.url = URL: label.input_file_url = Enter URL or Input File label.select_feature = Select feature: label.name = Name label.name_param = Name: {0} label.group = Group label.group_name = Group Name label.group_description = Group Description label.edit_group_name_description = Edit Group Name/Description label.colour = Colour: label.description = Description: label.start = Start: label.end = End: label.current_parameter_set_name = Current parameter set name: label.service_action = Service Action: label.post_url = POST URL: label.url_suffix = URL Suffix label.sequence_source = Sequence Source label.per_seq = per Sequence label.result_vertically_separable = Results are vertically separable label.amend = Amend label.undo_command = Undo {0} label.redo_command = Redo {0} label.principal_component_analysis = Principal Component Analysis label.average_distance_identity = Average Distance Using % Identity label.neighbour_joining_identity = Neighbour Joining Using % Identity label.treecalc_title = {0} Using {1} label.tree_calc_av = Average Distance label.tree_calc_nj = Neighbour Joining label.select_score_model = Select score model label.score_model_pid = % Identity label.score_model_blosum62 = BLOSUM62 label.score_model_pam250 = PAM 250 label.score_model_conservation = Physicochemical property conservation label.score_model_enhconservation = Physicochemical property conservation label.status_bar = Status bar label.out_to_textbox = Output to Textbox label.clustalx = Clustalx label.clustal = Clustal label.zappo = Zappo label.taylor = Taylor label.blc = BLC label.fasta = Fasta label.msf = MSF label.pfam = PFAM label.pileup = Pileup label.pir = PIR label.hydrophobicity = Hydrophobicity label.helix_propensity = Helix Propensity label.strand_propensity = Strand Propensity label.turn_propensity = Turn Propensity label.buried_index = Buried Index label.purine_pyrimidine = Purine/Pyrimidine label.percentage_identity = Percentage Identity label.blosum62 = BLOSUM62 label.blosum62_score = BLOSUM62 Score label.tcoffee_scores = T-Coffee Scores label.average_distance_bloslum62 = Average Distance Using BLOSUM62 label.neighbour_blosum62 = Neighbour Joining Using BLOSUM62 label.show_annotations = Show annotations label.colour_text = Colour Text label.show_non_conversed = Show nonconserved label.overview_window = Overview Window label.none = None label.above_identity_threshold = Above Identity Threshold label.show_sequence_features = Show Sequence Features label.nucleotide = Nucleotide label.to_new_alignment = To New Alignment label.to_this_alignment = Add To This Alignment label.apply_colour_to_all_groups = Apply Colour To All Groups label.modify_identity_thereshold = Modify Identity Threshold... label.modify_conservation_thereshold = Modify Conservation Threshold... label.input_from_textbox = Input from textbox label.centre_column_labels = Centre column labels label.automatic_scrolling = Automatic Scrolling label.documentation = Documentation label.about = About... label.show_sequence_limits = Show Sequence Limits label.feature_settings = Feature Settings... label.sequence_features = Sequence Features label.all_columns = All Columns label.all_sequences = All Sequences label.selected_columns = Selected Columns label.selected_sequences = Selected Sequences label.all_but_selected_region = All but Selected Region (Shift+Ctrl+H) label.selected_region = Selected Region label.all_sequences_columns = All Sequences and Columns label.group_consensus = Group Consensus label.group_conservation = Group Conservation label.show_consensus_histogram = Show Consensus Histogram label.show_consensus_logo = Show Consensus Logo label.norm_consensus_logo = Normalise Consensus Logo label.apply_all_groups = Apply to all groups label.autocalculated_annotation = Autocalculated Annotation label.min_colour = Minimum Colour label.max_colour = Maximum Colour label.use_original_colours = Use Original Colours label.threshold_minmax = Threshold is min/max label.represent_group_with = Represent Group with {0} label.selection = Selection label.group_colour = Group Colour label.sequence = Sequence label.view_pdb_structure = View PDB Structure label.min = Min: label.max = Max: label.colour_by_label = Colour by label label.new_feature = New Feature label.match_case = Match Case label.view_alignment_editor = View in alignment editor label.labels = Labels label.output_values = Output Values... label.output_points = Output points... label.output_transformed_points = Output transformed points label.input_data = Input Data... label.nucleotide_matrix = Nucleotide matrix label.protein_matrix = Protein matrix label.show_bootstrap_values = Show Bootstrap Values label.show_distances = Show distances label.mark_unassociated_leaves = Mark Unassociated Leaves label.fit_to_window = Fit To Window label.newick_format = Newick Format label.select_newick_like_tree_file = Select a newick-like tree file label.colours = Colours label.view_mapping = View Mapping label.wireframe = Wireframe label.depthcue = Depthcue label.z_buffering = Z Buffering label.charge_cysteine = Charge & Cysteine label.all_chains_visible = All Chains Visible label.successfully_added_features_alignment = Successfully added features to alignment label.keyboard_editing_mode = Keyboard editing mode is {0} label.paste_features_annotations_Tcoffee_here = Paste your features / annotations / T-coffee score file here. label.removed_columns = Removed {0} columns. label.removed_empty_columns = Removed {0} empty columns. label.paste_newick_tree_file = Paste your Newick tree file here. label.order_by_params = Order by {0} label.html_content = {0} label.paste_pdb_file= Paste your PDB file here. label.paste_pdb_file_for_sequence = Paste PDB file for sequence {0} label.could_not_parse_newick_file = Could not parse Newick file\!\n {0} label.successfully_pasted_tcoffee_scores_to_alignment= Successfully pasted T-Coffee scores to alignment. label.failed_add_tcoffee_scores = Failed to add T-Coffee scores: label.successfully_pasted_annotation_to_alignment= Successfully pasted annotation to alignment. label.couldnt_parse_pasted_text_as_valid_annotation_feature_GFF_tcoffee_file = Couldn't parse pasted text as a valid annotation, feature, GFF, or T-Coffee score file label.successfully_pasted_alignment_file = Successfully pasted alignment file label.paste_your_alignment_file = Paste your alignment file here label.paste_your = Paste your label.finished_searching = Finished searching label.search_results= Search results {0} : {1} label.found_match_for = Found match for {0} label.font = Font: label.size = Size: label.style = Style: label.enter_redundancy_threshold = Enter the redundancy threshold label.calculating = Calculating.... label.modify_conservation_visibility = Modify conservation visibility label.colour_residues_above_occurence = Colour residues above % occurence label.set_this_label_text = set this label text label.sequences_from = Sequences from {0} label.successfully_loaded_file = Successfully loaded file {0} label.successfully_saved_to_file_in_format = Successfully saved to file: {0} in {1} format. label.copied_sequences_to_clipboard = Copied {0} sequences to clipboard. label.check_file_matches_sequence_ids_alignment = Check that the file matches sequence IDs in the alignment. label.problem_reading_tcoffee_score_file = Problem reading T-COFFEE score file label.source_to_target = {0} ... {1} label.per_sequence_only= Per-sequence only label.to_file = to File label.to_textbox = to Textbox label.jalview = Jalview label.csv_spreadsheet = CSV (Spreadsheet) label.status = [Status] label.channels = Channels label.channel_title_item_count = {0} ({1}) label.blog_item_published_on_date = {0} {1} label.select_das_service_from_table = Select a DAS service from the table to read a full description here. label.session_update = Session Update label.new_vamsas_session = New Vamsas Session label.load_vamsas_session = Load Vamsas Session label.save_vamsas_session = Save Vamsas Session label.select_vamsas_session_opened_as_new_vamsas_session= Select a vamsas session to be opened as a new vamsas session. label.open_saved_vamsas_session = Open a saved VAMSAS session label.groovy_console = Groovy Console... label.lineart = Lineart label.dont_ask_me_again = Don't ask me again label.select_eps_character_rendering_style = Select EPS character rendering style label.invert_selection = Invert Selection label.optimise_order = Optimise Order label.seq_sort_by_score = Seq sort by Score label.load_colours = Load Colours label.save_colours = Save Colours label.fetch_das_features = Fetch DAS Features label.selected_database_to_fetch_from = Selected {0} database {1} to fetch from {2} label.database_param = Database: {0} label.example = Example label.example_param = Example: {0} label.select_file_format_before_saving = You must select a file format before saving! label.file_format_not_specified = File format not specified label.alignment_contains_hidden_columns = The Alignment contains hidden columns.\nDo you want to save only the visible alignment? label.couldnt_save_file = Couldn't save file: {0} label.error_saving_file = Error Saving File label.remove_from_default_list = Remove from default list? label.remove_user_defined_colour = Remove user defined colour label.you_must_select_least_two_sequences = You must select at least 2 sequences. label.invalid_selection = Invalid Selection label.principal_component_analysis_must_take_least_four_input_sequences = Principal component analysis must take\nat least 4 input sequences. label.sequence_selection_insufficient = Sequence selection insufficient label.you_need_more_two_sequences_selected_build_tree = You need to have more than two sequences selected to build a tree! label.not_enough_sequences = Not enough sequences label.selected_region_to_tree_may_only_contain_residues_or_gaps = The selected region to create a tree may\nonly contain residues or gaps.\nTry using the Pad function in the edit menu,\nor one of the multiple sequence alignment web services. label.sequences_selection_not_aligned = Sequences in selection are not aligned label.sequences_must_be_aligned_before_creating_tree = The sequences must be aligned before creating a tree.\nTry using the Pad function in the edit menu,\n or one of the multiple sequence alignment web services. label.sequences_not_aligned = Sequences not aligned label.problem_reading_tree_file = Problem reading tree file label.possible_problem_with_tree_file = Possible problem with tree file label.select_at_least_three_bases_in_at_least_one_sequence_to_cDNA_translation = Please select at least three bases in at least one sequence in order to perform a cDNA translation. label.translation_failed = Translation Failed label.error_when_translating_sequences_submit_bug_report = Unfortunately, something went wrong when translating your sequences.\nPlease take a look in the Jalview java console\nand submit a bug report including the stacktrace. label.implementation_error = Implementation error: label.automatically_associate_pdb_files_with_sequences_same_name = Do you want to automatically associate the {0} PDB files with sequences in the alignment that have the same name? label.automatically_associate_pdb_files_by_name = Automatically Associate PDB files by name label.ignore_unmatched_dropped_files_info = Do you want to ignore the {0} files whose names did not match any sequence IDs ? label.ignore_unmatched_dropped_files = Ignore unmatched dropped files? label.enter_view_name = Enter View Name label.enter_label = Enter label label.enter_label_for_the_structure = Enter a label for the structure? label.pdb_entry_is_already_displayed = {0} is already displayed.\nDo you want to re-use this viewer ? label.map_sequences_to_visible_window = Map Sequences to Visible Window: {0} label.add_pdbentry_to_view = Do you want to add {0} to the view called\n'{1}'\n label.align_to_existing_structure_view = Align to existing structure view label.pdb_entries_couldnt_be_retrieved = The following pdb entries could not be retrieved from the PDB\:\n{0}\nPlease try downloading them manually. label.couldnt_load_file = Couldn't load file label.couldnt_find_pdb_id_in_file = Couldn't find a PDB id in the file supplied. Please enter an Id to identify this structure. label.no_pdb_id_in_file = No PDB Id in File label.couldnt_read_pasted_text = Couldn't read the pasted text {0} label.error_parsing_text = Error parsing text label.enter_local_das_source = Enter Nickname & URL of Local DAS Source label.you_can_only_edit_or_remove_local_das_sources = You can only edit or remove local DAS Sources! label.public_das_source = Public DAS source - not editable label.input_alignment_from_url = Input Alignment From URL label.input_alignment = Input Alignment label.couldnt_import_as_vamsas_session = Couldn't import '{0}' as a new vamsas session. label.vamsas_document_import_failed = Vamsas Document Import Failed label.couldnt_locate = Couldn't locate {0} label.url_not_found = URL not found label.no_link_selected = No link selected label.new_sequence_url_link = New sequence URL link label.cannot_edit_annotations_in_wrapped_view = Cannot edit annotations in wrapped view label.wrapped_view_no_edit = Wrapped view - no edit label.error_retrieving_data = Error Retrieving Data label.user_colour_scheme_must_have_name = User colour scheme must have a name label.no_name_colour_scheme = No name for colour scheme label.invalid_url = Invalid URL ! label.error_loading_file = Error loading file label.problems_opening_file = Encountered problems opening {0}!! label.file_open_error = File open error label.no_das_sources_selected_warn = No das sources were selected.\nPlease select some sources and\ntry again. label.no_das_sources_selected_title = No DAS Sources Selected label.colour_scheme_exists_overwrite = Colour scheme {0} exists.\nContinue saving colour scheme as {1}?" label.duplicate_scheme_name = Duplicate scheme name label.jalview_new_questionnaire = There is a new Questionnaire available. Would you like to complete it now ?\n label.jalview_user_survey = Jalview User Survey label.alignment_properties = Alignment Properties: {0} label.alignment_props = Alignment Properties label.input_cut_paste = Cut & Paste Input label.input_cut_paste_params = Cut & Paste Input - {0} label.alignment_output_command = Alignment output - {0} label.annotations = Annotations label.features = Features label.overview_params = Overview {0} label.paste_newick_file = Paste Newick file label.load_tree_from_file = From File - label.colour_by_annotation = Colour by Annotation label.selection_output_command = Selection output - {0} label.annotation_for_displayid =

Annotation for {0}

label.pdb_sequence_mapping = PDB - Sequence Mapping label.pca_details = PCA details label.redundancy_threshold_selection = Redundancy threshold selection label.user_defined_colours = User defined colours label.jalviewLite_release = JalviewLite - Release {0} label.jaview_build_date = Build date: {0} label.jalview_authors_1 = Authors: : Jim Procter, Andrew Waterhouse, Lauren Lui, Jan Engelhardt, Natasha Sherstnev, label.jalview_authors_2 = Daniel Barton, Michele Clamp, James Cuff, Steve Searle, David Martin & Geoff Barton. label.jalview_dev_managers = Development managed by The Barton Group, University of Dundee, Scotland, UK. label.jalview_distribution_lists = For help, see the FAQ at www.jalview.org and/or join the jalview-discuss@jalview.org mailing list label.jalview_please_cite = If you use Jalview, please cite: label.jalview_cite_1_authors = Waterhouse, A.M., Procter, J.B., Martin, D.M.A, Clamp, M. and Barton, G. J. (2009) label.jalview_cite_1_title = Jalview Version 2 - a multiple sequence alignment editor and analysis workbench label.jalview_cite_1_ref = Bioinformatics doi: 10.1093/bioinformatics/btp033 label.right_click = Right click label.to_add_annotation = to add annotation label.alignment_has_no_annotations = Alignment has no annotations label.retrieving_pdb_data = Retrieving PDB data... label.label = Label label.no_features_added_to_this_alignment = No Features added to this alignment!! label.features_can_be_added_from_searches_1 = (Features can be added from searches or label.features_can_be_added_from_searches_2 = from Jalview / GFF features files) label.calculating_pca= Calculating PCA label.reveal_columns = Reveal Columns label.jalview_cannot_open_file = Jalview can't open file label.jalview_applet = Jalview applet label.loading_data = Loading data label.memory_stats = Total Free Memory: {0} MB; Max Memory: {1} MB; {2} % label.calculating_tree = Calculating tree label.state_queueing = queuing label.state_running = running label.state_complete = complete label.state_completed = finished label.state_job_cancelled = job cancelled!! label.state_job_error = job error! label.server_error_try_later = Server Error! (try later) label.error_loading_pdb_data = Error loading PDB data!! label.fetching_pdb_data = Fetching PDB data... label.structure_type = Structure type label.settings_for_type = Settings for {0} label.view_full_application = View in Full Application label.load_associated_tree = Load Associated Tree ... label.load_features_annotations = Load Features/Annotations ... label.export_features = Export Features ... label.export_annotations = Export Annotations ... label.jalview_copy = Copy (Jalview Only) label.jalview_cut = Cut (Jalview Only) label.to_upper_case = To Upper Case label.to_lower_case = To Lower Case label.toggle_case = Toggle Case label.edit_name_description = Edit Name/Description ... label.create_sequence_feature = Create Sequence Feature ... label.edit_sequence = Edit Sequence label.edit_sequences = Edit Sequences label.sequence_details = Sequence Details label.jmol_help = Jmol Help label.all = All label.sort_by = Sort by label.sort_by_score = Sort by Score label.sort_by_density = Sort by Density label.sequence_sort_by_density = Sequence sort by Density label.reveal = Reveal label.hide_columns = Hide Columns label.load_jalview_annotations = Load Jalview Annotations or Features File label.load_tree_file = Load a tree file label.retrieve_parse_sequence_database_records_alignment_or_selected_sequences = Retrieve and parse sequence database records for the alignment or the currently selected sequences label.standard_databases = Standard Databases label.fetch_embl_uniprot = Fetch from EMBL/EMBLCDS or Uniprot/PDB and any selected DAS sources label.reset_min_max_colours_to_defaults = Reset min and max colours to defaults from user preferences. label.align_structures_using_linked_alignment_views = Align structures using {0} linked alignment views label.connect_to_session = Connect to session {0} label.threshold_feature_display_by_score = Threshold the feature display by score. label.threshold_feature_no_thereshold = No Threshold label.threshold_feature_above_thereshold = Above Threshold label.threshold_feature_below_thereshold = Below Threshold label.adjust_thereshold = Adjust threshold label.toggle_absolute_relative_display_threshold = Toggle between absolute and relative display threshold. label.display_features_same_type_different_label_using_different_colour = Display features of the same type with a different label using a different colour. (e.g. domain features) label.select_colour_minimum_value = Select Colour for Minimum Value label.select_colour_maximum_value = Select Colour for Maximum Value label.open_new_jmol_view_with_all_structures_associated_current_selection_superimpose_using_alignment = Open a new Jmol view with all structures associated with the current selection and superimpose them using the alignment. label.open_url_param = Open URL {0} label.open_url_seqs_param = Open URL ({0}..) ({1} seqs) label.load_pdb_file_associate_with_sequence = Load a PDB file and associate it with sequence '{0}' label.reveal_hidden_columns = Reveal Hidden Columns with Right Mouse Button label.dark_colour = Dark Colour label.light_colour = Light Colour label.highlightnode = Left click to select leaves.
Double-click to invert leaves.
Right click to change colour. label.load_colour_scheme = Load colour scheme label.toggle_enabled_views = When enabled, allows many views to be selected. label.edit_notes_parameter_set = Click to edit the notes for this parameter set. label.open_local_file = Open local file label.enable_automatically_sort_alignment_when_open_new_tree = Enable this to automatically sort
the alignment when you open
a new tree. label.listen_for_selections = Listen for selections label.selections_mirror_selections_made_same_sequences_other_views = When selected, selections in this view will mirror
selections made on the same sequences in other views. label.toggle_sequence_visibility = Shift+H toggles sequence visiblity label.toggle_columns_visibility = Ctrl+H toggles column visiblity. label.toggles_visibility_hidden_selected_regions = H toggles visibility of hidden or selected regions label.rename_tab_eXpand_reGroup= Right-click to rename tab
Press X to eXpand tabs, G to reGroup. label.right_align_sequence_id = Right Align Sequence Id label.sequence_id_tooltip = Sequence ID Tooltip label.no_services = label.select_copy_raw_html = Select this if you want to copy raw html label.share_data_vamsas_applications = Share data with other vamsas applications label.connect_to = Connect to label.join_existing_vamsas_session = Join an existing vamsas session label.from_url = from URL label.any_trees_calculated_or_loaded_alignment_automatically_sort = When selected, any trees calculated or loaded onto the alignment will automatically sort the alignment label.sort_with_new_tree = Sort With New Tree label.from_textbox = from Textbox label.window = Window label.preferences = Preferences label.tools = Tools label.fetch_sequences = Fetch Sequence(s) label.stop_vamsas_session = Stop Vamsas Session label.collect_garbage = Collect Garbage label.show_memory_usage = Show Memory Usage label.show_java_console = Show Java Console label.show_jalview_news = Show Jalview News label.monospaced_fonts_faster_to_render = Monospaced fonts are faster to render label.anti_alias_fonts = Anti-alias Fonts (Slower to render) label.monospaced_font= Monospaced label.quality = Quality label.maximize_window = Maximize Window label.conservation = Conservation label.consensus = Consensus label.histogram = Histogram label.logo = Logo label.non_positional_features = Non-positional Features label.database_references = Database References label.share_selection_across_views = Share selection across views label.scroll_highlighted_regions = Scroll to highlighted regions label.gap_symbol = Gap Symbol label.alignment_colour = Alignment Colour label.address = Address label.port = Port label.default_browser_unix = Default Browser (Unix) label.send_usage_statistics = Send usage statistics label.check_for_questionnaires = Check for questionnaires label.check_for_latest_version = Check for latest version label.url_linkfrom_sequence_id = URL link from Sequence ID label.use_proxy_server = Use a proxy server label.eps_rendering_style = EPS rendering style label.append_start_end = Append /start-end (/15-380) label.full_sequence_id = Full Sequence Id label.smooth_font = Smooth Font label.autocalculate_consensus = AutoCalculate Consensus label.pad_gaps = Pad Gaps label.pad_gaps_when_editing = Pad Gaps When Editing label.automatically_set_id_width = Automatically set ID width label.figure_id_column_width = Figure ID column width label.use_modeller_output = Use Modeller Output label.wrap_alignment = Wrap Alignment label.right_align_ids = Right Align Ids label.sequence_name_italics = Sequence Name Italics label.open_overview = Open Overview label.default_colour_scheme_for_alignment = Default Colour Scheme for alignment label.annotation_shading_default = Annotation Shading Default label.default_minimum_colour_annotation_shading = Default Minimum Colour for annotation shading label.default_maximum_colour_annotation_shading = Default Maximum Colour for annotation shading label.visual = Visual label.connections = Connections label.output = Output label.editing = Editing label.das_settings = DAS Settings label.web_services = Web Services label.right_click_to_edit_currently_selected_parameter = Right click to edit currently selected parameter. label.let_jmol_manage_structure_colours = Let Jmol manage structure colours label.marks_leaves_tree_not_associated_with_sequence = Marks leaves of tree not associated with a sequence label.index_web_services_menu_by_host_site = Index web services in menu by the host site label.option_want_informed_web_service_URL_cannot_be_accessed_jalview_when_starts_up = Check this option if you want to be informed
when a web service URL cannot be accessed by Jalview
when it starts up label.new_service_url = New Service URL label.edit_service_url = Edit Service URL label.delete_service_url = Delete Service URL label.details = Details label.options = Options label.parameters = Parameters label.available_das_sources = Available DAS Sources label.full_details = Full Details label.authority = Authority label.type = Type label.proxy_server = Proxy Server label.file_output = File Output label.select_input_type = Select input type label.set_options_for_type = Set options for type label.data_input_parameters = Data input parameters label.data_returned_by_service = Data returned by service label.rsbs_encoded_service = RSBS Encoded Service label.parsing_errors = Parsing errors label.simple_bioinformatics_rest_services = Simple Bioinformatics Rest Services label.web_service_discovery_urls = Web Service Discovery URLS label.input_parameter_name = Input Parameter name label.short_descriptive_name_for_service = Short descriptive name for service label.function_service_performs = What kind of function the service performs (e.g. alignment, analysis, search, etc). label.brief_description_service = Brief description of service label.url_post_data_service = URL to post data to service. Include any special parameters needed here label.optional_suffix = Optional suffix added to URL when retrieving results from service label.preferred_gap_character = Which gap character does this service prefer? label.gap_character = Gap character label.move_return_type_up_order= Move return type up order label.move_return_type_down_order= Move return type down order label.update_user_parameter_set = Update this existing user parameter set label.delete_user_parameter_set = Delete the currently selected user parameter set label.create_user_parameter_set = Create a new parameter set with the current settings. label.revert_changes_user_parameter_set = Undo all changes to the current parameter set label.start_job_current_settings = Start Job with current settings label.cancel_job_close_dialog = Close this dialog and cancel job label.input_output = Input/Output label.cut_paste = Cut'n'Paste label.adjusting_parameters_for_calculation = Adjusting parameters for existing Calculation label.2d_rna_structure_line = 2D RNA {0} label.2d_rna_sequence_name = 2D RNA - {0} label.edit_name_and_description_current_group = Edit name and description of current group. label.view_structure_for = View structure for {0} label.view_all_structures = View all {0} structures. label.view_all_representative_structures = View all {0} representative structures. label.open_new_jmol_view_with_all_representative_structures_associated_current_selection_superimpose_using_alignment = Opens a new Jmol view with all representative structures\nassociated with the current selection\nsuperimposed with the current alignment. label.associate_structure_with_sequence = Associate Structure with Sequence label.from_file = from file label.enter_pdb_id = Enter PDB Id label.discover_pdb_ids = Discover PDB ids label.text_colour = Text Colour label.structure = Structure label.view_structure = View Structure label.clustalx_colours = Clustalx colours label.above_identity_percentage = Above % Identity label.create_sequence_details_report_annotation_for = Annotation for {0} label.sequece_details_for = Sequece Details for {0} label.sequence_name = Sequence Name label.sequence_description = Sequence Description label.edit_sequence_name_description = Edit Sequence Name/Description label.spaces_converted_to_backslashes = Spaces have been converted to _ label.no_spaces_allowed_sequence_name = No spaces allowed in Sequence Name label.select_outline_colour = Select Outline Colour label.web_browser_not_found_unix = Unixers\: Couldn't find default web browser.\nAdd the full path to your browser in Preferences." label.web_browser_not_found = Web browser not found label.select_pdb_file_for = Select a PDB file for {0} label.html = HTML label.wrap = Wrap label.show_database_refs = Show Database Refs label.show_non_positional_features = Show Non-Positional Features label.save_png_image = Save As PNG Image label.load_tree_for_sequence_set = Load a tree for this sequence set label.export_image = Export Image label.vamsas_store = VAMSAS store label.translate_cDNA = Translate cDNA label.extract_scores = Extract Scores label.get_cross_refs = Get Cross References label.sort_alignment_new_tree = Sort Alignment With New Tree label.add_sequences = Add Sequences label.new_window = New Window label.refresh_available_sources = Refresh Available Sources label.use_registry = Use Registry label.add_local_source = Add Local Source label.set_as_default = Set as Default label.show_labels = Show labels label.background_colour = Background Colour label.associate_nodes_with = Associate Nodes With label.jalview_pca_calculation = Jalview PCA Calculation label.link_name = Link Name label.pdb_file = PDB file label.colour_with_jmol = Colour with Jmol label.align_structures = Align structures label.jmol = Jmol label.sort_alignment_by_tree = Sort Alignment By Tree label.mark_unlinked_leaves = Mark Unlinked Leaves label.associate_leaves_with = Associate Leaves With label.save_colour_scheme_with_unique_name_added_to_colour_menu = Save your colour scheme with a unique name and it will be added to the Colour menu label.case_sensitive = Case Sensitive label.lower_case_colour = Lower Case Colour label.index_by_host = Index by host label.index_by_type = Index by type label.enable_jabaws_services = Enable JABAWS Services label.display_warnings = Display warnings label.move_url_up = Move URL up label.move_url_down = Move URL down label.add_sbrs_definition = Add a SBRS definition label.edit_sbrs_definition = Edit SBRS definition label.delete_sbrs_definition = Delete SBRS definition label.your_sequences_have_been_verified = Your sequences have been verified against known sequence databases. Some of the ids have been\n altered, most likely the start/end residue will have been updated.\n Save your alignment to maintain the updated id.\n\n label.sequence_names_updated = Sequence names updated label.dbref_search_completed = DBRef search completed label.show_all_chains = Show all chains label.fetch_all_param = Fetch all {0} label.paste_new_window = Paste To New Window label.settings_for_param = Settings for {0} label.view_params = View {0} label.select_all_views = Select all views label.align_sequences_to_existing_alignment = Align sequences to an existing alignment label.realign_with_params = Realign with {0} label.calcname_with_default_settings = {0} with Defaults label.action_with_default_settings = {0} with default settings label.edit_settings_and_run = Edit settings and run... label.view_and_change_parameters_before_alignment = View and change the parameters before alignment label.run_with_preset_params = Run {0} with preset label.view_and_change_parameters_before_running_calculation = View and change parameters before running calculation label.view_documentation = View documentation label.select_return_type = Select return type label.translation_of_params = Translation of {0} label.features_for_params = Features for - {0} label.annotations_for_params = Annotations for - {0} label.generating_features_for_params = Generating features for - {0} label.generating_annotations_for_params = Generating annotations for - {0} label.varna_params = VARNA - {0} label.sequence_feature_settings = Sequence Feature Settings label.pairwise_aligned_sequences = Pairwise Aligned Sequences label.original_data_for_params = Original Data for {0} label.points_for_params = Points for {0} label.transformed_points_for_params = Transformed points for {0} label.graduated_color_for_params = Graduated Feature Colour for {0} label.select_backgroud_colour = Select Background Colour label.invalid_font = Invalid Font label.separate_multiple_accession_ids = Separate multiple accession ids with semi colon ";" label.replace_commas_semicolons = Replace commas with semi-colons label.parsing_failed_syntax_errors_shown_below_param = Parsing failed. Syntax errors shown below {0} -label.parsing_failed_unrecoverable_exception_thrown_param = \nParsing failed. An unrecoverable exception was thrown:\n {0} +label.parsing_failed_unrecoverable_exception_thrown_param = \nParsing failed. An unrecoverable exception was thrown\:\n {0} label.example_query_param = Example query: {0} label.enter_value_increase_conservation_visibility = Enter value to increase conservation visibility label.enter_percentage_identity_above_which_colour_residues = Enter % identity above which to colour residues -label.wswublast_client_credits = To display sequence features an exact Uniprot id with 100% sequence identity match must be entered.\nIn order to display these features, try changing the names of your sequences to the ids suggested below.\n\nRunning WSWUBlast at EBI.\nPlease quote Pillai S., Silventoinen V., Kallio K., Senger M., Sobhany S., Tate J., Velankar S., Golovin A., Henrick K., Rice P., Stoehr P., Lopez R.\nSOAP-based services provided by the European Bioinformatics Institute.\nNucleic Acids Res. 33(1):W25-W28 (2005)); +label.wswublast_client_credits = To display sequence features an exact Uniprot id with 100% sequence identity match must be entered.\nIn order to display these features, try changing the names of your sequences to the ids suggested below.\n\nRunning WSWUBlast at EBI.\nPlease quote Pillai S., Silventoinen V., Kallio K., Senger M., Sobhany S., Tate J., Velankar S., Golovin A., Henrick K., Rice P., Stoehr P., Lopez R.\nSOAP-based services provided by the European Bioinformatics Institute.\nNucleic Acids Res. 33(1)\:W25-W28 (2005)); label.blasting_for_unidentified_sequence = BLASTing for unidentified sequences label.select_columns_containing = Select columns containing label.select_columns_not_containing = Select columns that do not contain option.trim_retrieved_seqs = Trim retrieved sequences label.trim_retrieved_sequences = When the reference sequence is longer than the sequence that you are working with, only keep the relevant subsequences. +label.no_colour_selection_in_scheme = Please, make a colour selection before to apply colour scheme +label.no_colour_selection_warn = Error saving colour scheme \ No newline at end of file diff --git src/jalview/gui/UserDefinedColours.java src/jalview/gui/UserDefinedColours.java old mode 100755 new mode 100644 index 43c648e..34d9885 --- src/jalview/gui/UserDefinedColours.java +++ src/jalview/gui/UserDefinedColours.java @@ -1,989 +1,1027 @@ -/* - * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2) - * Copyright (C) 2014 The Jalview Authors - * - * This file is part of Jalview. - * - * Jalview is free software: you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation, either version 3 - * of the License, or (at your option) any later version. - * - * Jalview is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Jalview. If not, see . - * The Jalview Authors are detailed in the 'AUTHORS' file. - */ -package jalview.gui; - -import jalview.api.structures.JalviewStructureDisplayI; -import jalview.datamodel.SequenceGroup; -import jalview.io.JalviewFileChooser; -import jalview.jbgui.GUserDefinedColours; -import jalview.schemes.ColourSchemeI; -import jalview.schemes.ResidueProperties; -import jalview.schemes.UserColourScheme; -import jalview.util.ColorUtils; -import jalview.util.MessageManager; - -import java.awt.Color; -import java.awt.Font; -import java.awt.event.ActionEvent; -import java.awt.event.MouseEvent; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.InputStreamReader; -import java.io.OutputStreamWriter; -import java.io.PrintWriter; -import java.util.ArrayList; -import java.util.Hashtable; -import java.util.StringTokenizer; - -import javax.swing.JButton; -import javax.swing.JInternalFrame; -import javax.swing.JOptionPane; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; - -/** - * This panel allows the user to assign colours to Amino Acid residue codes, and - * save the colour scheme. - * - * @author Andrew Waterhouse - * @author Mungo Carstairs - */ -public class UserDefinedColours extends GUserDefinedColours implements - ChangeListener -{ - private static final int MY_FRAME_HEIGHT = 420; - - private static final int MY_FRAME_WIDTH = 810; - - private static final int MY_FRAME_WIDTH_CASE_SENSITIVE = 970; - - AlignmentPanel ap; - - SequenceGroup seqGroup; - - ArrayList selectedButtons; - - ColourSchemeI oldColourScheme; - - JInternalFrame frame; - - JalviewStructureDisplayI jmol; - - ArrayList upperCaseButtons; - - ArrayList lowerCaseButtons; - - /** - * Creates a new UserDefinedColours object. - * - * @param ap - * DOCUMENT ME! - * @param sg - * DOCUMENT ME! - */ - public UserDefinedColours(AlignmentPanel ap, SequenceGroup sg) - { - super(); - - lcaseColour.setEnabled(false); - - this.ap = ap; - seqGroup = sg; - - if (seqGroup != null) - { - oldColourScheme = seqGroup.cs; - } - else - { - oldColourScheme = ap.av.getGlobalColourScheme(); - } - - if (oldColourScheme instanceof UserColourScheme) - { - schemeName.setText(((UserColourScheme) oldColourScheme).getName()); - if (((UserColourScheme) oldColourScheme).getLowerCaseColours() != null) - { - caseSensitive.setSelected(true); - lcaseColour.setEnabled(true); - resetButtonPanel(true); - } - else - { - resetButtonPanel(false); - } - } - else - { - resetButtonPanel(false); - } - - showFrame(); - } - - public UserDefinedColours(JalviewStructureDisplayI jmol, - ColourSchemeI oldcs) - { - super(); - this.jmol = jmol; - - colorChooser.getSelectionModel().addChangeListener(this); - - oldColourScheme = oldcs; - - if (oldColourScheme instanceof UserColourScheme) - { - schemeName.setText(((UserColourScheme) oldColourScheme).getName()); - } - - resetButtonPanel(false); - - showFrame(); - - } - - void showFrame() - { - colorChooser.getSelectionModel().addChangeListener(this); - frame = new JInternalFrame(); - frame.setContentPane(this); - Desktop.addInternalFrame(frame, - MessageManager.getString("label.user_defined_colours"), - MY_FRAME_WIDTH, MY_FRAME_HEIGHT, true); - - if (seqGroup != null) - { - frame.setTitle(frame.getTitle() + " (" + seqGroup.getName() + ")"); - } - } - - void resetButtonPanel(boolean caseSensitive) - { - buttonPanel.removeAll(); - - if (upperCaseButtons == null) - { - upperCaseButtons = new ArrayList(); - } - - JButton button; - String label; - for (int i = 0; i < 20; i++) - { - if (caseSensitive) - { - label = ResidueProperties.aa[i]; - } - else - { - label = ResidueProperties.aa2Triplet.get(ResidueProperties.aa[i]) - .toString(); - } - - button = makeButton(label, ResidueProperties.aa[i], upperCaseButtons, - i); - - buttonPanel.add(button); - } - - buttonPanel.add(makeButton("B", "B", upperCaseButtons, 20)); - buttonPanel.add(makeButton("Z", "Z", upperCaseButtons, 21)); - buttonPanel.add(makeButton("X", "X", upperCaseButtons, 22)); - buttonPanel.add(makeButton("Gap", "-", upperCaseButtons, 23)); - - if (!caseSensitive) - { - gridLayout.setRows(6); - gridLayout.setColumns(4); - } - else - { - gridLayout.setRows(7); - int cols = 7; - gridLayout.setColumns(cols + 1); - - if (lowerCaseButtons == null) - { - lowerCaseButtons = new ArrayList(); - } - - for (int i = 0; i < 20; i++) - { - int row = i / cols + 1; - int index = (row * cols) + i; - button = makeButton(ResidueProperties.aa[i].toLowerCase(), - ResidueProperties.aa[i].toLowerCase(), lowerCaseButtons, i); - - buttonPanel.add(button, index); - } - } - - if (caseSensitive) - { - buttonPanel.add(makeButton("b", "b", lowerCaseButtons, 20)); - buttonPanel.add(makeButton("z", "z", lowerCaseButtons, 21)); - buttonPanel.add(makeButton("x", "x", lowerCaseButtons, 22)); - } - - // JAL-1360 widen the frame dynamically to accommodate case-sensitive AA - // codes - if (this.frame != null) - { - int newWidth = caseSensitive ? MY_FRAME_WIDTH_CASE_SENSITIVE - : MY_FRAME_WIDTH; - this.frame.setSize(newWidth, this.frame.getHeight()); - } - - buttonPanel.validate(); - validate(); - } - - /** - * DOCUMENT ME! - * - * @param evt - * DOCUMENT ME! - */ - @Override - public void stateChanged(ChangeEvent evt) - { - if (selectedButtons != null) - { - JButton button = null; - final Color newColour = colorChooser.getColor(); - for (int i = 0; i < selectedButtons.size(); i++) - { - button = selectedButtons.get(i); - button.setBackground(newColour); - button.setForeground(ColorUtils.brighterThan(newColour)); - } - if (button == lcaseColour) - { - for (int i = 0; i < lowerCaseButtons.size(); i++) - { - button = lowerCaseButtons.get(i); - button.setBackground(newColour); - button.setForeground(ColorUtils.brighterThan(button - .getBackground())); - } - } - } - } - - /** - * Performs actions when a residue button is clicked. This manages the button - * selection set (highlighted by brighter foreground text). - *

- * On select button(s) with Ctrl/click or Shift/click: set button foreground - * text to brighter than background. - *

- * On unselect button(s) with Ctrl/click on selected, or click to release - * current selection: reset foreground text to darker than background. - *

- * Simple click: clear selection (resetting foreground to darker); set clicked - * button foreground to brighter - *

- * Finally, synchronize the colour chooser to the colour of the first button - * in the selected set. - * - * @param e - */ - public void colourButtonPressed(MouseEvent e) - { - if (selectedButtons == null) - { - selectedButtons = new ArrayList(); - } - - JButton pressed = (JButton) e.getSource(); - - if (e.isShiftDown()) - { - JButton start, end = (JButton) e.getSource(); - if (selectedButtons.size() > 0) - { - start = selectedButtons.get(selectedButtons.size() - 1); - } - else - { - start = (JButton) e.getSource(); - } - - int startIndex = 0, endIndex = 0; - for (int b = 0; b < buttonPanel.getComponentCount(); b++) - { - if (buttonPanel.getComponent(b) == start) - { - startIndex = b; - } - if (buttonPanel.getComponent(b) == end) - { - endIndex = b; - } - } - - if (startIndex > endIndex) - { - int temp = startIndex; - startIndex = endIndex; - endIndex = temp; - } - - for (int b = startIndex; b <= endIndex; b++) - { - JButton button = (JButton) buttonPanel.getComponent(b); - if (!selectedButtons.contains(button)) - { - button.setForeground(ColorUtils.brighterThan(button - .getBackground())); - selectedButtons.add(button); - } - } - } - else if (!e.isControlDown()) - { - for (int b = 0; b < selectedButtons.size(); b++) - { - JButton button = selectedButtons.get(b); - button.setForeground(ColorUtils.darkerThan(button.getBackground())); - } - selectedButtons.clear(); - pressed.setForeground(ColorUtils.brighterThan(pressed.getBackground())); - selectedButtons.add(pressed); - - } - else if (e.isControlDown()) - { - if (selectedButtons.contains(pressed)) - { - pressed.setForeground(ColorUtils.darkerThan(pressed.getBackground())); - selectedButtons.remove(pressed); - } - else - { - pressed.setForeground(ColorUtils.brighterThan(pressed - .getBackground())); - selectedButtons.add(pressed); - } - } - - if (selectedButtons.size() > 0) - { - colorChooser.setColor((selectedButtons.get(0)).getBackground()); - } - } - - /** - * DOCUMENT ME! - * - * @param label - * DOCUMENT ME! - * @param aa - * DOCUMENT ME! - */ - JButton makeButton(String label, String aa, - ArrayList caseSensitiveButtons, int buttonIndex) - { - final JButton button; - Color col; - - if (buttonIndex < caseSensitiveButtons.size()) - { - button = caseSensitiveButtons.get(buttonIndex); - col = button.getBackground(); - } - else - { - button = new JButton(); - button.addMouseListener(new java.awt.event.MouseAdapter() - { - @Override - public void mouseClicked(MouseEvent e) - { - colourButtonPressed(e); - } - }); - - caseSensitiveButtons.add(button); - - col = Color.white; - if (oldColourScheme != null) - { - try - { - col = oldColourScheme.findColour(aa.charAt(0), -1, null); - } catch (Exception ex) - { - } - } - } - - if (caseSensitive.isSelected()) - { - button.setMargin(new java.awt.Insets(2, 2, 2, 2)); - } - else - { - button.setMargin(new java.awt.Insets(2, 14, 2, 14)); - } - - button.setOpaque(true); // required for the next line to have effect - button.setBackground(col); - button.setText(label); - button.setForeground(ColorUtils.darkerThan(col)); - button.setFont(new java.awt.Font("Verdana", Font.BOLD, 10)); - - return button; - } - - /** - * DOCUMENT ME! - * - * @param e - * DOCUMENT ME! - */ - @Override - protected void okButton_actionPerformed(ActionEvent e) - { - applyButton_actionPerformed(null); - - try - { - frame.setClosed(true); - } catch (Exception ex) - { - } - } - - /** - * DOCUMENT ME! - * - * @param e - * DOCUMENT ME! - */ - @Override - protected void applyButton_actionPerformed(ActionEvent e) - { - UserColourScheme ucs = getSchemeFromButtons(); - ucs.setName(schemeName.getText()); - - if (seqGroup != null) - { - seqGroup.cs = ucs; - ap.paintAlignment(true); - } - else if (ap != null) - { - ap.alignFrame.changeColour(ucs); - } - else if (jmol != null) - { - jmol.setJalviewColourScheme(ucs); - } - } - - UserColourScheme getSchemeFromButtons() - { - - Color[] newColours = new Color[24]; - - for (int i = 0; i < 24; i++) - { - JButton button = upperCaseButtons.get(i); - newColours[i] = button.getBackground(); - } - - UserColourScheme ucs = new UserColourScheme(newColours); - - if (caseSensitive.isSelected()) - { - newColours = new Color[23]; - for (int i = 0; i < 23; i++) - { - JButton button = lowerCaseButtons.get(i); - newColours[i] = button.getBackground(); - } - ucs.setLowerCaseColours(newColours); - } - - if (ap != null) - { - ucs.setThreshold(0, ap.av.getIgnoreGapsConsensus()); - } - - return ucs; - } - - /** - * DOCUMENT ME! - * - * @param e - * DOCUMENT ME! - */ - @Override - protected void loadbutton_actionPerformed(ActionEvent e) - { - upperCaseButtons = new ArrayList(); - lowerCaseButtons = new ArrayList(); - - JalviewFileChooser chooser = new JalviewFileChooser( - jalview.bin.Cache.getProperty("LAST_DIRECTORY"), new String[] - { "jc" }, new String[] - { "Jalview User Colours" }, "Jalview User Colours"); - chooser.setFileView(new jalview.io.JalviewFileView()); - chooser.setDialogTitle(MessageManager - .getString("label.load_colour_scheme")); - chooser.setToolTipText(MessageManager.getString("action.load")); - - int value = chooser.showOpenDialog(this); - - if (value == JalviewFileChooser.APPROVE_OPTION) - { - File choice = chooser.getSelectedFile(); - jalview.bin.Cache.setProperty("LAST_DIRECTORY", choice.getParent()); - String defaultColours = jalview.bin.Cache.getDefault( - "USER_DEFINED_COLOURS", choice.getPath()); - if (defaultColours.indexOf(choice.getPath()) == -1) - { - defaultColours = defaultColours.concat("|") - .concat(choice.getPath()); - } - - jalview.bin.Cache.setProperty("USER_DEFINED_COLOURS", defaultColours); - - UserColourScheme ucs = loadColours(choice.getAbsolutePath()); - Color[] colors = ucs.getColours(); - schemeName.setText(ucs.getName()); - - if (ucs.getLowerCaseColours() != null) - { - caseSensitive.setSelected(true); - lcaseColour.setEnabled(true); - resetButtonPanel(true); - for (int i = 0; i < lowerCaseButtons.size(); i++) - { - JButton button = lowerCaseButtons.get(i); - button.setBackground(ucs.getLowerCaseColours()[i]); - } - - } - else - { - caseSensitive.setSelected(false); - lcaseColour.setEnabled(false); - resetButtonPanel(false); - } - - for (int i = 0; i < upperCaseButtons.size(); i++) - { - JButton button = upperCaseButtons.get(i); - button.setBackground(colors[i]); - } - - } - } - - /** - * DOCUMENT ME! - * - * @return DOCUMENT ME! - */ - public static UserColourScheme loadDefaultColours() - { - UserColourScheme ret = null; - - String colours = jalview.bin.Cache.getProperty("USER_DEFINED_COLOURS"); - if (colours != null) - { - if (colours.indexOf("|") > -1) - { - colours = colours.substring(0, colours.indexOf("|")); - } - - ret = loadColours(colours); - } - - if (ret == null) - { - Color[] newColours = new Color[24]; - for (int i = 0; i < 24; i++) - { - newColours[i] = Color.white; - } - ret = new UserColourScheme(newColours); - } - - return ret; - } - - /** - * DOCUMENT ME! - * - * @param file - * DOCUMENT ME! - * - * @return DOCUMENT ME! - */ - static UserColourScheme loadColours(String file) - { - UserColourScheme ucs = null; - Color[] newColours = null; - try - { - InputStreamReader in = new InputStreamReader( - new FileInputStream(file), "UTF-8"); - - jalview.schemabinding.version2.JalviewUserColours jucs = new jalview.schemabinding.version2.JalviewUserColours(); - - org.exolab.castor.xml.Unmarshaller unmar = new org.exolab.castor.xml.Unmarshaller( - jucs); - jucs = (jalview.schemabinding.version2.JalviewUserColours) unmar - .unmarshal(in); - - newColours = new Color[24]; - - Color[] lowerCase = null; - boolean caseSensitive = false; - - String name; - int index; - for (int i = 0; i < jucs.getColourCount(); i++) - { - name = jucs.getColour(i).getName(); - if (ResidueProperties.aa3Hash.containsKey(name)) - { - index = ((Integer) ResidueProperties.aa3Hash.get(name)) - .intValue(); - } - else - { - index = ResidueProperties.aaIndex[name.charAt(0)]; - } - if (index == -1) - { - continue; - } - - if (name.toLowerCase().equals(name)) - { - if (lowerCase == null) - { - lowerCase = new Color[23]; - } - caseSensitive = true; - lowerCase[index] = new Color(Integer.parseInt(jucs.getColour(i) - .getRGB(), 16)); - } - else - { - newColours[index] = new Color(Integer.parseInt(jucs.getColour(i) - .getRGB(), 16)); - } - } - - if (newColours != null) - { - ucs = new UserColourScheme(newColours); - ucs.setName(jucs.getSchemeName()); - if (caseSensitive) - { - ucs.setLowerCaseColours(lowerCase); - } - } - - } catch (Exception ex) - { - // Could be Archive Jalview format - try - { - InputStreamReader in = new InputStreamReader(new FileInputStream( - file), "UTF-8"); - - jalview.binding.JalviewUserColours jucs = new jalview.binding.JalviewUserColours(); - - jucs = jucs.unmarshal(in); - - newColours = new Color[jucs.getColourCount()]; - - for (int i = 0; i < 24; i++) - { - newColours[i] = new Color(Integer.parseInt(jucs.getColour(i) - .getRGB(), 16)); - } - if (newColours != null) - { - ucs = new UserColourScheme(newColours); - ucs.setName(jucs.getSchemeName()); - } - } catch (Exception ex2) - { - ex2.printStackTrace(); - } - - if (newColours == null) - { - System.out.println("Error loading User ColourFile\n" + ex); - } - } - - return ucs; - } - - /** - * DOCUMENT ME! - * - * @param e - * DOCUMENT ME! - */ - @Override - protected void savebutton_actionPerformed(ActionEvent e) - { - if (schemeName.getText().trim().length() < 1) - { - JOptionPane.showInternalMessageDialog(Desktop.desktop, MessageManager - .getString("label.user_colour_scheme_must_have_name"), - MessageManager.getString("label.no_name_colour_scheme"), - JOptionPane.WARNING_MESSAGE); - return; - } - - if (userColourSchemes != null - && userColourSchemes.containsKey(schemeName.getText())) - { - int reply = JOptionPane.showInternalConfirmDialog(Desktop.desktop, - MessageManager.formatMessage( - "label.colour_scheme_exists_overwrite", new Object[] - { schemeName.getText(), schemeName.getText() }), - MessageManager.getString("label.duplicate_scheme_name"), - JOptionPane.YES_NO_OPTION); - if (reply != JOptionPane.YES_OPTION) - { - return; - } - - userColourSchemes.remove(schemeName.getText()); - } - JalviewFileChooser chooser = new JalviewFileChooser( - jalview.bin.Cache.getProperty("LAST_DIRECTORY"), new String[] - { "jc" }, new String[] - { "Jalview User Colours" }, "Jalview User Colours"); - - chooser.setFileView(new jalview.io.JalviewFileView()); - chooser.setDialogTitle("Save colour scheme"); - chooser.setToolTipText(MessageManager.getString("action.save")); - - int value = chooser.showSaveDialog(this); - - if (value == JalviewFileChooser.APPROVE_OPTION) - { - String choice = chooser.getSelectedFile().getPath(); - String defaultColours = jalview.bin.Cache.getDefault( - "USER_DEFINED_COLOURS", choice); - if (defaultColours.indexOf(choice) == -1) - { - if (defaultColours.length() > 0) - { - defaultColours = defaultColours.concat("|"); - } - defaultColours = defaultColours.concat(choice); - } - - userColourSchemes.put(schemeName.getText(), getSchemeFromButtons()); - - ap.alignFrame.updateUserColourMenu(); - - jalview.bin.Cache.setProperty("USER_DEFINED_COLOURS", defaultColours); - - jalview.schemabinding.version2.JalviewUserColours ucs = new jalview.schemabinding.version2.JalviewUserColours(); - - ucs.setSchemeName(schemeName.getText()); - try - { - PrintWriter out = new PrintWriter(new OutputStreamWriter( - new FileOutputStream(choice), "UTF-8")); - - for (int i = 0; i < buttonPanel.getComponentCount(); i++) - { - JButton button = (JButton) buttonPanel.getComponent(i); - jalview.schemabinding.version2.Colour col = new jalview.schemabinding.version2.Colour(); - col.setName(button.getText()); - col.setRGB(jalview.util.Format.getHexString(button - .getBackground())); - ucs.addColour(col); - } - - ucs.marshal(out); - out.close(); - } catch (Exception ex) - { - ex.printStackTrace(); - } - } - } - - /** - * DOCUMENT ME! - * - * @param e - * DOCUMENT ME! - */ - @Override - protected void cancelButton_actionPerformed(ActionEvent e) - { - if (ap != null) - { - if (seqGroup != null) - { - seqGroup.cs = oldColourScheme; - } - else if (ap != null) - { - ap.av.setGlobalColourScheme(oldColourScheme); - } - ap.paintAlignment(true); - } - - if (jmol != null) - { - jmol.setJalviewColourScheme(oldColourScheme); - } - - try - { - frame.setClosed(true); - } catch (Exception ex) - { - } - } - - static Hashtable userColourSchemes; - - public static Hashtable getUserColourSchemes() - { - return userColourSchemes; - } - - public static void initUserColourSchemes(String files) - { - userColourSchemes = new Hashtable(); - - if (files == null || files.length() == 0) - { - return; - } - - // In case colours can't be loaded, we'll remove them - // from the default list here. - StringBuffer coloursFound = new StringBuffer(); - StringTokenizer st = new StringTokenizer(files, "|"); - while (st.hasMoreElements()) - { - String file = st.nextToken(); - try - { - UserColourScheme ucs = loadColours(file); - if (ucs != null) - { - if (coloursFound.length() > 0) - { - coloursFound.append("|"); - } - coloursFound.append(file); - userColourSchemes.put(ucs.getName(), ucs); - } - } catch (Exception ex) - { - System.out.println("Error loading User ColourFile\n" + ex); - } - } - if (!files.equals(coloursFound.toString())) - { - if (coloursFound.toString().length() > 1) - { - jalview.bin.Cache.setProperty("USER_DEFINED_COLOURS", - coloursFound.toString()); - } - else - { - jalview.bin.Cache.applicationProperties - .remove("USER_DEFINED_COLOURS"); - } - } - } - - public static void removeColourFromDefaults(String target) - { - // The only way to find colours by name is to load them in - // In case colours can't be loaded, we'll remove them - // from the default list here. - - userColourSchemes = new Hashtable(); - - StringBuffer coloursFound = new StringBuffer(); - StringTokenizer st = new StringTokenizer( - jalview.bin.Cache.getProperty("USER_DEFINED_COLOURS"), "|"); - - while (st.hasMoreElements()) - { - String file = st.nextToken(); - try - { - UserColourScheme ucs = loadColours(file); - if (ucs != null && !ucs.getName().equals(target)) - { - if (coloursFound.length() > 0) - { - coloursFound.append("|"); - } - coloursFound.append(file); - userColourSchemes.put(ucs.getName(), ucs); - } - } catch (Exception ex) - { - System.out.println("Error loading User ColourFile\n" + ex); - } - } - - if (coloursFound.toString().length() > 1) - { - jalview.bin.Cache.setProperty("USER_DEFINED_COLOURS", - coloursFound.toString()); - } - else - { - jalview.bin.Cache.applicationProperties - .remove("USER_DEFINED_COLOURS"); - } - - } - - @Override - public void caseSensitive_actionPerformed(ActionEvent e) - { - resetButtonPanel(caseSensitive.isSelected()); - lcaseColour.setEnabled(caseSensitive.isSelected()); - } - - @Override - public void lcaseColour_actionPerformed(ActionEvent e) - { - if (selectedButtons == null) - { - selectedButtons = new ArrayList(); - } - else - { - selectedButtons.clear(); - } - selectedButtons.add(lcaseColour); - } -} +/* + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2) + * Copyright (C) 2014 The Jalview Authors + * + * This file is part of Jalview. + * + * Jalview is free software: you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation, either version 3 + * of the License, or (at your option) any later version. + * + * Jalview is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Jalview. If not, see . + * The Jalview Authors are detailed in the 'AUTHORS' file. + */ +package jalview.gui; + +import jalview.api.structures.JalviewStructureDisplayI; +import jalview.datamodel.SequenceGroup; +import jalview.io.JalviewFileChooser; +import jalview.jbgui.GUserDefinedColours; +import jalview.schemes.ColourSchemeI; +import jalview.schemes.ResidueProperties; +import jalview.schemes.UserColourScheme; +import jalview.util.ColorUtils; +import jalview.util.MessageManager; + +import java.awt.Color; +import java.awt.Font; +import java.awt.event.ActionEvent; +import java.awt.event.MouseEvent; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.InputStreamReader; +import java.io.OutputStreamWriter; +import java.io.PrintWriter; +import java.util.ArrayList; +import java.util.Hashtable; +import java.util.StringTokenizer; + +import javax.swing.JButton; +import javax.swing.JInternalFrame; +import javax.swing.JOptionPane; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; + +/** + * This panel allows the user to assign colours to Amino Acid residue codes, and + * save the colour scheme. + * + * @author Andrew Waterhouse + * @author Mungo Carstairs + */ +public class UserDefinedColours extends GUserDefinedColours implements + ChangeListener +{ + private static final int MY_FRAME_HEIGHT = 420; + + private static final int MY_FRAME_WIDTH = 810; + + private static final int MY_FRAME_WIDTH_CASE_SENSITIVE = 970; + + AlignmentPanel ap; + + SequenceGroup seqGroup; + + ArrayList selectedButtons; + + ColourSchemeI oldColourScheme; + + JInternalFrame frame; + + JalviewStructureDisplayI jmol; + + ArrayList upperCaseButtons; + + ArrayList lowerCaseButtons; + + /** + * Creates a new UserDefinedColours object. + * + * @param ap + * DOCUMENT ME! + * @param sg + * DOCUMENT ME! + */ + public UserDefinedColours(AlignmentPanel ap, SequenceGroup sg) + { + super(); + + lcaseColour.setEnabled(false); + + this.ap = ap; + seqGroup = sg; + + if (seqGroup != null) + { + oldColourScheme = seqGroup.cs; + } + else + { + oldColourScheme = ap.av.getGlobalColourScheme(); + } + + if (oldColourScheme instanceof UserColourScheme) + { + schemeName.setText(((UserColourScheme) oldColourScheme).getName()); + if (((UserColourScheme) oldColourScheme).getLowerCaseColours() != null) + { + caseSensitive.setSelected(true); + lcaseColour.setEnabled(true); + resetButtonPanel(true); + } + else + { + resetButtonPanel(false); + } + } + else + { + resetButtonPanel(false); + } + + showFrame(); + } + + public UserDefinedColours(JalviewStructureDisplayI jmol, + ColourSchemeI oldcs) + { + super(); + this.jmol = jmol; + + colorChooser.getSelectionModel().addChangeListener(this); + + oldColourScheme = oldcs; + + if (oldColourScheme instanceof UserColourScheme) + { + schemeName.setText(((UserColourScheme) oldColourScheme).getName()); + } + + resetButtonPanel(false); + + showFrame(); + + } + + void showFrame() + { + colorChooser.getSelectionModel().addChangeListener(this); + frame = new JInternalFrame(); + frame.setContentPane(this); + Desktop.addInternalFrame(frame, + MessageManager.getString("label.user_defined_colours"), + MY_FRAME_WIDTH, MY_FRAME_HEIGHT, true); + + if (seqGroup != null) + { + frame.setTitle(frame.getTitle() + " (" + seqGroup.getName() + ")"); + } + } + + void resetButtonPanel(boolean caseSensitive) + { + buttonPanel.removeAll(); + + if (upperCaseButtons == null) + { + upperCaseButtons = new ArrayList(); + } + + JButton button; + String label; + for (int i = 0; i < 20; i++) + { + if (caseSensitive) + { + label = ResidueProperties.aa[i]; + } + else + { + label = ResidueProperties.aa2Triplet.get(ResidueProperties.aa[i]) + .toString(); + } + + button = makeButton(label, ResidueProperties.aa[i], upperCaseButtons, + i); + + buttonPanel.add(button); + } + + buttonPanel.add(makeButton("B", "B", upperCaseButtons, 20)); + buttonPanel.add(makeButton("Z", "Z", upperCaseButtons, 21)); + buttonPanel.add(makeButton("X", "X", upperCaseButtons, 22)); + buttonPanel.add(makeButton("Gap", "-", upperCaseButtons, 23)); + + if (!caseSensitive) + { + gridLayout.setRows(6); + gridLayout.setColumns(4); + } + else + { + gridLayout.setRows(7); + int cols = 7; + gridLayout.setColumns(cols + 1); + + if (lowerCaseButtons == null) + { + lowerCaseButtons = new ArrayList(); + } + + for (int i = 0; i < 20; i++) + { + int row = i / cols + 1; + int index = (row * cols) + i; + button = makeButton(ResidueProperties.aa[i].toLowerCase(), + ResidueProperties.aa[i].toLowerCase(), lowerCaseButtons, i); + + buttonPanel.add(button, index); + } + } + + if (caseSensitive) + { + buttonPanel.add(makeButton("b", "b", lowerCaseButtons, 20)); + buttonPanel.add(makeButton("z", "z", lowerCaseButtons, 21)); + buttonPanel.add(makeButton("x", "x", lowerCaseButtons, 22)); + } + + // JAL-1360 widen the frame dynamically to accommodate case-sensitive AA + // codes + if (this.frame != null) + { + int newWidth = caseSensitive ? MY_FRAME_WIDTH_CASE_SENSITIVE + : MY_FRAME_WIDTH; + this.frame.setSize(newWidth, this.frame.getHeight()); + } + + buttonPanel.validate(); + validate(); + } + + /** + * DOCUMENT ME! + * + * @param evt + * DOCUMENT ME! + */ + @Override + public void stateChanged(ChangeEvent evt) + { + if (selectedButtons != null) + { + JButton button = null; + final Color newColour = colorChooser.getColor(); + for (int i = 0; i < selectedButtons.size(); i++) + { + button = selectedButtons.get(i); + button.setBackground(newColour); + button.setForeground(ColorUtils.brighterThan(newColour)); + } + if (button == lcaseColour) + { + for (int i = 0; i < lowerCaseButtons.size(); i++) + { + button = lowerCaseButtons.get(i); + button.setBackground(newColour); + button.setForeground(ColorUtils.brighterThan(button + .getBackground())); + } + } + } + } + + /** + * Performs actions when a residue button is clicked. This manages the button + * selection set (highlighted by brighter foreground text). + *

+ * On select button(s) with Ctrl/click or Shift/click: set button foreground + * text to brighter than background. + *

+ * On unselect button(s) with Ctrl/click on selected, or click to release + * current selection: reset foreground text to darker than background. + *

+ * Simple click: clear selection (resetting foreground to darker); set clicked + * button foreground to brighter + *

+ * Finally, synchronize the colour chooser to the colour of the first button + * in the selected set. + * + * @param e + */ + public void colourButtonPressed(MouseEvent e) + { + if (selectedButtons == null) + { + selectedButtons = new ArrayList(); + } + + JButton pressed = (JButton) e.getSource(); + + if (e.isShiftDown()) + { + JButton start, end = (JButton) e.getSource(); + if (selectedButtons.size() > 0) + { + start = selectedButtons.get(selectedButtons.size() - 1); + } + else + { + start = (JButton) e.getSource(); + } + + int startIndex = 0, endIndex = 0; + for (int b = 0; b < buttonPanel.getComponentCount(); b++) + { + if (buttonPanel.getComponent(b) == start) + { + startIndex = b; + } + if (buttonPanel.getComponent(b) == end) + { + endIndex = b; + } + } + + if (startIndex > endIndex) + { + int temp = startIndex; + startIndex = endIndex; + endIndex = temp; + } + + for (int b = startIndex; b <= endIndex; b++) + { + JButton button = (JButton) buttonPanel.getComponent(b); + if (!selectedButtons.contains(button)) + { + button.setForeground(ColorUtils.brighterThan(button + .getBackground())); + selectedButtons.add(button); + } + } + } + else if (!e.isControlDown()) + { + for (int b = 0; b < selectedButtons.size(); b++) + { + JButton button = selectedButtons.get(b); + button.setForeground(ColorUtils.darkerThan(button.getBackground())); + } + selectedButtons.clear(); + pressed.setForeground(ColorUtils.brighterThan(pressed.getBackground())); + selectedButtons.add(pressed); + + } + else if (e.isControlDown()) + { + if (selectedButtons.contains(pressed)) + { + pressed.setForeground(ColorUtils.darkerThan(pressed.getBackground())); + selectedButtons.remove(pressed); + } + else + { + pressed.setForeground(ColorUtils.brighterThan(pressed + .getBackground())); + selectedButtons.add(pressed); + } + } + + if (selectedButtons.size() > 0) + { + colorChooser.setColor((selectedButtons.get(0)).getBackground()); + } + } + + /** + * DOCUMENT ME! + * + * @param label + * DOCUMENT ME! + * @param aa + * DOCUMENT ME! + */ + JButton makeButton(String label, String aa, + ArrayList caseSensitiveButtons, int buttonIndex) + { + final JButton button; + Color col; + + if (buttonIndex < caseSensitiveButtons.size()) + { + button = caseSensitiveButtons.get(buttonIndex); + col = button.getBackground(); + } + else + { + button = new JButton(); + button.addMouseListener(new java.awt.event.MouseAdapter() + { + @Override + public void mouseClicked(MouseEvent e) + { + colourButtonPressed(e); + } + }); + + caseSensitiveButtons.add(button); + + col = Color.white; + if (oldColourScheme != null) + { + try + { + col = oldColourScheme.findColour(aa.charAt(0), -1, null); + } catch (Exception ex) + { + } + } + } + + if (caseSensitive.isSelected()) + { + button.setMargin(new java.awt.Insets(2, 2, 2, 2)); + } + else + { + button.setMargin(new java.awt.Insets(2, 14, 2, 14)); + } + + button.setOpaque(true); // required for the next line to have effect + button.setBackground(col); + button.setText(label); + button.setForeground(ColorUtils.darkerThan(col)); + button.setFont(new java.awt.Font("Verdana", Font.BOLD, 10)); + + return button; + } + + /** + * DOCUMENT ME! + * + * @param e + * DOCUMENT ME! + */ + @Override + protected void okButton_actionPerformed(ActionEvent e) + { + //Check if the user have done any selection + boolean showWarning = (upperCaseButtons==null) || + ((upperCaseButtons!=null) && (upperCaseButtons.size()==0)) || + (lowerCaseButtons==null) || + ((lowerCaseButtons!=null) && (lowerCaseButtons.size()==0)); + if (showWarning){ + JOptionPane.showMessageDialog(Desktop.desktop, + MessageManager.getString("label.no_colour_selection_in_scheme"),MessageManager.getString("label.no_colour_selection_warn"), + JOptionPane.WARNING_MESSAGE); + + }else{ + applyButton_actionPerformed(null); + + try + { + frame.setClosed(true); + } catch (Exception ex) + { + } + } + } + + /** + * DOCUMENT ME! + * + * @param e + * DOCUMENT ME! + */ + @Override + protected void applyButton_actionPerformed(ActionEvent e) + { + //Check if the user have done any selection + boolean showWarning = (upperCaseButtons==null) || + ((upperCaseButtons!=null) && (upperCaseButtons.size()==0)) || + (lowerCaseButtons==null) || + ((lowerCaseButtons!=null) && (lowerCaseButtons.size()==0)); + if (showWarning){ + JOptionPane.showMessageDialog(Desktop.desktop, + MessageManager.getString("label.no_colour_selection_in_scheme"),MessageManager.getString("label.no_colour_selection_warn"), + JOptionPane.WARNING_MESSAGE); + + } + UserColourScheme ucs = getSchemeFromButtons(); + ucs.setName(schemeName.getText()); + + if (seqGroup != null) + { + seqGroup.cs = ucs; + ap.paintAlignment(true); + } + else if (ap != null) + { + ap.alignFrame.changeColour(ucs); + } + else if (jmol != null) + { + jmol.setJalviewColourScheme(ucs); + } + } + + UserColourScheme getSchemeFromButtons() + { + + Color[] newColours = new Color[24]; + + int length = upperCaseButtons.size(); + if (length<24){ + int i = 0; + for (JButton btn:upperCaseButtons){ + newColours[i] = btn.getBackground(); + i++; + } + }else{ + for (int i = 0; i < 24; i++){ + JButton button = (JButton) upperCaseButtons.get(i); + newColours[i] = button.getBackground(); + } + } + UserColourScheme ucs = new UserColourScheme(newColours); + + if (caseSensitive.isSelected()) + { + newColours = new Color[23]; + length = lowerCaseButtons.size(); + if (length<23){ + int i = 0; + for (JButton btn:lowerCaseButtons){ + newColours[i] = btn.getBackground(); + i++; + } + }else{ + for (int i = 0; i < 23; i++){ + JButton button = (JButton) lowerCaseButtons.get(i); + newColours[i] = button.getBackground(); + } + } + ucs.setLowerCaseColours(newColours); + } + + if (ap != null) + { + ucs.setThreshold(0, ap.av.getIgnoreGapsConsensus()); + } + + return ucs; + } + + /** + * DOCUMENT ME! + * + * @param e + * DOCUMENT ME! + */ + @Override + protected void loadbutton_actionPerformed(ActionEvent e) + { + upperCaseButtons = new ArrayList(); + lowerCaseButtons = new ArrayList(); + + JalviewFileChooser chooser = new JalviewFileChooser( + jalview.bin.Cache.getProperty("LAST_DIRECTORY"), new String[] + { "jc" }, new String[] + { "Jalview User Colours" }, "Jalview User Colours"); + chooser.setFileView(new jalview.io.JalviewFileView()); + chooser.setDialogTitle(MessageManager + .getString("label.load_colour_scheme")); + chooser.setToolTipText(MessageManager.getString("action.load")); + + int value = chooser.showOpenDialog(this); + + if (value == JalviewFileChooser.APPROVE_OPTION) + { + File choice = chooser.getSelectedFile(); + jalview.bin.Cache.setProperty("LAST_DIRECTORY", choice.getParent()); + String defaultColours = jalview.bin.Cache.getDefault( + "USER_DEFINED_COLOURS", choice.getPath()); + if (defaultColours.indexOf(choice.getPath()) == -1) + { + defaultColours = defaultColours.concat("|") + .concat(choice.getPath()); + } + + jalview.bin.Cache.setProperty("USER_DEFINED_COLOURS", defaultColours); + + UserColourScheme ucs = loadColours(choice.getAbsolutePath()); + Color[] colors = ucs.getColours(); + schemeName.setText(ucs.getName()); + + if (ucs.getLowerCaseColours() != null) + { + caseSensitive.setSelected(true); + lcaseColour.setEnabled(true); + resetButtonPanel(true); + for (int i = 0; i < lowerCaseButtons.size(); i++) + { + JButton button = lowerCaseButtons.get(i); + button.setBackground(ucs.getLowerCaseColours()[i]); + } + + } + else + { + caseSensitive.setSelected(false); + lcaseColour.setEnabled(false); + resetButtonPanel(false); + } + + for (int i = 0; i < upperCaseButtons.size(); i++) + { + JButton button = upperCaseButtons.get(i); + button.setBackground(colors[i]); + } + + } + } + + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public static UserColourScheme loadDefaultColours() + { + UserColourScheme ret = null; + + String colours = jalview.bin.Cache.getProperty("USER_DEFINED_COLOURS"); + if (colours != null) + { + if (colours.indexOf("|") > -1) + { + colours = colours.substring(0, colours.indexOf("|")); + } + + ret = loadColours(colours); + } + + if (ret == null) + { + Color[] newColours = new Color[24]; + for (int i = 0; i < 24; i++) + { + newColours[i] = Color.white; + } + ret = new UserColourScheme(newColours); + } + + return ret; + } + + /** + * DOCUMENT ME! + * + * @param file + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + static UserColourScheme loadColours(String file) + { + UserColourScheme ucs = null; + Color[] newColours = null; + try + { + InputStreamReader in = new InputStreamReader( + new FileInputStream(file), "UTF-8"); + + jalview.schemabinding.version2.JalviewUserColours jucs = new jalview.schemabinding.version2.JalviewUserColours(); + + org.exolab.castor.xml.Unmarshaller unmar = new org.exolab.castor.xml.Unmarshaller( + jucs); + jucs = (jalview.schemabinding.version2.JalviewUserColours) unmar + .unmarshal(in); + + newColours = new Color[24]; + + Color[] lowerCase = null; + boolean caseSensitive = false; + + String name; + int index; + for (int i = 0; i < jucs.getColourCount(); i++) + { + name = jucs.getColour(i).getName(); + if (ResidueProperties.aa3Hash.containsKey(name)) + { + index = ((Integer) ResidueProperties.aa3Hash.get(name)) + .intValue(); + } + else + { + index = ResidueProperties.aaIndex[name.charAt(0)]; + } + if (index == -1) + { + continue; + } + + if (name.toLowerCase().equals(name)) + { + if (lowerCase == null) + { + lowerCase = new Color[23]; + } + caseSensitive = true; + lowerCase[index] = new Color(Integer.parseInt(jucs.getColour(i) + .getRGB(), 16)); + } + else + { + newColours[index] = new Color(Integer.parseInt(jucs.getColour(i) + .getRGB(), 16)); + } + } + + if (newColours != null) + { + ucs = new UserColourScheme(newColours); + ucs.setName(jucs.getSchemeName()); + if (caseSensitive) + { + ucs.setLowerCaseColours(lowerCase); + } + } + + } catch (Exception ex) + { + // Could be Archive Jalview format + try + { + InputStreamReader in = new InputStreamReader(new FileInputStream( + file), "UTF-8"); + + jalview.binding.JalviewUserColours jucs = new jalview.binding.JalviewUserColours(); + + jucs = jucs.unmarshal(in); + + newColours = new Color[jucs.getColourCount()]; + + for (int i = 0; i < 24; i++) + { + newColours[i] = new Color(Integer.parseInt(jucs.getColour(i) + .getRGB(), 16)); + } + if (newColours != null) + { + ucs = new UserColourScheme(newColours); + ucs.setName(jucs.getSchemeName()); + } + } catch (Exception ex2) + { + ex2.printStackTrace(); + } + + if (newColours == null) + { + System.out.println("Error loading User ColourFile\n" + ex); + } + } + + return ucs; + } + + /** + * DOCUMENT ME! + * + * @param e + * DOCUMENT ME! + */ + @Override + protected void savebutton_actionPerformed(ActionEvent e) + { + if (schemeName.getText().trim().length() < 1) + { + JOptionPane.showInternalMessageDialog(Desktop.desktop, MessageManager + .getString("label.user_colour_scheme_must_have_name"), + MessageManager.getString("label.no_name_colour_scheme"), + JOptionPane.WARNING_MESSAGE); + return; + } + + if (userColourSchemes != null + && userColourSchemes.containsKey(schemeName.getText())) + { + int reply = JOptionPane.showInternalConfirmDialog(Desktop.desktop, + MessageManager.formatMessage( + "label.colour_scheme_exists_overwrite", new Object[] + { schemeName.getText(), schemeName.getText() }), + MessageManager.getString("label.duplicate_scheme_name"), + JOptionPane.YES_NO_OPTION); + if (reply != JOptionPane.YES_OPTION) + { + return; + } + + userColourSchemes.remove(schemeName.getText()); + } + JalviewFileChooser chooser = new JalviewFileChooser( + jalview.bin.Cache.getProperty("LAST_DIRECTORY"), new String[] + { "jc" }, new String[] + { "Jalview User Colours" }, "Jalview User Colours"); + + chooser.setFileView(new jalview.io.JalviewFileView()); + chooser.setDialogTitle("Save colour scheme"); + chooser.setToolTipText(MessageManager.getString("action.save")); + + int value = chooser.showSaveDialog(this); + + if (value == JalviewFileChooser.APPROVE_OPTION) + { + String choice = chooser.getSelectedFile().getPath(); + String defaultColours = jalview.bin.Cache.getDefault( + "USER_DEFINED_COLOURS", choice); + if (defaultColours.indexOf(choice) == -1) + { + if (defaultColours.length() > 0) + { + defaultColours = defaultColours.concat("|"); + } + defaultColours = defaultColours.concat(choice); + } + + userColourSchemes.put(schemeName.getText(), getSchemeFromButtons()); + + ap.alignFrame.updateUserColourMenu(); + + jalview.bin.Cache.setProperty("USER_DEFINED_COLOURS", defaultColours); + + jalview.schemabinding.version2.JalviewUserColours ucs = new jalview.schemabinding.version2.JalviewUserColours(); + + ucs.setSchemeName(schemeName.getText()); + try + { + PrintWriter out = new PrintWriter(new OutputStreamWriter( + new FileOutputStream(choice), "UTF-8")); + + for (int i = 0; i < buttonPanel.getComponentCount(); i++) + { + JButton button = (JButton) buttonPanel.getComponent(i); + jalview.schemabinding.version2.Colour col = new jalview.schemabinding.version2.Colour(); + col.setName(button.getText()); + col.setRGB(jalview.util.Format.getHexString(button + .getBackground())); + ucs.addColour(col); + } + + ucs.marshal(out); + out.close(); + } catch (Exception ex) + { + ex.printStackTrace(); + } + } + } + + /** + * DOCUMENT ME! + * + * @param e + * DOCUMENT ME! + */ + @Override + protected void cancelButton_actionPerformed(ActionEvent e) + { + if (ap != null) + { + if (seqGroup != null) + { + seqGroup.cs = oldColourScheme; + } + else if (ap != null) + { + ap.av.setGlobalColourScheme(oldColourScheme); + } + ap.paintAlignment(true); + } + + if (jmol != null) + { + jmol.setJalviewColourScheme(oldColourScheme); + } + + try + { + frame.setClosed(true); + } catch (Exception ex) + { + } + } + + static Hashtable userColourSchemes; + + public static Hashtable getUserColourSchemes() + { + return userColourSchemes; + } + + public static void initUserColourSchemes(String files) + { + userColourSchemes = new Hashtable(); + + if (files == null || files.length() == 0) + { + return; + } + + // In case colours can't be loaded, we'll remove them + // from the default list here. + StringBuffer coloursFound = new StringBuffer(); + StringTokenizer st = new StringTokenizer(files, "|"); + while (st.hasMoreElements()) + { + String file = st.nextToken(); + try + { + UserColourScheme ucs = loadColours(file); + if (ucs != null) + { + if (coloursFound.length() > 0) + { + coloursFound.append("|"); + } + coloursFound.append(file); + userColourSchemes.put(ucs.getName(), ucs); + } + } catch (Exception ex) + { + System.out.println("Error loading User ColourFile\n" + ex); + } + } + if (!files.equals(coloursFound.toString())) + { + if (coloursFound.toString().length() > 1) + { + jalview.bin.Cache.setProperty("USER_DEFINED_COLOURS", + coloursFound.toString()); + } + else + { + jalview.bin.Cache.applicationProperties + .remove("USER_DEFINED_COLOURS"); + } + } + } + + public static void removeColourFromDefaults(String target) + { + // The only way to find colours by name is to load them in + // In case colours can't be loaded, we'll remove them + // from the default list here. + + userColourSchemes = new Hashtable(); + + StringBuffer coloursFound = new StringBuffer(); + StringTokenizer st = new StringTokenizer( + jalview.bin.Cache.getProperty("USER_DEFINED_COLOURS"), "|"); + + while (st.hasMoreElements()) + { + String file = st.nextToken(); + try + { + UserColourScheme ucs = loadColours(file); + if (ucs != null && !ucs.getName().equals(target)) + { + if (coloursFound.length() > 0) + { + coloursFound.append("|"); + } + coloursFound.append(file); + userColourSchemes.put(ucs.getName(), ucs); + } + } catch (Exception ex) + { + System.out.println("Error loading User ColourFile\n" + ex); + } + } + + if (coloursFound.toString().length() > 1) + { + jalview.bin.Cache.setProperty("USER_DEFINED_COLOURS", + coloursFound.toString()); + } + else + { + jalview.bin.Cache.applicationProperties + .remove("USER_DEFINED_COLOURS"); + } + + } + + @Override + public void caseSensitive_actionPerformed(ActionEvent e) + { + resetButtonPanel(caseSensitive.isSelected()); + lcaseColour.setEnabled(caseSensitive.isSelected()); + } + + @Override + public void lcaseColour_actionPerformed(ActionEvent e) + { + if (selectedButtons == null) + { + selectedButtons = new ArrayList(); + } + else + { + selectedButtons.clear(); + } + selectedButtons.add(lcaseColour); + } +}