why using translate twice?

 GC gc = e.gc;
  gc.setAdvanced(true);
 
  Bounds b = image.getBounds();

  Transform transform = new Transform(display);
  // The rotation point is the center of the image
  transform.translate(50 + b.width/2, 50 + b.height/2);
  // Rotate
  transform.rotate(45);
  // Back to the orginal coordinate system
  transform.translate(-50 - b.width/2, -50 - b.height/2);
  gc.setTransform(transform);
  gc.drawImage(image, 50, 50);
  transform.dispose();

above the code, a translate method is used twice . why is it used twice??
gamjaradioAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
objectsConnect With a Mentor Commented:
1. translates to the centre of image
2. rotate image
3. translate back to top left corner

try it without the translates to see the difference
0
 
objectsCommented:
so that it is rotated on the centre of the image
without the translations it would rotate arounf the top left corner of image
0
 
gamjaradioAuthor Commented:
hm...
I can not understand..

please , tell me more detaily?
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
gamjaradioAuthor Commented:
thanks
0
 
gamjaradioAuthor Commented:
can you tell me the meaning of 'translate method'?
0
 
objectsCommented:
shifts points a fixed number of pixels in x and y direction
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.