Solved

why using translate twice?

Posted on 2010-11-14
6
418 Views
Last Modified: 2013-12-15
 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??
0
Comment
Question by:gamjaradio
  • 3
  • 3
6 Comments
 
LVL 92

Expert Comment

by:objects
ID: 34132907
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
 

Author Comment

by:gamjaradio
ID: 34133009
hm...
I can not understand..

please , tell me more detaily?
0
 
LVL 92

Accepted Solution

by:
objects earned 500 total points
ID: 34133031
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
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Closing Comment

by:gamjaradio
ID: 34141546
thanks
0
 

Author Comment

by:gamjaradio
ID: 34142139
can you tell me the meaning of 'translate method'?
0
 
LVL 92

Expert Comment

by:objects
ID: 34142155
shifts points a fixed number of pixels in x and y direction
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

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

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
How to install Selenium IDE and loops for quick automated testing. Get Selenium IDE from http://seleniumhq.org Go to that link and select download selenium in the right hand columnThat will then direct you to their download page.From that page s…
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question