This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
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 EJB 3 in Action this week in the EJB and other Java EE Technologies 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
Author

How do I flip/translate a GObject?

Cody Lancer
Greenhorn

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

Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36478
    
  16
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.

Beware
: 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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How do I flip/translate a GObject?
 
Similar Threads
Checkerboard Exercise - "Art and Science of Java"
Generating a mandelbrot with Java
Help me print out a triangle
ACM.graphics.Goval Error
Moving Train program, beginner assigned with a difficult program