X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Frenderer%2FAnnotationRenderer.java;h=bc47fc64d2b29e5eff5cc160cce2cba400a55426;hb=838e4f91d4a53dd315640dbc9ff6ef7a815ee576;hp=2ba7aff98d562611520cd95375b42dee3891f3eb;hpb=be32c14cd8e48fe0a207cd7030cb9cd46f894678;p=jalview.git diff --git a/src/jalview/renderer/AnnotationRenderer.java b/src/jalview/renderer/AnnotationRenderer.java index 2ba7aff..bc47fc6 100644 --- a/src/jalview/renderer/AnnotationRenderer.java +++ b/src/jalview/renderer/AnnotationRenderer.java @@ -1,6 +1,6 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$) - * Copyright (C) $$Year-Rel$$ The Jalview Authors + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.9.0b1) + * Copyright (C) 2015 The Jalview Authors * * This file is part of Jalview. * @@ -47,6 +47,12 @@ import com.stevesoft.pat.Regex; public class AnnotationRenderer { + private static final int UPPER_TO_LOWER = 'a' - 'A'; // 32 + + private static final int CHAR_A = 'A'; // 65 + + private static final int CHAR_Z = 'Z'; // 90 + /** * flag indicating if timing and redraw parameter info should be output */ @@ -96,9 +102,9 @@ public class AnnotationRenderer // if (validRes && column>1 && row_annotations[column-2]!=null && // dc.equals(row_annotations[column-2].displayCharacter)) { - g.fillPolygon(new int[] - { lastSSX + 5, lastSSX + 5, lastSSX }, new int[] - { y + iconOffset, y + 14 + iconOffset, y + 8 + iconOffset }, 3); + g.fillPolygon(new int[] { lastSSX + 5, lastSSX + 5, lastSSX }, + new int[] { y + iconOffset, y + 14 + iconOffset, + y + 8 + iconOffset }, 3); x1 += 5; } if (diffdownstream) @@ -112,9 +118,8 @@ public class AnnotationRenderer // display a forward arrow if (diffdownstream) { - g.fillPolygon(new int[] - { x2 - 5, x2 - 5, x2 }, new int[] - { y + iconOffset, y + 14 + iconOffset, y + 8 + iconOffset }, 3); + g.fillPolygon(new int[] { x2 - 5, x2 - 5, x2 }, new int[] { + y + iconOffset, y + 14 + iconOffset, y + 8 + iconOffset }, 3); x2 -= 5; } if (diffupstream) @@ -132,7 +137,7 @@ public class AnnotationRenderer private FontMetrics fm; - private final boolean MAC = new jalview.util.Platform().isAMac(); + private final boolean MAC = jalview.util.Platform.isAMac(); boolean av_renderHistogram = true, av_renderProfile = true, av_normaliseProfile = false; @@ -221,9 +226,9 @@ public class AnnotationRenderer // if (validRes && column>1 && row_annotations[column-2]!=null && // dc.equals(row_annotations[column-2].displayCharacter)) { - g.fillPolygon(new int[] - { lastSSX + 5, lastSSX + 5, lastSSX }, new int[] - { y + iconOffset, y + 14 + iconOffset, y + 8 + iconOffset }, 3); + g.fillPolygon(new int[] { lastSSX + 5, lastSSX + 5, lastSSX }, + new int[] { y + iconOffset, y + 14 + iconOffset, + y + 8 + iconOffset }, 3); x1 += 5; } if (diffdownstream) @@ -237,9 +242,8 @@ public class AnnotationRenderer // display a forward arrow if (diffdownstream) { - g.fillPolygon(new int[] - { x2 - 5, x2 - 5, x2 }, new int[] - { y + iconOffset, y + 14 + iconOffset, y + 8 + iconOffset }, 3); + g.fillPolygon(new int[] { x2 - 5, x2 - 5, x2 }, new int[] { + y + iconOffset, y + 14 + iconOffset, y + 8 + iconOffset }, 3); x2 -= 5; } if (diffupstream) @@ -628,17 +632,17 @@ public class AnnotationRenderer // // if (scaleColLabel) // { - // justify the label and scale to fit in column - if (fmWidth > charWidth) - { - // scale only if the current font isn't already small enough - fmScaling = charWidth; - fmScaling /= fmWidth; - g.setFont(ofont.deriveFont(AffineTransform - .getScaleInstance(fmScaling, 1.0))); - // and update the label's width to reflect the scaling. - fmWidth = charWidth; - } + // justify the label and scale to fit in column + if (fmWidth > charWidth) + { + // scale only if the current font isn't already small enough + fmScaling = charWidth; + fmScaling /= fmWidth; + g.setFont(ofont.deriveFont(AffineTransform + .getScaleInstance(fmScaling, 1.0))); + // and update the label's width to reflect the scaling. + fmWidth = charWidth; + } // } } // TODO is it ok to use width of / show all characters here? @@ -715,14 +719,14 @@ public class AnnotationRenderer } } - if (ss >= 65) + if (isRNA && (ss >= CHAR_A) && (ss <= CHAR_Z)) { // distinguish between forward/backward base-pairing - if (displayChar.indexOf(ss + 32) > -1) + int ssLowerCase = ss + UPPER_TO_LOWER; + // TODO would .equals() be safer here? or charAt(0)? + if (displayChar.indexOf(ssLowerCase) > -1) { - - ss = (char) (ss + 32); - + ss = (char) ssLowerCase; } } @@ -1090,11 +1094,9 @@ public class AnnotationRenderer { g.fillRect(lastSSX, y + 4 + iconOffset, (x * charWidth) - lastSSX - 4, 7); - g.fillPolygon(new int[] - { (x * charWidth) - 4, (x * charWidth) - 4, (x * charWidth) }, - new int[] - { y + iconOffset, y + 14 + iconOffset, y + 7 + iconOffset }, - 3); + g.fillPolygon(new int[] { (x * charWidth) - 4, (x * charWidth) - 4, + (x * charWidth) }, new int[] { y + iconOffset, + y + 14 + iconOffset, y + 7 + iconOffset }, 3); } else { @@ -1249,8 +1251,7 @@ public class AnnotationRenderer g.setColor(_aa.threshold.colour); Graphics2D g2 = (Graphics2D) g; g2.setStroke(new BasicStroke(1, BasicStroke.CAP_SQUARE, - BasicStroke.JOIN_ROUND, 3f, new float[] - { 5f, 3f }, 0f)); + BasicStroke.JOIN_ROUND, 3f, new float[] { 5f, 3f }, 0f)); y2 = (int) (y - ((_aa.threshold.value - min) / range) * graphHeight); g.drawLine(0, y2, (eRes - sRes) * charWidth, y2); @@ -1433,8 +1434,7 @@ public class AnnotationRenderer g.setColor(_aa.threshold.colour); Graphics2D g2 = (Graphics2D) g; g2.setStroke(new BasicStroke(1, BasicStroke.CAP_SQUARE, - BasicStroke.JOIN_ROUND, 3f, new float[] - { 5f, 3f }, 0f)); + BasicStroke.JOIN_ROUND, 3f, new float[] { 5f, 3f }, 0f)); y2 = (int) (y - ((_aa.threshold.value - min) / range) * _aa.graphHeight);