Author: clopes
Date: 2011-11-01 13:55:06 -0700 (Tue, 01 Nov 2011)
New Revision: 27361

Modified:
   
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/model/converters/SVGExporter.as
Log:
Added workaround for converting Flash's text glow filter to SVG.

Modified: 
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/model/converters/SVGExporter.as
===================================================================
--- 
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/model/converters/SVGExporter.as
        2011-11-01 20:52:58 UTC (rev 27360)
+++ 
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/model/converters/SVGExporter.as
        2011-11-01 20:55:06 UTC (rev 27361)
@@ -380,6 +380,7 @@
             if (lbl != null && lbl.visible && lbl.alpha > 0) {
                 var text:String = lbl.text;
                 var lblSize:int = Math.round(lbl.size*_scale);
+                var filter:Object, gf:GlowFilter;
                 
                 if (text != null && text != "" && lblSize >= 1) {
                     var field:TextField = lbl.textField;
@@ -444,20 +445,46 @@
                     var c:String = Utils.rgbColorAsString(lbl.color);
                     var a:Number = ds.alpha;
                     var ta:String = getTextAnchor(lbl);
-    
-                    svg += '<text font-family="'+family+'" 
font-style="'+style+'" font-weight="'+weight+'" stroke="none" fill="'+c+'"' +
-                                ' fill-opacity="'+a+'" font-size="'+lblSize+'" 
x="'+p.x+'" y="'+p.y+'" style="text-anchor:'+ta+';">';
                     
-                    if (lines.length > 0) {
-                        for (var i:int = 0; i < lines.length; i++) {
-                            var ln:String = lines[i];
-                            svg += '<tspan style="text-anchor:'+ta+';" 
x="'+p.x+'" dy="'+textHeight+'">'+ln+'</tspan>';
+                    // Glow filter:
+                    var sc:String = "none", so:Number = 0, sw:Number = 0;
+                    var filters:Array = lbl.filters;
+                    
+                    if (filters != null) {
+                        for each (filter in filters) {
+                            if (filter is GlowFilter) {
+                                gf = filter as GlowFilter;
+                                so = gf.alpha;
+                                
+                                if (so > 0) {
+                                    sc = Utils.rgbColorAsString(gf.color);
+                                    sw = Math.max(0.1, gf.blurX);
+                                    
+                                    drawText(so);
+                                }
+                            }
                         }
-                    } else {
-                        svg += text;
                     }
                     
-                    svg += '</text>';
+                    // TODO: use filters instead, when Safari and IE supports 
it
+                    drawText(0);
+    
+                    function drawText(so:Number):void {                
+                        svg += '<text font-family="'+family+'" 
font-style="'+style+'" font-weight="'+weight+'"' +
+                                    ' stroke="'+sc+'" stroke-width="'+sw+'" 
stroke-opacity="'+so+'" stroke-linejoin="round" fill="'+c+'"' +
+                                    ' fill-opacity="'+a+'" 
font-size="'+lblSize+'" x="'+p.x+'" y="'+p.y+'" style="text-anchor:'+ta+';">';
+                        
+                        if (lines.length > 0) {
+                            for (var i:int = 0; i < lines.length; i++) {
+                                var ln:String = lines[i];
+                                svg += '<tspan style="text-anchor:'+ta+';" 
x="'+p.x+'" dy="'+textHeight+'">'+ln+'</tspan>';
+                            }
+                        } else {
+                            svg += text;
+                        }
+                    
+                        svg += '</text>';
+                    }
                 }
             }
             

-- 
You received this message because you are subscribed to the Google Groups 
"cytoscape-cvs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/cytoscape-cvs?hl=en.

Reply via email to