Author: Christian Lopes
Date: 2010-11-17 16:10:49 -0800 (Wed, 17 Nov 2010)
New Revision: 22889

Modified:
   
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/model/converters/SVGExporter.as
Log:
Added dashed lines (edges) support to the SVG exporter.

Modified: 
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/model/converters/SVGExporter.as
===================================================================
--- 
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/model/converters/SVGExporter.as
        2010-11-18 00:09:46 UTC (rev 22888)
+++ 
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/model/converters/SVGExporter.as
        2010-11-18 00:10:49 UTC (rev 22889)
@@ -35,6 +35,7 @@
     import flare.vis.data.EdgeSprite;
     import flare.vis.data.NodeSprite;
     
+    import flash.display.CapsStyle;
     import flash.display.DisplayObject;
     import flash.filters.BitmapFilter;
     import flash.filters.GlowFilter;
@@ -47,6 +48,7 @@
     import org.cytoscapeweb.util.Anchors;
     import org.cytoscapeweb.util.ArrowShapes;
     import org.cytoscapeweb.util.Fonts;
+    import org.cytoscapeweb.util.LineStyles;
     import org.cytoscapeweb.util.NodeShapes;
     import org.cytoscapeweb.util.Utils;
     import org.cytoscapeweb.util.VisualProperties;
@@ -179,7 +181,19 @@
                     
                     var w:Number = e.lineWidth * _scale;
                     var loop:Boolean = e.source === e.target;
+                    var lineStyle:String = e.props.lineStyle;
+                    var solid:Boolean = lineStyle === LineStyles.SOLID;
+                    var cap:String = 'butt';
+                    var dashArr:String = '';
                     
+                    if (!solid) {
+                        var onLength:Number = LineStyles.getOnLength(e, 
lineStyle);
+                        var offLength:Number = LineStyles.getOffLength(e, 
lineStyle);
+                        dashArr = 
'stroke-dasharray="'+onLength+','+offLength+'"';
+                        cap = LineStyles.getCaps(lineStyle);
+                        cap = cap === CapsStyle.ROUND ? 'round' : 'butt';
+                    }
+                    
                     // First let's draw any glow (e.g. for selected edges):
                     // -----------------------------------------------------
                     var filters:Array = e.filters;
@@ -193,7 +207,7 @@
                             
                             // The current version of AlivePDF does not 
support glows, gradients, etc.
                             // So we just draw a bigger shape behind the node:
-                            svg += '<g stroke-linejoin="round" 
stroke-width="'+gw+'" stroke-linecap="butt" fill="none" stroke-opacity="'+a+'" 
stroke="'+c+'">';
+                            svg += '<g stroke-linejoin="round" 
stroke-width="'+gw+'" stroke-linecap="'+cap+'" fill="none" 
stroke-opacity="'+a+'" stroke="'+c+'" '+dashArr+'>';
                             svg += drawEdgeShaft(start, end, c1, c2, loop);
                             svg += '</g>';
                             
@@ -214,7 +228,7 @@
                     
                     // Draw the edge's line and joints:
                     // -----------------------------------------------------
-                    svg += '<g stroke-linejoin="round" stroke-width="'+w+'" 
stroke-linecap="butt" fill="none" stroke-opacity="'+a+'" stroke="'+c+'">';
+                    svg += '<g stroke-linejoin="round" stroke-width="'+w+'" 
stroke-linecap="'+cap+'" fill="none" stroke-opacity="'+a+'" stroke="'+c+'" 
'+dashArr+'>';
                     svg += drawEdgeShaft(start, end, c1, c2, loop);
                     svg += '</g>';
                     

-- 
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