1    // Copyright 2004 Adam Megacz, see the COPYING file for licensing [GPL]
2    package org.xwt.translators;
3    import java.util.*;
4    
5    // FIXME: need to support style sheets and the 'style=' attribute
6    // FIXME: need to convert markers into subboxes
7    public class SVG {
8    
9        /*
10       public static void parseNode(String name, String[] keys, Object[] vals, Template t) {
11           Hash h = new Hash();
12           for(int i=0; i<keys.length; i++) if (vals[i] != null) h.put(keys[i], vals[i]);
13   
14           Hash props = new Hash();
15           props.put("transform", h.get("transform"));
16           props.put("fill", h.get("fill"));
17           props.put("stroke", h.get("stroke"));
18           if ("visible".equals(h.get("overflow")) || "auto".equals(h.get("overflow")))
19               Log.info(VectorGraphics.class, "warning: overflow={auto|visible} not supported; ignoring");
20           if (h.get("display") != null) props.put("invisible", new Boolean("none".equals(h.get("display"))));
21   
22   
23           // FIXME: "the automatic transformation that is created due to
24           // a viewBox does not affect the x, y, width and height
25           // attributes".  Also, transform+viewbox together?
26   
27           if (h.get("preserveAspectRatio") != null) {
28               StringTokenizer st = new StringTokenizer((String)h.get("preserveAspectRatio"), " ");
29               String align = st.nextToken();
30               if ("defer".equals(align)) align = st.nextToken();
31               if (!align.equals("none")) {
32                   // FIXME, need to beef up XWT's align property
33                   align = "";
34                   if (align.startsWith("yMin")) align = "top";
35                   else if (align.startsWith("yMax")) align = "bottom";
36                   if (align.startsWith("xMin")) align += "left";
37                   else if (align.startsWith("xMax")) align += "right";
38                   props.put("align", align);
39               }
40               // FIXME: need to implement scaling property on boxes, also size-to-viewbox
41               props.put("scaling", "uniform");
42               if (st.hasMoreTokens()) {
43                   String meetOrSlice = st.nextToken();
44                   if (meetOrSlice.equals("meet")) props.put("scaling", "meet");          // keep within viewport
45                   else if (meetOrSlice.equals("slice")) props.put("scaling", "slice");   // expand beyond viewport
46               }
47           }
48   
49           // FIXME: insert an extra layer of boxen and put this transform on the inner layer
50           if (h.get("viewBox") != null) {
51               PathTokenizer pt = new PathTokenizer(h.get("viewBox").toString());
52               String transform = (String)props.get("transform");
53               if (transform == null) transform = "";
54               transform = "translate(" + (-1 * pt.parseFloat()) + ", " + (-1 * pt.parseFloat()) + ") " + 
55                   "scale(" + pt.parseFloat() + "%, " + pt.parseFloat() + "%) ";
56           }
57           
58           String path = (String)h.get("d");
59           if (name.equals("g")) {
60               path = null;
61   
62           } else if (name.equals("font")) {
63               VectorGraphics.Font f = currentFont = new VectorGraphics.Font();
64               if (h.get("horiz-origin-x") != null) f.horiz_origin_x = Float.parseFloat(h.get("horiz-origin-x").toString());
65               if (h.get("horiz-origin-y") != null) f.horiz_origin_y = Float.parseFloat(h.get("horiz-origin-y").toString());
66               if (h.get("horiz-adv-x") != null) f.horiz_adv_x = Float.parseFloat(h.get("horiz-adv-x").toString());
67               if (h.get("vert-origin-x") != null) f.vert_origin_x = Float.parseFloat(h.get("vert-origin-x").toString());
68               if (h.get("vert-origin-y") != null) f.vert_origin_y = Float.parseFloat(h.get("vert-origin_y").toString());
69               if (h.get("vert-adv-y") != null) f.vert_adv_y = Float.parseFloat(h.get("vert-adv-y").toString());
70   
71           } else if (name.equals("hkern")) {
72           //FIXME
73   
74           } else if (name.equals("vkern")) {
75           //FIXME
76   
77           } else if (name.equals("font-face")) {
78           //FIXME
79   
80           } else if (name.equals("glyph") || name.equals("missing-glyph")) {
81               String glyphName = name.equals("missing-glyph") ? "missing-glyph" : (String)h.get("glyph-name");
82               VectorGraphics.Font.Glyph g = new VectorGraphics.Font.Glyph(glyphName, (String)h.get("unicode"), t, currentFont);
83               if (h.get("horiz-adv-x") != null) g.horiz_adv_x = Float.parseFloat(h.get("horiz-adv-x").toString());
84               if (h.get("vert-origin-x") != null) g.vert_origin_x = Float.parseFloat(h.get("vert-origin-x").toString());
85               if (h.get("vert-origin-y") != null) g.vert_origin_y = Float.parseFloat(h.get("vert-origin-y").toString());
86               if (h.get("vert-adv-y") != null) g.vert_adv_y = Float.parseFloat(h.get("vert-adv-y").toString());
87               if ("v".equals(h.get("orientation"))) g.isVerticallyOriented = true;
88   
89           } else if (name.equals("svg")) {
90               // FIXME: handle percentages
91               // FIXME: what if these aren't provided?
92               // FIXME (in general)
93               float x = Float.parseFloat(h.get("x").toString());
94               float y = Float.parseFloat(h.get("y").toString());
95               float width = Float.parseFloat(h.get("width").toString());
96               float height = Float.parseFloat(h.get("height").toString());
97               h.put("viewBox", x + ", " + y + ", " + (x + width) + ", " + (y + height));
98               path = "";
99               
100          } else if (name.equals("path")) {
101              path = h.get("d").toString();
102  	    
103          } else if (name.equals("rect")) {
104              float x = Float.parseFloat(h.get("x").toString());
105              float y = Float.parseFloat(h.get("y").toString());
106              float width = Float.parseFloat(h.get("width").toString());
107              float height = Float.parseFloat(h.get("height").toString());
108              float rx = Float.parseFloat(h.get("rx").toString());
109              float ry = Float.parseFloat(h.get("ry").toString());
110              path =
111                  "M" + (x + rx) + "," + y +
112                  "H" + (x + width - rx) +
113                  "A" + rx + "," + rx + ",0,0,1," + (x + width) + "," + (y + ry) +
114                  "V" + (y + width - ry) +
115                  "A" + rx + "," + rx + ",0,0,1," + (x + width - rx) + "," +
116                  (y + height) +
117                  "H" + (x + rx) +
118                  "A" + rx + "," + rx + ",0,0,1," + x + "," + (y + height - ry) +
119                  "V" + (y + ry) +
120                  "A" + rx + "," + rx + ",0,0,1," + (x + rx) + "," + (y + ry) +
121                  "Z";
122  	    
123          } else if (name.equals("circle")) {
124              float r = Float.parseFloat(h.get("r").toString());
125              float cx = Float.parseFloat(h.get("cx").toString());
126              float cy = Float.parseFloat(h.get("cy").toString());
127              path = "A " + r + " " + r + " 1 1 " + cx + " " + cy;
128  	    
129          } else if (name.equals("ellipse")) {
130              float rx = Float.parseFloat(h.get("rx").toString());
131              float ry = Float.parseFloat(h.get("ry").toString());
132              float cx = Float.parseFloat(h.get("cx").toString());
133              float cy = Float.parseFloat(h.get("cy").toString());
134              path = "A " + rx + " " + ry + " 1 1 " + cx + " " + cy;
135  	    
136          } else if (name.equals("line")) {
137              float x1 = Float.parseFloat(h.get("x1").toString());
138              float y1 = Float.parseFloat(h.get("y1").toString());
139              float x2 = Float.parseFloat(h.get("x2").toString());
140              float y2 = Float.parseFloat(h.get("y2").toString());
141              path = "M " + x1 + " " + y1 + " L " + x2 + " " + y2;
142                  
143          } else if (name.equals("polyline") || name.equals("polygon")) {
144              StringTokenizer st = new StringTokenizer(h.get("points").toString(), ", ", false);
145              String s = "M ";
146              while(st.hasMoreTokens()) s += st.nextToken() + " " + st.nextToken() + " ";
147              path = s + (name.equals("polygon") ? "z" : "");
148  
149          } else {
150              Log.info(VectorGraphics.class, "unknown element in VectorGraphics namespace: " + name);
151          }
152          props.put("path", path);
153          t.keys = new String[props.size()];
154          System.arraycopy(props.keys(), 0, t.keys, 0, t.keys.length);
155          t.vals = new String[props.size()];
156          for(int i=0; i<t.keys.length; i++) t.vals[i] = props.get(t.keys[i]);
157          
158  
159          // FIXME!!!!
160          if (h.get("viewBox") != null) {
161          StringTokenizer st = new StringTokenizer(h.get("viewBox").toString(), ", ", false);
162          if (t.transform == null) t.transform = "";
163          Point p1, p2;
164          VectorGraphics.RasterPath.fromString(path).getBoundingBox(p1, p2);
165          
166          float minx = st.parseFloat();
167          float miny = st.parseFloat();
168          float width = st.parseFloat();
169          float height = st.parseFloat();
170          t.transform += "translate(" + (-1 * p1.x) + ", " + (-1 * p1.y) + ") " +
171          "scale(" + ((p2.x - p1.x) / width) + ", " + ((p2.y - p1.y) / height) + ") " + 
172          "translate(" + minx + ", " + miny + ") ";
173          
174          // FIXME: preserveAspectRatio
175          }
176  
177      }
178      */
179  
180      /*
181      public static class Font {
182          Font() { }
183          float horiz_origin_x = 0,  horiz_origin_y = 0, horiz_adv_x = 0;
184          float vert_origin_x = 0, vert_origin_y = 0, vert_adv_y = 0;
185  
186          // FIXME: avoid using substring() in here ore creating any objects
187          public void render(String text, DoubleBuffer buf, int x, int y, int fillcolor, int strokecolor, int size) {
188              // FIXME: points, not pixels
189              Affine a = buf.a;
190              float scaleFactor = (float)(1.0/1000.0) * (float)size;
191              for(int pos=0; pos<text.length(); pos++) { 
192                  Glyph g;
193                  for(g = (Glyph)glyphByUnicode.get(text.substring(pos, pos+1));
194                      g != null && !g.unicode.equals(text.substring(pos, pos + g.unicode.length()));
195                      g = g.next);
196                  if (g == null) {
197                      g = (Glyph)glyphByName.get("missing-glyph");
198                  } else {
199                      pos += g.unicode.length() - 1;
200                  }
201                  if (g != null) {
202                      System.out.println("  " + g.unicode);
203                      g.render(buf, x, y, fillcolor, strokecolor, scaleFactor);
204                      x += (int)(g.horiz_adv_x * size / 1000.0);
205                  } else {
206                      x += (int)(horiz_adv_x * size / 1000.0);
207                  }
208              }
209              buf.setTransform(a);
210          }
211  
212          / ** all glyphs, keyed by their <tt>name</tt> property * /
213          Hashtable glyphByName = new Hashtable();
214  
215          / ** linked list of glyphs, stored by the first character of their <tt>unicode</tt> property * /
216          Hashtable glyphByUnicode = new Hashtable();
217  
218          // a Glyph in an VectorGraphics font
219          public static class Glyph {
220  
221              // FIXME: lang attribute
222              boolean isVerticallyOriented = false;
223              Template t = null;
224              Box b = null;
225  
226              float horiz_adv_x = 0;
227              float vert_origin_x = 0;
228              float vert_origin_y = 0;
229              float vert_adv_y = 0;
230  
231              String unicode = null;
232  
233              // forms the linked list in glyphByUnicode; glyphs appear in the order specified in the font
234              public Glyph next = null;
235  
236              Glyph(String name, String unicode, Template t, VectorGraphics.Font f) {
237                  if (unicode != null)
238                      if (f.glyphByUnicode.get(unicode.substring(0, 1)) == null) {
239                          f.glyphByUnicode.put(unicode.substring(0, 1), this);
240                      } else {
241                          Glyph g;
242                          for(g = (Glyph)f.glyphByUnicode.get(unicode.substring(0, 1)); g.next != null; g = g.next);
243                          g.next = this;
244                      }
245                  if (name != null) f.glyphByUnicode.put(name, this);
246                  this.unicode = unicode;
247                  this.t = t;
248                  horiz_adv_x = f.horiz_adv_x;
249                  vert_origin_x = f.vert_origin_x;
250                  vert_origin_y = f.vert_origin_y;
251                  vert_adv_y = f.vert_adv_y;
252              }
253              public void render(DoubleBuffer buf, int x, int y, int fillcolor, int strokecolor, float scaleFactor) {
254                  // FEATURE: make b double-buffered for increased performance
255                  if (b == null) {
256                      b = new Box(t, new org.xwt.util.Vec(), new org.xwt.util.Vec(), null, 0, 0);
257                      b.put("absolute", Boolean.TRUE);
258                      b.prerender();
259                      t = null;
260                  }
261                  // FIXME
262                  b.put("width", new Integer(1000));
263                  b.put("height", new Integer(1000));
264                  b.fillcolor = fillcolor;
265                  b.strokecolor = strokecolor;
266  
267                  // we toss an extra flip on the ctm so that fonts stick "up" instead of down
268                  b.render(0, 0, buf.getWidth(), buf.getHeight(), buf,
269                           Affine.flip(false, true).multiply(Affine.scale(scaleFactor, scaleFactor).multiply(Affine.translate(x, y))).multiply(buf.a));
270              }
271          }
272      }
273      */
274  
275  
276      /** Copied verbatim from the SVG specification */
277      public static Hashtable colors = new Hashtable(400);
278      static {
279  	colors.put("aliceblue", new Integer((240 << 16) | (248 << 8) | 255));
280  	colors.put("antiquewhite", new Integer((250 << 16) | (235 << 8) | 215));
281  	colors.put("aqua", new Integer((0 << 16) | (255 << 8) | 255));
282  	colors.put("aquamarine", new Integer((127 << 16) | (255 << 8) | 212));
283  	colors.put("azure", new Integer((240 << 16) | (255 << 8) | 255));
284  	colors.put("beige", new Integer((245 << 16) | (245 << 8) | 220));
285  	colors.put("bisque", new Integer((255 << 16) | (228 << 8) | 196));
286  	colors.put("black", new Integer((0 << 16) | (0 << 8) | 0));
287  	colors.put("blanchedalmond", new Integer((255 << 16) | (235 << 8) | 205));
288  	colors.put("blue", new Integer((0 << 16) | (0 << 8) | 255));
289  	colors.put("blueviolet", new Integer((138 << 16) | (43 << 8) | 226));
290  	colors.put("brown", new Integer((165 << 16) | (42 << 8) | 42));
291  	colors.put("burlywood", new Integer((222 << 16) | (184 << 8) | 135));
292  	colors.put("cadetblue", new Integer((95 << 16) | (158 << 8) | 160));
293  	colors.put("chartreuse", new Integer((127 << 16) | (255 << 8) | 0));
294  	colors.put("chocolate", new Integer((210 << 16) | (105 << 8) | 30));
295  	colors.put("coral", new Integer((255 << 16) | (127 << 8) | 80));
296  	colors.put("cornflowerblue", new Integer((100 << 16) | (149 << 8) | 237));
297  	colors.put("cornsilk", new Integer((255 << 16) | (248 << 8) | 220));
298  	colors.put("crimson", new Integer((220 << 16) | (20 << 8) | 60));
299  	colors.put("cyan", new Integer((0 << 16) | (255 << 8) | 255));
300  	colors.put("darkblue", new Integer((0 << 16) | (0 << 8) | 139));
301  	colors.put("darkcyan", new Integer((0 << 16) | (139 << 8) | 139));
302  	colors.put("darkgoldenrod", new Integer((184 << 16) | (134 << 8) | 11));
303  	colors.put("darkgray", new Integer((169 << 16) | (169 << 8) | 169));
304  	colors.put("darkgreen", new Integer((0 << 16) | (100 << 8) | 0));
305  	colors.put("darkgrey", new Integer((169 << 16) | (169 << 8) | 169));
306  	colors.put("darkkhaki", new Integer((189 << 16) | (183 << 8) | 107));
307  	colors.put("darkmagenta", new Integer((139 << 16) | (0 << 8) | 139));
308  	colors.put("darkolivegreen", new Integer((85 << 16) | (107 << 8) | 47));
309  	colors.put("darkorange", new Integer((255 << 16) | (140 << 8) | 0));
310  	colors.put("darkorchid", new Integer((153 << 16) | (50 << 8) | 204));
311  	colors.put("darkred", new Integer((139 << 16) | (0 << 8) | 0));
312  	colors.put("darksalmon", new Integer((233 << 16) | (150 << 8) | 122));
313  	colors.put("darkseagreen", new Integer((143 << 16) | (188 << 8) | 143));
314  	colors.put("darkslateblue", new Integer((72 << 16) | (61 << 8) | 139));
315  	colors.put("darkslategray", new Integer((47 << 16) | (79 << 8) | 79));
316  	colors.put("darkslategrey", new Integer((47 << 16) | (79 << 8) | 79));
317  	colors.put("darkturquoise", new Integer((0 << 16) | (206 << 8) | 209));
318  	colors.put("darkviolet", new Integer((148 << 16) | (0 << 8) | 211));
319  	colors.put("deeppink", new Integer((255 << 16) | (20 << 8) | 147));
320  	colors.put("deepskyblue", new Integer((0 << 16) | (191 << 8) | 255));
321  	colors.put("dimgray", new Integer((105 << 16) | (105 << 8) | 105));
322  	colors.put("dimgrey", new Integer((105 << 16) | (105 << 8) | 105));
323  	colors.put("dodgerblue", new Integer((30 << 16) | (144 << 8) | 255));
324  	colors.put("firebrick", new Integer((178 << 16) | (34 << 8) | 34));
325  	colors.put("floralwhite", new Integer((255 << 16) | (250 << 8) | 240));
326  	colors.put("forestgreen", new Integer((34 << 16) | (139 << 8) | 34));
327  	colors.put("fuchsia", new Integer((255 << 16) | (0 << 8) | 255));
328  	colors.put("gainsboro", new Integer((220 << 16) | (220 << 8) | 220));
329  	colors.put("ghostwhite", new Integer((248 << 16) | (248 << 8) | 255));
330  	colors.put("gold", new Integer((255 << 16) | (215 << 8) | 0));
331  	colors.put("goldenrod", new Integer((218 << 16) | (165 << 8) | 32));
332  	colors.put("gray", new Integer((128 << 16) | (128 << 8) | 128));
333  	colors.put("grey", new Integer((128 << 16) | (128 << 8) | 128));
334  	colors.put("green", new Integer((0 << 16) | (128 << 8) | 0));
335  	colors.put("greenyellow", new Integer((173 << 16) | (255 << 8) | 47));
336  	colors.put("honeydew", new Integer((240 << 16) | (255 << 8) | 240));
337  	colors.put("hotpink", new Integer((255 << 16) | (105 << 8) | 180));
338  	colors.put("indianred", new Integer((205 << 16) | (92 << 8) | 92));
339  	colors.put("indigo", new Integer((75 << 16) | (0 << 8) | 130));
340  	colors.put("ivory", new Integer((255 << 16) | (255 << 8) | 240));
341  	colors.put("khaki", new Integer((240 << 16) | (230 << 8) | 140));
342  	colors.put("lavender", new Integer((230 << 16) | (230 << 8) | 250));
343  	colors.put("lavenderblush", new Integer((255 << 16) | (240 << 8) | 245));
344  	colors.put("lawngreen", new Integer((124 << 16) | (252 << 8) | 0));
345  	colors.put("lemonchiffon", new Integer((255 << 16) | (250 << 8) | 205));
346  	colors.put("lightblue", new Integer((173 << 16) | (216 << 8) | 230));
347  	colors.put("lightcoral", new Integer((240 << 16) | (128 << 8) | 128));
348  	colors.put("lightcyan", new Integer((224 << 16) | (255 << 8) | 255));
349  	colors.put("lightgoldenrodyellow", new Integer((250 << 16) | (250 << 8) | 210));
350  	colors.put("lightgray", new Integer((211 << 16) | (211 << 8) | 211));
351  	colors.put("lightgreen", new Integer((144 << 16) | (238 << 8) | 144));
352  	colors.put("lightgrey", new Integer((211 << 16) | (211 << 8) | 211));
353  	colors.put("lightpink", new Integer((255 << 16) | (182 << 8) | 193));
354  	colors.put("lightsalmon", new Integer((255 << 16) | (160 << 8) | 122));
355  	colors.put("lightseagreen", new Integer((32 << 16) | (178 << 8) | 170));
356  	colors.put("lightskyblue", new Integer((135 << 16) | (206 << 8) | 250));
357  	colors.put("lightslategray", new Integer((119 << 16) | (136 << 8) | 153));
358  	colors.put("lightslategrey", new Integer((119 << 16) | (136 << 8) | 153));
359  	colors.put("lightsteelblue", new Integer((176 << 16) | (196 << 8) | 222));
360  	colors.put("lightyellow", new Integer((255 << 16) | (255 << 8) | 224));
361  	colors.put("lime", new Integer((0 << 16) | (255 << 8) | 0));
362  	colors.put("limegreen", new Integer((50 << 16) | (205 << 8) | 50));
363  	colors.put("linen", new Integer((250 << 16) | (240 << 8) | 230));
364  	colors.put("magenta", new Integer((255 << 16) | (0 << 8) | 255));
365  	colors.put("maroon", new Integer((128 << 16) | (0 << 8) | 0));
366  	colors.put("mediumaquamarine", new Integer((102 << 16) | (205 << 8) | 170));
367  	colors.put("mediumblue", new Integer((0 << 16) | (0 << 8) | 205));
368  	colors.put("mediumorchid", new Integer((186 << 16) | (85 << 8) | 211));
369  	colors.put("mediumpurple", new Integer((147 << 16) | (112 << 8) | 219));
370  	colors.put("mediumseagreen", new Integer((60 << 16) | (179 << 8) | 113));
371  	colors.put("mediumslateblue", new Integer((123 << 16) | (104 << 8) | 238));
372  	colors.put("mediumspringgreen", new Integer((0 << 16) | (250 << 8) | 154));
373  	colors.put("mediumturquoise", new Integer((72 << 16) | (209 << 8) | 204));
374  	colors.put("mediumvioletred", new Integer((199 << 16) | (21 << 8) | 133));
375  	colors.put("midnightblue", new Integer((25 << 16) | (25 << 8) | 112));
376  	colors.put("mintcream", new Integer((245 << 16) | (255 << 8) | 250));
377  	colors.put("mistyrose", new Integer((255 << 16) | (228 << 8) | 225));
378  	colors.put("moccasin", new Integer((255 << 16) | (228 << 8) | 181));
379  	colors.put("navajowhite", new Integer((255 << 16) | (222 << 8) | 173));
380  	colors.put("navy", new Integer((0 << 16) | (0 << 8) | 128));
381  	colors.put("oldlace", new Integer((253 << 16) | (245 << 8) | 230));
382  	colors.put("olive", new Integer((128 << 16) | (128 << 8) | 0));
383  	colors.put("olivedrab", new Integer((107 << 16) | (142 << 8) | 35));
384  	colors.put("orange", new Integer((255 << 16) | (165 << 8) | 0));
385  	colors.put("orangered", new Integer((255 << 16) | (69 << 8) | 0));
386  	colors.put("orchid", new Integer((218 << 16) | (112 << 8) | 214));
387  	colors.put("palegoldenrod", new Integer((238 << 16) | (232 << 8) | 170));
388  	colors.put("palegreen", new Integer((152 << 16) | (251 << 8) | 152));
389  	colors.put("paleturquoise", new Integer((175 << 16) | (238 << 8) | 238));
390  	colors.put("palevioletred", new Integer((219 << 16) | (112 << 8) | 147));
391  	colors.put("papayawhip", new Integer((255 << 16) | (239 << 8) | 213));
392  	colors.put("peachpuff", new Integer((255 << 16) | (218 << 8) | 185));
393  	colors.put("peru", new Integer((205 << 16) | (133 << 8) | 63));
394  	colors.put("pink", new Integer((255 << 16) | (192 << 8) | 203));
395  	colors.put("plum", new Integer((221 << 16) | (160 << 8) | 221));
396  	colors.put("powderblue", new Integer((176 << 16) | (224 << 8) | 230));
397  	colors.put("purple", new Integer((128 << 16) | (0 << 8) | 128));
398  	colors.put("red", new Integer((255 << 16) | (0 << 8) | 0));
399  	colors.put("rosybrown", new Integer((188 << 16) | (143 << 8) | 143));
400  	colors.put("royalblue", new Integer((65 << 16) | (105 << 8) | 225));
401  	colors.put("saddlebrown", new Integer((139 << 16) | (69 << 8) | 19));
402  	colors.put("salmon", new Integer((250 << 16) | (128 << 8) | 114));
403  	colors.put("sandybrown", new Integer((244 << 16) | (164 << 8) | 96));
404  	colors.put("seagreen", new Integer((46 << 16) | (139 << 8) | 87));
405  	colors.put("seashell", new Integer((255 << 16) | (245 << 8) | 238));
406  	colors.put("sienna", new Integer((160 << 16) | (82 << 8) | 45));
407  	colors.put("silver", new Integer((192 << 16) | (192 << 8) | 192));
408  	colors.put("skyblue", new Integer((135 << 16) | (206 << 8) | 235));
409  	colors.put("slateblue", new Integer((106 << 16) | (90 << 8) | 205));
410  	colors.put("slategray", new Integer((112 << 16) | (128 << 8) | 144));
411  	colors.put("slategrey", new Integer((112 << 16) | (128 << 8) | 144));
412  	colors.put("snow", new Integer((255 << 16) | (250 << 8) | 250));
413  	colors.put("springgreen", new Integer((0 << 16) | (255 << 8) | 127));
414  	colors.put("steelblue", new Integer((70 << 16) | (130 << 8) | 180));
415  	colors.put("tan", new Integer((210 << 16) | (180 << 8) | 140));
416  	colors.put("teal", new Integer((0 << 16) | (128 << 8) | 128));
417  	colors.put("thistle", new Integer((216 << 16) | (191 << 8) | 216));
418  	colors.put("tomato", new Integer((255 << 16) | (99 << 8) | 71));
419  	colors.put("turquoise", new Integer((64 << 16) | (224 << 8) | 208));
420  	colors.put("violet", new Integer((238 << 16) | (130 << 8) | 238));
421  	colors.put("wheat", new Integer((245 << 16) | (222 << 8) | 179));
422  	colors.put("white", new Integer((255 << 16) | (255 << 8) | 255));
423  	colors.put("whitesmoke", new Integer((245 << 16) | (245 << 8) | 245));
424  	colors.put("yellow", new Integer((255 << 16) | (255 << 8) | 0));
425  	colors.put("yellowgreen", new Integer((154 << 16) | (205 << 8) | 50));
426      }
427  
428  }
429