From 925fb2ee9513a30337cc736996a3487e39d42530 Mon Sep 17 00:00:00 2001 From: amwaterhouse Date: Wed, 18 Apr 2007 12:03:49 +0000 Subject: [PATCH] Alignment of labels and text --- src/jalview/gui/AnnotationLabels.java | 68 ++++++++++----------------------- src/jalview/gui/AnnotationPanel.java | 24 +++++++----- 2 files changed, 34 insertions(+), 58 deletions(-) diff --git a/src/jalview/gui/AnnotationLabels.java b/src/jalview/gui/AnnotationLabels.java index 9590d80..e7e3970 100755 --- a/src/jalview/gui/AnnotationLabels.java +++ b/src/jalview/gui/AnnotationLabels.java @@ -378,9 +378,8 @@ public class AnnotationLabels setToolTipText(ap.av.alignment. getAlignmentAnnotation()[selectedRow].description); } - } - repaint(); + } /** @@ -561,32 +560,36 @@ public class AnnotationLabels AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation(); int fontHeight = g.getFont().getSize(); - int y = fontHeight; + int y = 0; int x = 0; int graphExtras = 0; + int offset =0; if (aa != null) { for (int i = 0; i < aa.length; i++) { + g.setColor(Color.black); + if (!aa[i].visible) { continue; } - x = width - fm.stringWidth(aa[i].label) - 3; - if (aa[i].graph > 0 && aa[i].graphHeight > 0) - { - graphExtras = y; + y += aa[i].height; - y += (aa[i].height / 3); + offset = -aa[i].height/2; - if (aa[i].graphGroup < 0) - { - graphExtras = y + fontHeight; - } + if(aa[i].hasText) + { + offset += fm.getHeight()/2; + offset -= fm.getDescent(); } + else + offset += fm.getDescent(); + + x = width - fm.stringWidth(aa[i].label) - 3; if (aa[i].graphGroup > -1) { @@ -601,7 +604,7 @@ public class AnnotationLabels if (groupSize * (fontHeight + 8) < aa[i].height) { - graphExtras += (aa[i].height - (groupSize * (fontHeight + 8))) / 2; + graphExtras = (aa[i].height - (groupSize * (fontHeight + 8))) / 2; } for (int gg = 0; gg < aa.length; gg++) @@ -609,15 +612,15 @@ public class AnnotationLabels if (aa[gg].graphGroup == aa[i].graphGroup) { x = width - fm.stringWidth(aa[gg].label) - 3; - g.drawString(aa[gg].label, x, graphExtras); + g.drawString(aa[gg].label, x,y - graphExtras); if (aa[gg].annotations[0] != null) { g.setColor(aa[gg].annotations[0].colour); } - g.drawLine(x, graphExtras + 3, + g.drawLine(x, y - graphExtras - 3, x + fm.stringWidth(aa[gg].label), - graphExtras + 3); + y - graphExtras - 3); g.setColor(Color.black); graphExtras += fontHeight + 8; @@ -626,38 +629,7 @@ public class AnnotationLabels } else { - g.drawString(aa[i].label, x, y); - } - - if (aa[i].graph > 0) - { - /* if (aa[i].graphLines != null) - { - for (int gl = 0; gl < aa[i].graphLines.size(); gl++) - { - x = width - fm.stringWidth(aa[i].getGraphLine(gl).label) - 3; - g.drawString(aa[i].getGraphLine(gl).label, x, graphExtras); - g.setColor(aa[i].getGraphLine(gl).colour); - Graphics2D g2 = (Graphics2D) g; - g2.setStroke(new BasicStroke(1, - BasicStroke.CAP_SQUARE, - BasicStroke.JOIN_ROUND, 3f, - new float[] - {5f, 3f}, 0f)); - - graphExtras += 3; - - g.drawLine(x, graphExtras, - x+fm.stringWidth(aa[i].label), - graphExtras); - g2.setStroke(new BasicStroke()); - } - }*/ - y += ( (2 * aa[i].height) / 3); - } - else - { - y += aa[i].height; + g.drawString(aa[i].label, x, y +offset); } } } diff --git a/src/jalview/gui/AnnotationPanel.java b/src/jalview/gui/AnnotationPanel.java index 86fef5f..2f444d6 100755 --- a/src/jalview/gui/AnnotationPanel.java +++ b/src/jalview/gui/AnnotationPanel.java @@ -687,11 +687,11 @@ public class AnnotationPanel AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation(); - int x = 0, y = 0; + int x = 0, y=0; int column = 0; char lastSS; int lastSSX; - int iconOffset = av.charHeight / 2; + int iconOffset = 0; boolean validRes = false; boolean[] graphGroupDrawn = new boolean[aa.length]; @@ -721,9 +721,20 @@ public class AnnotationPanel if (row.hasText) { + iconOffset = av.charHeight / 2 + 4; y -= av.charHeight; } } + else if (row.hasText) + { + iconOffset = av.charHeight -fm.getDescent(); + + } + else + { + iconOffset = 0; + } + if (av.updatingConsensus && aa[i] == av.consensus) { @@ -763,14 +774,7 @@ public class AnnotationPanel continue; } - if (row.hasText) - { - iconOffset = av.charHeight / 2 + 4; - } - else - { - iconOffset = 0; - } + x = 0; while (x < endRes - startRes) -- 1.7.10.2