Forums Register Login

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

+Pie Number of slices to send: Send
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!!

+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
You're welcome Did you find the post from Rob Spoor recommending you dispose of all surplus Graphics objects?
Yeah, but is it art? What do you think tiny ad?
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1082 times.
Similar Threads
Turning images around the clock
how to streach an image all over the button
saving transformed images
V2 - Problem with Image & Browse file.
JButton with ImageIcon Size Problem
Why wont my code run? Does Anyone Know What I am Doing Wrong?
Jerky image rotation when controlling with keys in keyboard
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 05:22:53.