From: Ben Soares Date: Thu, 27 Jul 2023 19:14:25 +0000 (+0100) Subject: JAL-244 Allow wrap manual adjustments to be smaller than the actual id widths. X-Git-Tag: Release_2_11_4_0~216^2~9 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=3a10cfaddf4f4a0949fbecca95f97ccf1d1ca1d6;p=jalview.git JAL-244 Allow wrap manual adjustments to be smaller than the actual id widths. --- diff --git a/src/jalview/gui/IdCanvas.java b/src/jalview/gui/IdCanvas.java index d9997a0..ab21714 100755 --- a/src/jalview/gui/IdCanvas.java +++ b/src/jalview/gui/IdCanvas.java @@ -435,15 +435,19 @@ public class IdCanvas extends JPanel implements ViewportListenerI if (labels != null && alignViewport.isShowAnnotation()) { + int thisIdWidth = getWidth(); g.translate(0, ypos + (alheight * charHeight)); - int getAnnotationsIdWidth = labels.drawLabels(g, false, -1, false, - null); - int thisIdWidth = idWidth < 0 ? getAnnotationsIdWidth : idWidth; - if (thisIdWidth > getWidth()) + if (!manuallyAdjusted()) { - this.setPreferredSize( - new Dimension(this.getHeight(), thisIdWidth)); - this.repaint(); + int getAnnotationsIdWidth = labels.drawLabels(g, false, -1, false, + null); + thisIdWidth = idWidth < 0 ? getAnnotationsIdWidth : idWidth; + if (thisIdWidth > getWidth()) + { + this.setPreferredSize( + new Dimension(this.getHeight(), thisIdWidth)); + this.repaint(); + } } labels.drawComponent(g, false, thisIdWidth); g.translate(0, -ypos - (alheight * charHeight)); @@ -601,4 +605,16 @@ public class IdCanvas extends JPanel implements ViewportListenerI repaint(); } } + + private boolean manuallyAdjusted = false; + + public boolean manuallyAdjusted() + { + return manuallyAdjusted; + } + + public void setManuallyAdjusted(boolean b) + { + manuallyAdjusted = b; + } } diff --git a/src/jalview/gui/IdwidthAdjuster.java b/src/jalview/gui/IdwidthAdjuster.java index eef5bfb..0ebdfa1 100755 --- a/src/jalview/gui/IdwidthAdjuster.java +++ b/src/jalview/gui/IdwidthAdjuster.java @@ -46,8 +46,6 @@ public class IdwidthAdjuster extends JPanel AlignmentPanel ap; - private boolean manuallyAdjusted = false; - /** * Creates a new IdwidthAdjuster object. * @@ -151,7 +149,7 @@ public class IdwidthAdjuster extends JPanel ap.validateAnnotationDimensions(false); ap.paintAlignment(true, false); - manuallyAdjusted = true; + ap.getIdPanel().getIdCanvas().setManuallyAdjusted(true); } public void setWidth(int newWidth) @@ -167,7 +165,7 @@ public class IdwidthAdjuster extends JPanel public boolean manuallyAdjusted() { - return manuallyAdjusted; + return ap.getIdPanel().getIdCanvas().manuallyAdjusted(); } @Override