Merge branch 'feature/JAL-2250colourAllGroups' into develop
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Mon, 11 Mar 2019 15:04:23 +0000 (15:04 +0000)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Mon, 11 Mar 2019 15:04:23 +0000 (15:04 +0000)
12 files changed:
help/html/features/preferences.html
resources/lang/Messages.properties
resources/lang/Messages_es.properties
src/jalview/ext/ensembl/EnsemblSequenceFetcher.java
src/jalview/gui/AlignFrame.java
src/jalview/gui/AnnotationColourChooser.java
src/jalview/gui/PopupMenu.java
src/jalview/gui/ScalePanel.java
src/jalview/jbgui/GAlignFrame.java
src/jalview/schemes/AnnotationColourGradient.java
src/jalview/schemes/ResidueColourScheme.java
test/jalview/schemes/AnnotationColourGradientTest.java

index 52e88db..8c6b699 100755 (executable)
@@ -62,8 +62,7 @@
       sequence alignments and EPS files.
     </li>
     <li>The <a href="#editing"><strong>&quot;Editing&quot;</strong>
-        Preferences</a> tab contains settings affecting the export of
-      sequence alignments and EPS files.
+        Preferences</a> tab contains settings affecting behaviour when editing alignments.
     </li>
     <li>The <a href="../webServices/webServicesPrefs.html"><strong>&quot;Web
           Service&quot;</strong> Preferences</a> tab allows you to configure the <a
     the backbone atoms in the PDB file will be extracted as annotation
     lines shown on the alignment.
   <p>
-    <em>Default structure viewer</em> - choose JMOL or CHIMERA for
+    <em>Default structure viewer</em> - choose Jmol or CHIMERA for
     viewing 3D structures.
   <p>
     <em>Path to Chimera program</em> - Optional, as Jalview will search
         Preferences tab</strong></a>
   </p>
   <p>
-    <em>Default Browser (Unix)</em><br> Its difficult in Java to
+    <em>Default Browser (Unix)</em><br> It's difficult in Java to
     detect the default web browser for Unix users. If Jalview can't find
     your default web browser, enter the name or full path to your web
     browser application.
     just those you have configured yourself <em>via</em> the <em>Edit
       Links</em> buttons. Press <em>Show all</em> to clear any filters.
   </p>
-  <p>The links table is prepoulated with persistent URLs for many common
+  <p>The links table is prepopulated with persistent URLs for many common
     bioinformatics databases (since 2.10.2). These links are downloaded by Jalview from
     the <em>identifiers.org</em> website, and the names and URLs are not
     user editable.
     allows the user to set a default rendering style for EPS export:
   <ul>
     <li>&quot;Prompt each time&quot;<br> Choose this to be
-      asked select between Lineart and Text each time you make an EPS
+      asked to select between Lineart and Text each time you make an EPS
       file.
     </li>
     <li>&quot;Lineart&quot;<br> EPS files will accurately
     ignored if <em>&quot;Automatically set ID width&quot;</em> is set.
   </p>
   <p>
-    <em>Sequence//Start-End Numbering</em><br> The output tab also
+    <em>Sequence/Start-End Numbering</em><br> The output tab also
     has a group of checkboxes for each file format. If these are ticked,
     then Jalview will write files with the start and end sequence
     positions appended to each sequence id:
index aabda20..c5f2372 100644 (file)
@@ -1391,3 +1391,4 @@ label.alignment = alignment
 label.pca = PCA
 label.create_image_of = Create {0} image of {1}
 label.click_to_edit = Click to edit, right-click for menu
+label.by_annotation_tooltip = Annotation Colour is configured from the main Colour menu
index b32842e..7ad1828 100644 (file)
@@ -1392,3 +1392,4 @@ label.alignment = alineamiento
 label.pca = ACP
 label.create_image_of = Crear imagen {0} de {1}
 label.click_to_edit = Haga clic para editar, clic en el botón derecho para ver el menú  
+label.by_annotation_tooltip = El color de anotación se configura desde el menú principal de colores
index 4da0e3c..8296985 100644 (file)
@@ -92,9 +92,9 @@ abstract class EnsemblSequenceFetcher extends DbSourceProxyImpl
      * this allows an easy change from http to https in future if needed
      */
     ensemblDomain = Cache.getDefault(ENSEMBL_BASEURL,
-            DEFAULT_ENSEMBL_BASEURL);
+            DEFAULT_ENSEMBL_BASEURL).trim();
     ensemblGenomesDomain = Cache.getDefault(ENSEMBL_GENOMES_BASEURL,
-            DEFAULT_ENSEMBL_GENOMES_BASEURL);
+            DEFAULT_ENSEMBL_GENOMES_BASEURL).trim();
     domain = ensemblDomain;
   }
 
@@ -169,6 +169,6 @@ abstract class EnsemblSequenceFetcher extends DbSourceProxyImpl
 
   protected void setDomain(String d)
   {
-    domain = d;
+    domain = d == null ? null : d.trim();
   }
 }
index e17b331..8dd6d0c 100644 (file)
@@ -136,6 +136,7 @@ import java.util.Hashtable;
 import java.util.List;
 import java.util.Vector;
 
+import javax.swing.ButtonGroup;
 import javax.swing.JCheckBoxMenuItem;
 import javax.swing.JEditorPane;
 import javax.swing.JInternalFrame;
@@ -5593,15 +5594,16 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
     colourMenu.add(textColour);
     colourMenu.addSeparator();
 
-    ColourMenuHelper.addMenuItems(colourMenu, this, viewport.getAlignment(),
-            false);
+    ButtonGroup bg = ColourMenuHelper.addMenuItems(colourMenu, this,
+            viewport.getAlignment(), false);
 
+    colourMenu.add(annotationColour);
+    bg.add(annotationColour);
     colourMenu.addSeparator();
     colourMenu.add(conservationMenuItem);
     colourMenu.add(modifyConservation);
     colourMenu.add(abovePIDThreshold);
     colourMenu.add(modifyPID);
-    colourMenu.add(annotationColour);
 
     ColourSchemeI colourScheme = viewport.getGlobalColourScheme();
     ColourMenuHelper.setColourSelected(colourMenu, colourScheme);
index 384635b..12693f0 100644 (file)
@@ -317,7 +317,7 @@ public class AnnotationColourChooser extends AnnotationRowFilter
   @Override
   public void reset()
   {
-    av.setGlobalColourScheme(oldcs);
+    this.ap.alignFrame.changeColour(oldcs);
     if (av.getAlignment().getGroups() != null)
     {
 
@@ -442,7 +442,7 @@ public class AnnotationColourChooser extends AnnotationRowFilter
 
     acg.setThresholdIsMinMax(thresholdIsMin.isSelected());
 
-    av.setGlobalColourScheme(acg);
+    this.ap.alignFrame.changeColour(acg);
 
     if (av.getAlignment().getGroups() != null)
     {
@@ -465,5 +465,4 @@ public class AnnotationColourChooser extends AnnotationRowFilter
     super.sliderDragReleased();
     ap.paintAlignment(true, true);
   }
-
 }
index bc7fb3b..8059935 100644 (file)
@@ -46,6 +46,7 @@ import jalview.schemes.Blosum62ColourScheme;
 import jalview.schemes.ColourSchemeI;
 import jalview.schemes.ColourSchemes;
 import jalview.schemes.PIDColourScheme;
+import jalview.schemes.ResidueColourScheme;
 import jalview.util.GroupUrlLink;
 import jalview.util.GroupUrlLink.UrlStringTooLongException;
 import jalview.util.MessageManager;
@@ -68,11 +69,13 @@ import java.util.SortedMap;
 import java.util.TreeMap;
 import java.util.Vector;
 
+import javax.swing.ButtonGroup;
 import javax.swing.JCheckBoxMenuItem;
 import javax.swing.JColorChooser;
 import javax.swing.JMenu;
 import javax.swing.JMenuItem;
 import javax.swing.JPopupMenu;
+import javax.swing.JRadioButtonMenuItem;
 
 /**
  * DOCUMENT ME!
@@ -92,6 +95,8 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
 
   protected JCheckBoxMenuItem conservationMenuItem = new JCheckBoxMenuItem();
 
+  protected JRadioButtonMenuItem annotationColour;
+
   protected JMenuItem modifyConservation = new JMenuItem();
 
   AlignmentPanel ap;
@@ -1411,6 +1416,13 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
       }
     });
 
+    annotationColour = new JRadioButtonMenuItem(
+            MessageManager.getString("action.by_annotation"));
+    annotationColour.setName(ResidueColourScheme.ANNOTATION_COLOUR);
+    annotationColour.setEnabled(false);
+    annotationColour.setToolTipText(
+            MessageManager.getString("label.by_annotation_tooltip"));
+
     modifyConservation.setText(MessageManager
             .getString("label.modify_conservation_threshold"));
     modifyConservation.addActionListener(new ActionListener()
@@ -1441,7 +1453,10 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
     colourMenu.add(textColour);
     colourMenu.addSeparator();
 
-    ColourMenuHelper.addMenuItems(colourMenu, this, sg, false);
+    ButtonGroup bg = ColourMenuHelper.addMenuItems(colourMenu, this, sg,
+            false);
+    bg.add(annotationColour);
+    colourMenu.add(annotationColour);
 
     colourMenu.addSeparator();
     colourMenu.add(conservationMenuItem);
index 0f2b765..b95c569 100755 (executable)
@@ -274,6 +274,7 @@ public class ScalePanel extends JPanel
   @Override
   public void mouseReleased(MouseEvent evt)
   {
+    boolean wasDragging = mouseDragging;
     mouseDragging = false;
     ap.getSeqPanel().stopScrolling();
 
@@ -285,7 +286,8 @@ public class ScalePanel extends JPanel
       res = av.getAlignment().getHiddenColumns()
               .visibleToAbsoluteColumn(res);
     }
-    res = Math.min(res, av.getAlignment().getWidth() - 1);
+    res = Math.min(res, av.getRanges().getEndRes());
+    res = Math.max(0, res);
 
     if (!stretchingGroup)
     {
@@ -312,6 +314,12 @@ public class ScalePanel extends JPanel
       {
         sg.setStartRes(res);
       }
+      if (wasDragging)
+      {
+        min = Math.min(res, min);
+        max = Math.max(res, max);
+        av.getColumnSelection().stretchGroup(res, sg, min, max);
+      }
     }
     stretchingGroup = false;
     ap.paintAlignment(false, false);
index 0ee03bc..9f41c92 100755 (executable)
@@ -28,6 +28,7 @@ import jalview.bin.Cache;
 import jalview.gui.JvSwingUtils;
 import jalview.gui.Preferences;
 import jalview.io.FileFormats;
+import jalview.schemes.ResidueColourScheme;
 import jalview.util.MessageManager;
 import jalview.util.Platform;
 
@@ -125,7 +126,7 @@ public class GAlignFrame extends JInternalFrame
 
   protected JMenuItem modifyPID;
 
-  protected JMenuItem annotationColour;
+  protected JRadioButtonMenuItem annotationColour;
 
   protected JMenu sortByTreeMenu = new JMenu();
 
@@ -1962,8 +1963,9 @@ public class GAlignFrame extends JInternalFrame
       }
     });
 
-    annotationColour = new JMenuItem(
+    annotationColour = new JRadioButtonMenuItem(
             MessageManager.getString("action.by_annotation"));
+    annotationColour.setName(ResidueColourScheme.ANNOTATION_COLOUR);
     annotationColour.addActionListener(new ActionListener()
     {
       @Override
index c74fdbc..54eaeb0 100755 (executable)
@@ -319,9 +319,9 @@ public class AnnotationColourGradient extends FollowerColourScheme
     if (annotationThreshold != null)
     {
       if ((aboveAnnotationThreshold == ABOVE_THRESHOLD
-              && aj.value < annotationThreshold.value)
+              && aj.value <= annotationThreshold.value)
               || (aboveAnnotationThreshold == BELOW_THRESHOLD
-                      && aj.value > annotationThreshold.value))
+                      && aj.value >= annotationThreshold.value))
       {
         return Color.white;
       }
@@ -478,7 +478,7 @@ public class AnnotationColourGradient extends FollowerColourScheme
   @Override
   public String getSchemeName()
   {
-    return "Annotation";
+    return ANNOTATION_COLOUR;
   }
 
   @Override
index 2f7a5e0..03ab536 100755 (executable)
@@ -46,6 +46,12 @@ public abstract class ResidueColourScheme implements ColourSchemeI
   public static final String USER_DEFINED_MENU = "*User Defined*";
 
   /*
+   * the canonical name of the annotation colour scheme 
+   * (may be used to identify it in menu items)
+   */
+  public static final String ANNOTATION_COLOUR = "Annotation";
+
+  /*
    * lookup up by character value e.g. 'G' to the colors array index
    * e.g. if symbolIndex['K'] = 11 then colors[11] is the colour for K
    */
index be8b58d..22124f7 100644 (file)
@@ -214,9 +214,10 @@ public class AnnotationColourGradientTest
     {
       Color result = testee.findColour('a', col, seq);
       /*
-       * expect white below threshold of 5
+       * expect white at or below threshold of 5
        */
-      Color expected = col < 5 ? Color.white : new Color(50 + 10 * col,
+      Color expected = col <= 5 ? Color.white
+              : new Color(50 + 10 * col,
               200 - 10 * col,
               150 + 10 * col);
       assertEquals(result, expected, "for column " + col);
@@ -230,11 +231,12 @@ public class AnnotationColourGradientTest
     for (int col = 0; col < WIDTH; col++)
     {
       /*
-       * colours for values >= threshold are graduated
+       * colours for values > threshold are graduated
        * range is 6-10 so steps of 100/5 = 20
        */
       int factor = col - THRESHOLD_FIVE;
-      Color expected = col < 5 ? Color.white : new Color(50 + 20 * factor,
+      Color expected = col <= 5 ? Color.white
+              : new Color(50 + 20 * factor,
               200 - 20 * factor,
               150 + 20 * factor);
       Color result = testee.findColour('a', col, seq);
@@ -255,7 +257,8 @@ public class AnnotationColourGradientTest
     for (int col = 0; col < WIDTH; col++)
     {
       Color result = testee.findColour('a', col, seq);
-      Color expected = col > 5 ? Color.white : new Color(50 + 10 * col,
+      Color expected = col >= 5 ? Color.white
+              : new Color(50 + 10 * col,
               200 - 10 * col, 150 + 10 * col);
       assertEquals(result, expected, "for column " + col);
     }
@@ -268,10 +271,11 @@ public class AnnotationColourGradientTest
     for (int col = 0; col < WIDTH; col++)
     {
       /*
-       * colours for values <= threshold are graduated
+       * colours for values < threshold are graduated
        * range is 0-5 so steps of 100/5 = 20
        */
-      Color expected = col > 5 ? Color.white : new Color(50 + 20 * col,
+      Color expected = col >= 5 ? Color.white
+              : new Color(50 + 20 * col,
               200 - 20 * col, 150 + 20 * col);
       Color result = testee.findColour('a', col, seq);
       assertEquals(result, expected, "for column " + col);