用于转储 yEd 图表的最简单格式

发布于 2024-11-12 06:25:59 字数 159 浏览 3 评论 0原文

我目前正在尝试在 java 中转储 yEd 的图表。我一直在尝试使用graphml作为格式,但我发现它非常麻烦。特别是,节点的大小不会根据标签的大小进行调整,因此大多数时候标签会比实际文件大。

我可以做些什么来解决这个问题,而无需实际进入并指定每个节点的宽度和高度?

谢谢

I'm currently trying to dump a graph within java for yEd. I've been trying to use graphml for the format, but I've found it to be very cumbersome. Particularly, the size of the nodes will not resize for the size of the label, so most of the time the label will be bigger than the actual file.

Is there anything I can do to remedy this without actually going in and specifying each node's width and height?

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

情深缘浅 2024-11-19 06:25:59

有一种方法,尽管这种方法使用非官方 API,并且可能不适用于除当前版本(截至撰写时为 3.9.2)之外的任何版本。

在 GraphML 中,在图形级别添加以下键:

  <g:key id="ppkey" for="graph" yfiles.type="postprocessors"/>
  <g:graph id="G" edgedefault="directed">
    <g:data key="ppkey">
      <y:Postprocessors>
        <y:Processor class="A.A.A.A.A">
          <y:Option name="IGNORE_WIDTHS" value="false"/>
          <y:Option name="IGNORE_HEIGHTS" value="true"/>
          <y:Option name="ADAPT_TO_MAXIMUM_NODE" value="false"/>
        </y:Processor>
      </y:Postprocessors>
    </g:data>
  </g:graph>

正如您所看到的,“AAAAA”显然是一个混淆的类名,并且可能会在构建之间发生变化,并在某种程度上破坏您的脚本。

造成这种不便的原因实际上很简单:yEd 不应该以自动化方式使用(许可证甚至明确禁止纯自动用例),因此针对交互式使用进行了优化。所以点击按钮实际上是有意的。为什么?因为 yEd 是一个基于强大的商业库的免费产品,并且它是免费的,因为高级用户购买了该库的许可证,从而在某种程度上赞助了 yEd 的开发和支持。如果您确实需要以编程方式利用该功能,您应该考虑直接授权该库。

也就是说,您也可以尝试 Excel 导入 - 它会自动为您执行此步骤,但是您必须创建一个 Excel 文件才能开始。

There is a way, although that way uses unofficial API and may not work in any release but the current one (3.9.2 as of writing).

In the GraphML add the following key on the graph level:

  <g:key id="ppkey" for="graph" yfiles.type="postprocessors"/>
  <g:graph id="G" edgedefault="directed">
    <g:data key="ppkey">
      <y:Postprocessors>
        <y:Processor class="A.A.A.A.A">
          <y:Option name="IGNORE_WIDTHS" value="false"/>
          <y:Option name="IGNORE_HEIGHTS" value="true"/>
          <y:Option name="ADAPT_TO_MAXIMUM_NODE" value="false"/>
        </y:Processor>
      </y:Postprocessors>
    </g:data>
  </g:graph>

As you can see "A.A.A.A.A" obviously is an obfuscated class name and that may change between builds and in a way break your script.

The reason for this inconvenience is actually quite simple: yEd is not supposed to be used in an automated way (the license even explicitly forbids the purely automatic use case) and thus is optimized for interactive use. So clicking on the button is in fact intended. Why? Because yEd is a free product based on a powerful commercial library and it is only free because power users buy a license for the library and thus in a way sponsor yEd's development and support. If you really need to programmatically leverage that power you should take a look at licensing the library directly.

That said, you could also try the Excel import - it will automatically perform this step for you, however you will have to create an excel file to start from.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文