JAL-1690 preserve scaling in New View, synch id width changes
[jalview.git] / src / jalview / gui / IdwidthAdjuster.java
index 71e2040..3d82256 100755 (executable)
@@ -29,6 +29,8 @@ import java.awt.event.MouseMotionListener;
 
 import javax.swing.JPanel;
 
+import jalview.api.AlignViewportI;
+
 /**
  * DOCUMENT ME!
  * 
@@ -88,6 +90,20 @@ public class IdwidthAdjuster extends JPanel implements MouseListener,
   {
     active = false;
     repaint();
+
+    /*
+     * If in a SplitFrame with co-scaled alignments, set the other's id width to
+     * match
+     */
+    final AlignViewportI viewport = ap.getAlignViewport();
+    if (viewport.getCodingComplement() != null
+            && viewport.isScaleProteinAsCdna())
+    {
+      viewport.getCodingComplement().setIdWidth(viewport.getIdWidth());
+      SplitFrame sf = (SplitFrame) ap.alignFrame.getSplitViewContainer();
+      sf.repaint();
+    }
+
   }
 
   /**
@@ -124,12 +140,14 @@ public class IdwidthAdjuster extends JPanel implements MouseListener,
   {
     active = true;
 
-    int curwidth = ap.getAlignViewport().getIdWidth();
+    final AlignViewportI viewport = ap.getAlignViewport();
+    int curwidth = viewport.getIdWidth();
     int dif = evt.getX() - oldX;
 
-    if (((curwidth + dif) > 20) || (dif > 0))
+    final int newWidth = curwidth + dif;
+    if ((newWidth > 20) || (dif > 0))
     {
-      ap.getAlignViewport().setIdWidth(curwidth + dif);
+      viewport.setIdWidth(newWidth);
 
       ap.paintAlignment(true);
     }