RCC(8) 规范或类似规范的维恩图生成软件
请注意:虽然赏金不再可用,但我仍然热衷于任何能够回答此问题的人做出贡献;我还在关注,等着看有没有更好的答案。谢谢,请继续阅读...
我正在寻找一种方法来转换任意一组 RCC
W {EC} Y
、X {TPP} Y
、Z {NTPP} Y
、 Z {PO} X
。
..可以用下图表示,具有圆形或方形区域:
..或者:
有谁知道至少可以以编程方式生成此类图(通过 API)的软件)来自类似 RCC 的约束规范?
我知道这样的约束网络可能未指定,从而排除了与任何单个此类图的匹配(可能存在许多解决方案)。理想情况下,我希望通过能够生成可能的替代方案来解决这个问题,但目前无法采取任何替代方案(并引发错误)。
需要明确的是,在这个问题中,我特别要求能够以声明方式基于类似 RCC 的约束来计算图表布局的软件。我不关心将 RCC 的 DSL 转换为其他语法的工具,也不对特定的图像序列化格式或方法感兴趣。我希望找到一种算法来执行此操作,以处理最多六个唯一集的任意数量的约束。
注释: Graphviz(如下面提到的 @vickirk )是图表布局软件包的一个示例,它类似于我所追求的。不幸的是,似乎 Graphviz 本身无法帮助解决这个问题(但我很高兴被证明是错误的!)。看来这是一个非常难的问题。
Please note: While the bounty is no longer available, I'm still keen for anyone with an answer to this question to contribute; I'm still watching it, and I'm waiting to see if there is a better answer. Thanks, and please read on...
I am looking for a way to convert an arbitrary set of RCC-like spatial relations (or similar) describing a constraint network into Venn-diagram-like images. For example, the constraint network as expressed in RCC8:
W {EC} Y
, X {TPP} Y
, Z {NTPP} Y
, Z {PO} X
.
..could be represented by the following diagram with circular or square regions:
..alternatively:
Is anyone aware of software that can at least generate such diagrams programmatically (via an API) from a specification of RCC-like constraints?
I am aware that such a constraint network could be underspecified, precluding a match to any single such diagram (many solutions may exist). Ideally, I would like to deal with this by being able to generate possible alternatives, but can resort to none (and raising an error) for now.
Just to be clear, in this question I am specifically asking for software which can calculate a diagram layout based on RCC-like constraints in a declarative manner. I am not concerned with tools to turn a DSL for RCC into some other syntax, nor am I interested in particular image serialization formats or methods. I am hoping to find an algorithm to do this for dealing with an arbitrary number of constraints for up to six unique sets.
Notes: Graphviz (as @vickirk mentioned below) is an example of a diagram layout software package, which is akin to what I'm after. Unfortunately, it seems that Graphviz itself cannot help with this problem (but I'd be very happy to be proven wrong!). It seems this is a very hard problem.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
谁需要后端?这是一个使用 HTML/CSS/JS 的工作原型:
http://jsfiddle.net/ RuvE6/6/
只需在字段中输入 RCC8 代码语法并点击按钮即可!
当前的一些限制:
编辑:它是如何工作的
基本上,有两个系列这些图表显示的关系:
然后还有子类型或变体,例如:
这两个基本概念都有点 融入 HTML 渲染世界:
我使用特殊类处理变体(相当粗略地)摆动边距以完成所需的布局:
(子级具有负上边距以接触父级)
(添加了一个包装器以触发 CSS子元素 - 第二个元素的左边距为负,与第一个元素重叠。)
jsfiddle 中注释掉了一些静态标记,显示了我开始使用的结构。
为了完成功能循环,有一些代码将 RCC8 语句解析为 A {XX} B 部分,并尝试为每个部分呈现必要的标记。它会在进入不重复区域时进行检查。之后我还会检查并将所有兄弟姐妹的高度设置为相同,这确保它们能够正确重叠和/或邻接。
这段代码实际上只是一个开始,它有自己的想法。它基本上是一个线性图,这意味着它不能处理存在复杂邻接的情况,例如:
A {EC} B, C {EC} B, D {EC} B
这些可能会通过智能 JS 解析和更复杂的 CSS 来处理,但可能很快就会进入更强制导向的布局领域(更智能 气泡图)。
Who need's a backend? Here's a working prototype using HTML/CSS/JS:
http://jsfiddle.net/RuvE6/6/
Just enter the RCC8 code syntax in the field and hit the button!
Some current limitations:
Edit: How it works
Basically, there are two families of relationships shown with these diagrams:
There are then sub-types or variations, like:
Both of the basic concepts are kind of baked into the HTML rendering world:
<div class="region"><div class="region"></div></div>
<div class="region"></div><div class="region"></div>
I handle the variations with special classes that (rather crudely) wiggle margins around to accomplish the desired layout:
<div class="region"><div class="region touches-parent"></div></div>
(child has negative top margin to touch parent)<div class="ven"><div class="region"></div><div class="region touches-parent"></div></div>
(a wrapper is added to trigger CSS on the children - the second element has negative left margin to overlap the first.)There is some static markup commented out in the jsfiddle showing the structure I started with.
To complete the functional loop, there is a bit of code that parses the RCC8 statement into A {XX} B parts, and attempts to render the necessary markup for each part. It checks as it goes to not duplicate regions. I also go through afterwards and set the heights of all sibling the same, which ensures they will overlap and/or abut properly.
This code is really just a start, and it has it's conceits. It's basically a linear diagram, which means it doesn't, for instance, handle cases where there are complicated adjacencies, like this:
A {EC} B, C {EC} B, D {EC} B
These might be handled be smarted JS parsing and more complicated CSS, but probably quickly venture into the realm of more force-directed layouts (a smarter bubble chart, for instance).
我不知道有什么软件可以生成这样的图表。但是,如果我必须解决您的问题,我可能会探索使用 可缩放矢量图形 (SVG)< 的可能性/a>.我认为您可以将 RCC 的 DSL 转换为 SVG XML,然后可以渲染它(也许在 Web 浏览器中)。您可以通过搜索“svg venn 图”轻松地在网络上找到示例。一个不错的例子是这里:这是我从中生成的一个图表网站
这是相应的 SVG 代码(也来自该网站):
还有一个用于 SVG 的 Apache 工具包,名为Batik,它应该支持 SVG 的显示、生成或操作。
另一种选择是使用 TikZ & PGF 与 LaTeX:这里有强大的宏,可以让您以编程方式放置形状,并且渲染由 LaTeX 完成。这是一个示例:
它产生以下内容(即 RCC8 TPP 关系):
您可以从 LaTeX 中看到代码中,您可以在 X 的西南方向绘制 Y 圆 (
X.south west
),表示 Y 的锚点也在西南方向 (anchor=south west
)。您可以在此处找到更复杂的示例,以及一些其他讨论此处。虽然这还不是为您绘制 RCC8 关系的布局算法,但我认为您可以定义 LaTeX 宏,将 RCC8 关系转换为 PGF/TikZ 宏。缺点是您必须随后编译 LaTeX 代码。
我希望这有帮助,祝你好运!
I don't know of any software that can generate such diagrams. However, If I had to tackle your problem I would probably explore the possibility of using Scalable Vector Graphics (SVG). I think you can translate your DSL for RCC into SVG XML, and then you can render it (maybe in a Web browser). You can easily find examples on the Web by searching for "svg venn diagram". A nice one is here: here's a diagram that I generate from that website
and here's the corresponding SVG code (also from the website):
There's also an Apache toolkit for SVG called Batik, which should support display, generation or manipulation of SVGs.
Another option is to use TikZ & PGF with LaTeX: there you have powerful macros that let you programmatically place shapes, and the rendering is done by LaTeX. Here's an example:
which produces the following (i.e. the RCC8 TPP relation):
You can see from the LaTeX code that you can draw the Y circle at south west of X (
X.south west
) saying that Y's anchor is also at south west (anchor=south west
). You can find a more complex example here, and some additional discussion here.Although this is not yet a layout algorithm that draws RCC8 relation for you, I think you can define LaTeX macro that translate RCC8 relations into PGF/TikZ macros. The drawback is that you must then compile the LaTeX code.
I hope this helps and good luck!
你评估过antlr吗?你可以为RCC8定义一个EBNF语法。使用antlr生成项目列表。此项目列表可用作软件的输入,例如 VennMaster 用于绘制图表。
其他选项包括 Goolge Charts 、
http://bioinfogp.cnb.csic.es/tools /venny/index.html
Have you evaluated antlr, You could define an EBNF grammar for RCC8. Use antlr to generate an item list. This item list can be used as an input to software like VennMaster for drawing diagrams.
Other options are Goolge Charts ,
http://bioinfogp.cnb.csic.es/tools/venny/index.html