Merge branch 'features/JAL-2360colourSchemeApplicability' into
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Thu, 5 Jan 2017 13:45:13 +0000 (13:45 +0000)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Thu, 5 Jan 2017 13:45:13 +0000 (13:45 +0000)
features/JAL-2371collectionColourScheme

Conflicts:
src/jalview/appletgui/APopupMenu.java

1  2 
src/jalview/appletgui/APopupMenu.java
src/jalview/appletgui/AlignFrame.java
src/jalview/gui/PopupMenu.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
    @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)
      {
        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();
      }
Simple merge
@@@ -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());