Merge branch 'develop' of https://source.jalview.org/git/jalview into develop
authortcofoegbu <tcnofoegbu@dundee.ac.uk>
Tue, 8 Nov 2016 10:22:05 +0000 (10:22 +0000)
committertcofoegbu <tcnofoegbu@dundee.ac.uk>
Tue, 8 Nov 2016 10:22:05 +0000 (10:22 +0000)
help/html/colourSchemes/abovePID.html
src/jalview/gui/Desktop.java
src/jalview/gui/Preferences.java
src/jalview/jbgui/GSequenceLink.java
src/jalview/util/Platform.java
test/jalview/ext/htsjdk/TestHtsContigDb.java
test/jalview/gui/AlignFrameTest.java
test/jalview/gui/AppVarnaTest.java
test/jalview/io/PfamFormatInputTest.java
test/jalview/util/PlatformTest.java [new file with mode: 0644]
test/jalview/ws/jabaws/DisorderAnnotExportImport.java

index 614764b..ad47dae 100755 (executable)
@@ -36,9 +36,10 @@ td {
   </p>
   <p>Selecting this option causes the colour scheme to be applied to
     only those residues that occur in that column more than a certain
-    percentage of the time. For instance selecting the threshold to be
-    100 will only colour those columns with 100 % identity. This
-    threshold option can be applied to the Zappo, Taylor, Hydrophobicity
-    and User colour schemes.</p>
+    percentage of the time. For instance, selecting the threshold to be
+    100 will only colour those columns with 100% identity.</p>
+   <p>To be coloured, a residue must match the consensus (most commonly occurring) residue for the column (or joint equal consensus).</p>
+   <p>The percentage calculation may include or exclude gaps in the column, depending on the option selected for the <a href="../calculations/consensus.html">consensus calculation</a>.</p>
+   <p>With a threshold of 0, colouring is unchanged (including non-consensus residues).</p>
 </body>
 </html>
index d06dd26..28606f1 100644 (file)
@@ -2282,12 +2282,19 @@ public class Desktop extends jalview.jbgui.GDesktop implements
           // only need to check links if there is one with a
           // SEQUENCE_ID which is not the default EMBL_EBI link
           ListIterator<String> li = links.listIterator();
-          Boolean check = false;
-          while (li.hasNext() && !check)
+          boolean check = false;
+          List<JLabel> urls = new ArrayList<JLabel>();
+          while (li.hasNext())
           {
             String link = li.next();
-            check = (link.contains(SEQUENCE_ID) && !link
-                    .equals(EMBLEBI_STRING));
+            if (link.contains(SEQUENCE_ID) && !link.equals(EMBLEBI_STRING))
+            {
+              check = true;
+              int barPos = link.indexOf("|");
+              String urlMsg = barPos == -1 ? link : link.substring(0,
+                      barPos) + ": " + link.substring(barPos + 1);
+              urls.add(new JLabel(urlMsg));
+            }
           }
           if (!check)
           {
@@ -2306,6 +2313,10 @@ public class Desktop extends jalview.jbgui.GDesktop implements
                   MessageManager
                           .getString("label.SEQUENCE_ID_for_DB_ACCESSION2"));
           msgPanel.add(msg);
+          for (JLabel url : urls)
+          {
+            msgPanel.add(url);
+          }
           msgPanel.add(msg2);
 
           final JCheckBox jcb = new JCheckBox(
@@ -2315,15 +2326,10 @@ public class Desktop extends jalview.jbgui.GDesktop implements
             @Override
             public void actionPerformed(ActionEvent e)
             {
-              // update Cache settings if checkbox is selected
-              if (jcb.isSelected())
-              {
-                Cache.setProperty("CHECKURLLINKS", "false");
-              }
-              else
-              {
-                Cache.setProperty("CHECKURLLINKS", "true");
-              }
+              // update Cache settings for "don't show this again"
+              boolean showWarningAgain = !jcb.isSelected();
+              Cache.setProperty("CHECKURLLINKS",
+                      Boolean.valueOf(showWarningAgain).toString());
             }
           });
           msgPanel.add(jcb);
index 4f094e1..3bffd3a 100755 (executable)
@@ -20,8 +20,8 @@
  */
 package jalview.gui;
 
-import static jalview.util.UrlConstants.EMBLEBI_STRING;
 import static jalview.util.UrlConstants.DB_ACCESSION;
+import static jalview.util.UrlConstants.EMBLEBI_STRING;
 import static jalview.util.UrlConstants.SEQUENCE_ID;
 import static jalview.util.UrlConstants.SRS_STRING;
 
@@ -567,6 +567,7 @@ public class Preferences extends GPreferences
     else
     {
       Cache.applicationProperties.remove("SEQUENCE_LINKS");
+      sequenceURLLinks.clear();
     }
 
     Cache.applicationProperties.setProperty("USE_PROXY",
index b27752e..2689946 100755 (executable)
@@ -67,7 +67,7 @@ public class GSequenceLink extends Panel
       }
     });
     urlTB.setFont(JvSwingUtils.getLabelFont());
-    urlTB.setText("http://www.");
+    urlTB.setText("http://");
     urlTB.setBounds(new Rectangle(78, 40, 309, 23));
     urlTB.addKeyListener(new KeyAdapter()
     {
index 9df2060..49dc7ff 100644 (file)
@@ -30,6 +30,10 @@ import java.awt.event.MouseEvent;
  */
 public class Platform
 {
+  private static Boolean isAMac = null;
+
+  private static Boolean isHeadless = null;
+
   /**
    * sorry folks - Macs really are different
    * 
@@ -37,15 +41,21 @@ public class Platform
    */
   public static boolean isAMac()
   {
-    return java.lang.System.getProperty("os.name").indexOf("Mac") > -1;
+    if (isAMac == null)
+    {
+      isAMac = System.getProperty("os.name").indexOf("Mac") > -1;
+    }
+    return isAMac.booleanValue();
 
   }
 
   public static boolean isHeadless()
   {
-    String hdls = java.lang.System.getProperty("java.awt.headless");
-
-    return hdls != null && hdls.equals("true");
+    if (isHeadless == null)
+    {
+      isHeadless = "true".equals(System.getProperty("java.awt.headless"));
+    }
+    return isHeadless;
   }
 
   /**
@@ -89,7 +99,20 @@ public class Platform
    */
   public static boolean isControlDown(MouseEvent e)
   {
-    if (isAMac())
+    boolean aMac = isAMac();
+    return isControlDown(e, aMac);
+  }
+
+  /**
+   * Overloaded version of method (to allow unit testing)
+   * 
+   * @param e
+   * @param aMac
+   * @return
+   */
+  protected static boolean isControlDown(MouseEvent e, boolean aMac)
+  {
+    if (aMac)
     {
       /*
        * answer false for right mouse button
index f8c53b0..bdc14db 100644 (file)
@@ -33,7 +33,7 @@ import org.testng.annotations.Test;
  */
 public class TestHtsContigDb
 {
-  @Test
+  @Test(groups = "Functional")
   public final void testHTSReferenceSequence() throws Exception
   {
     HtsContigDb remmadb = new HtsContigDb("REEMADB", new File(
index 316d9af..b2ef3f7 100644 (file)
@@ -37,7 +37,7 @@ import org.testng.annotations.Test;
 public class AlignFrameTest
 {
 
-  @Test
+  @Test(groups = "Functional")
   public void testHideFeatureColumns()
   {
     SequenceI seq1 = new Sequence("Seq1", "ABCDEFGHIJ");
index 5bc0ddf..92770d5 100644 (file)
@@ -28,7 +28,7 @@ import org.testng.annotations.Test;
 
 public class AppVarnaTest
 {
-  @Test
+  @Test(groups = "Functional")
   public void testReplaceOddGaps()
   {
     String struct = "{(<]}>)";
index 0eaf94b..fb99865 100644 (file)
@@ -29,20 +29,20 @@ import org.testng.annotations.Test;
 
 public class PfamFormatInputTest
 {
-  @Test
+  @Test(groups = "Functional")
   public void testPfamFormatNoLimits() throws IOException
   {
-    AlignmentI al = new jalview.io.AppletFormatAdapter().readFile("ASEQ"
+    AlignmentI al = new AppletFormatAdapter().readFile("ASEQ"
             + '\t' + "...--FFAFAFF--", AppletFormatAdapter.PASTE, "PFAM");
     Assert.assertEquals(1, al.getHeight(), "Wrong number of sequences");
     Assert.assertTrue(al.hasValidSequence(),
             "Didn't extract limits from PFAM ID");
   }
 
-  @Test
+  @Test(groups = "Functional")
   public void testPfamFormatValidLimits() throws IOException
   {
-    AlignmentI al = new jalview.io.AppletFormatAdapter().readFile(
+    AlignmentI al = new AppletFormatAdapter().readFile(
             "ASEQ/15-25" + '\t' + "...--FFAFAFF--",
             AppletFormatAdapter.PASTE, "PFAM");
     Assert.assertEquals(1, al.getHeight(), "Wrong number of sequences");
diff --git a/test/jalview/util/PlatformTest.java b/test/jalview/util/PlatformTest.java
new file mode 100644 (file)
index 0000000..88fd1b9
--- /dev/null
@@ -0,0 +1,80 @@
+package jalview.util;
+
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
+
+import java.awt.Button;
+import java.awt.Event;
+import java.awt.event.MouseEvent;
+
+import org.testng.annotations.Test;
+
+public class PlatformTest
+{
+  Button b = new Button();
+
+  /**
+   * isControlDown for Mac should answer true for Meta-down, but not for right
+   * mouse (popup trigger)
+   */
+  @Test(groups = "Functional")
+  public void testIsControlDown_mac()
+  {
+    int clickCount = 1;
+    boolean isPopupTrigger = false;
+    int buttonNo = MouseEvent.BUTTON1;
+    boolean mac = true;
+
+    int mods = 0;
+    // not concerned with MouseEvent id, when, x, y, xAbs, yAbs values
+    assertFalse(Platform.isControlDown(new MouseEvent(b, 0, 0L, mods, 0, 0,
+            0, 0, clickCount, isPopupTrigger, buttonNo), mac));
+
+    mods = Event.CTRL_MASK;
+    assertFalse(Platform.isControlDown(new MouseEvent(b, 0, 0L, mods, 0, 0,
+            0, 0, clickCount, isPopupTrigger, buttonNo), mac));
+
+    mods = Event.META_MASK;
+    assertTrue(Platform.isControlDown(new MouseEvent(b, 0, 0L, mods, 0, 0,
+            0, 0, clickCount, isPopupTrigger, buttonNo), mac));
+
+    isPopupTrigger = true;
+    assertFalse(Platform.isControlDown(new MouseEvent(b, 0, 0L, mods, 0, 0,
+            0, 0, clickCount, isPopupTrigger, buttonNo), mac));
+
+    isPopupTrigger = false;
+    buttonNo = MouseEvent.BUTTON2;
+    mods = 0;
+    assertFalse(Platform.isControlDown(new MouseEvent(b, 0, 0L, mods, 0, 0,
+            0, 0, clickCount, isPopupTrigger, buttonNo), mac));
+  }
+
+  /**
+   * If not a Mac, we only care whether CTRL_MASK modifier is set on the mouse
+   * event
+   */
+  @Test(groups = "Functional")
+  public void testIsControlDown_notMac()
+  {
+    int clickCount = 1;
+    boolean isPopupTrigger = false;
+    int buttonNo = MouseEvent.BUTTON1;
+    boolean mac = false;
+
+    int mods = 0;
+    // not concerned with MouseEvent id, when, x, y, xAbs, yAbs values
+    assertFalse(Platform.isControlDown(new MouseEvent(b, 0, 0L, mods, 0, 0,
+            0, 0, clickCount, isPopupTrigger, buttonNo), mac));
+
+    mods = Event.CTRL_MASK;
+    assertTrue(Platform.isControlDown(new MouseEvent(b, 0, 0L, mods, 0, 0,
+            0, 0, clickCount, isPopupTrigger, buttonNo), mac));
+
+    mods = Event.CTRL_MASK | Event.SHIFT_MASK | Event.ALT_MASK;
+    clickCount = 2;
+    buttonNo = 2;
+    isPopupTrigger = true;
+    assertTrue(Platform.isControlDown(new MouseEvent(b, 0, 0L, mods, 0, 0,
+            0, 0, clickCount, isPopupTrigger, buttonNo), mac));
+  }
+}
index 9f62481..2067659 100644 (file)
@@ -119,11 +119,11 @@ public class DisorderAnnotExportImport
     {
       orig_alig.deleteAnnotation(aa);
     }
-    testAnnotationFileIO("Testing IUPred Annotation IO", orig_alig);
+    checkAnnotationFileIO("Testing IUPred Annotation IO", orig_alig);
 
   }
 
-  public static void testAnnotationFileIO(String testname, AlignmentI al)
+  static void checkAnnotationFileIO(String testname, AlignmentI al)
   {
     try
     {