Solved

why using translate twice?

Posted on 2010-11-14
6
410 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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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. …
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.
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.

757 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