Merge branch 'Release_2_8_3_Branch' of https://source.jalview.org/git/jalview into...
[jalview.git] / src / jalview / appletgui / AlignViewport.java
index 2d38008..fdc6a0c 100644 (file)
@@ -28,6 +28,7 @@ import jalview.bin.JalviewLite;
 import jalview.commands.CommandI;
 import jalview.datamodel.AlignmentI;
 import jalview.datamodel.ColumnSelection;
+import jalview.datamodel.SearchResults;
 import jalview.datamodel.Sequence;
 import jalview.datamodel.SequenceGroup;
 import jalview.datamodel.SequenceI;
@@ -42,14 +43,6 @@ import jalview.viewmodel.AlignmentViewport;
 public class AlignViewport extends AlignmentViewport implements
         AlignViewportI, SelectionSource, VamsasSource, CommandListener
 {
-  int startRes;
-
-  int endRes;
-
-  int startSeq;
-
-  int endSeq;
-
   boolean cursorMode = false;
 
   Font font = new Font("SansSerif", Font.PLAIN, 10);
@@ -103,7 +96,7 @@ public class AlignViewport extends AlignmentViewport implements
                           + widthScale + "). Ignoring.");
           widthScale = 1;
         }
-        if (applet.debug)
+        if (JalviewLite.debug)
         {
           System.err
                   .println("Alignment character width scaling factor is now "
@@ -126,7 +119,7 @@ public class AlignViewport extends AlignmentViewport implements
                           + heightScale + "). Ignoring.");
           heightScale = 1;
         }
-        if (applet.debug)
+        if (JalviewLite.debug)
         {
           System.err
                   .println("Alignment character height scaling factor is now "
@@ -157,6 +150,9 @@ public class AlignViewport extends AlignmentViewport implements
       setShowUnconserved(applet.getDefaultParameter("showUnconserved",
               getShowUnconserved()));
 
+      setScaleProteinAsCdna(applet.getDefaultParameter(
+              "scaleProteinAsCdna", isScaleProteinAsCdna()));
+
       String param = applet.getParameter("upperCase");
       if (param != null)
       {
@@ -167,9 +163,9 @@ public class AlignViewport extends AlignmentViewport implements
       }
       sortByTree = applet.getDefaultParameter("sortByTree", sortByTree);
 
-      followHighlight = applet.getDefaultParameter("automaticScrolling",
-              followHighlight);
-      followSelection = followHighlight;
+      setFollowHighlight(applet.getDefaultParameter("automaticScrolling",
+              isFollowHighlight()));
+      followSelection = isFollowHighlight();
 
       showSequenceLogo = applet.getDefaultParameter("showSequenceLogo",
               showSequenceLogo);
@@ -259,64 +255,6 @@ public class AlignViewport extends AlignmentViewport implements
     return sq;
   }
 
-  public int getStartRes()
-  {
-    return startRes;
-  }
-
-  public int getEndRes()
-  {
-    return endRes;
-  }
-
-  public int getStartSeq()
-  {
-    return startSeq;
-  }
-
-  public void setStartRes(int res)
-  {
-    this.startRes = res;
-  }
-
-  public void setStartSeq(int seq)
-  {
-    this.startSeq = seq;
-  }
-
-  public void setEndRes(int res)
-  {
-    if (res > alignment.getWidth() - 1)
-    {
-      // log.System.out.println(" Corrected res from " + res + " to maximum " +
-      // (alignment.getWidth()-1));
-      res = alignment.getWidth() - 1;
-    }
-    if (res < 0)
-    {
-      res = 0;
-    }
-    this.endRes = res;
-  }
-
-  public void setEndSeq(int seq)
-  {
-    if (seq > alignment.getHeight())
-    {
-      seq = alignment.getHeight();
-    }
-    if (seq < 0)
-    {
-      seq = 0;
-    }
-    this.endSeq = seq;
-  }
-
-  public int getEndSeq()
-  {
-    return endSeq;
-  }
-
   java.awt.Frame nullFrame;
 
   protected FeatureSettings featureSettings = null;
@@ -373,13 +311,6 @@ public class AlignViewport extends AlignmentViewport implements
     return centreColumnLabels;
   }
 
-  public boolean followHighlight = true;
-
-  public boolean getFollowHighlight()
-  {
-    return followHighlight;
-  }
-
   public boolean followSelection = true;
 
   /**
@@ -511,4 +442,29 @@ public class AlignViewport extends AlignmentViewport implements
     return this;
   }
 
+  /**
+   * If this viewport has a (Protein/cDNA) complement, then scroll the
+   * complementary alignment to match this one.
+   */
+  public void scrollComplementaryAlignment(AlignmentPanel complementPanel)
+  {
+    if (complementPanel == null)
+    {
+      return;
+    }
+
+    /*
+     * Populate a SearchResults object with the mapped location to scroll to. If
+     * there is no complement, or it is not following highlights, or no mapping
+     * is found, the result will be empty.
+     */
+    SearchResults sr = new SearchResults();
+    int seqOffset = findComplementScrollTarget(sr);
+    if (!sr.isEmpty())
+    {
+      complementPanel.setFollowingComplementScroll(true);
+      complementPanel.scrollToCentre(sr, seqOffset);
+    }
+  }
+
 }