* @param file the meta file.
*/
public void replay(final WmfFile file)
{
final Graphics2D graphics = file.getGraphics2D();
final MfDcState state = file.getCurrentState();
final MfLogFont lFont = state.getLogFont();
state.prepareDrawText();
final FontMetrics metrics = graphics.getFontMetrics();
final int textWidth = metrics.stringWidth(text);
final Point p = getScaledOrigin();
final int x = p.x + calcDeltaX(state.getVerticalTextAlignment(), textWidth);
int y = p.y + calcDeltaY(state.getHorizontalTextAlignment(), metrics);
if (isOpaque() || state.getBkMode() != BrushConstants.TRANSPARENT)
{
final Rectangle background = new Rectangle(x, y - metrics.getAscent(), textWidth, metrics.getHeight());
graphics.setColor(state.getBkColor());
graphics.fill(background);
graphics.setColor(state.getTextColor());
}
// System.out.println("X: " + x + " Y: " + p.y + " " + calcDeltaY(state.getHorizontalTextAlignment(), metrics));
final Graphics2D g2 = (Graphics2D) graphics.create();
g2.drawString(text, x, y);
if (lFont.isUnderline())
{ // Underline.
y += metrics.getDescent() / 8 + 1;
//state.prepareDraw();
g2.setStroke(new BasicStroke(metrics.getHeight() / 14));
g2.drawLine(x, y, x + textWidth, y);
//state.postDraw();
}
if (lFont.isStrikeOut())
{ // Underline.
//state.prepareDraw();
y -= metrics.getAscent() / 2.5 + 1;
g2.setStroke(new BasicStroke(metrics.getHeight() / 14));
g2.drawLine(x, y, x + textWidth, y);
//state.postDraw();
}
state.postDrawText();
}