Mercurial > MadButterfly
comparison nodejs/svg.js @ 1385:2ebb07ee455e
Fix the issue that we put the wrong entry for the groupMap for svg:g element.
Use clone_from_subtree for the svg:use tag.
author | wycc |
---|---|
date | Fri, 25 Mar 2011 02:31:55 +0800 |
parents | 98ea7146cef3 |
children | 669f79a4ecaf |
comparison
equal
deleted
inserted
replaced
1384:98ea7146cef3 | 1385:2ebb07ee455e |
---|---|
1106 root.center.y = coord.center.y; | 1106 root.center.y = coord.center.y; |
1107 | 1107 |
1108 this._set_bbox(n, coord); | 1108 this._set_bbox(n, coord); |
1109 // Set the group map only it is not defined before. The group might be | 1109 // Set the group map only it is not defined before. The group might be |
1110 // redefined by the svg:use tag | 1110 // redefined by the svg:use tag |
1111 if (this._groupMap[n.name()]==null) | 1111 if (this._groupMap[group_id]==undefined) |
1112 this._groupMap[n.name()] = n; | 1112 this._groupMap[group_id] = n; |
1113 | 1113 |
1114 make_mbnames(this.mb_rt, n, coord); | 1114 make_mbnames(this.mb_rt, n, coord); |
1115 return coord; | 1115 return coord; |
1116 }; | 1116 }; |
1117 | 1117 |
1155 n = this._groupMap[attr.value()]; | 1155 n = this._groupMap[attr.value()]; |
1156 if (n == null) { | 1156 if (n == null) { |
1157 sys.puts("Can not find object "+attr.value()); | 1157 sys.puts("Can not find object "+attr.value()); |
1158 return; | 1158 return; |
1159 } | 1159 } |
1160 nodes = n.childNodes(); | 1160 coord.clone_from_subtree(n.coord); |
1161 for(k in nodes) { | |
1162 var c = nodes[k].name(); | |
1163 var attr = nodes[k].attr('id'); | |
1164 var id; | |
1165 if (attr) { | |
1166 id = attr.value(); | |
1167 } | |
1168 if (c == "g") { | |
1169 this.parseGroup(accu,coord, id, nodes[k]); | |
1170 } else if (c == "path") { | |
1171 this.parsePath(accu,coord, id, nodes[k]); | |
1172 } else if (c == "text") { | |
1173 this.parseText(accu,coord, id, nodes[k]); | |
1174 } else if (c == "rect") { | |
1175 this.parseRect(accu_matrix,coord, id, nodes[k]); | |
1176 } else if (c == "image") { | |
1177 this.parseImage(accu_matrix,coord, id, nodes[k]); | |
1178 } else if (c == "use") { | |
1179 this.parseUse(accu_matrix,coord, id, nodes[k]); | |
1180 } | |
1181 attr = nodes[k].attr('duplicate-src'); | |
1182 if (attr == null) continue; | |
1183 id = attr.value(); | |
1184 try { | |
1185 this.mbnames[id].target = coord; | |
1186 } catch(e) { | |
1187 sys.puts("id "+id+" is not defined"); | |
1188 } | |
1189 } | |
1190 } | 1161 } |
1191 if (root.center.x > coord.center.x) | 1162 if (root.center.x > coord.center.x) |
1192 root.center.x = coord.center.x; | 1163 root.center.x = coord.center.x; |
1193 if (root.center.y > coord.center.y) | 1164 if (root.center.y > coord.center.y) |
1194 root.center.y = coord.center.y; | 1165 root.center.y = coord.center.y; |
1263 if (tcoord.center.x > nx) | 1234 if (tcoord.center.x > nx) |
1264 tcoord.center.x = nx; | 1235 tcoord.center.x = nx; |
1265 if (tcoord.center.y > ny) | 1236 if (tcoord.center.y > ny) |
1266 tcoord.center.y = ny; | 1237 tcoord.center.y = ny; |
1267 var img = this.mb_rt.image_new(x,y,w,h); | 1238 var img = this.mb_rt.image_new(x,y,w,h); |
1239 sys.puts('----'+ref); | |
1268 var img_data = ldr.load(ref); | 1240 var img_data = ldr.load(ref); |
1269 try { | 1241 try { |
1270 sys.puts('----'+ref); | |
1271 var paint = this.mb_rt.paint_image_new(img_data); | 1242 var paint = this.mb_rt.paint_image_new(img_data); |
1272 paint.fill(img); | 1243 paint.fill(img); |
1273 } catch(e) { | 1244 } catch(e) { |
1274 sys.puts(e); | 1245 sys.puts(e); |
1275 sys.puts("Can not load image "+ref); | 1246 sys.puts("--Can not load image "+ref); |
1276 } | 1247 } |
1277 tcoord.add_shape(img); | 1248 tcoord.add_shape(img); |
1278 | 1249 |
1279 this._set_bbox(n, tcoord); | 1250 this._set_bbox(n, tcoord); |
1280 | 1251 |