Skip to main content



      Home
Home » Eclipse Projects » Rich Client Platform (RCP) » why a translate method is used twice?
why a translate method is used twice? [message #639038] Sun, 14 November 2010 19:16 Go to next message
Eclipse UserFriend
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] Sun, 14 November 2010 20:02 Go to previous message
Eclipse UserFriend
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: Wed Jul 23 02:56:15 EDT 2025

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

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

Back to the top