/*
- * 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.
*
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
*/
// 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)
// 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)
// 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)
// 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)
//
// 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?
}
}
- 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;
}
}
{
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
{
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);
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);