1 /
55
56 package org.apache.poi.hssf.util;
57
58 import java.util.*;
59
60
72
73 public class HSSFColor
74 {
75 private final static int PALETTE_SIZE = 50;
76
77
78
79 public HSSFColor()
80 {
81 }
82
83
93
94 public final static Hashtable getTripletHash()
95 {
96 Hashtable hash = new Hashtable(PALETTE_SIZE);
97
98 hash.put(HSSFColor.BLACK.hexString, new HSSFColor.BLACK());
99 hash.put(HSSFColor.BROWN.hexString, new HSSFColor.BROWN());
100 hash.put(HSSFColor.OLIVE_GREEN.hexString,
101 new HSSFColor.OLIVE_GREEN());
102 hash.put(HSSFColor.DARK_GREEN.hexString, new HSSFColor.DARK_GREEN());
103 hash.put(HSSFColor.DARK_TEAL.hexString, new HSSFColor.DARK_TEAL());
104 hash.put(HSSFColor.DARK_BLUE.hexString, new HSSFColor.DARK_BLUE());
105 hash.put(HSSFColor.INDIGO.hexString, new HSSFColor.INDIGO());
106 hash.put(HSSFColor.GREY_80_PERCENT.hexString,
107 new HSSFColor.GREY_80_PERCENT());
108 hash.put(HSSFColor.ORANGE.hexString, new HSSFColor.ORANGE());
109 hash.put(HSSFColor.DARK_YELLOW.hexString,
110 new HSSFColor.DARK_YELLOW());
111 hash.put(HSSFColor.GREEN.hexString, new HSSFColor.GREEN());
112 hash.put(HSSFColor.TEAL.hexString, new HSSFColor.TEAL());
113 hash.put(HSSFColor.BLUE.hexString, new HSSFColor.BLUE());
114 hash.put(HSSFColor.BLUE_GREY.hexString, new HSSFColor.BLUE_GREY());
115 hash.put(HSSFColor.GREY_50_PERCENT.hexString,
116 new HSSFColor.GREY_50_PERCENT());
117 hash.put(HSSFColor.RED.hexString, new HSSFColor.RED());
118 hash.put(HSSFColor.LIGHT_ORANGE.hexString,
119 new HSSFColor.LIGHT_ORANGE());
120 hash.put(HSSFColor.LIME.hexString, new HSSFColor.LIME());
121 hash.put(HSSFColor.SEA_GREEN.hexString, new HSSFColor.SEA_GREEN());
122 hash.put(HSSFColor.AQUA.hexString, new HSSFColor.AQUA());
123 hash.put(HSSFColor.LIGHT_BLUE.hexString, new HSSFColor.LIGHT_BLUE());
124 hash.put(HSSFColor.VIOLET.hexString, new HSSFColor.VIOLET());
125 hash.put(HSSFColor.GREY_40_PERCENT.hexString,
126 new HSSFColor.GREY_40_PERCENT());
127 hash.put(HSSFColor.PINK.hexString, new HSSFColor.PINK());
128 hash.put(HSSFColor.GOLD.hexString, new HSSFColor.GOLD());
129 hash.put(HSSFColor.YELLOW.hexString, new HSSFColor.YELLOW());
130 hash.put(HSSFColor.BRIGHT_GREEN.hexString,
131 new HSSFColor.BRIGHT_GREEN());
132 hash.put(HSSFColor.BRIGHT_GREEN.hexString, new HSSFColor.TURQUOISE());
133 hash.put(HSSFColor.SKY_BLUE.hexString, new HSSFColor.SKY_BLUE());
134 hash.put(HSSFColor.PLUM.hexString, new HSSFColor.PLUM());
135 hash.put(HSSFColor.GREY_25_PERCENT.hexString,
136 new HSSFColor.GREY_25_PERCENT());
137 hash.put(HSSFColor.ROSE.hexString, new HSSFColor.ROSE());
138 hash.put(HSSFColor.LIGHT_YELLOW.hexString,
139 new HSSFColor.LIGHT_YELLOW());
140 hash.put(HSSFColor.LIGHT_GREEN.hexString,
141 new HSSFColor.LIGHT_GREEN());
142 hash.put(HSSFColor.LIGHT_TURQUOISE.hexString,
143 new HSSFColor.LIGHT_TURQUOISE());
144 hash.put(HSSFColor.PALE_BLUE.hexString, new HSSFColor.PALE_BLUE());
145 hash.put(HSSFColor.LAVENDER.hexString, new HSSFColor.LAVENDER());
146 hash.put(HSSFColor.WHITE.hexString, new HSSFColor.WHITE());
147 return hash;
148 }
149
150
153
154 public short getIndex()
155 {
156 return BLACK.index;
157 }
158
159
162
163 public short [] getTriplet()
164 {
165 return BLACK.triplet;
166 }
167
168
169
170
173
174 public String getHexString()
175 {
176 return BLACK.hexString;
177 }
178
179
183
184 public final static class BLACK
185 extends HSSFColor
186 {
187 public final static short index = 0x8;
188 public final static short[] triplet =
189 {
190 0, 0, 0
191 };
192 public final static String hexString = "0:0:0";
193
194 public short getIndex()
195 {
196 return index;
197 }
198
199 public short [] getTriplet()
200 {
201 return triplet;
202 }
203
204 public String getHexString()
205 {
206 return hexString;
207 }
208 }
209
210
214
215 public final static class BROWN
216 extends HSSFColor
217 {
218 public final static short index = 0x3c;
219 public final static short[] triplet =
220 {
221 153, 51, 0
222 };
223 public final static String hexString = "9999:3333:0";
224
225 public short getIndex()
226 {
227 return index;
228 }
229
230 public short [] getTriplet()
231 {
232 return triplet;
233 }
234
235 public String getHexString()
236 {
237 return hexString;
238 }
239 }
240
241
245
246 public static class OLIVE_GREEN
247 extends HSSFColor
248 {
249 public final static short index = 0x3b;
250 public final static short[] triplet =
251 {
252 51, 51, 0
253 };
254 public final static String hexString = "3333:3333:0";
255
256 public short getIndex()
257 {
258 return index;
259 }
260
261 public short [] getTriplet()
262 {
263 return triplet;
264 }
265
266 public String getHexString()
267 {
268 return hexString;
269 }
270 }
271
272
276
277 public final static class DARK_GREEN
278 extends HSSFColor
279 {
280 public final static short index = 0x3a;
281 public final static short[] triplet =
282 {
283 0, 51, 0
284 };
285 public final static String hexString = "0:3333:0";
286
287 public short getIndex()
288 {
289 return index;
290 }
291
292 public short [] getTriplet()
293 {
294 return triplet;
295 }
296
297 public String getHexString()
298 {
299 return hexString;
300 }
301 }
302
303
307
308 public final static class DARK_TEAL
309 extends HSSFColor
310 {
311 public final static short index = 0x38;
312 public final static short[] triplet =
313 {
314 0, 51, 102
315 };
316 public final static String hexString = "0:3333:6666";
317
318 public short getIndex()
319 {
320 return index;
321 }
322
323 public short [] getTriplet()
324 {
325 return triplet;
326 }
327
328 public String getHexString()
329 {
330 return hexString;
331 }
332 }
333
334
338
339 public final static class DARK_BLUE
340 extends HSSFColor
341 {
342 public final static short index = 0x12;
343 public final static short[] triplet =
344 {
345 0, 0, 128
346 };
347 public final static String hexString = "0:0:8080";
348
349 public short getIndex()
350 {
351 return index;
352 }
353
354 public short [] getTriplet()
355 {
356 return triplet;
357 }
358
359 public String getHexString()
360 {
361 return hexString;
362 }
363 }
364
365
369
370 public final static class INDIGO
371 extends HSSFColor
372 {
373 public final static short index = 0x3e;
374 public final static short[] triplet =
375 {
376 51, 51, 153
377 };
378 public final static String hexString = "3333:3333:9999";
379
380 public short getIndex()
381 {
382 return index;
383 }
384
385 public short [] getTriplet()
386 {
387 return triplet;
388 }
389
390 public String getHexString()
391 {
392 return hexString;
393 }
394 }
395
396
400
401 public final static class GREY_80_PERCENT
402 extends HSSFColor
403 {
404 public final static short index = 0x3f;
405 public final static short[] triplet =
406 {
407 51, 51, 51
408 };
409 public final static String hexString = "3333:3333:3333";
410
411 public short getIndex()
412 {
413 return index;
414 }
415
416 public short [] getTriplet()
417 {
418 return triplet;
419 }
420
421 public String getHexString()
422 {
423 return hexString;
424 }
425 }
426
427
431
432 public final static class DARK_RED
433 extends HSSFColor
434 {
435 public final static short index = 0x10;
436 public final static short[] triplet =
437 {
438 128, 0, 0
439 };
440 public final static String hexString = "8080:0:0";
441
442 public short getIndex()
443 {
444 return index;
445 }
446
447 public short [] getTriplet()
448 {
449 return triplet;
450 }
451
452 public String getHexString()
453 {
454 return hexString;
455 }
456 }
457
458
462
463 public final static class ORANGE
464 extends HSSFColor
465 {
466 public final static short index = 0x35;
467 public final static short[] triplet =
468 {
469 255, 102, 0
470 };
471 public final static String hexString = "FFFF:6666:0";
472
473 public short getIndex()
474 {
475 return index;
476 }
477
478 public short [] getTriplet()
479 {
480 return triplet;
481 }
482
483 public String getHexString()
484 {
485 return hexString;
486 }
487 }
488
489
493
494 public final static class DARK_YELLOW
495 extends HSSFColor
496 {
497 public final static short index = 0x13;
498 public final static short[] triplet =
499 {
500 128, 128, 0
501 };
502 public final static String hexString = "8080:8080:0";
503
504 public short getIndex()
505 {
506 return index;
507 }
508
509 public short [] getTriplet()
510 {
511 return triplet;
512 }
513
514 public String getHexString()
515 {
516 return hexString;
517 }
518 }
519
520
524
525 public final static class GREEN
526 extends HSSFColor
527 {
528 public final static short index = 0x11;
529 public final static short[] triplet =
530 {
531 0, 128, 0
532 };
533 public final static String hexString = "0:8080:0";
534
535 public short getIndex()
536 {
537 return index;
538 }
539
540 public short [] getTriplet()
541 {
542 return triplet;
543 }
544
545 public String getHexString()
546 {
547 return hexString;
548 }
549 }
550
551
555
556 public final static class TEAL
557 extends HSSFColor
558 {
559 public final static short index = 0x15;
560 public final static short[] triplet =
561 {
562 0, 128, 128
563 };
564 public final static String hexString = "0:8080:8080";
565
566 public short getIndex()
567 {
568 return index;
569 }
570
571 public short [] getTriplet()
572 {
573 return triplet;
574 }
575
576 public String getHexString()
577 {
578 return hexString;
579 }
580 }
581
582
586
587 public final static class BLUE
588 extends HSSFColor
589 {
590 public final static short index = 0xc;
591 public final static short[] triplet =
592 {
593 0, 0, 255
594 };
595 public final static String hexString = "0:0:FFFF";
596
597 public short getIndex()
598 {
599 return index;
600 }
601
602 public short [] getTriplet()
603 {
604 return triplet;
605 }
606
607 public String getHexString()
608 {
609 return hexString;
610 }
611 }
612
613
617
618 public final static class BLUE_GREY
619 extends HSSFColor
620 {
621 public final static short index = 0x36;
622 public final static short[] triplet =
623 {
624 102, 102, 153
625 };
626 public final static String hexString = "6666:6666:9999";
627
628 public short getIndex()
629 {
630 return index;
631 }
632
633 public short [] getTriplet()
634 {
635 return triplet;
636 }
637
638 public String getHexString()
639 {
640 return hexString;
641 }
642 }
643
644
648
649 public final static class GREY_50_PERCENT
650 extends HSSFColor
651 {
652 public final static short index = 0x17;
653 public final static short[] triplet =
654 {
655 128, 128, 128
656 };
657 public final static String hexString = "8080:8080:8080";
658
659 public short getIndex()
660 {
661 return index;
662 }
663
664 public short [] getTriplet()
665 {
666 return triplet;
667 }
668
669 public String getHexString()
670 {
671 return hexString;
672 }
673 }
674
675
679
680 public final static class RED
681 extends HSSFColor
682 {
683 public final static short index = 0xa;
684 public final static short[] triplet =
685 {
686 255, 0, 0
687 };
688 public final static String hexString = "FFFF:0:0";
689
690 public short getIndex()
691 {
692 return index;
693 }
694
695 public short [] getTriplet()
696 {
697 return triplet;
698 }
699
700 public String getHexString()
701 {
702 return hexString;
703 }
704 }
705
706
710
711 public final static class LIGHT_ORANGE
712 extends HSSFColor
713 {
714 public final static short index = 0x34;
715 public final static short[] triplet =
716 {
717 255, 153, 0
718 };
719 public final static String hexString = "FFF:9999:0";
720
721 public short getIndex()
722 {
723 return index;
724 }
725
726 public short [] getTriplet()
727 {
728 return triplet;
729 }
730
731 public String getHexString()
732 {
733 return hexString;
734 }
735 }
736
737
741
742 public final static class LIME
743 extends HSSFColor
744 {
745 public final static short index = 0x32;
746 public final static short[] triplet =
747 {
748 153, 204, 0
749 };
750 public final static String hexString = "9999:CCCC:0";
751
752 public short getIndex()
753 {
754 return index;
755 }
756
757 public short [] getTriplet()
758 {
759 return triplet;
760 }
761
762 public String getHexString()
763 {
764 return hexString;
765 }
766 }
767
768
772
773 public final static class SEA_GREEN
774 extends HSSFColor
775 {
776 public final static short index = 0x39;
777 public final static short[] triplet =
778 {
779 51, 153, 102
780 };
781 public final static String hexString = "3333:9999:6666";
782
783 public short getIndex()
784 {
785 return index;
786 }
787
788 public short [] getTriplet()
789 {
790 return triplet;
791 }
792
793 public String getHexString()
794 {
795 return hexString;
796 }
797 }
798
799
803
804 public final static class AQUA
805 extends HSSFColor
806 {
807 public final static short index = 0x31;
808 public final static short[] triplet =
809 {
810 51, 204, 204
811 };
812 public final static String hexString = "3333:CCCC:CCCC";
813
814 public short getIndex()
815 {
816 return index;
817 }
818
819 public short [] getTriplet()
820 {
821 return triplet;
822 }
823
824 public String getHexString()
825 {
826 return hexString;
827 }
828 }
829
830
834
835 public final static class LIGHT_BLUE
836 extends HSSFColor
837 {
838 public final static short index = 0x30;
839 public final static short[] triplet =
840 {
841 51, 102, 255
842 };
843 public final static String hexString = "3333:6666:FFFF";
844
845 public short getIndex()
846 {
847 return index;
848 }
849
850 public short [] getTriplet()
851 {
852 return triplet;
853 }
854
855 public String getHexString()
856 {
857 return hexString;
858 }
859 }
860
861
865
866 public final static class VIOLET
867 extends HSSFColor
868 {
869 public final static short index = 0x14;
870 public final static short[] triplet =
871 {
872 128, 0, 128
873 };
874 public final static String hexString = "8080:0:8080";
875
876 public short getIndex()
877 {
878 return index;
879 }
880
881 public short [] getTriplet()
882 {
883 return triplet;
884 }
885
886 public String getHexString()
887 {
888 return hexString;
889 }
890 }
891
892
896
897 public final static class GREY_40_PERCENT
898 extends HSSFColor
899 {
900 public final static short index = 0x37;
901 public final static short[] triplet =
902 {
903 150, 150, 150
904 };
905 public final static String hexString = "9696:9696:9696";
906
907 public short getIndex()
908 {
909 return index;
910 }
911
912 public short [] getTriplet()
913 {
914 return triplet;
915 }
916
917 public String getHexString()
918 {
919 return hexString;
920 }
921 }
922
923
927
928 public final static class PINK
929 extends HSSFColor
930 {
931 public final static short index = 0xe;
932 public final static short[] triplet =
933 {
934 255, 0, 255
935 };
936 public final static String hexString = "FFFF:0:FFFF";
937
938 public short getIndex()
939 {
940 return index;
941 }
942
943 public short [] getTriplet()
944 {
945 return triplet;
946 }
947
948 public String getHexString()
949 {
950 return hexString;
951 }
952 }
953
954
958
959 public final static class GOLD
960 extends HSSFColor
961 {
962 public final static short index = 0x33;
963 public final static short[] triplet =
964 {
965 255, 204, 0
966 };
967 public final static String hexString = "FFFF:CCCC:0";
968
969 public short getIndex()
970 {
971 return index;
972 }
973
974 public short [] getTriplet()
975 {
976 return triplet;
977 }
978
979 public String getHexString()
980 {
981 return hexString;
982 }
983 }
984
985
989
990 public final static class YELLOW
991 extends HSSFColor
992 {
993 public final static short index = 0xd;
994 public final static short[] triplet =
995 {
996 255, 255, 0
997 };
998 public final static String hexString = "FFFF:FFFF:0";
999
1000 public short getIndex()
1001 {
1002 return index;
1003 }
1004
1005 public short [] getTriplet()
1006 {
1007 return triplet;
1008 }
1009
1010 public String getHexString()
1011 {
1012 return hexString;
1013 }
1014 }
1015
1016
1020
1021 public final static class BRIGHT_GREEN
1022 extends HSSFColor
1023 {
1024 public final static short index = 0xb;
1025 public final static short[] triplet =
1026 {
1027 0, 255, 0
1028 };
1029 public final static String hexString = "0:FFFF:0";
1030
1031 public short getIndex()
1032 {
1033 return index;
1034 }
1035
1036 public String getHexString()
1037 {
1038 return hexString;
1039 }
1040
1041 public short [] getTriplet()
1042 {
1043 return triplet;
1044 }
1045 }
1046
1047
1051
1052 public final static class TURQUOISE
1053 extends HSSFColor
1054 {
1055 public final static short index = 0xf;
1056 public final static short[] triplet =
1057 {
1058 0, 255, 255
1059 };
1060 public final static String hexString = "0:FFFF:FFFF";
1061
1062 public short getIndex()
1063 {
1064 return index;
1065 }
1066
1067 public short [] getTriplet()
1068 {
1069 return triplet;
1070 }
1071
1072 public String getHexString()
1073 {
1074 return hexString;
1075 }
1076 }
1077
1078
1082
1083 public final static class SKY_BLUE
1084 extends HSSFColor
1085 {
1086 public final static short index = 0x28;
1087 public final static short[] triplet =
1088 {
1089 0, 204, 255
1090 };
1091 public final static String hexString = "0:CCCC:FFFF";
1092
1093 public short getIndex()
1094 {
1095 return index;
1096 }
1097
1098 public short [] getTriplet()
1099 {
1100 return triplet;
1101 }
1102
1103 public String getHexString()
1104 {
1105 return hexString;
1106 }
1107 }
1108
1109
1113
1114 public final static class PLUM
1115 extends HSSFColor
1116 {
1117 public final static short index = 0x3d;
1118 public final static short[] triplet =
1119 {
1120 153, 51, 102
1121 };
1122 public final static String hexString = "9999:3333:6666";
1123
1124 public short getIndex()
1125 {
1126 return index;
1127 }
1128
1129 public short [] getTriplet()
1130 {
1131 return triplet;
1132 }
1133
1134 public String getHexString()
1135 {
1136 return hexString;
1137 }
1138 }
1139
1140
1144
1145 public final static class GREY_25_PERCENT
1146 extends HSSFColor
1147 {
1148 public final static short index = 0x16;
1149 public final static short[] triplet =
1150 {
1151 192, 192, 192
1152 };
1153 public final static String hexString = "C0C0:C0C0:C0C0";
1154
1155 public short getIndex()
1156 {
1157 return index;
1158 }
1159
1160 public short [] getTriplet()
1161 {
1162 return triplet;
1163 }
1164
1165 public String getHexString()
1166 {
1167 return hexString;
1168 }
1169 }
1170
1171
1175
1176 public final static class ROSE
1177 extends HSSFColor
1178 {
1179 public final static short index = 0x2d;
1180 public final static short[] triplet =
1181 {
1182 255, 153, 204
1183 };
1184 public final static String hexString = "FFFF:9999:CCCC";
1185
1186 public short getIndex()
1187 {
1188 return index;
1189 }
1190
1191 public short [] getTriplet()
1192 {
1193 return triplet;
1194 }
1195
1196 public String getHexString()
1197 {
1198 return hexString;
1199 }
1200 }
1201
1202
1206
1207 public final static class TAN
1208 extends HSSFColor
1209 {
1210 public final static short index = 0x2f;
1211 public final static short[] triplet =
1212 {
1213 255, 204, 153
1214 };
1215 public final static String hexString = "FFFF:CCCC:9999";
1216
1217 public short getIndex()
1218 {
1219 return index;
1220 }
1221
1222 public short [] getTriplet()
1223 {
1224 return triplet;
1225 }
1226
1227 public String getHexString()
1228 {
1229 return hexString;
1230 }
1231 }
1232
1233
1237
1238 public final static class LIGHT_YELLOW
1239 extends HSSFColor
1240 {
1241 public final static short index = 0x2b;
1242 public final static short[] triplet =
1243 {
1244 255, 255, 153
1245 };
1246 public final static String hexString = "FFFF:FFFF:9999";
1247
1248 public short getIndex()
1249 {
1250 return index;
1251 }
1252
1253 public short [] getTriplet()
1254 {
1255 return triplet;
1256 }
1257
1258 public String getHexString()
1259 {
1260 return hexString;
1261 }
1262 }
1263
1264
1268
1269 public final static class LIGHT_GREEN
1270 extends HSSFColor
1271 {
1272 public final static short index = 0x2a;
1273 public final static short[] triplet =
1274 {
1275 204, 255, 204
1276 };
1277 public final static String hexString = "CCCC:FFFF:CCCC";
1278
1279 public short getIndex()
1280 {
1281 return index;
1282 }
1283
1284 public short [] getTriplet()
1285 {
1286 return triplet;
1287 }
1288
1289 public String getHexString()
1290 {
1291 return hexString;
1292 }
1293 }
1294
1295
1299
1300 public final static class LIGHT_TURQUOISE
1301 extends HSSFColor
1302 {
1303 public final static short index = 0x29;
1304 public final static short[] triplet =
1305 {
1306 204, 255, 255
1307 };
1308 public final static String hexString = "CCCC:FFFF:FFFF";
1309
1310 public short getIndex()
1311 {
1312 return index;
1313 }
1314
1315 public short [] getTriplet()
1316 {
1317 return triplet;
1318 }
1319
1320 public String getHexString()
1321 {
1322 return hexString;
1323 }
1324 }
1325
1326
1330
1331 public final static class PALE_BLUE
1332 extends HSSFColor
1333 {
1334 public final static short index = 0x2c;
1335 public final static short[] triplet =
1336 {
1337 153, 204, 255
1338 };
1339 public final static String hexString = "9999:CCCC:FFFF";
1340
1341 public short getIndex()
1342 {
1343 return index;
1344 }
1345
1346 public short [] getTriplet()
1347 {
1348 return triplet;
1349 }
1350
1351 public String getHexString()
1352 {
1353 return hexString;
1354 }
1355 }
1356
1357
1361
1362 public final static class LAVENDER
1363 extends HSSFColor
1364 {
1365 public final static short index = 0x2e;
1366 public final static short[] triplet =
1367 {
1368 204, 153, 255
1369 };
1370 public final static String hexString = "CCCC:9999:FFFF";
1371
1372 public short getIndex()
1373 {
1374 return index;
1375 }
1376
1377 public short [] getTriplet()
1378 {
1379 return triplet;
1380 }
1381
1382 public String getHexString()
1383 {
1384 return hexString;
1385 }
1386 }
1387
1388
1392
1393 public final static class WHITE
1394 extends HSSFColor
1395 {
1396 public final static short index = 0x9;
1397 public final static short[] triplet =
1398 {
1399 255, 255, 255
1400 };
1401 public final static String hexString = "FFFF:FFFF:FFFF";
1402
1403 public short getIndex()
1404 {
1405 return index;
1406 }
1407
1408 public short [] getTriplet()
1409 {
1410 return triplet;
1411 }
1412
1413 public String getHexString()
1414 {
1415 return hexString;
1416 }
1417 }
1418 }
1419