• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Cathy McDuff
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 48652
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 48652
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try this thread.
 
Cathy McDuff
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 48652
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome Did you find the post from Rob Spoor recommending you dispose of all surplus Graphics objects?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic