You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

XSLFColor.java 24KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612
  1. /*
  2. * ====================================================================
  3. * Licensed to the Apache Software Foundation (ASF) under one or more
  4. * contributor license agreements. See the NOTICE file distributed with
  5. * this work for additional information regarding copyright ownership.
  6. * The ASF licenses this file to You under the Apache License, Version 2.0
  7. * (the "License"); you may not use this file except in compliance with
  8. * the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. * ====================================================================
  18. */
  19. package org.apache.poi.xslf.usermodel;
  20. import org.apache.poi.util.Beta;
  21. import org.apache.poi.util.Internal;
  22. import org.apache.xmlbeans.XmlObject;
  23. import org.openxmlformats.schemas.drawingml.x2006.main.CTColor;
  24. import org.openxmlformats.schemas.drawingml.x2006.main.CTHslColor;
  25. import org.openxmlformats.schemas.drawingml.x2006.main.CTPresetColor;
  26. import org.openxmlformats.schemas.drawingml.x2006.main.CTSRgbColor;
  27. import org.openxmlformats.schemas.drawingml.x2006.main.CTScRgbColor;
  28. import org.openxmlformats.schemas.drawingml.x2006.main.CTSchemeColor;
  29. import org.openxmlformats.schemas.drawingml.x2006.main.CTSystemColor;
  30. import org.w3c.dom.Node;
  31. import java.awt.Color;
  32. import java.util.HashMap;
  33. import java.util.Map;
  34. /**
  35. * Encapsulates logic to read color definitions from DrawingML and convert them to java.awt.Color
  36. *
  37. * @author Yegor Kozlov
  38. */
  39. @Beta
  40. @Internal
  41. public class XSLFColor {
  42. private XmlObject _xmlObject;
  43. private Color _color;
  44. private CTSchemeColor _phClr;
  45. public XSLFColor(XmlObject obj, XSLFTheme theme, CTSchemeColor phClr) {
  46. _xmlObject = obj;
  47. _phClr = phClr;
  48. _color = toColor(obj, theme);
  49. }
  50. @Internal
  51. public XmlObject getXmlObject() {
  52. return _xmlObject;
  53. }
  54. /**
  55. *
  56. * @return the displayed color as a Java Color.
  57. * If not color information was found in the supplied xml object then a null is returned.
  58. */
  59. public Color getColor() {
  60. return _color == null ? null : applyColorTransform(_color);
  61. }
  62. private Color applyColorTransform(Color color){
  63. Color result = color;
  64. int alpha = getAlpha();
  65. if(alpha != -1){
  66. result = new Color(
  67. result.getRed(), result.getGreen(), result.getBlue(),
  68. Math.round(255 * alpha * 0.01f));
  69. }
  70. int lumOff = getLumOff();
  71. int lumMod = getLumMod();
  72. if(lumMod != -1 || lumOff != -1){
  73. result = modulateLuminanace(result,
  74. lumMod == -1 ? 100 : lumMod,
  75. lumOff == -1 ? 0 : lumOff);
  76. }
  77. int shade = getShade();
  78. if(shade != -1){
  79. result = shade(result, shade);
  80. }
  81. int tint = getTint();
  82. if(tint != -1){
  83. result = tint(result, tint);
  84. }
  85. return result;
  86. }
  87. Color toColor(XmlObject obj, XSLFTheme theme) {
  88. Color color = null;
  89. for (XmlObject ch : obj.selectPath("*")) {
  90. if (ch instanceof CTHslColor) {
  91. CTHslColor hsl = (CTHslColor)ch;
  92. int h = hsl.getHue2();
  93. int s = hsl.getSat2();
  94. int l = hsl.getLum2();
  95. // This conversion is not correct and differs from PowerPoint.
  96. // TODO: Revisit and improve.
  97. color = Color.getHSBColor(h / 60000f, s / 100000f, l / 100000f);
  98. } else if (ch instanceof CTPresetColor) {
  99. CTPresetColor prst = (CTPresetColor)ch;
  100. String colorName = prst.getVal().toString();
  101. color = presetColors.get(colorName);
  102. } else if (ch instanceof CTSchemeColor) {
  103. CTSchemeColor schemeColor = (CTSchemeColor)ch;
  104. String colorRef = schemeColor.getVal().toString();
  105. if(_phClr != null) {
  106. // context color overrides the theme
  107. colorRef = _phClr.getVal().toString();
  108. }
  109. // find referenced CTColor in the theme and convert it to java.awt.Color via a recursive call
  110. CTColor ctColor = theme.getCTColor(colorRef);
  111. if(ctColor != null) color = toColor(ctColor, null);
  112. } else if (ch instanceof CTScRgbColor) {
  113. // same as CTSRgbColor but with values expressed in percents
  114. CTScRgbColor scrgb = (CTScRgbColor)ch;
  115. int r = scrgb.getR();
  116. int g = scrgb.getG();
  117. int b = scrgb.getB();
  118. color = new Color(255 * r / 100000, 255 * g / 100000, 255 * b / 100000);
  119. } else if (ch instanceof CTSRgbColor) {
  120. CTSRgbColor srgb = (CTSRgbColor)ch;
  121. byte[] val = srgb.getVal();
  122. color = new Color(0xFF & val[0], 0xFF & val[1], 0xFF & val[2]);
  123. } else if (ch instanceof CTSystemColor) {
  124. CTSystemColor sys = (CTSystemColor)ch;
  125. if(sys.isSetLastClr()) {
  126. byte[] val = sys.getLastClr();
  127. color = new Color(0xFF & val[0], 0xFF & val[1], 0xFF & val[2]);
  128. } else {
  129. // YK: color is a string like "menuText" or "windowText", we return black for such cases
  130. String colorName = sys.getVal().toString();
  131. color = Color.black;
  132. }
  133. } else {
  134. throw new IllegalArgumentException("Unexpected color choice: " + ch.getClass());
  135. }
  136. }
  137. return color;
  138. }
  139. /**
  140. * Read a perecentage value from the supplied xml bean.
  141. * Example:
  142. * <a:tint val="45000"/>
  143. *
  144. * the returned value is 45
  145. *
  146. * @return the percentage value in the range [0 .. 100]
  147. */
  148. private int getPercentageValue(String elem){
  149. String query = "declare namespace a='http://schemas.openxmlformats.org/drawingml/2006/main' $this//a:" + elem;
  150. XmlObject[] obj;
  151. // first ask the context color and if not found, ask the actual color bean
  152. if(_phClr != null){
  153. obj = _phClr.selectPath(query);
  154. if(obj.length == 1){
  155. Node attr = obj[0].getDomNode().getAttributes().getNamedItem("val");
  156. if(attr != null) {
  157. return Integer.parseInt(attr.getNodeValue()) / 1000;
  158. }
  159. }
  160. }
  161. obj = _xmlObject.selectPath(query);
  162. if(obj.length == 1){
  163. Node attr = obj[0].getDomNode().getAttributes().getNamedItem("val");
  164. if(attr != null) {
  165. return Integer.parseInt(attr.getNodeValue()) / 1000;
  166. }
  167. }
  168. return -1;
  169. }
  170. private int getAngleValue(String elem){
  171. String color = "declare namespace a='http://schemas.openxmlformats.org/drawingml/2006/main' $this//a:" + elem;
  172. XmlObject[] obj;
  173. // first ask the context color and if not found, ask the actual color bean
  174. if(_phClr != null){
  175. obj = _xmlObject.selectPath( color );
  176. if(obj.length == 1){
  177. Node attr = obj[0].getDomNode().getAttributes().getNamedItem("val");
  178. if(attr != null) {
  179. return Integer.parseInt(attr.getNodeValue()) / 60000;
  180. }
  181. }
  182. }
  183. obj = _xmlObject.selectPath( color );
  184. if(obj.length == 1){
  185. Node attr = obj[0].getDomNode().getAttributes().getNamedItem("val");
  186. if(attr != null) {
  187. return Integer.parseInt(attr.getNodeValue()) / 60000;
  188. }
  189. }
  190. return -1;
  191. }
  192. /**
  193. * the opacity as expressed by a percentage value
  194. *
  195. * @return opacity in percents in the range [0..100]
  196. * or -1 if the value is not set
  197. */
  198. int getAlpha(){
  199. return getPercentageValue("alpha");
  200. }
  201. /**
  202. * the opacity as expressed by a percentage relative to the input color
  203. *
  204. * @return opacity in percents in the range [0..100]
  205. * or -1 if the value is not set
  206. */
  207. int getAlphaMod(){
  208. return getPercentageValue("alphaMod");
  209. }
  210. /**
  211. * the opacity as expressed by a percentage offset increase or decrease relative to
  212. * the input color. Increases will never increase the opacity beyond 100%, decreases will
  213. * never decrease the opacity below 0%.
  214. *
  215. * @return opacity shift in percents in the range [0..100]
  216. * or -1 if the value is not set
  217. */
  218. int getAlphaOff(){
  219. return getPercentageValue("alphaOff");
  220. }
  221. int getHue(){
  222. return getAngleValue("hue");
  223. }
  224. int getHueMod(){
  225. return getPercentageValue("hueMod");
  226. }
  227. int getHueOff(){
  228. return getPercentageValue("hueOff");
  229. }
  230. /**
  231. * specifies the input color with the specified luminance,
  232. * but with its hue and saturation unchanged.
  233. *
  234. * @return luminance in percents in the range [0..100]
  235. * or -1 if the value is not set
  236. */
  237. int getLum(){
  238. return getPercentageValue("lum");
  239. }
  240. /**
  241. * the luminance as expressed by a percentage relative to the input color
  242. *
  243. * @return luminance in percents in the range [0..100]
  244. * or -1 if the value is not set
  245. */
  246. int getLumMod(){
  247. return getPercentageValue("lumMod");
  248. }
  249. /**
  250. * the luminance shift as expressed by a percentage relative to the input color
  251. *
  252. * @return luminance shift in percents in the range [0..100]
  253. * or -1 if the value is not set
  254. */
  255. int getLumOff(){
  256. return getPercentageValue("lumOff");
  257. }
  258. /**
  259. * specifies the input color with the specified saturation,
  260. * but with its hue and luminance unchanged.
  261. *
  262. * @return saturation in percents in the range [0..100]
  263. * or -1 if the value is not set
  264. */
  265. int getSat(){
  266. return getPercentageValue("sat");
  267. }
  268. /**
  269. * the saturation as expressed by a percentage relative to the input color
  270. *
  271. * @return saturation in percents in the range [0..100]
  272. * or -1 if the value is not set
  273. */
  274. int getSatMod(){
  275. return getPercentageValue("satMod");
  276. }
  277. /**
  278. * the saturation shift as expressed by a percentage relative to the input color
  279. *
  280. * @return saturation shift in percents in the range [0..100]
  281. * or -1 if the value is not set
  282. */
  283. int getSatOff(){
  284. return getPercentageValue("satOff");
  285. }
  286. /**
  287. * specifies the input color with the specific red component, but with the blue and green color
  288. * components unchanged
  289. *
  290. * @return the value of the red component specified as a
  291. * percentage with 0% indicating minimal blue and 100% indicating maximum
  292. * or -1 if the value is not set
  293. */
  294. int getRed(){
  295. return getPercentageValue("red");
  296. }
  297. int getRedMod(){
  298. return getPercentageValue("redMod");
  299. }
  300. int getRedOff(){
  301. return getPercentageValue("redOff");
  302. }
  303. /**
  304. * specifies the input color with the specific green component, but with the red and blue color
  305. * components unchanged
  306. *
  307. * @return the value of the green component specified as a
  308. * percentage with 0% indicating minimal blue and 100% indicating maximum
  309. * or -1 if the value is not set
  310. */
  311. int getGreen(){
  312. return getPercentageValue("green");
  313. }
  314. int getGreenMod(){
  315. return getPercentageValue("greenMod");
  316. }
  317. int getGreenOff(){
  318. return getPercentageValue("greenOff");
  319. }
  320. /**
  321. * specifies the input color with the specific blue component, but with the red and green color
  322. * components unchanged
  323. *
  324. * @return the value of the blue component specified as a
  325. * percentage with 0% indicating minimal blue and 100% indicating maximum
  326. * or -1 if the value is not set
  327. */
  328. int getBlue(){
  329. return getPercentageValue("blue");
  330. }
  331. int getBlueMod(){
  332. return getPercentageValue("blueMod");
  333. }
  334. int getBlueOff(){
  335. return getPercentageValue("blueOff");
  336. }
  337. /**
  338. * specifies a darker version of its input color.
  339. * A 10% shade is 10% of the input color combined with 90% black.
  340. *
  341. * @return the value of the shade specified as a
  342. * percentage with 0% indicating minimal shade and 100% indicating maximum
  343. * or -1 if the value is not set
  344. */
  345. int getShade(){
  346. return getPercentageValue("shade");
  347. }
  348. /**
  349. * specifies a lighter version of its input color.
  350. * A 10% tint is 10% of the input color combined with 90% white.
  351. *
  352. * @return the value of the tint specified as a
  353. * percentage with 0% indicating minimal tint and 100% indicating maximum
  354. * or -1 if the value is not set
  355. */
  356. int getTint(){
  357. return getPercentageValue("tint");
  358. }
  359. /**
  360. * Apply lumMod / lumOff adjustments
  361. *
  362. * @param c the color to modify
  363. * @param lumMod luminance modulation in the range [0..100]
  364. * @param lumOff luminance offset in the range [0..100]
  365. * @return modified color
  366. */
  367. private static Color modulateLuminanace(Color c, int lumMod, int lumOff) {
  368. Color color;
  369. if (lumOff > 0) {
  370. color = new Color(
  371. (int) (Math.round((255 - c.getRed()) * (100.0 - lumMod) / 100.0 + c.getRed())),
  372. (int) (Math.round((255 - c.getGreen()) * lumOff / 100.0 + c.getGreen())),
  373. (int) (Math.round((255 - c.getBlue()) * lumOff / 100.0 + c.getBlue())),
  374. c.getAlpha()
  375. );
  376. } else {
  377. color = new Color(
  378. (int) (Math.round(c.getRed() * lumMod / 100.0)),
  379. (int) (Math.round(c.getGreen() * lumMod / 100.0)),
  380. (int) (Math.round(c.getBlue() * lumMod / 100.0)),
  381. c.getAlpha()
  382. );
  383. }
  384. return color;
  385. }
  386. /**
  387. * This algorithm returns result different from PowerPoint.
  388. * TODO: revisit and improve
  389. */
  390. private static Color shade(Color c, int shade) {
  391. return new Color(
  392. (int)(c.getRed() * shade * 0.01),
  393. (int)(c.getGreen() * shade * 0.01),
  394. (int)(c.getBlue() * shade * 0.01),
  395. c.getAlpha());
  396. }
  397. /**
  398. * This algorithm returns result different from PowerPoint.
  399. * TODO: revisit and improve
  400. */
  401. private static Color tint(Color c, int tint) {
  402. int r = c.getRed();
  403. int g = c.getGreen();
  404. int b = c.getBlue();
  405. float ftint = tint / 100.0f;
  406. int red = Math.round(ftint * r + (1 - ftint) * 255);
  407. int green = Math.round(ftint * g + (1 - ftint) * 255);
  408. int blue = Math.round(ftint * b + (1 - ftint) * 255);
  409. return new Color(red, green, blue);
  410. }
  411. /**
  412. * Preset colors defined in DrawingML
  413. */
  414. static final Map<String, Color> presetColors;
  415. static {
  416. presetColors = new HashMap<String, Color>();
  417. presetColors.put("aliceBlue", new Color(240, 248, 255));
  418. presetColors.put("antiqueWhite", new Color(250, 235, 215));
  419. presetColors.put("aqua", new Color(0, 255, 255));
  420. presetColors.put("aquamarine", new Color(127, 255, 212));
  421. presetColors.put("azure", new Color(240, 255, 255));
  422. presetColors.put("beige", new Color(245, 245, 220));
  423. presetColors.put("bisque", new Color(255, 228, 196));
  424. presetColors.put("black", new Color(0, 0, 0));
  425. presetColors.put("blanchedAlmond", new Color(255, 235, 205));
  426. presetColors.put("blue", new Color(0, 0, 255));
  427. presetColors.put("blueViolet", new Color(138, 43, 226));
  428. presetColors.put("brown", new Color(165, 42, 42));
  429. presetColors.put("burlyWood", new Color(222, 184, 135));
  430. presetColors.put("cadetBlue", new Color(95, 158, 160));
  431. presetColors.put("chartreuse", new Color(127, 255, 0));
  432. presetColors.put("chocolate", new Color(210, 105, 30));
  433. presetColors.put("coral", new Color(255, 127, 80));
  434. presetColors.put("cornflowerBlue", new Color(100, 149, 237));
  435. presetColors.put("crimson", new Color(220, 20, 60));
  436. presetColors.put("cyan", new Color(0, 255, 255));
  437. presetColors.put("deepPink", new Color(255, 20, 147));
  438. presetColors.put("deepSkyBlue", new Color(0, 191, 255));
  439. presetColors.put("dimGray", new Color(105, 105, 105));
  440. presetColors.put("dkBlue", new Color(0, 0, 139));
  441. presetColors.put("dkCyan", new Color(0, 139, 139));
  442. presetColors.put("dkGoldenrod", new Color(184, 134, 11));
  443. presetColors.put("dkGray", new Color(169, 169, 169));
  444. presetColors.put("dkGreen", new Color(0, 100, 0));
  445. presetColors.put("dkKhaki", new Color(189, 183, 107));
  446. presetColors.put("dkMagenta", new Color(139, 0, 139));
  447. presetColors.put("dkOliveGreen", new Color(85, 107, 47));
  448. presetColors.put("dkOrange", new Color(255, 140, 0));
  449. presetColors.put("dkOrchid", new Color(153, 50, 204));
  450. presetColors.put("dkRed", new Color(139, 0, 0));
  451. presetColors.put("dkSalmon", new Color(233, 150, 122));
  452. presetColors.put("dkSeaGreen", new Color(143, 188, 139));
  453. presetColors.put("dkSlateBlue", new Color(72, 61, 139));
  454. presetColors.put("dkSlateGray", new Color(47, 79, 79));
  455. presetColors.put("dkTurquoise", new Color(0, 206, 209));
  456. presetColors.put("dkViolet", new Color(148, 0, 211));
  457. presetColors.put("dodgerBlue", new Color(30, 144, 255));
  458. presetColors.put("firebrick", new Color(178, 34, 34));
  459. presetColors.put("floralWhite", new Color(255, 250, 240));
  460. presetColors.put("forestGreen", new Color(34, 139, 34));
  461. presetColors.put("fuchsia", new Color(255, 0, 255));
  462. presetColors.put("gainsboro", new Color(220, 220, 220));
  463. presetColors.put("ghostWhite", new Color(248, 248, 255));
  464. presetColors.put("gold", new Color(255, 215, 0));
  465. presetColors.put("goldenrod", new Color(218, 165, 32));
  466. presetColors.put("gray", new Color(128, 128, 128));
  467. presetColors.put("green", new Color(0, 128, 0));
  468. presetColors.put("greenYellow", new Color(173, 255, 47));
  469. presetColors.put("honeydew", new Color(240, 255, 240));
  470. presetColors.put("hotPink", new Color(255, 105, 180));
  471. presetColors.put("indianRed", new Color(205, 92, 92));
  472. presetColors.put("indigo", new Color(75, 0, 130));
  473. presetColors.put("ivory", new Color(255, 255, 240));
  474. presetColors.put("khaki", new Color(240, 230, 140));
  475. presetColors.put("lavender", new Color(230, 230, 250));
  476. presetColors.put("lavenderBlush", new Color(255, 240, 245));
  477. presetColors.put("lawnGreen", new Color(124, 252, 0));
  478. presetColors.put("lemonChiffon", new Color(255, 250, 205));
  479. presetColors.put("lime", new Color(0, 255, 0));
  480. presetColors.put("limeGreen", new Color(50, 205, 50));
  481. presetColors.put("linen", new Color(250, 240, 230));
  482. presetColors.put("ltBlue", new Color(173, 216, 230));
  483. presetColors.put("ltCoral", new Color(240, 128, 128));
  484. presetColors.put("ltCyan", new Color(224, 255, 255));
  485. presetColors.put("ltGoldenrodYellow", new Color(250, 250, 120));
  486. presetColors.put("ltGray", new Color(211, 211, 211));
  487. presetColors.put("ltGreen", new Color(144, 238, 144));
  488. presetColors.put("ltPink", new Color(255, 182, 193));
  489. presetColors.put("ltSalmon", new Color(255, 160, 122));
  490. presetColors.put("ltSeaGreen", new Color(32, 178, 170));
  491. presetColors.put("ltSkyBlue", new Color(135, 206, 250));
  492. presetColors.put("ltSlateGray", new Color(119, 136, 153));
  493. presetColors.put("ltSteelBlue", new Color(176, 196, 222));
  494. presetColors.put("ltYellow", new Color(255, 255, 224));
  495. presetColors.put("magenta", new Color(255, 0, 255));
  496. presetColors.put("maroon", new Color(128, 0, 0));
  497. presetColors.put("medAquamarine", new Color(102, 205, 170));
  498. presetColors.put("medBlue", new Color(0, 0, 205));
  499. presetColors.put("medOrchid", new Color(186, 85, 211));
  500. presetColors.put("medPurple", new Color(147, 112, 219));
  501. presetColors.put("medSeaGreen", new Color(60, 179, 113));
  502. presetColors.put("medSlateBlue", new Color(123, 104, 238));
  503. presetColors.put("medSpringGreen", new Color(0, 250, 154));
  504. presetColors.put("medTurquoise", new Color(72, 209, 204));
  505. presetColors.put("medVioletRed", new Color(199, 21, 133));
  506. presetColors.put("midnightBlue", new Color(25, 25, 112));
  507. presetColors.put("mintCream", new Color(245, 255, 250));
  508. presetColors.put("mistyRose", new Color(255, 228, 225));
  509. presetColors.put("moccasin", new Color(255, 228, 181));
  510. presetColors.put("navajoWhite", new Color(255, 222, 173));
  511. presetColors.put("navy", new Color(0, 0, 128));
  512. presetColors.put("oldLace", new Color(253, 245, 230));
  513. presetColors.put("olive", new Color(128, 128, 0));
  514. presetColors.put("oliveDrab", new Color(107, 142, 35));
  515. presetColors.put("orange", new Color(255, 165, 0));
  516. presetColors.put("orangeRed", new Color(255, 69, 0));
  517. presetColors.put("orchid", new Color(218, 112, 214));
  518. presetColors.put("paleGoldenrod", new Color(238, 232, 170));
  519. presetColors.put("paleGreen", new Color(152, 251, 152));
  520. presetColors.put("paleTurquoise", new Color(175, 238, 238));
  521. presetColors.put("paleVioletRed", new Color(219, 112, 147));
  522. presetColors.put("papayaWhip", new Color(255, 239, 213));
  523. presetColors.put("peachPuff", new Color(255, 218, 185));
  524. presetColors.put("peru", new Color(205, 133, 63));
  525. presetColors.put("pink", new Color(255, 192, 203));
  526. presetColors.put("plum", new Color(221, 160, 221));
  527. presetColors.put("powderBlue", new Color(176, 224, 230));
  528. presetColors.put("purple", new Color(128, 0, 128));
  529. presetColors.put("red", new Color(255, 0, 0));
  530. presetColors.put("rosyBrown", new Color(188, 143, 143));
  531. presetColors.put("royalBlue", new Color(65, 105, 225));
  532. presetColors.put("saddleBrown", new Color(139, 69, 19));
  533. presetColors.put("salmon", new Color(250, 128, 114));
  534. presetColors.put("sandyBrown", new Color(244, 164, 96));
  535. presetColors.put("seaGreen", new Color(46, 139, 87));
  536. presetColors.put("seaShell", new Color(255, 245, 238));
  537. presetColors.put("sienna", new Color(160, 82, 45));
  538. presetColors.put("silver", new Color(192, 192, 192));
  539. presetColors.put("skyBlue", new Color(135, 206, 235));
  540. presetColors.put("slateBlue", new Color(106, 90, 205));
  541. presetColors.put("slateGray", new Color(112, 128, 144));
  542. presetColors.put("snow", new Color(255, 250, 250));
  543. presetColors.put("springGreen", new Color(0, 255, 127));
  544. presetColors.put("steelBlue", new Color(70, 130, 180));
  545. presetColors.put("tan", new Color(210, 180, 140));
  546. presetColors.put("teal", new Color(0, 128, 128));
  547. presetColors.put("thistle", new Color(216, 191, 216));
  548. presetColors.put("tomato", new Color(255, 99, 71));
  549. presetColors.put("turquoise", new Color(64, 224, 208));
  550. presetColors.put("violet", new Color(238, 130, 238));
  551. presetColors.put("wheat", new Color(245, 222, 179));
  552. presetColors.put("white", new Color(255, 255, 255));
  553. presetColors.put("whiteSmoke", new Color(245, 245, 245));
  554. presetColors.put("yellow", new Color(255, 255, 0));
  555. presetColors.put("yellowGreen", new Color(154, 205, 50));
  556. }
  557. }