Link to home
Start Free TrialLog in
Avatar of lfrohman
lfrohman

asked on

java2D reverse text with g2d.transform(AffineTransform.getScaleInstance(-1, 1)) doesn't work

I am trying to build a graphic with text "mirrored", going from right to left
(with the letters backwards too). To test, I am using:

                  g2d.transform(AffineTransform.getScaleInstance(-1, 1));
                  g2d.drawString("-300,-300", -300, -300);
                  g2d.drawString("-300,0", -300, 0);
                  g2d.drawString("-300,300", -300, 300);
                  g2d.drawString("0,-300", 0, -300);
                  g2d.drawString("0,0", 0, 0);
                  g2d.drawString("0,300", 0, 300);
                  g2d.drawString("300,-300", 300, -300);
                  g2d.drawString("300,0", 300, 0);
                  g2d.drawString("300,300", 300, 300);

but no text shows up anywhere.
if I change the first line to:
                  g2d.transform(AffineTransform.getScaleInstance(1, 1));
it works as expected. Am I doing something wrong, or is this not allowed in java2D?
ASKER CERTIFIED SOLUTION
Avatar of VBGuru
VBGuru
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
sorry..
for AffineTransform.getScaleInstance(-1, 1)) set, you end up with the following coordinates
(300,-300),(300,0), (300,300), (0,-300),(0,0), (0,300),(-300,-300),(-300,0),(-300,300)