From: gmungoc Date: Wed, 29 Apr 2015 15:00:27 +0000 (+0100) Subject: JAL-1690 preserve scaling in New View, synch id width changes X-Git-Tag: Jalview_2_9~41 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=e6139c0f78da30cdf0dabb986706f3a2110c02fc;p=jalview.git JAL-1690 preserve scaling in New View, synch id width changes --- diff --git a/src/jalview/gui/IdwidthAdjuster.java b/src/jalview/gui/IdwidthAdjuster.java index 71e2040..3d82256 100755 --- a/src/jalview/gui/IdwidthAdjuster.java +++ b/src/jalview/gui/IdwidthAdjuster.java @@ -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); } diff --git a/src/jalview/gui/SplitFrame.java b/src/jalview/gui/SplitFrame.java index bfb3719..cab4d27 100644 --- a/src/jalview/gui/SplitFrame.java +++ b/src/jalview/gui/SplitFrame.java @@ -392,6 +392,8 @@ public class SplitFrame extends GSplitFrame implements SplitContainerI { AlignFrame topFrame = (AlignFrame) getTopFrame(); AlignFrame bottomFrame = (AlignFrame) getBottomFrame(); + final boolean scaleProteinAsCdna = topFrame.viewport + .isScaleProteinAsCdna(); AlignmentPanel newTopPanel = topFrame.newView(null, true); AlignmentPanel newBottomPanel = bottomFrame.newView(null, true); @@ -410,6 +412,19 @@ public class SplitFrame extends GSplitFrame implements SplitContainerI newBottomPanel.av.viewName = newTopPanel.av.viewName; newTopPanel.av.setCodingComplement(newBottomPanel.av); + /* + * These lines can be removed once scaleProteinAsCdna is added to element + * Viewport in jalview.xsd, as Jalview2XML.copyAlignPanel will then take + * care of it + */ + newTopPanel.av.setScaleProteinAsCdna(scaleProteinAsCdna); + newBottomPanel.av.setScaleProteinAsCdna(scaleProteinAsCdna); + + /* + * Line up id labels etc + */ + adjustLayout(); + final StructureSelectionManager ssm = StructureSelectionManager .getStructureSelectionManager(Desktop.instance); ssm.addCommandListener(newTopPanel.av);