my dog learned polymorphism
The moose likes Swing / AWT / SWT and the fly likes How do I flip/translate a GObject? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Make it so: Java DB Connections & Transactions this week in the JDBC forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How do I flip/translate a GObject?" Watch "How do I flip/translate a GObject?" New topic

How do I flip/translate a GObject?

Cody Lancer

Joined: Oct 16, 2011
Posts: 4
The drawEngine() method creates the object I am trying to face in the opposite direction.

Campbell Ritchie

Joined: Oct 13, 2005
Posts: 45415
If you cast your Graphics object to Graphics2D, you can use the affine transform methods.

For example, scaling by -1.0 in the x-axis might give you a mirror image.

: use the method which copies the Grahpics2D object before using affine transforms. Scale is probably all right, but you can get distortions using shear. Discard the copy after the transforms. I think the copy method is called create().

Moving to our GUIs forum, where we usually discuss such questions.
Consider Paul's rocket mass heater.
subject: How do I flip/translate a GObject?
It's not a secret anymore!