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 08:28 Go to next message
Greg Brown is currently offline Greg Brown
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 07:57 Go to previous messageGo to next message
Lakshmi Shanmugam
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 08:09 Go to previous message
Greg Brown is currently offline Greg Brown
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: Wed Aug 20 18:27:28 EDT 2014

Powered by FUDForum. Page generated in 0.02311 seconds