From: Renia Correya Date: Tue, 8 Oct 2024 11:45:54 +0000 (+0100) Subject: JAL-4476 Reformat secondary structure consensus annotation labels X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=refs%2Fheads%2Ffeature%2FJAL-4476_reformat_ss_consensus_annotation_labels;p=jalview.git JAL-4476 Reformat secondary structure consensus annotation labels --- 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;