X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fappletgui%2FAPopupMenu.java;h=3b37b62972d4179c2b193036e3835cac41928e04;hb=4663ab6ec8142df859d031bff618d78809e22082;hp=13dcd05eef19418af0272b31f210e7c774a1881e;hpb=cb5d856b1304448cae13a333cbd9017f81520d90;p=jalview.git diff --git a/src/jalview/appletgui/APopupMenu.java b/src/jalview/appletgui/APopupMenu.java index 13dcd05..3b37b62 100644 --- a/src/jalview/appletgui/APopupMenu.java +++ b/src/jalview/appletgui/APopupMenu.java @@ -1,36 +1,62 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.0b1) + * 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. + * 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 . + * 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.appletgui; -import java.util.*; - -import java.awt.*; -import java.awt.event.*; - -import jalview.analysis.*; -import jalview.commands.*; -import jalview.datamodel.*; -import jalview.schemes.*; -import jalview.util.MessageManager; -import jalview.util.UrlLink; +import jalview.analysis.AAFrequency; +import jalview.analysis.Conservation; +import jalview.commands.ChangeCaseCommand; +import jalview.commands.EditCommand; +import jalview.commands.EditCommand.Action; +import jalview.datamodel.DBRefEntry; +import jalview.datamodel.PDBEntry; +import jalview.datamodel.Sequence; +import jalview.datamodel.SequenceFeature; +import jalview.datamodel.SequenceGroup; +import jalview.datamodel.SequenceI; import jalview.io.AppletFormatAdapter; import jalview.io.SequenceAnnotationReport; +import jalview.schemes.Blosum62ColourScheme; +import jalview.schemes.BuriedColourScheme; +import jalview.schemes.ClustalxColourScheme; +import jalview.schemes.HelixColourScheme; +import jalview.schemes.HydrophobicColourScheme; +import jalview.schemes.NucleotideColourScheme; +import jalview.schemes.PIDColourScheme; +import jalview.schemes.ResidueProperties; +import jalview.schemes.StrandColourScheme; +import jalview.schemes.TaylorColourScheme; +import jalview.schemes.TurnColourScheme; +import jalview.schemes.ZappoColourScheme; +import jalview.util.MessageManager; +import jalview.util.UrlLink; + +import java.awt.CheckboxMenuItem; +import java.awt.Frame; +import java.awt.Menu; +import java.awt.MenuItem; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.util.Vector; public class APopupMenu extends java.awt.PopupMenu implements ActionListener, ItemListener @@ -87,15 +113,19 @@ public class APopupMenu extends java.awt.PopupMenu implements Menu editMenu = new Menu(MessageManager.getString("action.edit")); - MenuItem copy = new MenuItem(MessageManager.getString("label.jalview_copy")); + MenuItem copy = new MenuItem( + MessageManager.getString("label.jalview_copy")); MenuItem cut = new MenuItem(MessageManager.getString("label.jalview_cut")); - MenuItem toUpper = new MenuItem(MessageManager.getString("label.to_upper_case")); + MenuItem toUpper = new MenuItem( + MessageManager.getString("label.to_upper_case")); - MenuItem toLower = new MenuItem(MessageManager.getString("label.to_lower_case")); + MenuItem toLower = new MenuItem( + MessageManager.getString("label.to_lower_case")); - MenuItem toggleCase = new MenuItem(MessageManager.getString("label.toggle_case")); + MenuItem toggleCase = new MenuItem( + MessageManager.getString("label.toggle_case")); Menu outputmenu = new Menu(); @@ -107,16 +137,23 @@ public class APopupMenu extends java.awt.PopupMenu implements MenuItem repGroup = new MenuItem(); - MenuItem sequenceName = new MenuItem(MessageManager.getString("label.edit_name_description")); + MenuItem sequenceName = new MenuItem( + MessageManager.getString("label.edit_name_description")); - MenuItem sequenceFeature = new MenuItem(MessageManager.getString("label.create_sequence_feature")); + MenuItem sequenceFeature = new MenuItem( + MessageManager.getString("label.create_sequence_feature")); - MenuItem editSequence = new MenuItem(MessageManager.getString("label.edit_sequence")); + MenuItem editSequence = new MenuItem( + MessageManager.getString("label.edit_sequence")); - MenuItem sequenceDetails = new MenuItem(MessageManager.getString("label.sequence_details") + "..."); + MenuItem sequenceDetails = new MenuItem( + MessageManager.getString("label.sequence_details") + "..."); - MenuItem selSeqDetails = new MenuItem(MessageManager.getString("label.sequence_details") + "..."); + MenuItem selSeqDetails = new MenuItem( + MessageManager.getString("label.sequence_details") + "..."); + MenuItem makeReferenceSeq = new MenuItem(); + Sequence seq; MenuItem revealAll = new MenuItem(); @@ -163,7 +200,9 @@ public class APopupMenu extends java.awt.PopupMenu implements if (sg != null && sg.getSize() > 0) { - editGroupName.setLabel(MessageManager.formatMessage("label.name_param", new String[]{sg.getName()})); + editGroupName.setLabel(MessageManager.formatMessage( + "label.name_param", new String[] + { sg.getName() })); showText.setState(sg.getDisplayText()); showColourText.setState(sg.getColourText()); showBoxes.setState(sg.getDisplayBoxes()); @@ -172,7 +211,9 @@ public class APopupMenu extends java.awt.PopupMenu implements { menu1.setLabel(MessageManager.getString("action.edit_new_group")); groupMenu.remove(unGroupMenuItem); - } else { + } + else + { menu1.setLabel(MessageManager.getString("action.edit_group")); groupMenu.remove(createGroupMenuItem); } @@ -308,7 +349,20 @@ public class APopupMenu extends java.awt.PopupMenu implements if (seq != null) { seqMenu.setLabel(seq.getName()); - repGroup.setLabel(MessageManager.formatMessage("label.represent_group_with", new String[]{seq.getName()})); + if (seq == ap.av.getAlignment().getSeqrep()) + { + makeReferenceSeq.setLabel(MessageManager + .getString("action.unmark_as_reference"));// Unmark + // representative"); + } + else + { + makeReferenceSeq.setLabel(MessageManager + .getString("action.set_as_reference")); // ); + } + repGroup.setLabel(MessageManager.formatMessage( + "label.represent_group_with", new String[] + { seq.getName() })); } else { @@ -474,6 +528,10 @@ public class APopupMenu extends java.awt.PopupMenu implements { editName(); } + else if (source == makeReferenceSeq) + { + makeReferenceSeq_actionPerformed(); + } else if (source == sequenceDetails) { showSequenceDetails(); @@ -532,7 +590,9 @@ public class APopupMenu extends java.awt.PopupMenu implements if (sg != null) { if (seq == null) + { seq = (Sequence) sg.getSequenceAt(0); + } EditNameDialog dialog = new EditNameDialog(seq.getSequenceAsString( sg.getStartRes(), sg.getEndRes() + 1), null, @@ -542,8 +602,8 @@ public class APopupMenu extends java.awt.PopupMenu implements if (dialog.accept) { - EditCommand editCommand = new EditCommand("Edit Sequences", - EditCommand.REPLACE, dialog.getName().replace(' ', + EditCommand editCommand = new EditCommand(MessageManager.getString("label.edit_sequences"), + Action.REPLACE, dialog.getName().replace(' ', ap.av.getGapCharacter()), sg.getSequencesAsArray(ap.av.getHiddenRepSequences()), sg.getStartRes(), sg.getEndRes() + 1, @@ -630,7 +690,7 @@ public class APopupMenu extends java.awt.PopupMenu implements features, true, ap)) { ap.alignFrame.sequenceFeatures.setState(true); - ap.av.showSequenceFeatures(true); + ap.av.setShowSequenceFeatures(true);; ap.highlightSearchResults(null); } } @@ -647,16 +707,15 @@ public class APopupMenu extends java.awt.PopupMenu implements Frame frame = new Frame(); frame.add(cap); - jalview.bin.JalviewLite.addFrame(frame, - MessageManager.formatMessage("label.selection_output_command", new String[]{e.getActionCommand()}),600, 500); + jalview.bin.JalviewLite.addFrame(frame, MessageManager.formatMessage( + "label.selection_output_command", new String[] + { e.getActionCommand() }), 600, 500); // JBPNote: getSelectionAsNewSequence behaviour has changed - this method // now returns a full copy of sequence data // TODO consider using getSequenceSelection instead here cap.setText(new jalview.io.AppletFormatAdapter().formatSequences( - e.getActionCommand(), - new Alignment(ap.av.getSelectionAsNewSequence()), - ap.av.showJVSuffix)); + e.getActionCommand(), ap.av.getShowJVSuffix(), ap.av, true)); } @@ -679,7 +738,9 @@ public class APopupMenu extends java.awt.PopupMenu implements StringBuffer contents = new StringBuffer(); for (SequenceI seq : sequences) { - contents.append(MessageManager.formatMessage("label.annotation_for_displayid",new String[]{seq.getDisplayId(true)})); + contents.append(MessageManager.formatMessage( + "label.annotation_for_displayid", new String[] + { seq.getDisplayId(true) })); new SequenceAnnotationReport(null) .createSequenceAnnotationReport( contents, @@ -687,7 +748,7 @@ public class APopupMenu extends java.awt.PopupMenu implements true, true, false, - (ap.seqPanel.seqCanvas.fr != null) ? ap.seqPanel.seqCanvas.fr.minmax + (ap.seqPanel.seqCanvas.fr != null) ? ap.seqPanel.seqCanvas.fr.getMinMax() : null); contents.append("

"); } @@ -696,7 +757,9 @@ public class APopupMenu extends java.awt.PopupMenu implements jalview.bin.JalviewLite.addFrame(frame, "Sequence Details for " + (sequences.length == 1 ? sequences[0].getDisplayId(true) : "Selection"), 600, 500); - cap.setText(MessageManager.formatMessage("label.html_content", new String[]{contents.toString()})); + cap.setText(MessageManager.formatMessage("label.html_content", + new String[] + { contents.toString() })); } void editName() @@ -721,11 +784,15 @@ public class APopupMenu extends java.awt.PopupMenu implements PDBEntry entry = (PDBEntry) seq.getPDBId().firstElement(); if (ap.av.applet.jmolAvailable) + { new jalview.appletgui.AppletJmol(entry, new Sequence[] { seq }, null, ap, AppletFormatAdapter.URL); + } else + { new MCview.AppletPDBViewer(entry, new Sequence[] { seq }, null, ap, AppletFormatAdapter.URL); + } } else @@ -735,8 +802,9 @@ public class APopupMenu extends java.awt.PopupMenu implements cap.setPDBImport(seq); Frame frame = new Frame(); frame.add(cap); - jalview.bin.JalviewLite.addFrame(frame, - MessageManager.formatMessage("label.paste_pdb_file_for_sequence", new String[]{seq.getName()}), 400, 300); + jalview.bin.JalviewLite.addFrame(frame, MessageManager.formatMessage( + "label.paste_pdb_file_for_sequence", new String[] + { seq.getName() }), 400, 300); } } @@ -746,27 +814,31 @@ public class APopupMenu extends java.awt.PopupMenu implements sequenceFeature.addActionListener(this); editGroupName.addActionListener(this); - unGroupMenuItem.setLabel(MessageManager.getString("action.remove_group")); + unGroupMenuItem.setLabel(MessageManager + .getString("action.remove_group")); unGroupMenuItem.addActionListener(this); - createGroupMenuItem.setLabel(MessageManager.getString("action.create_group")); + createGroupMenuItem.setLabel(MessageManager + .getString("action.create_group")); createGroupMenuItem.addActionListener(this); - nucleotideMenuItem.setLabel(MessageManager.getString("label.nucleotide")); + nucleotideMenuItem.setLabel(MessageManager + .getString("label.nucleotide")); nucleotideMenuItem.addActionListener(this); conservationMenuItem.addItemListener(this); abovePIDColour.addItemListener(this); colourMenu.setLabel(MessageManager.getString("label.group_colour")); - showBoxes.setLabel(MessageManager.getString("label.boxes")); + showBoxes.setLabel(MessageManager.getString("action.boxes")); showBoxes.setState(true); showBoxes.addItemListener(this); sequenceName.addActionListener(this); sequenceDetails.addActionListener(this); selSeqDetails.addActionListener(this); - displayNonconserved.setLabel(MessageManager.getString("label.show_non_conversed")); + displayNonconserved.setLabel(MessageManager + .getString("label.show_non_conversed")); displayNonconserved.setState(false); displayNonconserved.addItemListener(this); - showText.setLabel(MessageManager.getString("label.text")); + showText.setLabel(MessageManager.getString("action.text")); showText.addItemListener(this); showColourText.setLabel(MessageManager.getString("label.colour_text")); showColourText.addItemListener(this); @@ -774,10 +846,12 @@ public class APopupMenu extends java.awt.PopupMenu implements seqMenu.setLabel(MessageManager.getString("label.sequence")); pdb.setLabel(MessageManager.getString("label.view_pdb_structure")); hideSeqs.setLabel(MessageManager.getString("action.hide_sequences")); - repGroup.setLabel(MessageManager.formatMessage("label.represent_group_with", new String[]{""})); + repGroup.setLabel(MessageManager.formatMessage( + "label.represent_group_with", new String[] + { "" })); revealAll.setLabel(MessageManager.getString("action.reveal_all")); revealSeq.setLabel(MessageManager.getString("action.reveal_sequences")); - menu1.setLabel(MessageManager.getString("label.group")+":"); + menu1.setLabel(MessageManager.getString("label.group") + ":"); add(groupMenu); this.add(seqMenu); this.add(hideSeqs); @@ -808,34 +882,34 @@ public class APopupMenu extends java.awt.PopupMenu implements colourMenu.add(abovePIDColour); colourMenu.add(conservationMenuItem); - noColourmenuItem.setLabel("None"); + noColourmenuItem.setLabel(MessageManager.getString("label.none")); noColourmenuItem.addActionListener(this); - clustalColour.setLabel("Clustalx colours"); + clustalColour.setLabel(MessageManager.getString("label.clustalx_colours")); clustalColour.addActionListener(this); - zappoColour.setLabel("Zappo"); + zappoColour.setLabel(MessageManager.getString("label.zappo")); zappoColour.addActionListener(this); - taylorColour.setLabel("Taylor"); + taylorColour.setLabel(MessageManager.getString("label.taylor")); taylorColour.addActionListener(this); - hydrophobicityColour.setLabel("Hydrophobicity"); + hydrophobicityColour.setLabel(MessageManager.getString("label.hydrophobicity")); hydrophobicityColour.addActionListener(this); - helixColour.setLabel("Helix propensity"); + helixColour.setLabel(MessageManager.getString("label.helix_propensity")); helixColour.addActionListener(this); - strandColour.setLabel("Strand propensity"); + strandColour.setLabel(MessageManager.getString("label.strand_propensity")); strandColour.addActionListener(this); - turnColour.setLabel("Turn propensity"); + turnColour.setLabel(MessageManager.getString("label.turn_propensity")); turnColour.addActionListener(this); - buriedColour.setLabel("Buried Index"); + buriedColour.setLabel(MessageManager.getString("label.buried_index")); buriedColour.addActionListener(this); - abovePIDColour.setLabel("Above % Identity"); + abovePIDColour.setLabel(MessageManager.getString("label.above_identity_percentage")); - userDefinedColour.setLabel("User Defined"); + userDefinedColour.setLabel(MessageManager.getString("action.user_defined")); userDefinedColour.addActionListener(this); - PIDColour.setLabel("Percentage Identity"); + PIDColour.setLabel(MessageManager.getString("action.percentage_identity")); PIDColour.addActionListener(this); BLOSUM62Colour.setLabel("BLOSUM62"); BLOSUM62Colour.addActionListener(this); - conservationMenuItem.setLabel("Conservation"); + conservationMenuItem.setLabel(MessageManager.getString("label.conservation")); editMenu.add(copy); copy.addActionListener(this); @@ -851,6 +925,7 @@ public class APopupMenu extends java.awt.PopupMenu implements toLower.addActionListener(this); editMenu.add(toggleCase); seqMenu.add(sequenceName); + seqMenu.add(makeReferenceSeq); // seqMenu.add(sequenceDetails); if (!ap.av.applet.useXtrnalSviewer) @@ -870,6 +945,7 @@ public class APopupMenu extends java.awt.PopupMenu implements repGroup.addActionListener(this); revealAll.addActionListener(this); revealSeq.addActionListener(this); + makeReferenceSeq.addActionListener(this); } void refresh() @@ -947,7 +1023,7 @@ public class APopupMenu extends java.awt.PopupMenu implements int threshold = SliderPanel.setPIDSliderSource(ap, sg.cs, getGroup() .getName()); - sg.cs.setThreshold(threshold, ap.av.getIgnoreGapsConsensus()); + sg.cs.setThreshold(threshold, ap.av.isIgnoreGapsConsensus()); SliderPanel.showPIDSlider(); @@ -955,7 +1031,7 @@ public class APopupMenu extends java.awt.PopupMenu implements else // remove PIDColouring { - sg.cs.setThreshold(0, ap.av.getIgnoreGapsConsensus()); + sg.cs.setThreshold(0, ap.av.isIgnoreGapsConsensus()); } refresh(); @@ -1059,6 +1135,28 @@ public class APopupMenu extends java.awt.PopupMenu implements getGroup().setDisplayText(showText.getState()); refresh(); } + public void makeReferenceSeq_actionPerformed() + { + if (!ap.av.getAlignment().hasSeqrep()) + { + // initialise the display flags so the user sees something happen + ap.av.setDisplayReferenceSeq(true); + ap.av.setColourByReferenceSeq(true); + ap.av.getAlignment().setSeqrep(seq); + } + else + { + if (ap.av.getAlignment().getSeqrep() == seq) + { + ap.av.getAlignment().setSeqrep(null); + } + else + { + ap.av.getAlignment().setSeqrep(seq); + } + } + refresh(); + } public void showNonconserved_itemStateChanged() {