From f3e21a7b9556252fd1ede2c8323a64320842db79 Mon Sep 17 00:00:00 2001 From: Renia Correya Date: Tue, 8 Oct 2024 12:45:54 +0100 Subject: [PATCH] JAL-4476 Reformat secondary structure consensus annotation labels --- src/jalview/gui/AnnotationLabels.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/jalview/gui/AnnotationLabels.java b/src/jalview/gui/AnnotationLabels.java index db4e654..df07e91 100755 --- a/src/jalview/gui/AnnotationLabels.java +++ b/src/jalview/gui/AnnotationLabels.java @@ -1620,7 +1620,24 @@ public class AnnotationLabels extends JPanel // g.drawLine(20, y + offset, x - 20, y + offset); } - g.drawString(label, x, y + offset); + if(label.contains("Secondary Structure Consensus")) { + //label.replace("Secondary Structure Consensus", "Secondary Structure Consensus" + "\n"); + // Split the string into lines using the newline character + String[] lines = label.split("(?<=Secondary Structure Consensus)", 2); + + // Set the starting y position + int lineHeight = g.getFontMetrics().getHeight(); + labelWidth = Math.max(fm.stringWidth(lines[0]), fm.stringWidth(lines[1])) + 3; + + x = width - labelWidth; + for (int k = 0; k < lines.length; k++) { + // Draw each line, offsetting the y position by lineHeight for each line + g.drawString(lines[k].trim(), x, y + offset +(k * lineHeight)); + } + } + else { + g.drawString(label, x, y + offset); + } } } lastSeqRef = aa[i].sequenceRef; -- 1.7.10.2