From: Miller, Brett B <[EMAIL PROTECTED]> wrote
> Gday All,

G'day mate.
> [Font transform problems]

You can transform a font independently of the Graphics2D transform by
sending Font.deriveFont(AffineTransform t) to the original font object. So
if you derive a flipped, non-scaled font using something like

Font invertedFont =
originalFont.deriveFont(AffineTransform.getScaleInstance(1.0, -1.0));

and draw the text using invertedFont, it should all come out in the wash.

As an example, putting this in the paint() of your window illustrates the
kind of thing:

    // Use a big font
    g.setFont(new Font("Serif", 0, 24));

    // Flip coordinates so (0,0) is bottom left
    g.scale(1.0, -1.0);
    g.translate(0, -this.getHeight());

    // Draw the first, now upside down string
    g.drawString("String Number One", 50, 50);

    // Invert the font making in the right way up again




g.setFont(g.getFont().deriveFont(AffineTransform.getScaleInstance(1.0, -1.0)
));
    g.drawString("String Number Two", 50, 50);

See you later, sport...
Pete

--
Pete Cockerell
California, USA
http://216.102.89.91

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to