aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes AffineTransform - Rotation is being when ignored when I set the Transform Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "AffineTransform - Rotation is being when ignored when I set the Transform" Watch "AffineTransform - Rotation is being when ignored when I set the Transform" New topic
Author

AffineTransform - Rotation is being when ignored when I set the Transform

Cathy McDuff
Greenhorn

Joined: May 09, 2014
Posts: 18
Hello everyone!

Hope you are all well.

I'm experimenting with AffineTransform, I've never used it before so I'm not sure where I've gone wrong. Basically I've created just a simple test GUI to see how the code works and all that. Anyway, there are two buttons which turn an image left and right and a third button with moves the image to the right (East). When you first run the program the image is facing down (South). Now to turn left or right I'm using an Affine Transform and the rotate method. That works fine. The issue is when I move the image to the right, it ignore whatever rotation I previously I made (from turn left and right buttons). Therefore when I click to move the image, it faces down again even if it was facing left or up or right before I moved it. It will always be facing down. How do I get it to keep the rotation and just move? Btw I'm using the setTranslate method to move the image.

Below is my code. Forgive me for the messiness - this was just for testing purposes and I apologise for breaking/violating Java conventions and laws - I'm still in the learning process.


I've included all the classes in case you want to compile and run the code to better understand what it's doing wrong.

Images.java



direction.java





testRotate.java




Thank you very much!!

Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38353
    
  23
Moving to our GUIs forum, where we usually discuss such things. Search the forum and you will find another discussion where people talked about transforms earlier today.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38353
    
  23
Try this thread.
Cathy McDuff
Greenhorn

Joined: May 09, 2014
Posts: 18
Hi Campbell,

Thank you for your reply!

I did find that thread really helpful. Also I was using the method setToTranslate which was causing the problem. I've changed this to just translate and it's working correctly. Thanks again
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38353
    
  23
You're welcome Did you find the post from Rob Spoor recommending you dispose of all surplus Graphics objects?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: AffineTransform - Rotation is being when ignored when I set the Transform