&& (displayChar.length() > 0))
{
Graphics2D gg = ((Graphics2D) g);
- AffineTransform oldTransform = gg.getTransform();
float fmWidth = fm.charsWidth(displayChar.toCharArray(), 0,
displayChar.length());
*/
final int xPos = (x * charWidth) + charOffset;
final int yPos = y + iconOffset;
+
+ /*
+ * translate to drawing position _before_ applying any scaling
+ */
gg.translate(xPos, yPos);
if (scaledToFit)
{
{
gg.drawString(displayChar, 0, 0);
}
+ if (scaledToFit)
+ {
+ /*
+ * undo scaling before translating back
+ * (restoring saved transform does NOT work in JS PDFGraphics!)
+ */
+ gg.transform(AffineTransform
+ .getScaleInstance(1D / fmScaling, 1.0));
+ }
gg.translate(-xPos, -yPos);
- gg.setTransform(oldTransform);
}
}
if (row.hasIcons)
boolean isStructureProfile = profl[0] == AlignmentAnnotation.STRUCTURE_PROFILE;
boolean isCdnaProfile = profl[0] == AlignmentAnnotation.CDNA_PROFILE;
float ht = normaliseProfile ? y - _aa.graphHeight : y1;
- double htn = normaliseProfile ? _aa.graphHeight : (y2 - y1);// aa.graphHeight;
+ final double normaliseFactor = normaliseProfile ? _aa.graphHeight : (y2 - y1);
/**
* Render a single base for a sequence profile, a base pair for
}
// next profl[] position is profile % for the character(s)
- double newHeight = htn * scale * profl[c++];
+ double newHeight = normaliseFactor * scale * profl[c++];
/*
* Set character colour as per alignment colour scheme; use the
* this is off by a very small amount
*/
final int hght = (int) (ht2 + (newAsc - newDec));
- Graphics2D gg = (Graphics2D) g.create();
- gg.setFont(ofont);
- int xShift = (int) (x * charWidth / sx);
- int yShift = (int) (hght / sy);
+ Graphics2D gg = (Graphics2D) g;
+ int xShift = (int) Math.round(x * charWidth / sx);
+ int yShift = (int) Math.round(hght / sy);
gg.transform(AffineTransform.getScaleInstance(sx, sy));
gg.drawString(s, xShift, yShift);
- gg.dispose();
+ gg.transform(
+ AffineTransform.getScaleInstance(1D / sx, 1D / sy));
ht2 += newHeight;
}
else
{
+ /*
+ * Java ('normal') method is to scale the font to fit
+ */
final int hght = (int) (ht + (newAsc - newDec));
Font font = ofont
.deriveFont(AffineTransform.getScaleInstance(sx, sy));
ht += newHeight;
}
}
- g.setFont(ofont);
}
}
x++;