From 3a10cfaddf4f4a0949fbecca95f97ccf1d1ca1d6 Mon Sep 17 00:00:00 2001 From: Ben Soares Date: Thu, 27 Jul 2023 20:14:25 +0100 Subject: [PATCH] JAL-244 Allow wrap manual adjustments to be smaller than the actual id widths. --- src/jalview/gui/IdCanvas.java | 30 +++++++++++++++++++++++------- src/jalview/gui/IdwidthAdjuster.java | 6 ++---- 2 files changed, 25 insertions(+), 11 deletions(-) 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 -- 1.7.10.2