Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Drawing gradients
Drawing gradients [message #649063] Mon, 17 January 2011 13:28 Go to next message
Greg Brown is currently offline Greg BrownFriend
Messages: 16
Registered: December 2010
Junior Member
I tried to post this question a couple minutes ago, but it looks like it didn't go through. Trying again...

When drawing gradients, is it preferable to use a Pattern or GC#fillGradientRectangle()? I assume a pattern will be more efficient but I'd just like to confirm.

Also, when disposing a gradient Pattern, is it necessary to also dispose the Color values passed to the constructor? I assume yes since it doesn't look like Pattern#dispose() will do it, but again just want to confirm.

Thanks for your help.

Greg
Re: Drawing gradients [message #649487 is a reply to message #649063] Wed, 19 January 2011 12:57 Go to previous messageGo to next message
Lakshmi ShanmugamFriend
Messages: 274
Registered: July 2009
Location: India
Senior Member
Hi,

If you have created the Color (i.e, using new Color) then you should dispose it. If you have not created it, but have got it from somewhere (for eg, display.getSystemColor()) then you should not dispose it.
This article on management of OS resources in SWT may be useful --> http://www.eclipse.org/articles/swt-design-2/swt-design-2.ht ml


Lakshmi P Shanmugam
Re: Drawing gradients [message #649492 is a reply to message #649487] Wed, 19 January 2011 13:09 Go to previous message
Greg Brown is currently offline Greg BrownFriend
Messages: 16
Registered: December 2010
Junior Member
I have read that article - just wanted to confirm that the Colors used by the gradient Pattern should also be disposed. That is what I am currently doing in my code.

Thanks for your help.

Greg
Previous Topic:Same accelerator key for multiple SWT widgets
Next Topic:Measuring text
Goto Forum:
  


Current Time: Fri Dec 19 13:55:48 GMT 2014

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

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