On Sun, Aug 7, 2011 at 3:59 AM, Nicolas Vervelle <nverve...@gmail.com>wrote:

> Hi Bob,
>
> I am not sure that we need to specify explicit values for ids for Enum
> (even if we need ids outside the enum).
>
> There are many things that can be done properly with Enums.
> For example, the ordinal() method should return an automatic numeric
> identifier for each instance (it starts at 0 for the first and increments by
> one for each)
>
> I will try to find time to look at the current code to see what can be
> done.
> What are the enums where you are not really satisfied ?
>
>
Take a careful look, but I did study this rather extensively, so please
don't just assume you can use Enums without  ID everywhere.

EnumPalette -- we need to have the ids, and they have to be defined in a
separate class so that they are defined before the EnumPalette() initializer
is run. That's because we save a palette byte for every atom. I don't want
to save a full Enum reference (probably a long?) for every atom, just a
byte. So we need that ID, and we also need that in the form of a simple
PALETTE_... constant. True, if we stored a full reference to an EnumPalette
for every atom, then we could dispense with both  the ID and the PALETTE_...
constant, but  not otherwise.

We just have to make absolutely sure we are not running through  Enum
value()s just to get some information  that is more easily saved in
constants.

Take a look. Check performance.

Bob


> Nico
>
> On Sat, Aug 6, 2011 at 5:20 PM, Robert Hanson <hans...@stolaf.edu> wrote:
>
>> I took a whack at this and found one bug even. Hopefully introduced no
>> more. But it does feel right. There are some instances, such  as with the
>> axesMode and with proteinStructure where we need to have an integer ID still
>> and refer to that because that is documented as being exposed.
>>
>> Very interesting that if you do this:
>>
>> enum EnumTest {
>>
>>   TEST(1);
>>
>>   public int id;
>>
>>   EnumTest(int id) {
>>     this.id = id;
>>   }
>> }
>>
>> Then even though TEST is a final static reference and can be used in
>> static classes, TEST.id is not and cannot, for example, be used in switch()
>> statements. I guess that's because the instantiation of an EnumTest is not
>> static, only its hidden reference identifier is. So that complicated things
>> -- there are a few cases where we need to have faster access to the class --
>> for example in coloring atoms -- and for that I also kept the constants.
>> That's not totally satisfying, but we would have to reserve a reference to
>> an Enum instead of a byte for every single atom if we did it more cleanly,
>> and I just don't want to do that. Or I'm missing  something. I did opt for
>> structure references to EnumStructure, and that worked very nicely. Still
>> have an ID there to distinguish proteins.
>>
>> Bob
>>
>>
>>>
>>
>>
>> --
>> Robert M. Hanson
>> Professor of Chemistry
>> St. Olaf College
>> 1520 St. Olaf Ave.
>> Northfield, MN 55057
>> http://www.stolaf.edu/people/hansonr
>> phone: 507-786-3107
>>
>>
>> If nature does not answer first what we want,
>> it is better to take what answer we get.
>>
>> -- Josiah Willard Gibbs, Lecture XXX, Monday, February 5, 1900
>>
>>
>> ------------------------------------------------------------------------------
>> BlackBerry&reg; DevCon Americas, Oct. 18-20, San Francisco, CA
>> The must-attend event for mobile developers. Connect with experts.
>> Get tools for creating Super Apps. See the latest technologies.
>> Sessions, hands-on labs, demos & much more. Register early & save!
>> http://p.sf.net/sfu/rim-blackberry-1
>> _______________________________________________
>> Jmol-developers mailing list
>> Jmol-developers@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/jmol-developers
>>
>>
>
>
> ------------------------------------------------------------------------------
> BlackBerry&reg; DevCon Americas, Oct. 18-20, San Francisco, CA
> The must-attend event for mobile developers. Connect with experts.
> Get tools for creating Super Apps. See the latest technologies.
> Sessions, hands-on labs, demos & much more. Register early & save!
> http://p.sf.net/sfu/rim-blackberry-1
> _______________________________________________
> Jmol-developers mailing list
> Jmol-developers@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/jmol-developers
>
>


-- 
Robert M. Hanson
Professor of Chemistry
St. Olaf College
1520 St. Olaf Ave.
Northfield, MN 55057
http://www.stolaf.edu/people/hansonr
phone: 507-786-3107


If nature does not answer first what we want,
it is better to take what answer we get.

-- Josiah Willard Gibbs, Lecture XXX, Monday, February 5, 1900
------------------------------------------------------------------------------
BlackBerry&reg; DevCon Americas, Oct. 18-20, San Francisco, CA
The must-attend event for mobile developers. Connect with experts. 
Get tools for creating Super Apps. See the latest technologies.
Sessions, hands-on labs, demos & much more. Register early & save!
http://p.sf.net/sfu/rim-blackberry-1
_______________________________________________
Jmol-developers mailing list
Jmol-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jmol-developers

Reply via email to