Link to home
Start Free TrialLog in
Avatar of gdkinney_2
gdkinney_2

asked on

I am Implementing the paintComponent method where I use the Graphics drawString method but the Strings are upside down.

I am Implementing the paintComponent method where I use the Graphics drawString method but the Strings are upside down.

I am also using

g2d.translate(0, getHeight());
g2d.scale(scaleX, -scaleY);

so that the origin is the lower left corner instead of the upper left corner.  This is because I want to add zooming both in and out by changing the magnitude of the numbers in the scale method call.  How can I do this and make my drawString draw the Strings right side up?

Thanks
ASKER CERTIFIED SOLUTION
Avatar of Mick Barry
Mick Barry
Flag of Australia 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
Avatar of gdkinney_2
gdkinney_2

ASKER

I did but then when I implement zooming in and out by changing the magnitude of scaleX and scaleY the zooming occurs relative to the upper left corner when I use:

g2d.scale(scaleX, scaleY);

they want the origin to be the lower left corner and have zooming occur relative to the lower left corner by using:

g2d.scale(scaleX, -scaleY);

It seems that I can not have both at the same time namely:

1) Origin in lower left corner so that zooming occurs relative to lower left corner
by using
g2d.scale(scaleX, -scaleY);

2) And have drawString draw with characters right side up.

This is what my users want though both of these at the same time.  Can it be done?
SOLUTION
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
Thanks CEHJ

That worked!
:-)
Why did you accept that comment? Its the same as what I already suggested.
Objects

Your right I apologize I should have given you the points probably.  I think I had taken out the line

g2d.translate(0, getHeight());

when I tried your solution so it did not work at the time.  My fault sorry about that.
Please feel free to reassign the points
Decided to split the points on this one because even though CEHJ's solution was after Object's solution it did contain the translate line.  Hopefully everyone will be happy with this.