Solved

why using translate twice?

Posted on 2010-11-14
6
412 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

In our object-oriented world the class is a minimal unit, a brick for constructing our applications. It is an abstraction and we know well how to use it. In well-designed software we are not usually interested in knowing how objects look in memory. …
Here is a helpful source code for C++ Builder programmers that allows you to manage and manipulate HTML content from C++ code, while also handling HTML events like onclick, onmouseover, ... Some objects defined and used in this source include: …
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 use and create new code templates in NetBeans IDE 8.0 for Windows.

919 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now