Merge branch 'develop' into features/JAL-2360colourSchemeApplicability
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Thu, 5 Jan 2017 12:24:37 +0000 (12:24 +0000)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Thu, 5 Jan 2017 12:24:37 +0000 (12:24 +0000)
Conflicts:
src/jalview/gui/PopupMenu.java

1  2 
examples/appletParameters.html
resources/lang/Messages.properties
resources/lang/Messages_es.properties
src/jalview/appletgui/APopupMenu.java
src/jalview/appletgui/AlignFrame.java
src/jalview/bin/JalviewLite.java
src/jalview/gui/PopupMenu.java

Simple merge
Simple merge
Simple merge
@@@ -41,11 -41,10 +41,13 @@@ import jalview.io.SequenceAnnotationRep
  import jalview.schemes.Blosum62ColourScheme;
  import jalview.schemes.BuriedColourScheme;
  import jalview.schemes.ClustalxColourScheme;
++import jalview.schemes.ColourSchemeI;
  import jalview.schemes.HelixColourScheme;
  import jalview.schemes.HydrophobicColourScheme;
++import jalview.schemes.JalviewColourScheme;
  import jalview.schemes.NucleotideColourScheme;
  import jalview.schemes.PIDColourScheme;
 +import jalview.schemes.PurinePyrimidineColourScheme;
  import jalview.schemes.StrandColourScheme;
  import jalview.schemes.TaylorColourScheme;
  import jalview.schemes.TurnColourScheme;
@@@ -78,33 -76,33 +80,37 @@@ public class APopupMenu extends java.aw
  
    MenuItem editGroupName = new MenuItem();
  
--  protected MenuItem clustalColour = new MenuItem();
++  CheckboxMenuItem noColour = new CheckboxMenuItem();
  
--  protected MenuItem zappoColour = new MenuItem();
++  protected CheckboxMenuItem clustalColour = new CheckboxMenuItem();
  
--  protected MenuItem taylorColour = new MenuItem();
++  protected CheckboxMenuItem zappoColour = new CheckboxMenuItem();
  
--  protected MenuItem hydrophobicityColour = new MenuItem();
++  protected CheckboxMenuItem taylorColour = new CheckboxMenuItem();
  
--  protected MenuItem helixColour = new MenuItem();
++  protected CheckboxMenuItem hydrophobicityColour = new CheckboxMenuItem();
  
--  protected MenuItem strandColour = new MenuItem();
++  protected CheckboxMenuItem helixColour = new CheckboxMenuItem();
  
--  protected MenuItem turnColour = new MenuItem();
++  protected CheckboxMenuItem strandColour = new CheckboxMenuItem();
  
--  protected MenuItem buriedColour = new MenuItem();
++  protected CheckboxMenuItem turnColour = new CheckboxMenuItem();
  
--  protected CheckboxMenuItem abovePIDColour = new CheckboxMenuItem();
++  protected CheckboxMenuItem buriedColour = new CheckboxMenuItem();
  
--  protected MenuItem userDefinedColour = new MenuItem();
++  protected CheckboxMenuItem PIDColour = new CheckboxMenuItem();
  
--  protected MenuItem PIDColour = new MenuItem();
++  protected CheckboxMenuItem BLOSUM62Colour = new CheckboxMenuItem();
  
--  protected MenuItem BLOSUM62Colour = new MenuItem();
++  CheckboxMenuItem nucleotideColour = new CheckboxMenuItem();
  
--  MenuItem noColourmenuItem = new MenuItem();
++  CheckboxMenuItem purinePyrimidineColour = new CheckboxMenuItem();
  
--  protected CheckboxMenuItem conservationMenuItem = new CheckboxMenuItem();
++  protected MenuItem userDefinedColour = new MenuItem();
++
++  protected CheckboxMenuItem abovePIDColour = new CheckboxMenuItem();
++
++  protected CheckboxMenuItem conservationColour = new CheckboxMenuItem();
  
    final AlignmentPanel ap;
  
  
    MenuItem createGroupMenuItem = new MenuItem();
  
--  MenuItem nucleotideMenuItem = new MenuItem();
--
-   MenuItem purinePyrimidineMenuItem = new MenuItem();
    Menu colourMenu = new Menu();
  
    CheckboxMenuItem showBoxes = new CheckboxMenuItem();
        {
          menu1.setLabel(MessageManager.getString("action.edit_group"));
          groupMenu.remove(createGroupMenuItem);
+         if (sg.cs != null)
+         {
+           abovePIDColour.setState(sg.cs.getThreshold() > 0);
 -          conservationMenuItem.setState(sg.cs.conservationApplied());
++          conservationColour.setState(sg.cs.conservationApplied());
+         }
        }
++      setSelectedColour(sg.cs);
      }
      else
      {
    }
  
    /**
++   * 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)
++  {
++    if (cs == null)
++    {
++      noColour.setState(true);
++    }
++    else
++    {
++      for (int i = 0; i < colourMenu.getItemCount(); i++)
++      {
++        MenuItem item = colourMenu.getItem(i);
++        if (item instanceof CheckboxMenuItem)
++        {
++          if (cs.getSchemeName().equals(item.getName()))
++          {
++            ((CheckboxMenuItem) item).setState(true);
++          }
++        }
++      }
++    }
++  }
++
++  /**
     * Adds a 'Link' menu item with a sub-menu item for each hyperlink provided.
     * 
     * @param seq
      linkMenu.add(item);
    }
  
++  /**
++   * Actions on selecting / unselecting a checkbox menu item
++   */
    @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 == abovePIDColour)
 -    {
 -      abovePIDColour_itemStateChanged();
 -    }
 -    else if (source == conservationMenuItem)
++    if (source == noColour)
      {
-       showText_itemStateChanged();
 -      conservationMenuItem_itemStateChanged();
 -    }
 -    else if (source == showColourText)
 -    {
 -      showColourText_itemStateChanged();
 -    }
 -    else if (source == showText)
 -    {
 -      showText_itemStateChanged();
++      noColourmenuItem_actionPerformed();
      }
-     else if (evt.getSource() == showBoxes)
 -    else if (source == showBoxes)
++    else if (source == clustalColour)
      {
--      showBoxes_itemStateChanged();
++      clustalColour_actionPerformed();
      }
-     else if (evt.getSource() == displayNonconserved)
 -    else if (source == 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)
      {
--      clustalColour_actionPerformed();
++      PIDColour_actionPerformed();
      }
      else if (source == zappoColour)
      {
      {
        buriedColour_actionPerformed();
      }
--    else if (source == nucleotideMenuItem)
++    else if (source == nucleotideColour)
      {
        nucleotideMenuItem_actionPerformed();
      }
-     else if (source == purinePyrimidineMenuItem)
 -
 -    else if (source == userDefinedColour)
++    else if (source == purinePyrimidineColour)
      {
 -      userDefinedColour_actionPerformed();
 +      purinePyrimidineColour_actionPerformed();
      }
-     else if (source == userDefinedColour)
 -    else if (source == PIDColour)
++    else if (source == abovePIDColour)
      {
-       userDefinedColour_actionPerformed();
 -      PIDColour_actionPerformed();
++      abovePIDColour_itemStateChanged();
      }
-     else if (source == PIDColour)
 -    else if (source == BLOSUM62Colour)
++    else if (source == conservationColour)
      {
-       PIDColour_actionPerformed();
 -      BLOSUM62Colour_actionPerformed();
++      conservationMenuItem_itemStateChanged();
      }
-     else if (source == BLOSUM62Colour)
 -    else if (source == noColourmenuItem)
++    else if (source == showColourText)
      {
-       BLOSUM62Colour_actionPerformed();
 -      noColourmenuItem_actionPerformed();
++      showColourText_itemStateChanged();
 +    }
-     else if (source == noColourmenuItem)
++    else if (source == showText)
 +    {
-       noColourmenuItem_actionPerformed();
++      showText_itemStateChanged();
 +    }
-     else if (source == conservationMenuItem)
++    else if (source == showBoxes)
 +    {
-       conservationMenuItem_itemStateChanged();
++      showBoxes_itemStateChanged();
++    }
++    else if (source == displayNonconserved)
++    {
++      this.showNonconserved_itemStateChanged();
++    }
++  }
++
++  /**
++   * Actions on clicking a menu item
++   */
++  @Override
++  public void actionPerformed(ActionEvent evt)
++  {
++    Object source = evt.getSource();
++    if (source == userDefinedColour)
++    {
++      userDefinedColour_actionPerformed();
      }
      else if (source == unGroupMenuItem)
      {
      groupMenu.add(unGroupMenuItem);
      groupMenu.add(menu1);
  
--    colourMenu.add(noColourmenuItem);
++    colourMenu.add(noColour);
      colourMenu.add(clustalColour);
      colourMenu.add(BLOSUM62Colour);
      colourMenu.add(PIDColour);
      colourMenu.add(strandColour);
      colourMenu.add(turnColour);
      colourMenu.add(buriedColour);
--    colourMenu.add(nucleotideMenuItem);
-     colourMenu.add(purinePyrimidineMenuItem);
++    colourMenu.add(nucleotideColour);
++    colourMenu.add(purinePyrimidineColour);
      colourMenu.add(userDefinedColour);
      colourMenu.addSeparator();
      colourMenu.add(abovePIDColour);
--    colourMenu.add(conservationMenuItem);
++    colourMenu.add(conservationColour);
  
--    noColourmenuItem.setLabel(MessageManager.getString("label.none"));
--    noColourmenuItem.addActionListener(this);
++    noColour.setLabel(MessageManager.getString("label.none"));
++    noColour.addItemListener(this);
  
++    /*
++     * setName allows setSelectedColour to do its thing
++     */
      clustalColour.setLabel(MessageManager
 -            .getString("label.clustalx_colours"));
 -    clustalColour.addActionListener(this);
 -    zappoColour.setLabel(MessageManager.getString("label.zappo"));
 -    zappoColour.addActionListener(this);
 -    taylorColour.setLabel(MessageManager.getString("label.taylor"));
 -    taylorColour.addActionListener(this);
 +            .getString("label.colourScheme_clustal"));
-     clustalColour.addActionListener(this);
++    clustalColour.setName(JalviewColourScheme.Clustal.toString());
++    clustalColour.addItemListener(this);
++    BLOSUM62Colour.setLabel(MessageManager
++            .getString("label.colourScheme_blosum62"));
++    BLOSUM62Colour.setName(JalviewColourScheme.Blosum62.toString());
++    BLOSUM62Colour.addItemListener(this);
++    PIDColour.setLabel(MessageManager
++            .getString("label.colourScheme_%_identity"));
++    PIDColour.setName(JalviewColourScheme.PID.toString());
++    PIDColour.addItemListener(this);
 +    zappoColour.setLabel(MessageManager
 +            .getString("label.colourScheme_zappo"));
-     zappoColour.addActionListener(this);
++    zappoColour.setName(JalviewColourScheme.Zappo.toString());
++    zappoColour.addItemListener(this);
 +    taylorColour.setLabel(MessageManager
 +            .getString("label.colourScheme_taylor"));
-     taylorColour.addActionListener(this);
++    taylorColour.setName(JalviewColourScheme.Taylor.toString());
++    taylorColour.addItemListener(this);
      hydrophobicityColour.setLabel(MessageManager
 -            .getString("label.hydrophobicity"));
 -    hydrophobicityColour.addActionListener(this);
 -    helixColour
 -            .setLabel(MessageManager.getString("label.helix_propensity"));
 -    helixColour.addActionListener(this);
 +            .getString("label.colourScheme_hydrophobic"));
-     hydrophobicityColour.addActionListener(this);
++    hydrophobicityColour
++            .setName(JalviewColourScheme.Hydrophobic.toString());
++    hydrophobicityColour.addItemListener(this);
 +    helixColour.setLabel(MessageManager
 +            .getString("label.colourScheme_helix_propensity"));
-     helixColour.addActionListener(this);
++    helixColour.setName(JalviewColourScheme.Helix.toString());
++    helixColour.addItemListener(this);
      strandColour.setLabel(MessageManager
 -            .getString("label.strand_propensity"));
 -    strandColour.addActionListener(this);
 -    turnColour.setLabel(MessageManager.getString("label.turn_propensity"));
 -    turnColour.addActionListener(this);
 -    buriedColour.setLabel(MessageManager.getString("label.buried_index"));
 -    buriedColour.addActionListener(this);
 -    abovePIDColour.setLabel(MessageManager
 -            .getString("label.above_identity_percentage"));
 +            .getString("label.colourScheme_strand_propensity"));
-     strandColour.addActionListener(this);
++    strandColour.setName(JalviewColourScheme.Strand.toString());
++    strandColour.addItemListener(this);
 +    turnColour.setLabel(MessageManager
 +            .getString("label.colourScheme_turn_propensity"));
-     turnColour.addActionListener(this);
++    turnColour.setName(JalviewColourScheme.Turn.toString());
++    turnColour.addItemListener(this);
 +    buriedColour.setLabel(MessageManager
 +            .getString("label.colourScheme_buried_index"));
-     buriedColour.addActionListener(this);
-     abovePIDColour.setLabel(MessageManager
-             .getString("label.above_identity_threshold"));
++    buriedColour.setName(JalviewColourScheme.Buried.toString());
++    buriedColour.addItemListener(this);
++    nucleotideColour.setLabel(MessageManager
++            .getString("label.colourScheme_nucleotide"));
++    nucleotideColour.setName(JalviewColourScheme.Nucleotide.toString());
++    nucleotideColour.addItemListener(this);
++    purinePyrimidineColour.setLabel(MessageManager
++            .getString("label.colourScheme_purine/pyrimidine"));
++    purinePyrimidineColour.setName(JalviewColourScheme.PurinePyrimidine
++            .toString());
++    purinePyrimidineColour.addItemListener(this);
  
      userDefinedColour.setLabel(MessageManager
              .getString("action.user_defined"));
      userDefinedColour.addActionListener(this);
--    PIDColour.setLabel(MessageManager
-             .getString("label.colourScheme_%_identity"));
-     PIDColour.addActionListener(this);
-     BLOSUM62Colour.setLabel(MessageManager
-             .getString("label.colourScheme_blosum62"));
-     BLOSUM62Colour.addActionListener(this);
-     conservationMenuItem.setLabel(MessageManager
-             .getString("label.conservation"));
-     nucleotideMenuItem.setLabel(MessageManager
-             .getString("label.colourScheme_nucleotide"));
-     nucleotideMenuItem.addActionListener(this);
-     purinePyrimidineMenuItem.setLabel(MessageManager
-             .getString("label.colourScheme_purine/pyrimidine"));
-     purinePyrimidineMenuItem.addActionListener(this);
-     conservationMenuItem.addItemListener(this);
 -            .getString("label.percentage_identity"));
 -    PIDColour.addActionListener(this);
 -    BLOSUM62Colour.setLabel("BLOSUM62");
 -    BLOSUM62Colour.addActionListener(this);
 -    conservationMenuItem.setLabel(MessageManager
++
++    abovePIDColour.setLabel(MessageManager
++            .getString("label.above_identity_threshold"));
 +    abovePIDColour.addItemListener(this);
++    conservationColour.setLabel(MessageManager
+             .getString("label.conservation"));
++    conservationColour.addItemListener(this);
  
      editMenu.add(copy);
      copy.addActionListener(this);
        return;
      }
  
--    if (conservationMenuItem.getState())
++    if (conservationColour.getState())
      {
        sg.cs.setConservation(Conservation.calculateConservation("Group", sg
                .getSequences(ap.av.getHiddenRepSequences()), 0, ap.av
Simple merge
Simple merge
@@@ -421,11 -476,74 +421,18 @@@ public class PopupMenu extends JPopupMe
        groupName.setText(MessageManager
                .getString("label.edit_name_and_description_current_group"));
  
 -      if (sg.cs instanceof ZappoColourScheme)
 -      {
 -        zappoColour.setSelected(true);
 -      }
 -      else if (sg.cs instanceof TaylorColourScheme)
 -      {
 -        taylorColour.setSelected(true);
 -      }
 -      else if (sg.cs instanceof PIDColourScheme)
 -      {
 -        PIDColour.setSelected(true);
 -      }
 -      else if (sg.cs instanceof Blosum62ColourScheme)
 -      {
 -        BLOSUM62Colour.setSelected(true);
 -      }
 -      else if (sg.cs instanceof UserColourScheme)
 -      {
 -        userDefinedColour.setSelected(true);
 -      }
 -      else if (sg.cs instanceof HydrophobicColourScheme)
 -      {
 -        hydrophobicityColour.setSelected(true);
 -      }
 -      else if (sg.cs instanceof HelixColourScheme)
 -      {
 -        helixColour.setSelected(true);
 -      }
 -      else if (sg.cs instanceof StrandColourScheme)
 -      {
 -        strandColour.setSelected(true);
 -      }
 -      else if (sg.cs instanceof TurnColourScheme)
 -      {
 -        turnColour.setSelected(true);
 -      }
 -      else if (sg.cs instanceof BuriedColourScheme)
 -      {
 -        buriedColour.setSelected(true);
 -      }
 -      else if (sg.cs instanceof ClustalxColourScheme)
 -      {
 -        clustalColour.setSelected(true);
 -      }
 -      else if (sg.cs instanceof PurinePyrimidineColourScheme)
 -      {
 -        purinePyrimidineColour.setSelected(true);
 -      }
 -
 -      /*
 -       * else if (sg.cs instanceof CovariationColourScheme) {
 -       * covariationColour.setSelected(true); }
 -       */
 -      else
 -      {
 -        noColourmenuItem.setSelected(true);
 -      }
 +      ColourMenuHelper.setColourSelected(colourMenu, sg.cs);
  
-       if (sg.cs != null && sg.cs.conservationApplied())
+       if (sg.cs != null)
        {
-         conservationMenuItem.setSelected(true);
+         if (sg.cs.conservationApplied())
+         {
 -        conservationMenuItem.setSelected(true);
++          conservationMenuItem.setSelected(true);
+         }
+         if (sg.cs.getThreshold() > 0)
+         {
+           abovePIDColour.setSelected(true);
+         }
        }
        displayNonconserved.setSelected(sg.getShowNonconserved());
        showText.setSelected(sg.getDisplayText());