1 /*
2  * Copyright (c) 2015 John May <jwmay@users.sf.net>
3  *
4  * Contact: cdk-devel@lists.sourceforge.net
5  *
6  * This program is free software; you can redistribute it and/or modify it
7  * under the terms of the GNU Lesser General Public License as published by
8  * the Free Software Foundation; either version 2.1 of the License, or (at
9  * your option) any later version. All we ask is that proper credit is given
10  * for our work, which includes - but is not limited to - adding the above
11  * copyright notice to the beginning of your source code files, and to any
12  * copyright notice that you may distribute with programs based on this work.
13  *
14  * This program is distributed in the hope that it will be useful, but WITHOUT
15  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
17  * License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 U
22  */
23 
24 package org.openscience.cdk.renderer.color;
25 
26 import org.openscience.cdk.config.Elements;
27 import org.openscience.cdk.interfaces.IAtom;
28 
29 import java.awt.Color;
30 
31 import static org.openscience.cdk.config.Elements.Unknown;
32 
33 /**
34  * Default Jmol colors.
35  * @see <a href="http://Jmol.sourceforge.net/jscolors/">Jmol, Colors</a>
36  */
37 public final class JmolColors implements IAtomColorer {
38 
39     private static final Color hexFFFFFF = new Color(0xFFFFFF);
40     private static final Color hexD9FFFF = new Color(0xD9FFFF);
41     private static final Color hexCC80FF = new Color(0xCC80FF);
42     private static final Color hexC2FF00 = new Color(0xC2FF00);
43     private static final Color hexFFB5B5 = new Color(0xFFB5B5);
44     private static final Color hex909090 = new Color(0x909090);
45     private static final Color hex3050F8 = new Color(0x3050F8);
46     private static final Color hexFF0D0D = new Color(0xFF0D0D);
47     private static final Color hex90E050 = new Color(0x90E050);
48     private static final Color hexB3E3F5 = new Color(0xB3E3F5);
49     private static final Color hexAB5CF2 = new Color(0xAB5CF2);
50     private static final Color hex8AFF00 = new Color(0x8AFF00);
51     private static final Color hexBFA6A6 = new Color(0xBFA6A6);
52     private static final Color hexF0C8A0 = new Color(0xF0C8A0);
53     private static final Color hexFF8000 = new Color(0xFF8000);
54     private static final Color hexFFFF30 = new Color(0xFFFF30);
55     private static final Color hex1FF01F = new Color(0x1FF01F);
56     private static final Color hex80D1E3 = new Color(0x80D1E3);
57     private static final Color hex8F40D4 = new Color(0x8F40D4);
58     private static final Color hex3DFF00 = new Color(0x3DFF00);
59     private static final Color hexE6E6E6 = new Color(0xE6E6E6);
60     private static final Color hexBFC2C7 = new Color(0xBFC2C7);
61     private static final Color hexA6A6AB = new Color(0xA6A6AB);
62     private static final Color hex8A99C7 = new Color(0x8A99C7);
63     private static final Color hex9C7AC7 = new Color(0x9C7AC7);
64     private static final Color hexE06633 = new Color(0xE06633);
65     private static final Color hexF090A0 = new Color(0xF090A0);
66     private static final Color hex50D050 = new Color(0x50D050);
67     private static final Color hexC88033 = new Color(0xC88033);
68     private static final Color hex7D80B0 = new Color(0x7D80B0);
69     private static final Color hexC28F8F = new Color(0xC28F8F);
70     private static final Color hex668F8F = new Color(0x668F8F);
71     private static final Color hexBD80E3 = new Color(0xBD80E3);
72     private static final Color hexFFA100 = new Color(0xFFA100);
73     private static final Color hexA62929 = new Color(0xA62929);
74     private static final Color hex5CB8D1 = new Color(0x5CB8D1);
75     private static final Color hex702EB0 = new Color(0x702EB0);
76     private static final Color hex00FF00 = new Color(0x00FF00);
77     private static final Color hex94FFFF = new Color(0x94FFFF);
78     private static final Color hex94E0E0 = new Color(0x94E0E0);
79     private static final Color hex73C2C9 = new Color(0x73C2C9);
80     private static final Color hex54B5B5 = new Color(0x54B5B5);
81     private static final Color hex3B9E9E = new Color(0x3B9E9E);
82     private static final Color hex248F8F = new Color(0x248F8F);
83     private static final Color hex0A7D8C = new Color(0x0A7D8C);
84     private static final Color hex006985 = new Color(0x006985);
85     private static final Color hexC0C0C0 = new Color(0xC0C0C0);
86     private static final Color hexFFD98F = new Color(0xFFD98F);
87     private static final Color hexA67573 = new Color(0xA67573);
88     private static final Color hex668080 = new Color(0x668080);
89     private static final Color hex9E63B5 = new Color(0x9E63B5);
90     private static final Color hexD47A00 = new Color(0xD47A00);
91     private static final Color hex940094 = new Color(0x940094);
92     private static final Color hex429EB0 = new Color(0x429EB0);
93     private static final Color hex57178F = new Color(0x57178F);
94     private static final Color hex00C900 = new Color(0x00C900);
95     private static final Color hex70D4FF = new Color(0x70D4FF);
96     private static final Color hexFFFFC7 = new Color(0xFFFFC7);
97     private static final Color hexD9FFC7 = new Color(0xD9FFC7);
98     private static final Color hexC7FFC7 = new Color(0xC7FFC7);
99     private static final Color hexA3FFC7 = new Color(0xA3FFC7);
100     private static final Color hex8FFFC7 = new Color(0x8FFFC7);
101     private static final Color hex61FFC7 = new Color(0x61FFC7);
102     private static final Color hex45FFC7 = new Color(0x45FFC7);
103     private static final Color hex30FFC7 = new Color(0x30FFC7);
104     private static final Color hex1FFFC7 = new Color(0x1FFFC7);
105     private static final Color hex00FF9C = new Color(0x00FF9C);
106     private static final Color hex00E675 = new Color(0x00E675);
107     private static final Color hex00D452 = new Color(0x00D452);
108     private static final Color hex00BF38 = new Color(0x00BF38);
109     private static final Color hex00AB24 = new Color(0x00AB24);
110     private static final Color hex4DC2FF = new Color(0x4DC2FF);
111     private static final Color hex4DA6FF = new Color(0x4DA6FF);
112     private static final Color hex2194D6 = new Color(0x2194D6);
113     private static final Color hex267DAB = new Color(0x267DAB);
114     private static final Color hex266696 = new Color(0x266696);
115     private static final Color hex175487 = new Color(0x175487);
116     private static final Color hexD0D0E0 = new Color(0xD0D0E0);
117     private static final Color hexFFD123 = new Color(0xFFD123);
118     private static final Color hexB8B8D0 = new Color(0xB8B8D0);
119     private static final Color hexA6544D = new Color(0xA6544D);
120     private static final Color hex575961 = new Color(0x575961);
121     private static final Color hex9E4FB5 = new Color(0x9E4FB5);
122     private static final Color hexAB5C00 = new Color(0xAB5C00);
123     private static final Color hex754F45 = new Color(0x754F45);
124     private static final Color hex428296 = new Color(0x428296);
125     private static final Color hex420066 = new Color(0x420066);
126     private static final Color hex007D00 = new Color(0x007D00);
127     private static final Color hex70ABFA = new Color(0x70ABFA);
128     private static final Color hex00BAFF = new Color(0x00BAFF);
129     private static final Color hex00A1FF = new Color(0x00A1FF);
130     private static final Color hex008FFF = new Color(0x008FFF);
131     private static final Color hex0080FF = new Color(0x0080FF);
132     private static final Color hex006BFF = new Color(0x006BFF);
133     private static final Color hex545CF2 = new Color(0x545CF2);
134     private static final Color hex785CE3 = new Color(0x785CE3);
135     private static final Color hex8A4FE3 = new Color(0x8A4FE3);
136     private static final Color hexA136D4 = new Color(0xA136D4);
137     private static final Color hexB31FD4 = new Color(0xB31FD4);
138     private static final Color hexB31FBA = new Color(0xB31FBA);
139     private static final Color hexB30DA6 = new Color(0xB30DA6);
140     private static final Color hexBD0D87 = new Color(0xBD0D87);
141     private static final Color hexC70066 = new Color(0xC70066);
142     private static final Color hexCC0059 = new Color(0xCC0059);
143     private static final Color hexD1004F = new Color(0xD1004F);
144     private static final Color hexD90045 = new Color(0xD90045);
145     private static final Color hexE00038 = new Color(0xE00038);
146     private static final Color hexE6002E = new Color(0xE6002E);
147     private static final Color hexEB0026 = new Color(0xEB0026);
148 
149     @Override
getAtomColor(IAtom atom)150     public Color getAtomColor(IAtom atom) {
151         return getAtomColor(atom, hexB31FBA);
152     }
153 
154     @Override
getAtomColor(IAtom atom, Color defaultColor)155     public Color getAtomColor(IAtom atom, Color defaultColor) {
156         Elements elem = Elements.ofString(atom.getSymbol());
157         if (elem == Unknown)
158             elem = Elements.ofNumber(atom.getAtomicNumber());
159         switch (elem) {
160             case Hydrogen:
161                 return hexFFFFFF;
162             case Helium:
163                 return hexD9FFFF;
164             case Lithium:
165                 return hexCC80FF;
166             case Beryllium:
167                 return hexC2FF00;
168             case Boron:
169                 return hexFFB5B5;
170             case Carbon:
171                 return hex909090;
172             case Nitrogen:
173                 return hex3050F8;
174             case Oxygen:
175                 return hexFF0D0D;
176             case Fluorine:
177                 return hex90E050;
178             case Neon:
179                 return hexB3E3F5;
180             case Sodium:
181                 return hexAB5CF2;
182             case Magnesium:
183                 return hex8AFF00;
184             case Aluminium:
185                 return hexBFA6A6;
186             case Silicon:
187                 return hexF0C8A0;
188             case Phosphorus:
189                 return hexFF8000;
190             case Sulfur:
191                 return hexFFFF30;
192             case Chlorine:
193                 return hex1FF01F;
194             case Argon:
195                 return hex80D1E3;
196             case Potassium:
197                 return hex8F40D4;
198             case Calcium:
199                 return hex3DFF00;
200             case Scandium:
201                 return hexE6E6E6;
202             case Titanium:
203                 return hexBFC2C7;
204             case Vanadium:
205                 return hexA6A6AB;
206             case Chromium:
207                 return hex8A99C7;
208             case Manganese:
209                 return hex9C7AC7;
210             case Iron:
211                 return hexE06633;
212             case Cobalt:
213                 return hexF090A0;
214             case Nickel:
215                 return hex50D050;
216             case Copper:
217                 return hexC88033;
218             case Zinc:
219                 return hex7D80B0;
220             case Gallium:
221                 return hexC28F8F;
222             case Germanium:
223                 return hex668F8F;
224             case Arsenic:
225                 return hexBD80E3;
226             case Selenium:
227                 return hexFFA100;
228             case Bromine:
229                 return hexA62929;
230             case Krypton:
231                 return hex5CB8D1;
232             case Rubidium:
233                 return hex702EB0;
234             case Strontium:
235                 return hex00FF00;
236             case Yttrium:
237                 return hex94FFFF;
238             case Zirconium:
239                 return hex94E0E0;
240             case Niobium:
241                 return hex73C2C9;
242             case Molybdenum:
243                 return hex54B5B5;
244             case Technetium:
245                 return hex3B9E9E;
246             case Ruthenium:
247                 return hex248F8F;
248             case Rhodium:
249                 return hex0A7D8C;
250             case Palladium:
251                 return hex006985;
252             case Silver:
253                 return hexC0C0C0;
254             case Cadmium:
255                 return hexFFD98F;
256             case Indium:
257                 return hexA67573;
258             case Tin:
259                 return hex668080;
260             case Antimony:
261                 return hex9E63B5;
262             case Tellurium:
263                 return hexD47A00;
264             case Iodine:
265                 return hex940094;
266             case Xenon:
267                 return hex429EB0;
268             case Caesium:
269                 return hex57178F;
270             case Barium:
271                 return hex00C900;
272             case Lanthanum:
273                 return hex70D4FF;
274             case Cerium:
275                 return hexFFFFC7;
276             case Praseodymium:
277                 return hexD9FFC7;
278             case Neodymium:
279                 return hexC7FFC7;
280             case Promethium:
281                 return hexA3FFC7;
282             case Samarium:
283                 return hex8FFFC7;
284             case Europium:
285                 return hex61FFC7;
286             case Gadolinium:
287                 return hex45FFC7;
288             case Terbium:
289                 return hex30FFC7;
290             case Dysprosium:
291                 return hex1FFFC7;
292             case Holmium:
293                 return hex00FF9C;
294             case Erbium:
295                 return hex00E675;
296             case Thulium:
297                 return hex00D452;
298             case Ytterbium:
299                 return hex00BF38;
300             case Lutetium:
301                 return hex00AB24;
302             case Hafnium:
303                 return hex4DC2FF;
304             case Tantalum:
305                 return hex4DA6FF;
306             case Tungsten:
307                 return hex2194D6;
308             case Rhenium:
309                 return hex267DAB;
310             case Osmium:
311                 return hex266696;
312             case Iridium:
313                 return hex175487;
314             case Platinum:
315                 return hexD0D0E0;
316             case Gold:
317                 return hexFFD123;
318             case Mercury:
319                 return hexB8B8D0;
320             case Thallium:
321                 return hexA6544D;
322             case Lead:
323                 return hex575961;
324             case Bismuth:
325                 return hex9E4FB5;
326             case Polonium:
327                 return hexAB5C00;
328             case Astatine:
329                 return hex754F45;
330             case Radon:
331                 return hex428296;
332             case Francium:
333                 return hex420066;
334             case Radium:
335                 return hex007D00;
336             case Actinium:
337                 return hex70ABFA;
338             case Thorium:
339                 return hex00BAFF;
340             case Protactinium:
341                 return hex00A1FF;
342             case Uranium:
343                 return hex008FFF;
344             case Neptunium:
345                 return hex0080FF;
346             case Plutonium:
347                 return hex006BFF;
348             case Americium:
349                 return hex545CF2;
350             case Curium:
351                 return hex785CE3;
352             case Berkelium:
353                 return hex8A4FE3;
354             case Californium:
355                 return hexA136D4;
356             case Einsteinium:
357                 return hexB31FD4;
358             case Fermium:
359                 return hexB31FBA;
360             case Mendelevium:
361                 return hexB30DA6;
362             case Nobelium:
363                 return hexBD0D87;
364             case Lawrencium:
365                 return hexC70066;
366             case Rutherfordium:
367                 return hexCC0059;
368             case Dubnium:
369                 return hexD1004F;
370             case Seaborgium:
371                 return hexD90045;
372             case Bohrium:
373                 return hexE00038;
374             case Hassium:
375                 return hexE6002E;
376             case Meitnerium:
377                 return hexEB0026;
378             default:
379                 return defaultColor;
380         }
381     }
382 }
383