mirror of
https://github.com/Quodatum/graphxq.git
synced 2026-04-23 01:33:03 +01:00
started
This commit is contained in:
parent
bfd2f26579
commit
2088ccd269
20 changed files with 1167 additions and 3 deletions
117
src/graphxq.xqm
Normal file
117
src/graphxq.xqm
Normal file
|
|
@ -0,0 +1,117 @@
|
|||
(:~
|
||||
: restxq interface to graphviz
|
||||
: @author andy bunce
|
||||
: @since sept 2012
|
||||
:)
|
||||
|
||||
module namespace grxq = 'apb.graphviz.web';
|
||||
declare default function namespace 'apb.graphviz.web';
|
||||
import module namespace gr = 'apb.graphviz' at "graphxq/graphviz.xqm";
|
||||
declare namespace rest = 'http://exquery.org/ns/restxq';
|
||||
|
||||
declare
|
||||
%rest:GET %rest:path("graphxq")
|
||||
%output:method("html5")
|
||||
%rest:form-param("dot","{$dot}","")
|
||||
%rest:form-param("url","{$url}")
|
||||
function graphxq($dot,$url) {
|
||||
let $edot:=if($url) then "" else fn:encode-for-uri($dot)
|
||||
let $dot2:=getdot($dot,$url)
|
||||
let $svg:=get-svg($dot)
|
||||
return <html>
|
||||
<head>
|
||||
<title>Graphviz</title>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="tree xquery svg" />
|
||||
<script type="text/javascript"><![CDATA[
|
||||
var _gaq = _gaq || [];
|
||||
_gaq.push(['_setAccount', 'UA-34544921-1']);
|
||||
_gaq.push(['_setDomainName', 'rhcloud.com']);
|
||||
_gaq.push(['_trackPageview']);
|
||||
|
||||
(function() {
|
||||
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
||||
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
||||
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
||||
})();
|
||||
]]></script>
|
||||
<style type="text/css">pre {{background-color:#FFFFDD;}}</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>RestXQ interface to graphviz</h1>
|
||||
<p>Enter a string in the dot language
|
||||
Examples: <a href="?dot=digraph {{ a -> b}}">digraph {{ a -> b}}</a>,
|
||||
<a href="?hedge={{github|https://github.com/apb2006/hedgetree}}(ab({{tree|%23treexml}}))">another </a>
|
||||
.</p>
|
||||
<p> Or enter a Url to a xml document examples:
|
||||
<a href="?url=graphxq/samples/process.dot">process</a>,
|
||||
<a href="?url=hedgetree/samples/hier.dot">hedgeweb</a>
|
||||
<a href="?url=https://raw.github.com/apb2006/hedgetree/master/src/hedgetree/samples/hedgeweb.xml">remote</a>
|
||||
</p>
|
||||
<form method="get" action="./graphxq" style="background-color:#EEEEEE;padding:8px;">
|
||||
|
||||
|
||||
<textarea name="dot" rows="2" cols="80">{$dot}</textarea>
|
||||
<p></p>
|
||||
<p>Or enter the url to a node XML source
|
||||
<input name="url" value="{$url}" style="width:30em"/></p>
|
||||
<button type="submit">Redraw</button>
|
||||
</form >
|
||||
<h2 id="isvg">Inline SVG</h2>
|
||||
<div style="width:300px;height:200px">{$svg}</div>
|
||||
|
||||
<h2 id="svg">Object referencing <a href="graphxq/svg?dot={$edot}&url={$url}">svg</a>,
|
||||
( <a href="graphxq/svg?dl=1&dot={$edot}&url={$url}">download</a> svg)</h2>
|
||||
<object height="150" width="300" data="graphxq/svg?dot={$edot}&url={$url}"
|
||||
style="border:5px solid red;" type="image/svg+xml">
|
||||
SVG Here
|
||||
</object>
|
||||
<h2 id="svgxml">SVG xml</h2>
|
||||
<pre>
|
||||
{fn:serialize($svg)}
|
||||
</pre>
|
||||
|
||||
|
||||
<h2 id="layout">Layout xml</h2>
|
||||
|
||||
<h2>About</h2>
|
||||
<p> Source: @github:<iframe src="http://ghbtns.com/github-btn.html?user=apb2006&repo=graphxq&type=watch"
|
||||
allowtransparency="true" frameborder="0" scrolling="0" width="62px" height="20px"></iframe>, Twitter:
|
||||
<a href="https://twitter.com/share" class="twitter-share-button" data-via="apb1704" data-count="none">Tweet</a>
|
||||
<script>!function(d,s,id){{var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){{js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}}}(document,"script","twitter-wjs");</script>.
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
};
|
||||
|
||||
(:~ @return svg for hedge with download option.
|
||||
:)
|
||||
declare
|
||||
%rest:GET %rest:path("graphxq/svg")
|
||||
%rest:form-param("dot","{$dot}")
|
||||
%rest:form-param("url","{$url}")
|
||||
%rest:form-param("dl","{$dl}")
|
||||
function graphxq-svg($dot,$url,$dl) {
|
||||
let $dot2:=getdot($dot,$url)
|
||||
let $svg:=get-svg($dot2)
|
||||
let $down:=<rest:response>
|
||||
<http:response>
|
||||
<http:header name="Content-Disposition" value='attachment;filename="graphxq.svg"'/>
|
||||
</http:response>
|
||||
</rest:response>
|
||||
return ($down[$dl],$svg)
|
||||
};
|
||||
|
||||
(:~ use dot or url :)
|
||||
declare %private function getdot($dot,$url) as xs:string{
|
||||
if($url) then
|
||||
try{fn:unparsed-text(fn:resolve-uri($url))} catch * { "digraph {{ failed to load remote }}" }
|
||||
else
|
||||
$dot
|
||||
};
|
||||
(:~ post process svg :)
|
||||
declare %private function get-svg($dot as xs:string) as node(){
|
||||
let $svgx:=gr:dot($dot,())
|
||||
return gr:autosize($svgx)
|
||||
};
|
||||
23
src/graphxq/dotml/.svn/all-wcprops
Normal file
23
src/graphxq/dotml/.svn/all-wcprops
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
K 25
|
||||
svn:wc:ra_dav:version-url
|
||||
V 39
|
||||
/apb/haveli/svn/!svn/ver/22/trunk/dotml
|
||||
END
|
||||
filters.svg
|
||||
K 25
|
||||
svn:wc:ra_dav:version-url
|
||||
V 51
|
||||
/apb/haveli/svn/!svn/ver/22/trunk/dotml/filters.svg
|
||||
END
|
||||
dotpatch.xsl
|
||||
K 25
|
||||
svn:wc:ra_dav:version-url
|
||||
V 52
|
||||
/apb/haveli/svn/!svn/ver/22/trunk/dotml/dotpatch.xsl
|
||||
END
|
||||
dotml2dot.xsl
|
||||
K 25
|
||||
svn:wc:ra_dav:version-url
|
||||
V 53
|
||||
/apb/haveli/svn/!svn/ver/22/trunk/dotml/dotml2dot.xsl
|
||||
END
|
||||
130
src/graphxq/dotml/.svn/entries
Normal file
130
src/graphxq/dotml/.svn/entries
Normal file
|
|
@ -0,0 +1,130 @@
|
|||
10
|
||||
|
||||
dir
|
||||
31
|
||||
https://free1.projectlocker.com/apb/haveli/svn/trunk/dotml
|
||||
https://free1.projectlocker.com/apb/haveli/svn
|
||||
|
||||
|
||||
|
||||
2010-05-05T15:00:02.461415Z
|
||||
22
|
||||
bunce.andy@gmail.com
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
fcc18bc9-29a6-4af3-8859-6d999b9301f9
|
||||
|
||||
filters.svg
|
||||
file
|
||||
|
||||
|
||||
|
||||
|
||||
2011-03-06T15:01:30.000000Z
|
||||
e224c2cb06bf5c56caeeddf5198c6015
|
||||
2010-05-05T15:00:02.461415Z
|
||||
22
|
||||
bunce.andy@gmail.com
|
||||
has-props
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
4263
|
||||
|
||||
dotpatch.xsl
|
||||
file
|
||||
|
||||
|
||||
|
||||
|
||||
2011-03-06T15:01:30.000000Z
|
||||
51115836e92588473c2f056c013f94ab
|
||||
2010-05-05T15:00:02.461415Z
|
||||
22
|
||||
bunce.andy@gmail.com
|
||||
has-props
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
6390
|
||||
|
||||
dotml2dot.xsl
|
||||
file
|
||||
|
||||
|
||||
|
||||
|
||||
2011-03-06T15:01:30.000000Z
|
||||
42b23cbb9e04cae1e8eaa28ca39228da
|
||||
2010-05-05T15:00:02.461415Z
|
||||
22
|
||||
bunce.andy@gmail.com
|
||||
has-props
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
5556
|
||||
|
||||
5
src/graphxq/dotml/.svn/prop-base/dotml2dot.xsl.svn-base
Normal file
5
src/graphxq/dotml/.svn/prop-base/dotml2dot.xsl.svn-base
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
K 12
|
||||
svn:keywords
|
||||
V 23
|
||||
Id Date Author HeadURL
|
||||
END
|
||||
5
src/graphxq/dotml/.svn/prop-base/dotpatch.xsl.svn-base
Normal file
5
src/graphxq/dotml/.svn/prop-base/dotpatch.xsl.svn-base
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
K 12
|
||||
svn:keywords
|
||||
V 23
|
||||
Id Date Author HeadURL
|
||||
END
|
||||
5
src/graphxq/dotml/.svn/prop-base/filters.svg.svn-base
Normal file
5
src/graphxq/dotml/.svn/prop-base/filters.svg.svn-base
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
K 12
|
||||
svn:keywords
|
||||
V 23
|
||||
Id Date Author HeadURL
|
||||
END
|
||||
83
src/graphxq/dotml/.svn/text-base/dotml2dot.xsl.svn-base
Normal file
83
src/graphxq/dotml/.svn/text-base/dotml2dot.xsl.svn-base
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<!--
|
||||
File dotml2dot.xsl
|
||||
Copyright 2002 - 2006 Martin Loetzsch
|
||||
Translates dotml documents into the native dot syntax.
|
||||
-->
|
||||
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml" xmlns:dotml="http://www.martin-loetzsch.de/DOTML">
|
||||
<xsl:output method="text"/>
|
||||
<xsl:variable xml:space="preserve" name="graph-attributes">bgcolor fontcolor fontname fontsize label margin nodesep rankdir ranksep ratio size</xsl:variable>
|
||||
<xsl:variable xml:space="preserve" name="cluster-attributes">bgcolor color fillcolor fontcolor fontname fontsize label labeljust labelloc style</xsl:variable>
|
||||
<xsl:variable xml:space="preserve" name="node-attributes">color fillcolor fixedsize fontcolor fontname fontsize height shape style URL width</xsl:variable>
|
||||
<xsl:variable xml:space="preserve" name="record-attributes">color fillcolor fontcolor fontname fontsize height style URL width</xsl:variable>
|
||||
<xsl:variable xml:space="preserve" name="edge-attributes">arrowhead arrowsize arrowtail constraint color decorate dir fontcolor fontname fontsize headlabel headport label labeldistance labelfloat labelfontcolor labelfontname labelfontsize minlen samehead sametail style taillabel tailport URL</xsl:variable>
|
||||
<xsl:key name="nodes" match="//dotml:node" use="concat(@id,ancestor::dotml:graph/@file-name)"/>
|
||||
<xsl:template match="*" priority="-1000">
|
||||
<xsl:apply-templates/>
|
||||
</xsl:template>
|
||||
<xsl:template match="text()"/>
|
||||
<xsl:template match="dotml:graph">digraph g {compound="true";<xsl:call-template name="copy-attributes">
|
||||
<xsl:with-param name="separator" select="';'"/>
|
||||
<xsl:with-param name="attributes" select="$graph-attributes"/>
|
||||
</xsl:call-template>
|
||||
<xsl:apply-templates/>}
|
||||
<dot-filename><xsl:value-of select="@file-name"/></dot-filename>
|
||||
</xsl:template>
|
||||
<xsl:template match="dotml:sub-graph">subgraph sub_graph_<xsl:value-of select="count(preceding::dotml:sub-graph)"/>{rank="<xsl:value-of select="@rank"/>";<xsl:apply-templates/>}</xsl:template>
|
||||
<xsl:template match="dotml:cluster">subgraph cluster_<xsl:value-of select="@id"/>{<xsl:call-template name="copy-attributes">
|
||||
<xsl:with-param name="separator" select="';'"/>
|
||||
<xsl:with-param name="attributes" select="$cluster-attributes"/>
|
||||
</xsl:call-template>
|
||||
<xsl:apply-templates/>}</xsl:template>
|
||||
<xsl:template match="dotml:node">node[label="<xsl:choose>
|
||||
<xsl:when test="@label">
|
||||
<xsl:value-of select="@label"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="@id"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>", <xsl:call-template name="copy-attributes">
|
||||
<xsl:with-param name="separator" select="','"/>
|
||||
<xsl:with-param name="attributes" select="$node-attributes"/>
|
||||
</xsl:call-template>] {<xsl:value-of select="@id"/>};</xsl:template>
|
||||
<xsl:template match="dotml:edge">edge[<xsl:call-template name="copy-attributes">
|
||||
<xsl:with-param name="separator" select="','"/>
|
||||
<xsl:with-param name="attributes" select="$edge-attributes"/>
|
||||
</xsl:call-template>lhead="<xsl:if test="@lhead">cluster_<xsl:value-of select="@lhead"/>
|
||||
</xsl:if>",ltail="<xsl:if test="@ltail">cluster_<xsl:value-of select="@ltail"/>
|
||||
</xsl:if>"] <xsl:if test="key('nodes',concat(@from,ancestor::dotml:graph/@file-name))/ancestor::dotml:record">struct<xsl:value-of select="count(key('nodes',concat(@from,ancestor::dotml:graph/@file-name))/preceding::dotml:record[local-name(..)!='record'])"/>:</xsl:if>
|
||||
<xsl:value-of select="@from"/> -> <xsl:if test="key('nodes',concat(@to,ancestor::dotml:graph/@file-name))/ancestor::dotml:record">struct<xsl:value-of select="count(key('nodes',concat(@to,ancestor::dotml:graph/@file-name))/preceding::dotml:record[local-name(..)!='record'])"/>:</xsl:if>
|
||||
<xsl:value-of select="@to"/>;</xsl:template>
|
||||
<xsl:template match="dotml:record">node[shape="record",label="<xsl:apply-templates select="dotml:*" mode="record-label"/>",<xsl:call-template name="copy-attributes">
|
||||
<xsl:with-param name="separator" select="','"/>
|
||||
<xsl:with-param name="attributes" select="$record-attributes"/>
|
||||
</xsl:call-template>]{struct<xsl:value-of select="count(preceding::dotml:record[local-name(..)!='record'])"/>};</xsl:template>
|
||||
<xsl:template match="dotml:record" mode="record-label">{<xsl:apply-templates select="dotml:*" mode="record-label"/>}<xsl:if test="position()!=last()"> | </xsl:if>
|
||||
</xsl:template>
|
||||
<xsl:template match="dotml:node" mode="record-label"><<xsl:value-of select="@id"/>> <xsl:choose>
|
||||
<xsl:when test="@label">
|
||||
<xsl:value-of select="@label"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="@id"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
<xsl:if test="position()!=last()"> | </xsl:if>
|
||||
</xsl:template>
|
||||
<xsl:template name="copy-attributes">
|
||||
<xsl:param name="attributes"/>
|
||||
<xsl:param name="separator"/>
|
||||
<xsl:choose>
|
||||
<xsl:when test="string-length(substring-after($attributes,' '))=0">
|
||||
<xsl:value-of select="$attributes"/>="<xsl:value-of select="@*[local-name()=$attributes]"/>"<xsl:value-of select="$separator"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="substring-before($attributes,' ')"/>="<xsl:value-of select="@*[local-name()=substring-before($attributes,' ')]"/>"<xsl:value-of select="$separator"/>
|
||||
<xsl:call-template name="copy-attributes">
|
||||
<xsl:with-param name="attributes" select="substring-after($attributes,' ')"/>
|
||||
<xsl:with-param name="separator" select="$separator"/>
|
||||
</xsl:call-template>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
</xsl:stylesheet>
|
||||
120
src/graphxq/dotml/.svn/text-base/dotpatch.xsl.svn-base
Normal file
120
src/graphxq/dotml/.svn/text-base/dotpatch.xsl.svn-base
Normal file
|
|
@ -0,0 +1,120 @@
|
|||
<?xml version="1.0"?>
|
||||
<!--
|
||||
tidy up graphviz svg o/p
|
||||
-->
|
||||
<xsl:stylesheet version="1.0" xmlns="http://www.w3.org/2000/svg" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:haveli="http://apb.info">
|
||||
<xsl:param name="dotsrc" select="/.."/>
|
||||
<xsl:param name="filter">MyFilter</xsl:param>
|
||||
<xsl:param name="rotate" select="false()"/>
|
||||
<xsl:output method="xml" encoding="UTF-8" indent="yes" omit-xml-declaration="yes"/>
|
||||
<xsl:template match="/svg:svg">
|
||||
<xsl:variable name="w" select="substring-before(@width,'px')"/>
|
||||
<xsl:variable name="h" select="substring-before(@height,'px')"/>
|
||||
<xsl:variable name="filters">
|
||||
<defs xmlns="http://www.w3.org/2000/svg">
|
||||
<filter id="Drop_Shadow" filterUnits="objectBoundingBox" x="-10%" y="-10%" width="150%" height="150%">
|
||||
<feGaussianBlur in="SourceAlpha" stdDeviation="3" result="blurredAlpha"/>
|
||||
<feOffset in="blurredAlpha" dx="3" dy="3" result="offsetBlurredAlpha"/>
|
||||
<feFlood result="flooded" style="flood-color:rgb(0,0,0);flood-opacity:0.65"/>
|
||||
<feComposite in="flooded" operator="in" in2="offsetBlurredAlpha" result="coloredShadow"/>
|
||||
<feComposite in="SourceGraphic" in2="coloredShadow" operator="over"/>
|
||||
</filter>
|
||||
<filter id="Bevel" filterUnits="objectBoundingBox" x="-10%" y="-10%" width="150%" height="150%">
|
||||
<feGaussianBlur in="SourceAlpha" stdDeviation="3" result="blur"/>
|
||||
<feSpecularLighting in="blur" surfaceScale="5" specularConstant="0.5" specularExponent="10" result="specOut" style="lighting-color:rgb(255,255,64)">
|
||||
<fePointLight x="-5000" y="-10000" z="20000"/>
|
||||
</feSpecularLighting>
|
||||
<feComposite in="specOut" in2="SourceAlpha" operator="in" result="specOut2"/>
|
||||
<feComposite in="SourceGraphic" in2="specOut2" operator="arithmetic" k1="0" k2="1" k3="1" k4="0" result="litPaint"/>
|
||||
</filter>
|
||||
<filter id="grey_bevel_shadow" filterUnits="objectBoundingBox" x="-10%" y="-10%" width="150%" height="150%">
|
||||
<feGaussianBlur result="blurredAlpha" in="SourceAlpha" stdDeviation="3"/>
|
||||
<feOffset result="offsetBlurredAlpha" in="blurredAlpha" dx="2" dy="1"/>
|
||||
<feDiffuseLighting result="bumpMapDiffuse" in="blurredAlpha" surfaceScale="5" diffuseConstant="0.5" style="lighting-color:rgb(255,255,255)">
|
||||
<feDistantLight azimuth="135" elevation="60"/>
|
||||
</feDiffuseLighting>
|
||||
<feComposite result="litPaint" in="bumpMapDiffuse" operator="arithmetic" k1="1" k2="0" k3="0" k4="0" in2="SourceGraphic"/>
|
||||
<feSpecularLighting result="bumpMapSpecular" in="blurredAlpha" surfaceScale="5" specularConstant="0.5" specularExponent="10" style="lighting-color:rgb(255,255,255)">
|
||||
<feDistantLight azimuth="135" elevation="60"/>
|
||||
</feSpecularLighting>
|
||||
<feComposite result="litPaint" in="litPaint" operator="arithmetic" k1="0" k2="1" k3="1" k4="0" in2="bumpMapSpecular"/>
|
||||
<feComposite result="litPaint" in="litPaint" operator="in" in2="SourceAlpha"/>
|
||||
<feMerge>
|
||||
<feMergeNode in="offsetBlurredAlpha"/>
|
||||
<feMergeNode in="litPaint"/>
|
||||
</feMerge>
|
||||
</filter>
|
||||
<filter id="Bumpy" filterUnits="objectBoundingBox" x="-10%" y="-10%" width="150%" height="150%">
|
||||
<feTurbulence type="turbulence" baseFrequency="0.15" numOctaves="1" result="image0"/>
|
||||
<feGaussianBlur stdDeviation="3" in="image0" result="image1"/>
|
||||
<feDiffuseLighting in="image1" surfaceScale="10" diffuseConstant="1" result="image3" style="lighting-color:rgb(255,255,255)">
|
||||
<feDistantLight azimuth="0" elevation="45"/>
|
||||
</feDiffuseLighting>
|
||||
<feComposite in="image3" in2="SourceGraphic" operator="arithmetic" k2="0.5" k3="0.5" result="image4"/>
|
||||
<feComposite in="image4" in2="SourceGraphic" operator="in" result="image5"/>
|
||||
</filter>
|
||||
<filter id="MyFilter" filterUnits="objectBoundingBox" x="-10%" y="-10%" width="150%" height="150%">
|
||||
<desc>Produces a 3D lighting effect suitable for pies and lines</desc>
|
||||
<feGaussianBlur in="SourceAlpha" stdDeviation="4" result="blur"/>
|
||||
<feOffset in="blur" dx="3" dy="5" result="offsetBlur"/>
|
||||
<feSpecularLighting in="blur" surfaceScale="5" specularConstant="1" specularExponent="30" style="lighting-color:White" result="specOut">
|
||||
<fePointLight x="-5000" y="-10000" z="20000"/>
|
||||
</feSpecularLighting>
|
||||
<feComposite in="specOut" in2="SourceAlpha" operator="in" result="specOut"/>
|
||||
<feComposite in="SourceGraphic" in2="specOut" operator="arithmetic" k1="0" k2="1" k3="1" k4="0" result="litPaint"/>
|
||||
<feMerge>
|
||||
<feMergeNode in="offsetBlur"/>
|
||||
<feMergeNode in="litPaint"/>
|
||||
</feMerge>
|
||||
</filter>
|
||||
<filter id="MyShadow" filterUnits="objectBoundingBox" x="-20%" y="-20%" width="180%" height="180%">
|
||||
<desc>Simple blurred shadow (ideal for headings)</desc>
|
||||
<feGaussianBlur in="SourceAlpha" stdDeviation="6" result="blur"/>
|
||||
<feOffset in="blur" dx="12" dy="10" result="offsetBlur"/>
|
||||
<feMerge>
|
||||
<feMergeNode in="offsetBlur"/>
|
||||
<feMergeNode in="SourceGraphic"/>
|
||||
</feMerge>
|
||||
</filter>
|
||||
</defs>
|
||||
</xsl:variable>
|
||||
<svg width="100%" height="100%" preserveAspectRatio="xMidYMid meet" viewBox="0 0 {$w} {$h}" text-rendering="optimizeLegibility">
|
||||
<xsl:if test="$dotsrc">
|
||||
<haveli:dot>
|
||||
<xsl:value-of select="$dotsrc"/>
|
||||
</haveli:dot>
|
||||
</xsl:if>
|
||||
<xsl:copy-of select="$filters"/>
|
||||
<xsl:choose>
|
||||
<xsl:when test="rotate">
|
||||
<g transform="rotate(90 {$w div 2} {$h div 2} )">
|
||||
<xsl:call-template name="copy-content"/>
|
||||
</g>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:call-template name="copy-content"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</svg>
|
||||
</xsl:template>
|
||||
<xsl:template name="copy-content">
|
||||
<xsl:apply-templates select="@*|processing-instruction()|*|text()"/>
|
||||
</xsl:template>
|
||||
<!--default behaviours for all nodes-->
|
||||
<xsl:template match="processing-instruction()|*|@*|text()">
|
||||
<xsl:copy>
|
||||
<xsl:call-template name="copy-content"/>
|
||||
</xsl:copy>
|
||||
</xsl:template>
|
||||
<!-- apply non text in nodes -->
|
||||
<xsl:template match="svg:g[@class='node']">
|
||||
<g>
|
||||
<g filter="url(#{$filter})">
|
||||
<xsl:apply-templates select="*[local-name()!='text']"/>
|
||||
</g>
|
||||
<g>
|
||||
<xsl:apply-templates select="svg:text"/>
|
||||
</g>
|
||||
</g>
|
||||
</xsl:template>
|
||||
</xsl:stylesheet>
|
||||
71
src/graphxq/dotml/.svn/text-base/filters.svg.svn-base
Normal file
71
src/graphxq/dotml/.svn/text-base/filters.svg.svn-base
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
|
||||
<!--
|
||||
filter defs
|
||||
-->
|
||||
|
||||
<defs xmlns="http://www.w3.org/2000/svg">
|
||||
<filter id="Drop_Shadow" filterUnits="objectBoundingBox" x="-10%" y="-10%" width="150%" height="150%">
|
||||
<feGaussianBlur in="SourceAlpha" stdDeviation="3" result="blurredAlpha"/>
|
||||
<feOffset in="blurredAlpha" dx="3" dy="3" result="offsetBlurredAlpha"/>
|
||||
<feFlood result="flooded" style="flood-color:rgb(0,0,0);flood-opacity:0.65"/>
|
||||
<feComposite in="flooded" operator="in" in2="offsetBlurredAlpha" result="coloredShadow"/>
|
||||
<feComposite in="SourceGraphic" in2="coloredShadow" operator="over"/>
|
||||
</filter>
|
||||
<filter id="Bevel" filterUnits="objectBoundingBox" x="-10%" y="-10%" width="150%" height="150%">
|
||||
<feGaussianBlur in="SourceAlpha" stdDeviation="3" result="blur"/>
|
||||
<feSpecularLighting in="blur" surfaceScale="5" specularConstant="0.5" specularExponent="10" result="specOut" style="lighting-color:rgb(255,255,64)">
|
||||
<fePointLight x="-5000" y="-10000" z="20000"/>
|
||||
</feSpecularLighting>
|
||||
<feComposite in="specOut" in2="SourceAlpha" operator="in" result="specOut2"/>
|
||||
<feComposite in="SourceGraphic" in2="specOut2" operator="arithmetic" k1="0" k2="1" k3="1" k4="0" result="litPaint"/>
|
||||
</filter>
|
||||
<filter id="grey_bevel_shadow" filterUnits="objectBoundingBox" x="-10%" y="-10%" width="150%" height="150%">
|
||||
<feGaussianBlur result="blurredAlpha" in="SourceAlpha" stdDeviation="3"/>
|
||||
<feOffset result="offsetBlurredAlpha" in="blurredAlpha" dx="2" dy="1"/>
|
||||
<feDiffuseLighting result="bumpMapDiffuse" in="blurredAlpha" surfaceScale="5" diffuseConstant="0.5" style="lighting-color:rgb(255,255,255)">
|
||||
<feDistantLight azimuth="135" elevation="60"/>
|
||||
</feDiffuseLighting>
|
||||
<feComposite result="litPaint" in="bumpMapDiffuse" operator="arithmetic" k1="1" k2="0" k3="0" k4="0" in2="SourceGraphic"/>
|
||||
<feSpecularLighting result="bumpMapSpecular" in="blurredAlpha" surfaceScale="5" specularConstant="0.5" specularExponent="10" style="lighting-color:rgb(255,255,255)">
|
||||
<feDistantLight azimuth="135" elevation="60"/>
|
||||
</feSpecularLighting>
|
||||
<feComposite result="litPaint" in="litPaint" operator="arithmetic" k1="0" k2="1" k3="1" k4="0" in2="bumpMapSpecular"/>
|
||||
<feComposite result="litPaint" in="litPaint" operator="in" in2="SourceAlpha"/>
|
||||
<feMerge>
|
||||
<feMergeNode in="offsetBlurredAlpha"/>
|
||||
<feMergeNode in="litPaint"/>
|
||||
</feMerge>
|
||||
</filter>
|
||||
<filter id="Bumpy" filterUnits="objectBoundingBox" x="-10%" y="-10%" width="150%" height="150%">
|
||||
<feTurbulence type="turbulence" baseFrequency="0.15" numOctaves="1" result="image0"/>
|
||||
<feGaussianBlur stdDeviation="3" in="image0" result="image1"/>
|
||||
<feDiffuseLighting in="image1" surfaceScale="10" diffuseConstant="1" result="image3" style="lighting-color:rgb(255,255,255)">
|
||||
<feDistantLight azimuth="0" elevation="45"/>
|
||||
</feDiffuseLighting>
|
||||
<feComposite in="image3" in2="SourceGraphic" operator="arithmetic" k2="0.5" k3="0.5" result="image4"/>
|
||||
<feComposite in="image4" in2="SourceGraphic" operator="in" result="image5"/>
|
||||
</filter>
|
||||
<filter id="MyFilter" filterUnits="objectBoundingBox" x="-10%" y="-10%" width="150%" height="150%">
|
||||
<desc>Produces a 3D lighting effect suitable for pies and lines</desc>
|
||||
<feGaussianBlur in="SourceAlpha" stdDeviation="4" result="blur"/>
|
||||
<feOffset in="blur" dx="3" dy="5" result="offsetBlur"/>
|
||||
<feSpecularLighting in="blur" surfaceScale="5" specularConstant="1" specularExponent="30" style="lighting-color:White" result="specOut">
|
||||
<fePointLight x="-5000" y="-10000" z="20000"/>
|
||||
</feSpecularLighting>
|
||||
<feComposite in="specOut" in2="SourceAlpha" operator="in" result="specOut"/>
|
||||
<feComposite in="SourceGraphic" in2="specOut" operator="arithmetic" k1="0" k2="1" k3="1" k4="0" result="litPaint"/>
|
||||
<feMerge>
|
||||
<feMergeNode in="offsetBlur"/>
|
||||
<feMergeNode in="litPaint"/>
|
||||
</feMerge>
|
||||
</filter>
|
||||
<filter id="MyShadow" filterUnits="objectBoundingBox" x="-20%" y="-20%" width="180%" height="180%">
|
||||
<desc>Simple blurred shadow (ideal for headings)</desc>
|
||||
<feGaussianBlur in="SourceAlpha" stdDeviation="6" result="blur"/>
|
||||
<feOffset in="blur" dx="12" dy="10" result="offsetBlur"/>
|
||||
<feMerge>
|
||||
<feMergeNode in="offsetBlur"/>
|
||||
<feMergeNode in="SourceGraphic"/>
|
||||
</feMerge>
|
||||
</filter>
|
||||
</defs>
|
||||
83
src/graphxq/dotml/dotml2dot.xsl
Normal file
83
src/graphxq/dotml/dotml2dot.xsl
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<!--
|
||||
File dotml2dot.xsl
|
||||
Copyright 2002 - 2006 Martin Loetzsch
|
||||
Translates dotml documents into the native dot syntax.
|
||||
-->
|
||||
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml" xmlns:dotml="http://www.martin-loetzsch.de/DOTML">
|
||||
<xsl:output method="text"/>
|
||||
<xsl:variable xml:space="preserve" name="graph-attributes">bgcolor fontcolor fontname fontsize label margin nodesep rankdir ranksep ratio size</xsl:variable>
|
||||
<xsl:variable xml:space="preserve" name="cluster-attributes">bgcolor color fillcolor fontcolor fontname fontsize label labeljust labelloc style</xsl:variable>
|
||||
<xsl:variable xml:space="preserve" name="node-attributes">color fillcolor fixedsize fontcolor fontname fontsize height shape style URL width</xsl:variable>
|
||||
<xsl:variable xml:space="preserve" name="record-attributes">color fillcolor fontcolor fontname fontsize height style URL width</xsl:variable>
|
||||
<xsl:variable xml:space="preserve" name="edge-attributes">arrowhead arrowsize arrowtail constraint color decorate dir fontcolor fontname fontsize headlabel headport label labeldistance labelfloat labelfontcolor labelfontname labelfontsize minlen samehead sametail style taillabel tailport URL</xsl:variable>
|
||||
<xsl:key name="nodes" match="//dotml:node" use="concat(@id,ancestor::dotml:graph/@file-name)"/>
|
||||
<xsl:template match="*" priority="-1000">
|
||||
<xsl:apply-templates/>
|
||||
</xsl:template>
|
||||
<xsl:template match="text()"/>
|
||||
<xsl:template match="dotml:graph">digraph g {compound="true";<xsl:call-template name="copy-attributes">
|
||||
<xsl:with-param name="separator" select="';'"/>
|
||||
<xsl:with-param name="attributes" select="$graph-attributes"/>
|
||||
</xsl:call-template>
|
||||
<xsl:apply-templates/>}
|
||||
<dot-filename><xsl:value-of select="@file-name"/></dot-filename>
|
||||
</xsl:template>
|
||||
<xsl:template match="dotml:sub-graph">subgraph sub_graph_<xsl:value-of select="count(preceding::dotml:sub-graph)"/>{rank="<xsl:value-of select="@rank"/>";<xsl:apply-templates/>}</xsl:template>
|
||||
<xsl:template match="dotml:cluster">subgraph cluster_<xsl:value-of select="@id"/>{<xsl:call-template name="copy-attributes">
|
||||
<xsl:with-param name="separator" select="';'"/>
|
||||
<xsl:with-param name="attributes" select="$cluster-attributes"/>
|
||||
</xsl:call-template>
|
||||
<xsl:apply-templates/>}</xsl:template>
|
||||
<xsl:template match="dotml:node">node[label="<xsl:choose>
|
||||
<xsl:when test="@label">
|
||||
<xsl:value-of select="@label"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="@id"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>", <xsl:call-template name="copy-attributes">
|
||||
<xsl:with-param name="separator" select="','"/>
|
||||
<xsl:with-param name="attributes" select="$node-attributes"/>
|
||||
</xsl:call-template>] {<xsl:value-of select="@id"/>};</xsl:template>
|
||||
<xsl:template match="dotml:edge">edge[<xsl:call-template name="copy-attributes">
|
||||
<xsl:with-param name="separator" select="','"/>
|
||||
<xsl:with-param name="attributes" select="$edge-attributes"/>
|
||||
</xsl:call-template>lhead="<xsl:if test="@lhead">cluster_<xsl:value-of select="@lhead"/>
|
||||
</xsl:if>",ltail="<xsl:if test="@ltail">cluster_<xsl:value-of select="@ltail"/>
|
||||
</xsl:if>"] <xsl:if test="key('nodes',concat(@from,ancestor::dotml:graph/@file-name))/ancestor::dotml:record">struct<xsl:value-of select="count(key('nodes',concat(@from,ancestor::dotml:graph/@file-name))/preceding::dotml:record[local-name(..)!='record'])"/>:</xsl:if>
|
||||
<xsl:value-of select="@from"/> -> <xsl:if test="key('nodes',concat(@to,ancestor::dotml:graph/@file-name))/ancestor::dotml:record">struct<xsl:value-of select="count(key('nodes',concat(@to,ancestor::dotml:graph/@file-name))/preceding::dotml:record[local-name(..)!='record'])"/>:</xsl:if>
|
||||
<xsl:value-of select="@to"/>;</xsl:template>
|
||||
<xsl:template match="dotml:record">node[shape="record",label="<xsl:apply-templates select="dotml:*" mode="record-label"/>",<xsl:call-template name="copy-attributes">
|
||||
<xsl:with-param name="separator" select="','"/>
|
||||
<xsl:with-param name="attributes" select="$record-attributes"/>
|
||||
</xsl:call-template>]{struct<xsl:value-of select="count(preceding::dotml:record[local-name(..)!='record'])"/>};</xsl:template>
|
||||
<xsl:template match="dotml:record" mode="record-label">{<xsl:apply-templates select="dotml:*" mode="record-label"/>}<xsl:if test="position()!=last()"> | </xsl:if>
|
||||
</xsl:template>
|
||||
<xsl:template match="dotml:node" mode="record-label"><<xsl:value-of select="@id"/>> <xsl:choose>
|
||||
<xsl:when test="@label">
|
||||
<xsl:value-of select="@label"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="@id"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
<xsl:if test="position()!=last()"> | </xsl:if>
|
||||
</xsl:template>
|
||||
<xsl:template name="copy-attributes">
|
||||
<xsl:param name="attributes"/>
|
||||
<xsl:param name="separator"/>
|
||||
<xsl:choose>
|
||||
<xsl:when test="string-length(substring-after($attributes,' '))=0">
|
||||
<xsl:value-of select="$attributes"/>="<xsl:value-of select="@*[local-name()=$attributes]"/>"<xsl:value-of select="$separator"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="substring-before($attributes,' ')"/>="<xsl:value-of select="@*[local-name()=substring-before($attributes,' ')]"/>"<xsl:value-of select="$separator"/>
|
||||
<xsl:call-template name="copy-attributes">
|
||||
<xsl:with-param name="attributes" select="substring-after($attributes,' ')"/>
|
||||
<xsl:with-param name="separator" select="$separator"/>
|
||||
</xsl:call-template>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
</xsl:stylesheet>
|
||||
121
src/graphxq/dotml/dotpatch.xsl
Normal file
121
src/graphxq/dotml/dotpatch.xsl
Normal file
|
|
@ -0,0 +1,121 @@
|
|||
<?xml version="1.0"?>
|
||||
<!--
|
||||
tidy up graphviz svg o/p
|
||||
-->
|
||||
<xsl:stylesheet version="1.0" xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink" >
|
||||
<xsl:param name="filter">MyFilter</xsl:param>
|
||||
<xsl:param name="rotate" select="false()"/>
|
||||
<xsl:output method="xml" encoding="UTF-8" indent="yes" omit-xml-declaration="yes"/>
|
||||
<xsl:template match="/svg:svg">
|
||||
<xsl:variable name="w" select="substring-before(@width,'pt')"/>
|
||||
<xsl:variable name="aa" select="string(@width)"/>
|
||||
<xsl:variable name="h" select="substring-before(@height,'pt')"/>
|
||||
<xsl:variable name="filters">
|
||||
<defs xmlns="http://www.w3.org/2000/svg">
|
||||
<filter id="Drop_Shadow" filterUnits="objectBoundingBox" x="-10%" y="-10%" width="150%" height="150%">
|
||||
<feGaussianBlur in="SourceAlpha" stdDeviation="3" result="blurredAlpha"/>
|
||||
<feOffset in="blurredAlpha" dx="3" dy="3" result="offsetBlurredAlpha"/>
|
||||
<feFlood result="flooded" style="flood-color:rgb(0,0,0);flood-opacity:0.65"/>
|
||||
<feComposite in="flooded" operator="in" in2="offsetBlurredAlpha" result="coloredShadow"/>
|
||||
<feComposite in="SourceGraphic" in2="coloredShadow" operator="over"/>
|
||||
</filter>
|
||||
<filter id="Bevel" filterUnits="objectBoundingBox" x="-10%" y="-10%" width="150%" height="150%">
|
||||
<feGaussianBlur in="SourceAlpha" stdDeviation="3" result="blur"/>
|
||||
<feSpecularLighting in="blur" surfaceScale="5" specularConstant="0.5" specularExponent="10" result="specOut" style="lighting-color:rgb(255,255,64)">
|
||||
<fePointLight x="-5000" y="-10000" z="20000"/>
|
||||
</feSpecularLighting>
|
||||
<feComposite in="specOut" in2="SourceAlpha" operator="in" result="specOut2"/>
|
||||
<feComposite in="SourceGraphic" in2="specOut2" operator="arithmetic" k1="0" k2="1" k3="1" k4="0" result="litPaint"/>
|
||||
</filter>
|
||||
<filter id="grey_bevel_shadow" filterUnits="objectBoundingBox" x="-10%" y="-10%" width="150%" height="150%">
|
||||
<feGaussianBlur result="blurredAlpha" in="SourceAlpha" stdDeviation="3"/>
|
||||
<feOffset result="offsetBlurredAlpha" in="blurredAlpha" dx="2" dy="1"/>
|
||||
<feDiffuseLighting result="bumpMapDiffuse" in="blurredAlpha" surfaceScale="5" diffuseConstant="0.5" style="lighting-color:rgb(255,255,255)">
|
||||
<feDistantLight azimuth="135" elevation="60"/>
|
||||
</feDiffuseLighting>
|
||||
<feComposite result="litPaint" in="bumpMapDiffuse" operator="arithmetic" k1="1" k2="0" k3="0" k4="0" in2="SourceGraphic"/>
|
||||
<feSpecularLighting result="bumpMapSpecular" in="blurredAlpha" surfaceScale="5" specularConstant="0.5" specularExponent="10" style="lighting-color:rgb(255,255,255)">
|
||||
<feDistantLight azimuth="135" elevation="60"/>
|
||||
</feSpecularLighting>
|
||||
<feComposite result="litPaint" in="litPaint" operator="arithmetic" k1="0" k2="1" k3="1" k4="0" in2="bumpMapSpecular"/>
|
||||
<feComposite result="litPaint" in="litPaint" operator="in" in2="SourceAlpha"/>
|
||||
<feMerge>
|
||||
<feMergeNode in="offsetBlurredAlpha"/>
|
||||
<feMergeNode in="litPaint"/>
|
||||
</feMerge>
|
||||
</filter>
|
||||
<filter id="Bumpy" filterUnits="objectBoundingBox" x="-10%" y="-10%" width="150%" height="150%">
|
||||
<feTurbulence type="turbulence" baseFrequency="0.15" numOctaves="1" result="image0"/>
|
||||
<feGaussianBlur stdDeviation="3" in="image0" result="image1"/>
|
||||
<feDiffuseLighting in="image1" surfaceScale="10" diffuseConstant="1" result="image3" style="lighting-color:rgb(255,255,255)">
|
||||
<feDistantLight azimuth="0" elevation="45"/>
|
||||
</feDiffuseLighting>
|
||||
<feComposite in="image3" in2="SourceGraphic" operator="arithmetic" k2="0.5" k3="0.5" result="image4"/>
|
||||
<feComposite in="image4" in2="SourceGraphic" operator="in" result="image5"/>
|
||||
</filter>
|
||||
<filter id="MyFilter" filterUnits="objectBoundingBox" x="-10%" y="-10%" width="150%" height="150%">
|
||||
<desc>Produces a 3D lighting effect suitable for pies and lines</desc>
|
||||
<feGaussianBlur in="SourceAlpha" stdDeviation="4" result="blur"/>
|
||||
<feOffset in="blur" dx="3" dy="5" result="offsetBlur"/>
|
||||
<feSpecularLighting in="blur" surfaceScale="5" specularConstant="1" specularExponent="30" style="lighting-color:White" result="specOut">
|
||||
<fePointLight x="-5000" y="-10000" z="20000"/>
|
||||
</feSpecularLighting>
|
||||
<feComposite in="specOut" in2="SourceAlpha" operator="in" result="specOut"/>
|
||||
<feComposite in="SourceGraphic" in2="specOut" operator="arithmetic" k1="0" k2="1" k3="1" k4="0" result="litPaint"/>
|
||||
<feMerge>
|
||||
<feMergeNode in="offsetBlur"/>
|
||||
<feMergeNode in="litPaint"/>
|
||||
</feMerge>
|
||||
</filter>
|
||||
<filter id="MyShadow" filterUnits="objectBoundingBox" x="-20%" y="-20%" width="180%" height="180%">
|
||||
<desc>Simple blurred shadow (ideal for headings)</desc>
|
||||
<feGaussianBlur in="SourceAlpha" stdDeviation="6" result="blur"/>
|
||||
<feOffset in="blur" dx="12" dy="10" result="offsetBlur"/>
|
||||
<feMerge>
|
||||
<feMergeNode in="offsetBlur"/>
|
||||
<feMergeNode in="SourceGraphic"/>
|
||||
</feMerge>
|
||||
</filter>
|
||||
</defs>
|
||||
</xsl:variable>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%" aa="{$aa}"
|
||||
preserveAspectRatio="xMidYMid meet" viewBox="0 0 {$w} {$h}" text-rendering="optimizeLegibility">
|
||||
|
||||
<xsl:copy-of select="$filters"/>
|
||||
|
||||
<xsl:choose>
|
||||
<xsl:when test="rotate">
|
||||
<g transform="rotate(90 {$w div 2} {$h div 2} )">
|
||||
<xsl:call-template name="copy-content"/>
|
||||
</g>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:apply-templates select="*"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</svg>
|
||||
</xsl:template>
|
||||
<xsl:template name="copy-content">
|
||||
<xsl:apply-templates select="@*|processing-instruction()|*|text()"/>
|
||||
</xsl:template>
|
||||
<!--default behaviours for all nodes-->
|
||||
<xsl:template match="processing-instruction()|*|@*|text()">
|
||||
<xsl:copy>
|
||||
<xsl:call-template name="copy-content"/>
|
||||
</xsl:copy>
|
||||
</xsl:template>
|
||||
<!-- apply non text in nodes -->
|
||||
<xsl:template match="svg:g[@class='node']">
|
||||
<g>
|
||||
<g filter="url(#{$filter})">
|
||||
<xsl:apply-templates select="*[local-name()!='text']"/>
|
||||
</g>
|
||||
<g>
|
||||
<xsl:apply-templates select="svg:text"/>
|
||||
</g>
|
||||
</g>
|
||||
</xsl:template>
|
||||
</xsl:stylesheet>
|
||||
71
src/graphxq/dotml/filters.svg
Normal file
71
src/graphxq/dotml/filters.svg
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
|
||||
<!--
|
||||
filter defs
|
||||
-->
|
||||
|
||||
<defs xmlns="http://www.w3.org/2000/svg">
|
||||
<filter id="Drop_Shadow" filterUnits="objectBoundingBox" x="-10%" y="-10%" width="150%" height="150%">
|
||||
<feGaussianBlur in="SourceAlpha" stdDeviation="3" result="blurredAlpha"/>
|
||||
<feOffset in="blurredAlpha" dx="3" dy="3" result="offsetBlurredAlpha"/>
|
||||
<feFlood result="flooded" style="flood-color:rgb(0,0,0);flood-opacity:0.65"/>
|
||||
<feComposite in="flooded" operator="in" in2="offsetBlurredAlpha" result="coloredShadow"/>
|
||||
<feComposite in="SourceGraphic" in2="coloredShadow" operator="over"/>
|
||||
</filter>
|
||||
<filter id="Bevel" filterUnits="objectBoundingBox" x="-10%" y="-10%" width="150%" height="150%">
|
||||
<feGaussianBlur in="SourceAlpha" stdDeviation="3" result="blur"/>
|
||||
<feSpecularLighting in="blur" surfaceScale="5" specularConstant="0.5" specularExponent="10" result="specOut" style="lighting-color:rgb(255,255,64)">
|
||||
<fePointLight x="-5000" y="-10000" z="20000"/>
|
||||
</feSpecularLighting>
|
||||
<feComposite in="specOut" in2="SourceAlpha" operator="in" result="specOut2"/>
|
||||
<feComposite in="SourceGraphic" in2="specOut2" operator="arithmetic" k1="0" k2="1" k3="1" k4="0" result="litPaint"/>
|
||||
</filter>
|
||||
<filter id="grey_bevel_shadow" filterUnits="objectBoundingBox" x="-10%" y="-10%" width="150%" height="150%">
|
||||
<feGaussianBlur result="blurredAlpha" in="SourceAlpha" stdDeviation="3"/>
|
||||
<feOffset result="offsetBlurredAlpha" in="blurredAlpha" dx="2" dy="1"/>
|
||||
<feDiffuseLighting result="bumpMapDiffuse" in="blurredAlpha" surfaceScale="5" diffuseConstant="0.5" style="lighting-color:rgb(255,255,255)">
|
||||
<feDistantLight azimuth="135" elevation="60"/>
|
||||
</feDiffuseLighting>
|
||||
<feComposite result="litPaint" in="bumpMapDiffuse" operator="arithmetic" k1="1" k2="0" k3="0" k4="0" in2="SourceGraphic"/>
|
||||
<feSpecularLighting result="bumpMapSpecular" in="blurredAlpha" surfaceScale="5" specularConstant="0.5" specularExponent="10" style="lighting-color:rgb(255,255,255)">
|
||||
<feDistantLight azimuth="135" elevation="60"/>
|
||||
</feSpecularLighting>
|
||||
<feComposite result="litPaint" in="litPaint" operator="arithmetic" k1="0" k2="1" k3="1" k4="0" in2="bumpMapSpecular"/>
|
||||
<feComposite result="litPaint" in="litPaint" operator="in" in2="SourceAlpha"/>
|
||||
<feMerge>
|
||||
<feMergeNode in="offsetBlurredAlpha"/>
|
||||
<feMergeNode in="litPaint"/>
|
||||
</feMerge>
|
||||
</filter>
|
||||
<filter id="Bumpy" filterUnits="objectBoundingBox" x="-10%" y="-10%" width="150%" height="150%">
|
||||
<feTurbulence type="turbulence" baseFrequency="0.15" numOctaves="1" result="image0"/>
|
||||
<feGaussianBlur stdDeviation="3" in="image0" result="image1"/>
|
||||
<feDiffuseLighting in="image1" surfaceScale="10" diffuseConstant="1" result="image3" style="lighting-color:rgb(255,255,255)">
|
||||
<feDistantLight azimuth="0" elevation="45"/>
|
||||
</feDiffuseLighting>
|
||||
<feComposite in="image3" in2="SourceGraphic" operator="arithmetic" k2="0.5" k3="0.5" result="image4"/>
|
||||
<feComposite in="image4" in2="SourceGraphic" operator="in" result="image5"/>
|
||||
</filter>
|
||||
<filter id="MyFilter" filterUnits="objectBoundingBox" x="-10%" y="-10%" width="150%" height="150%">
|
||||
<desc>Produces a 3D lighting effect suitable for pies and lines</desc>
|
||||
<feGaussianBlur in="SourceAlpha" stdDeviation="4" result="blur"/>
|
||||
<feOffset in="blur" dx="3" dy="5" result="offsetBlur"/>
|
||||
<feSpecularLighting in="blur" surfaceScale="5" specularConstant="1" specularExponent="30" style="lighting-color:White" result="specOut">
|
||||
<fePointLight x="-5000" y="-10000" z="20000"/>
|
||||
</feSpecularLighting>
|
||||
<feComposite in="specOut" in2="SourceAlpha" operator="in" result="specOut"/>
|
||||
<feComposite in="SourceGraphic" in2="specOut" operator="arithmetic" k1="0" k2="1" k3="1" k4="0" result="litPaint"/>
|
||||
<feMerge>
|
||||
<feMergeNode in="offsetBlur"/>
|
||||
<feMergeNode in="litPaint"/>
|
||||
</feMerge>
|
||||
</filter>
|
||||
<filter id="MyShadow" filterUnits="objectBoundingBox" x="-20%" y="-20%" width="180%" height="180%">
|
||||
<desc>Simple blurred shadow (ideal for headings)</desc>
|
||||
<feGaussianBlur in="SourceAlpha" stdDeviation="6" result="blur"/>
|
||||
<feOffset in="blur" dx="12" dy="10" result="offsetBlur"/>
|
||||
<feMerge>
|
||||
<feMergeNode in="offsetBlur"/>
|
||||
<feMergeNode in="SourceGraphic"/>
|
||||
</feMerge>
|
||||
</filter>
|
||||
</defs>
|
||||
67
src/graphxq/graphviz.xqm
Normal file
67
src/graphxq/graphviz.xqm
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
(:~
|
||||
: graphviz module
|
||||
: based on http://www.zorba-xquery.com/html/modules/zorba/image/graphviz
|
||||
:)
|
||||
|
||||
module namespace gr="apb.graphviz";
|
||||
declare default function namespace 'apb.graphviz';
|
||||
import module namespace proc="http://basex.org/modules/proc";
|
||||
import module namespace file="http://expath.org/ns/file";
|
||||
import module namespace xslt="http://basex.org/modules/xslt";
|
||||
|
||||
declare namespace svg= "http://www.w3.org/2000/svg";
|
||||
declare namespace xlink="http://www.w3.org/1999/xlink";
|
||||
|
||||
declare %private variable $gr:dotpath:=if(fn:environment-variable("DOTPATH"))
|
||||
then fn:environment-variable("DOTPATH")
|
||||
else "dot";
|
||||
(:~
|
||||
: folder for temp files
|
||||
:)
|
||||
declare %private variable $gr:tmpdir:=if(fn:environment-variable("TEMP"))
|
||||
then fn:environment-variable("TEMP")
|
||||
else "/tmp";
|
||||
|
||||
declare %private variable $gr:empty:=
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 300 20" version="1.1"
|
||||
width="100%" height="100%" preserveAspectRatio="xMidYMid meet">
|
||||
<text x="150" y="10" text-anchor="middle">Empty.</text>
|
||||
</svg>;
|
||||
|
||||
(:~
|
||||
:Layout one or more graphs given in the DOT language and render them as SVG.
|
||||
:)
|
||||
declare function dot( $dot as xs:string*, $params as xs:string*) as node()*{
|
||||
for $d in $dot
|
||||
return if($d)
|
||||
then dot1($d)
|
||||
else $gr:empty
|
||||
};
|
||||
|
||||
declare %private function dot1( $dot as xs:string) as node(){
|
||||
let $fname:=$gr:tmpdir || file:dir-separator() || random:uuid()
|
||||
let $junk:=file:write-text($fname,$dot)
|
||||
let $r:=proc:execute($gr:dotpath , ("-Tsvg",$fname))
|
||||
let $junk:=file:delete($fname)
|
||||
|
||||
return if($r/code="0")
|
||||
then fn:parse-xml($r/output)
|
||||
else fn:error()
|
||||
};
|
||||
(:~
|
||||
:Layout one ore more graphs given in the GXL language and render them as SVG.
|
||||
: gxl2dot Test.gxl > Test.dot
|
||||
:)
|
||||
declare function gxl($gxl as node()*, $params as xs:string*) as node()*{
|
||||
for $g in $gxl
|
||||
(: @TODO :)
|
||||
return fn:error()
|
||||
};
|
||||
|
||||
(:~
|
||||
: set svg to autosize 100%
|
||||
:)
|
||||
declare function autosize($svg as node()) as node(){
|
||||
xslt:transform($svg , fn:resolve-uri("dotml/dotpatch.xsl"))
|
||||
};
|
||||
|
||||
16
src/graphxq/samples/hier.dot
Normal file
16
src/graphxq/samples/hier.dot
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
digraph hierarchy_of_D {
|
||||
|
||||
node [color=Green,fontcolor=Blue,font=Courier]
|
||||
|
||||
B -> D
|
||||
C -> D
|
||||
|
||||
{rank=same; B C }
|
||||
|
||||
A -> B
|
||||
|
||||
A -> C
|
||||
|
||||
object -> A
|
||||
|
||||
}
|
||||
27
src/graphxq/samples/process.dot
Normal file
27
src/graphxq/samples/process.dot
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
digraph process {
|
||||
|
||||
subgraph cluster_0 {
|
||||
style=filled;
|
||||
color=lightgrey;
|
||||
node [style=filled,color=white];
|
||||
a0 -> a1 -> a2 -> a3;
|
||||
label = "process #1";
|
||||
}
|
||||
|
||||
subgraph cluster_1 {
|
||||
node [style=filled];
|
||||
b0 -> b1 -> b2 -> b3;
|
||||
label = "process #2";
|
||||
color=blue
|
||||
}
|
||||
start -> a0;
|
||||
start -> b0;
|
||||
a1 -> b3;
|
||||
b2 -> a3;
|
||||
a3 -> a0;
|
||||
a3 -> end;
|
||||
b3 -> end;
|
||||
|
||||
start [shape=Mdiamond];
|
||||
end [shape=Msquare];
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue