上下文
我正在尝试将DGML图转换为SVG。我正在使用Javascript来使用Jquery读取和解析DGML 节点和链接。我使用Visual Studio 2017创建了一个DGML图(它有一个交互式内置编辑器)。基本上我需要在DGML图上的节点位置和生成的SVG之间创建映射。我设法对节点和链接的每个属性进行转换,但名为 Bounds
的属性除外<?xml version="1.0" encoding="utf-8"?>
<DirectedGraph xmlns="http://schemas.microsoft.com/vs/2009/dgml">
<Nodes>
<Node Id="Node1" Background="#FF000000" Bounds="289.142857142857,-914.285714285714,56.9200000000001,25.96" Label="node 1" UseManualLocation="True" />
<Node Id="Node2" Bounds="-99.1466388157435,-813.468571428572,56.9200000000001,25.96" Label="node 2" UseManualLocation="True" />
<Node Id="Node3" Bounds="165.353095238095,-821.948571428572,56.9200000000001,25.96" Label="node 3" UseManualLocation="True" />
<Node Id="Node4" Bounds="231.884895804269,-672.637129778181,56.92,25.96" Label="node 4" UseManualLocation="True" />
<Node Id="Node5" Bounds="126.293653230212,-514.368957318116,56.9200000000001,25.96" Label="node 5" UseManualLocation="True" />
<Node Id="Node6" Bounds="513.21231765747,-699.551714460973,56.9200000000001,25.96" Label="node 6" UseManualLocation="True" />
</Nodes>
<Links>
<Link Source="Node1" Target="Node2" Bounds="-33.5154810441621,-893.916239433358,322.658338187019,83.7763765262094" />
<Link Source="Node1" Target="Node3" Bounds="218.428553771979,-888.325714285714,81.7729515442388,60.9960031621974" />
<Link Source="Node2" Target="Node4" Bounds="-42.8686314368827,-788.653915128306,267.113829712029,113.638782142621" />
<Link Source="Node2" Target="Node5" Bounds="-60.9032254171191,-787.508586425781,200.456326731834,265.952512098603" />
<Link Source="Node3" Target="Node4" Bounds="199.596870550233,-795.988597412109,51.3011424145167,115.130629087374" />
<Link Source="Node4" Target="Node5" Bounds="168.40836594804,-646.677165527344,83.2767077301747,124.821483021298" />
<Link Source="Node4" Target="Node6" Bounds="288.80489440918,-682.991837277453,215.448314485295,20.6119078319973" />
<Link Source="Node6" Target="Node1" Bounds="337.645038336076,-882.098554229514,190.482965266866,182.54683792092" />
</Links>
<Properties>
<Property Id="Background" Label="Background" Description="The background color" DataType="System.Windows.Media.Brush" />
<Property Id="Bounds" DataType="System.Windows.Rect" />
<Property Id="Label" Label="Label" Description="Displayable label of an Annotatable object" DataType="System.String" />
<Property Id="UseManualLocation" DataType="System.Boolean" />
</Properties>
</DirectedGraph>
我在属性标签中看到&#34; Bounds&#34;数据类型为System.Windows.Rect
,其中包含构造函数Rect(Double, Double, Double, Double)
- 初始化具有指定x坐标,y坐标,宽度和高度的Rect结构的新实例。
https://msdn.microsoft.com/en-us/library/system.windows.rect(v=vs.110).aspx
由于所有节点都具有相同的大小,因此假设最后两个参数是宽度和高度并没有错。
问题
DGML的图形坐标系如何定位?例如,SVG图形像大多数CG坐标一样开始,左上角起源;正X朝向右,正Y朝向底部。我在DGML参考
上找不到任何相关信息https://docs.microsoft.com/en-us/visualstudio/modeling/directed-graph-markup-language-dgml-reference
答案 0 :(得分:0)
查看图表我认为Y轴是倒置的(自上而下),X轴是经典的(左右)。坐标开始位于图2底部后面的Node2和Node5之间。
答案 1 :(得分:0)
我的DgmlPowerTools在“共享”工具栏项下提供了“另存为SVG”选项。