Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » why a translate method is used twice?
why a translate method is used twice? [message #639038] Mon, 15 November 2010 00:16 Go to next message
tom  is currently offline tom Friend
Messages: 17
Registered: August 2010
Junior Member
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??
Re: why a translate method is used twice? [message #639040 is a reply to message #639038] Mon, 15 November 2010 01:02 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 26235
Registered: July 2009
Senior Member
Tom,

Comments below.

tom wrote:
> 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??
Think of how differently a rotation would behave for a circle if that
circle where at the origin (nothing would change) verses if it's not at
the origin (it would actually rotate around the original).
Previous Topic:Dynamically displaying controls depending on selection from combo box / Master Details model
Next Topic:Replacing IPreferenceService?
Goto Forum:
  


Current Time: Thu Nov 27 22:30:19 GMT 2014

Powered by FUDForum. Page generated in 0.02038 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software