X-Git-Url: http://git.megacz.com/?p=org.ibex.core.git;a=blobdiff_plain;f=src%2Forg%2Fxwt%2Ftranslators%2FSVG.java;h=e69de29bb2d1d6434b8b29ae775ad8c2e48c5391;hp=3e2e780af0f86d78e094746368a10becc5f66817;hb=db4ab6de30e095d6448fb826c2e6f0d4ac53cc7b;hpb=ef73cbdf9c1fc30f4bc59453c7e759e0a507580f diff --git a/src/org/xwt/translators/SVG.java b/src/org/xwt/translators/SVG.java index 3e2e780..e69de29 100644 --- a/src/org/xwt/translators/SVG.java +++ b/src/org/xwt/translators/SVG.java @@ -1,428 +0,0 @@ -// Copyright 2004 Adam Megacz, see the COPYING file for licensing [GPL] -package org.xwt.translators; -import java.util.*; - -// FIXME: need to support style sheets and the 'style=' attribute -// FIXME: need to convert markers into subboxes -public class SVG { - - /* - public static void parseNode(String name, String[] keys, Object[] vals, Template t) { - Hash h = new Hash(); - for(int i=0; iname property * / - Hashtable glyphByName = new Hashtable(); - - / ** linked list of glyphs, stored by the first character of their unicode property * / - Hashtable glyphByUnicode = new Hashtable(); - - // a Glyph in an VectorGraphics font - public static class Glyph { - - // FIXME: lang attribute - boolean isVerticallyOriented = false; - Template t = null; - Box b = null; - - float horiz_adv_x = 0; - float vert_origin_x = 0; - float vert_origin_y = 0; - float vert_adv_y = 0; - - String unicode = null; - - // forms the linked list in glyphByUnicode; glyphs appear in the order specified in the font - public Glyph next = null; - - Glyph(String name, String unicode, Template t, VectorGraphics.Font f) { - if (unicode != null) - if (f.glyphByUnicode.get(unicode.substring(0, 1)) == null) { - f.glyphByUnicode.put(unicode.substring(0, 1), this); - } else { - Glyph g; - for(g = (Glyph)f.glyphByUnicode.get(unicode.substring(0, 1)); g.next != null; g = g.next); - g.next = this; - } - if (name != null) f.glyphByUnicode.put(name, this); - this.unicode = unicode; - this.t = t; - horiz_adv_x = f.horiz_adv_x; - vert_origin_x = f.vert_origin_x; - vert_origin_y = f.vert_origin_y; - vert_adv_y = f.vert_adv_y; - } - public void render(DoubleBuffer buf, int x, int y, int fillcolor, int strokecolor, float scaleFactor) { - // FEATURE: make b double-buffered for increased performance - if (b == null) { - b = new Box(t, new org.ibex.util.Vec(), new org.ibex.util.Vec(), null, 0, 0); - b.put("absolute", Boolean.TRUE); - b.prerender(); - t = null; - } - // FIXME - b.put("width", new Integer(1000)); - b.put("height", new Integer(1000)); - b.fillcolor = fillcolor; - b.strokecolor = strokecolor; - - // we toss an extra flip on the ctm so that fonts stick "up" instead of down - b.render(0, 0, buf.getWidth(), buf.getHeight(), buf, - Affine.flip(false, true).multiply(Affine.scale(scaleFactor, scaleFactor).multiply(Affine.translate(x, y))).multiply(buf.a)); - } - } - } - */ - - - /** Copied verbatim from the SVG specification */ - public static Hashtable colors = new Hashtable(400); - static { - colors.put("aliceblue", new Integer((240 << 16) | (248 << 8) | 255)); - colors.put("antiquewhite", new Integer((250 << 16) | (235 << 8) | 215)); - colors.put("aqua", new Integer((0 << 16) | (255 << 8) | 255)); - colors.put("aquamarine", new Integer((127 << 16) | (255 << 8) | 212)); - colors.put("azure", new Integer((240 << 16) | (255 << 8) | 255)); - colors.put("beige", new Integer((245 << 16) | (245 << 8) | 220)); - colors.put("bisque", new Integer((255 << 16) | (228 << 8) | 196)); - colors.put("black", new Integer((0 << 16) | (0 << 8) | 0)); - colors.put("blanchedalmond", new Integer((255 << 16) | (235 << 8) | 205)); - colors.put("blue", new Integer((0 << 16) | (0 << 8) | 255)); - colors.put("blueviolet", new Integer((138 << 16) | (43 << 8) | 226)); - colors.put("brown", new Integer((165 << 16) | (42 << 8) | 42)); - colors.put("burlywood", new Integer((222 << 16) | (184 << 8) | 135)); - colors.put("cadetblue", new Integer((95 << 16) | (158 << 8) | 160)); - colors.put("chartreuse", new Integer((127 << 16) | (255 << 8) | 0)); - colors.put("chocolate", new Integer((210 << 16) | (105 << 8) | 30)); - colors.put("coral", new Integer((255 << 16) | (127 << 8) | 80)); - colors.put("cornflowerblue", new Integer((100 << 16) | (149 << 8) | 237)); - colors.put("cornsilk", new Integer((255 << 16) | (248 << 8) | 220)); - colors.put("crimson", new Integer((220 << 16) | (20 << 8) | 60)); - colors.put("cyan", new Integer((0 << 16) | (255 << 8) | 255)); - colors.put("darkblue", new Integer((0 << 16) | (0 << 8) | 139)); - colors.put("darkcyan", new Integer((0 << 16) | (139 << 8) | 139)); - colors.put("darkgoldenrod", new Integer((184 << 16) | (134 << 8) | 11)); - colors.put("darkgray", new Integer((169 << 16) | (169 << 8) | 169)); - colors.put("darkgreen", new Integer((0 << 16) | (100 << 8) | 0)); - colors.put("darkgrey", new Integer((169 << 16) | (169 << 8) | 169)); - colors.put("darkkhaki", new Integer((189 << 16) | (183 << 8) | 107)); - colors.put("darkmagenta", new Integer((139 << 16) | (0 << 8) | 139)); - colors.put("darkolivegreen", new Integer((85 << 16) | (107 << 8) | 47)); - colors.put("darkorange", new Integer((255 << 16) | (140 << 8) | 0)); - colors.put("darkorchid", new Integer((153 << 16) | (50 << 8) | 204)); - colors.put("darkred", new Integer((139 << 16) | (0 << 8) | 0)); - colors.put("darksalmon", new Integer((233 << 16) | (150 << 8) | 122)); - colors.put("darkseagreen", new Integer((143 << 16) | (188 << 8) | 143)); - colors.put("darkslateblue", new Integer((72 << 16) | (61 << 8) | 139)); - colors.put("darkslategray", new Integer((47 << 16) | (79 << 8) | 79)); - colors.put("darkslategrey", new Integer((47 << 16) | (79 << 8) | 79)); - colors.put("darkturquoise", new Integer((0 << 16) | (206 << 8) | 209)); - colors.put("darkviolet", new Integer((148 << 16) | (0 << 8) | 211)); - colors.put("deeppink", new Integer((255 << 16) | (20 << 8) | 147)); - colors.put("deepskyblue", new Integer((0 << 16) | (191 << 8) | 255)); - colors.put("dimgray", new Integer((105 << 16) | (105 << 8) | 105)); - colors.put("dimgrey", new Integer((105 << 16) | (105 << 8) | 105)); - colors.put("dodgerblue", new Integer((30 << 16) | (144 << 8) | 255)); - colors.put("firebrick", new Integer((178 << 16) | (34 << 8) | 34)); - colors.put("floralwhite", new Integer((255 << 16) | (250 << 8) | 240)); - colors.put("forestgreen", new Integer((34 << 16) | (139 << 8) | 34)); - colors.put("fuchsia", new Integer((255 << 16) | (0 << 8) | 255)); - colors.put("gainsboro", new Integer((220 << 16) | (220 << 8) | 220)); - colors.put("ghostwhite", new Integer((248 << 16) | (248 << 8) | 255)); - colors.put("gold", new Integer((255 << 16) | (215 << 8) | 0)); - colors.put("goldenrod", new Integer((218 << 16) | (165 << 8) | 32)); - colors.put("gray", new Integer((128 << 16) | (128 << 8) | 128)); - colors.put("grey", new Integer((128 << 16) | (128 << 8) | 128)); - colors.put("green", new Integer((0 << 16) | (128 << 8) | 0)); - colors.put("greenyellow", new Integer((173 << 16) | (255 << 8) | 47)); - colors.put("honeydew", new Integer((240 << 16) | (255 << 8) | 240)); - colors.put("hotpink", new Integer((255 << 16) | (105 << 8) | 180)); - colors.put("indianred", new Integer((205 << 16) | (92 << 8) | 92)); - colors.put("indigo", new Integer((75 << 16) | (0 << 8) | 130)); - colors.put("ivory", new Integer((255 << 16) | (255 << 8) | 240)); - colors.put("khaki", new Integer((240 << 16) | (230 << 8) | 140)); - colors.put("lavender", new Integer((230 << 16) | (230 << 8) | 250)); - colors.put("lavenderblush", new Integer((255 << 16) | (240 << 8) | 245)); - colors.put("lawngreen", new Integer((124 << 16) | (252 << 8) | 0)); - colors.put("lemonchiffon", new Integer((255 << 16) | (250 << 8) | 205)); - colors.put("lightblue", new Integer((173 << 16) | (216 << 8) | 230)); - colors.put("lightcoral", new Integer((240 << 16) | (128 << 8) | 128)); - colors.put("lightcyan", new Integer((224 << 16) | (255 << 8) | 255)); - colors.put("lightgoldenrodyellow", new Integer((250 << 16) | (250 << 8) | 210)); - colors.put("lightgray", new Integer((211 << 16) | (211 << 8) | 211)); - colors.put("lightgreen", new Integer((144 << 16) | (238 << 8) | 144)); - colors.put("lightgrey", new Integer((211 << 16) | (211 << 8) | 211)); - colors.put("lightpink", new Integer((255 << 16) | (182 << 8) | 193)); - colors.put("lightsalmon", new Integer((255 << 16) | (160 << 8) | 122)); - colors.put("lightseagreen", new Integer((32 << 16) | (178 << 8) | 170)); - colors.put("lightskyblue", new Integer((135 << 16) | (206 << 8) | 250)); - colors.put("lightslategray", new Integer((119 << 16) | (136 << 8) | 153)); - colors.put("lightslategrey", new Integer((119 << 16) | (136 << 8) | 153)); - colors.put("lightsteelblue", new Integer((176 << 16) | (196 << 8) | 222)); - colors.put("lightyellow", new Integer((255 << 16) | (255 << 8) | 224)); - colors.put("lime", new Integer((0 << 16) | (255 << 8) | 0)); - colors.put("limegreen", new Integer((50 << 16) | (205 << 8) | 50)); - colors.put("linen", new Integer((250 << 16) | (240 << 8) | 230)); - colors.put("magenta", new Integer((255 << 16) | (0 << 8) | 255)); - colors.put("maroon", new Integer((128 << 16) | (0 << 8) | 0)); - colors.put("mediumaquamarine", new Integer((102 << 16) | (205 << 8) | 170)); - colors.put("mediumblue", new Integer((0 << 16) | (0 << 8) | 205)); - colors.put("mediumorchid", new Integer((186 << 16) | (85 << 8) | 211)); - colors.put("mediumpurple", new Integer((147 << 16) | (112 << 8) | 219)); - colors.put("mediumseagreen", new Integer((60 << 16) | (179 << 8) | 113)); - colors.put("mediumslateblue", new Integer((123 << 16) | (104 << 8) | 238)); - colors.put("mediumspringgreen", new Integer((0 << 16) | (250 << 8) | 154)); - colors.put("mediumturquoise", new Integer((72 << 16) | (209 << 8) | 204)); - colors.put("mediumvioletred", new Integer((199 << 16) | (21 << 8) | 133)); - colors.put("midnightblue", new Integer((25 << 16) | (25 << 8) | 112)); - colors.put("mintcream", new Integer((245 << 16) | (255 << 8) | 250)); - colors.put("mistyrose", new Integer((255 << 16) | (228 << 8) | 225)); - colors.put("moccasin", new Integer((255 << 16) | (228 << 8) | 181)); - colors.put("navajowhite", new Integer((255 << 16) | (222 << 8) | 173)); - colors.put("navy", new Integer((0 << 16) | (0 << 8) | 128)); - colors.put("oldlace", new Integer((253 << 16) | (245 << 8) | 230)); - colors.put("olive", new Integer((128 << 16) | (128 << 8) | 0)); - colors.put("olivedrab", new Integer((107 << 16) | (142 << 8) | 35)); - colors.put("orange", new Integer((255 << 16) | (165 << 8) | 0)); - colors.put("orangered", new Integer((255 << 16) | (69 << 8) | 0)); - colors.put("orchid", new Integer((218 << 16) | (112 << 8) | 214)); - colors.put("palegoldenrod", new Integer((238 << 16) | (232 << 8) | 170)); - colors.put("palegreen", new Integer((152 << 16) | (251 << 8) | 152)); - colors.put("paleturquoise", new Integer((175 << 16) | (238 << 8) | 238)); - colors.put("palevioletred", new Integer((219 << 16) | (112 << 8) | 147)); - colors.put("papayawhip", new Integer((255 << 16) | (239 << 8) | 213)); - colors.put("peachpuff", new Integer((255 << 16) | (218 << 8) | 185)); - colors.put("peru", new Integer((205 << 16) | (133 << 8) | 63)); - colors.put("pink", new Integer((255 << 16) | (192 << 8) | 203)); - colors.put("plum", new Integer((221 << 16) | (160 << 8) | 221)); - colors.put("powderblue", new Integer((176 << 16) | (224 << 8) | 230)); - colors.put("purple", new Integer((128 << 16) | (0 << 8) | 128)); - colors.put("red", new Integer((255 << 16) | (0 << 8) | 0)); - colors.put("rosybrown", new Integer((188 << 16) | (143 << 8) | 143)); - colors.put("royalblue", new Integer((65 << 16) | (105 << 8) | 225)); - colors.put("saddlebrown", new Integer((139 << 16) | (69 << 8) | 19)); - colors.put("salmon", new Integer((250 << 16) | (128 << 8) | 114)); - colors.put("sandybrown", new Integer((244 << 16) | (164 << 8) | 96)); - colors.put("seagreen", new Integer((46 << 16) | (139 << 8) | 87)); - colors.put("seashell", new Integer((255 << 16) | (245 << 8) | 238)); - colors.put("sienna", new Integer((160 << 16) | (82 << 8) | 45)); - colors.put("silver", new Integer((192 << 16) | (192 << 8) | 192)); - colors.put("skyblue", new Integer((135 << 16) | (206 << 8) | 235)); - colors.put("slateblue", new Integer((106 << 16) | (90 << 8) | 205)); - colors.put("slategray", new Integer((112 << 16) | (128 << 8) | 144)); - colors.put("slategrey", new Integer((112 << 16) | (128 << 8) | 144)); - colors.put("snow", new Integer((255 << 16) | (250 << 8) | 250)); - colors.put("springgreen", new Integer((0 << 16) | (255 << 8) | 127)); - colors.put("steelblue", new Integer((70 << 16) | (130 << 8) | 180)); - colors.put("tan", new Integer((210 << 16) | (180 << 8) | 140)); - colors.put("teal", new Integer((0 << 16) | (128 << 8) | 128)); - colors.put("thistle", new Integer((216 << 16) | (191 << 8) | 216)); - colors.put("tomato", new Integer((255 << 16) | (99 << 8) | 71)); - colors.put("turquoise", new Integer((64 << 16) | (224 << 8) | 208)); - colors.put("violet", new Integer((238 << 16) | (130 << 8) | 238)); - colors.put("wheat", new Integer((245 << 16) | (222 << 8) | 179)); - colors.put("white", new Integer((255 << 16) | (255 << 8) | 255)); - colors.put("whitesmoke", new Integer((245 << 16) | (245 << 8) | 245)); - colors.put("yellow", new Integer((255 << 16) | (255 << 8) | 0)); - colors.put("yellowgreen", new Integer((154 << 16) | (205 << 8) | 50)); - } - -}