From: gmungoc Date: Thu, 5 Jan 2017 13:45:13 +0000 (+0000) Subject: Merge branch 'features/JAL-2360colourSchemeApplicability' into X-Git-Tag: Release_2_10_3b1~357^2~24 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=e23c8a1df90ccbb262f477a1b6c4b49808da80ff;p=jalview.git Merge branch 'features/JAL-2360colourSchemeApplicability' into features/JAL-2371collectionColourScheme Conflicts: src/jalview/appletgui/APopupMenu.java --- e23c8a1df90ccbb262f477a1b6c4b49808da80ff diff --cc src/jalview/appletgui/APopupMenu.java index f126d55,b0f8347..941052d --- a/src/jalview/appletgui/APopupMenu.java +++ b/src/jalview/appletgui/APopupMenu.java @@@ -41,9 -41,10 +41,11 @@@ import jalview.io.SequenceAnnotationRep import jalview.schemes.Blosum62ColourScheme; import jalview.schemes.BuriedColourScheme; import jalview.schemes.ClustalxColourScheme; -import jalview.schemes.ColourSchemeI; +import jalview.schemes.CollectionColourScheme; ++import jalview.schemes.CollectionColourSchemeI; import jalview.schemes.HelixColourScheme; import jalview.schemes.HydrophobicColourScheme; + import jalview.schemes.JalviewColourScheme; import jalview.schemes.NucleotideColourScheme; import jalview.schemes.PIDColourScheme; import jalview.schemes.PurinePyrimidineColourScheme; @@@ -308,6 -314,35 +315,36 @@@ public class APopupMenu extends java.aw } /** + * Select the menu item (if any) matching the current colour scheme. This + * works by matching the menu item name (not display text) to the canonical + * name of the colour scheme. + * + * @param cs + */ - protected void setSelectedColour(ColourSchemeI cs) ++ protected void setSelectedColour(CollectionColourSchemeI cs) + { - if (cs == null) ++ if (cs == null || cs.getColourScheme() == null) + { + noColour.setState(true); + } + else + { ++ String name = cs.getColourScheme().getSchemeName(); + for (int i = 0; i < colourMenu.getItemCount(); i++) + { + MenuItem item = colourMenu.getItem(i); + if (item instanceof CheckboxMenuItem) + { - if (cs.getSchemeName().equals(item.getName())) ++ if (name.equals(item.getName())) + { + ((CheckboxMenuItem) item).setState(true); + } + } + } + } + } + + /** * Adds a 'Link' menu item with a sub-menu item for each hyperlink provided. * * @param seq @@@ -505,35 -543,22 +545,22 @@@ @Override public void itemStateChanged(ItemEvent evt) { - if (evt.getSource() == abovePIDColour) - { - abovePIDColour_itemStateChanged(); - } - else if (evt.getSource() == showColourText) - { - showColourText_itemStateChanged(); - } - else if (evt.getSource() == showText) + Object source = evt.getSource(); + if (source == noColour) { - showText_itemStateChanged(); + noColourmenuItem_actionPerformed(); } - else if (evt.getSource() == showBoxes) + else if (source == clustalColour) { - showBoxes_itemStateChanged(); + clustalColour_actionPerformed(); } - else if (evt.getSource() == displayNonconserved) + else if (source == BLOSUM62Colour) { - this.showNonconserved_itemStateChanged(); + BLOSUM62Colour_actionPerformed(); } - } - - @Override - public void actionPerformed(ActionEvent evt) - { - Object source = evt.getSource(); - if (source == clustalColour) - else if (source == PIDColour) ++ else if (evt.getSource() == PIDColour) { - clustalColour_actionPerformed(); + PIDColour_actionPerformed(); } else if (source == zappoColour) { @@@ -1185,13 -1242,12 +1246,14 @@@ return; } - if (conservationMenuItem.getState()) + if (conservationColour.getState()) { - Conservation conservation = Conservation.calculateConservation("Group", sg - sg.cs.setConservation(Conservation.calculateConservation("Group", sg ++ Conservation conservation = Conservation.calculateConservation( ++ "Group", sg .getSequences(ap.av.getHiddenRepSequences()), 0, ap.av .getAlignment().getWidth(), false, ap.av.getConsPercGaps(), - false)); + false); + sg.getGroupColourScheme().setConservation(conservation); SliderPanel.setConservationSlider(ap, sg.cs, sg.getName()); SliderPanel.showConservationSlider(); } diff --cc src/jalview/gui/PopupMenu.java index 50da272,f3927df..fdac7f8 --- a/src/jalview/gui/PopupMenu.java +++ b/src/jalview/gui/PopupMenu.java @@@ -422,11 -421,18 +422,18 @@@ public class PopupMenu extends JPopupMe groupName.setText(MessageManager .getString("label.edit_name_and_description_current_group")); - ColourMenuHelper.setColourSelected(colourMenu, sg.cs); + ColourMenuHelper.setColourSelected(colourMenu, sg.getColourScheme()); - if (sg.cs != null && sg.cs.conservationApplied()) + if (sg.cs != null) { - conservationMenuItem.setSelected(true); + if (sg.cs.conservationApplied()) + { + conservationMenuItem.setSelected(true); + } + if (sg.cs.getThreshold() > 0) + { + abovePIDColour.setSelected(true); + } } displayNonconserved.setSelected(sg.getShowNonconserved()); showText.setSelected(sg.getDisplayText());