Solved

why using translate twice?

Posted on 2010-11-14
6
415 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
ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

 

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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

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: …
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.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

778 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