Why is org.eclipse.swt.graphics.Image declared final? [message #460820] |
Thu, 08 September 2005 07:31 |
Eclipse User |
|
|
|
Originally posted by: mark_z.charter.net
Why is the Image class (org.eclipse.swt.graphics.Image) declared final?
I'm already making extensive use of an extended ImageDescriptor
(org.eclipse.jface.resource) class to cache getImageData(). I'd like to do
the same for createImage() which would return an extended Image, whose
dispose() method would be overloaded and make use of reference counting to
determine when it can really be disposed of. This isn't easily possible
with the Image class being declared final.
After reading the Javadocs on the Resource class, it seems that subclassing
really isn't supported by anything outside the SWT implementation. As such,
maybe a related caching feature could be an enhancement request to the
class? (I do prefer the choice they made with leaving Resource non-final,
as commented in the Javadocs. Why wasn't the same done for Image?)
Alternatively, I could do the same thing using a decorator pattern.
However, I'd still need to pass in something other than an Image (e.g. a
caching wrapper) to any of the classes. This, however, would require
extensive changes to the framework, as Image and Resource should probably
then be coded to interfaces.
Any comments/ideas?
--
Mark A. Ziesemer
|
|
|
|
|
Re: Why is org.eclipse.swt.graphics.Image declared final? [message #461582 is a reply to message #460820] |
Mon, 26 September 2005 22:23 |
Steve Northover Messages: 1636 Registered: July 2009 |
Senior Member |
|
|
See http://www.eclipse.org/swt/faq.php#subclassing
"Mark A. Ziesemer" <mark_z@charter.net> wrote in message
news:dfopcu$1gr$1@news.eclipse.org...
> Why is the Image class (org.eclipse.swt.graphics.Image) declared final?
>
> I'm already making extensive use of an extended ImageDescriptor
> (org.eclipse.jface.resource) class to cache getImageData(). I'd like to
do
> the same for createImage() which would return an extended Image, whose
> dispose() method would be overloaded and make use of reference counting to
> determine when it can really be disposed of. This isn't easily possible
> with the Image class being declared final.
>
> After reading the Javadocs on the Resource class, it seems that
subclassing
> really isn't supported by anything outside the SWT implementation. As
such,
> maybe a related caching feature could be an enhancement request to the
> class? (I do prefer the choice they made with leaving Resource non-final,
> as commented in the Javadocs. Why wasn't the same done for Image?)
>
> Alternatively, I could do the same thing using a decorator pattern.
> However, I'd still need to pass in something other than an Image (e.g. a
> caching wrapper) to any of the classes. This, however, would require
> extensive changes to the framework, as Image and Resource should probably
> then be coded to interfaces.
>
> Any comments/ideas?
>
> --
> Mark A. Ziesemer
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.02824 seconds