[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [platform-swt-dev] RGB Convenience Method
|
Ok, very fair question, not ignorance... This constructor is not _needed_
however it could:
* Make things simpler
* Provide a more efficient way of storing / restoring RGB objects
* Protect this type of restore from possible changes to the
hashCode() method
(i.e. if the hashCode() method was changed, the
constructor could be changed to match; otherwise breaking my method)
Obviously I'm doing the bit shifting on my own right now, but I wanted to
share this method and ping people to see if they would find it useful as
well. With the use of this function we could improve the efficiency of
the PreferenceConverter class which currently writes to comma delimited
strings (255,255,255) to save; and has to parse that string back to create
the RGB again. Further, with the use of hashcodes we could remove one
more use of StringTokenizer inside the PreferenceConverter class which is
now considered legacy[1] anyway, even though the split method will be used
in other places.
So you're right, this could just be done by the programmer anyway, but I
guess my real question is that, could this constructor improve other parts
related to the use of RGB.
~ Bryan
[1]
"StringTokenizer is a legacy class that is retained for compatibility
reasons"
http://java.sun.com/j2se/1.4.2/docs/api/java/util/StringTokenizer.html
Bryan W Clark
Research Intern - Collaborative User Experience Group
Cambridge, MA USA
"Steve Northover" <Steve_Northover@xxxxxxxxxx>
Sent by: platform-swt-dev-admin@xxxxxxxxxxx
08/07/2003 09:35 AM
Please respond to
platform-swt-dev@xxxxxxxxxxx
To
platform-swt-dev@xxxxxxxxxxx
cc
platform-swt-dev@xxxxxxxxxxx, platform-swt-dev-admin@xxxxxxxxxxx
Subject
Re: [platform-swt-dev] RGB Convenience Method
Why don't you just do that anyway? Pardon my ignorance but why do you
need the convenience constructor to do this?
Bryan W Clark/Cambridge/IBM@IBMUS
Sent by: platform-swt-dev-admin@xxxxxxxxxxx
08/06/2003 02:51 PM
Please respond to platform-swt-dev
To: platform-swt-dev@xxxxxxxxxxx
cc:
Subject: [platform-swt-dev] RGB Convenience Method
Hi ~
I would like to request a convenience constructor for the RGB class, I can
fill out a bug in bugzilla if it's appropriate. But I thought I'd ask
first.
public static int UPPER_LIMIT = 255;
public RGB(int hashcode) {
this( (hashcode & UPPER_LIMIT),(hashcode >> 8 & UPPER_LIMIT),
(hashcode >> 16));
}
This would allow me to save (like in a preference save) RGB's as hashcodes
and then bring them back from a single integer code. Any thoughts?
Thanks,
~ Bryan
Bryan W Clark
Research Intern - Collaborative User Experience Group
Cambridge, MA USA
_______________________________________________
platform-swt-dev mailing list
platform-swt-dev@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/platform-swt-dev