处理蜡染的 SVG XML

发布于 2025-01-04 06:14:10 字数 199 浏览 2 评论 0原文

我正在使用 Batik 来操作 SVG XML 并显示更改。然而,默认情况下,这涉及到使用 org.w3c.dom ,这是非常难以使用的。是否可以使用另一个 DOM 库来修改 XML,但它仍然可以与 Batik 一起使用?也许有 org.w3c.dom 的包装器?我相信 DOM 表示中的对象实际上是 Batik 子类,因此我无法转换为另一种表示并返回,除非我想重新渲染整个 SVG。

I am using Batik to manipulate SVG XML and display the changes. By default, however, this involves using org.w3c.dom which is exceedingly difficult to use. Is it possible to use another DOM library to modify the XML but have it still work with Batik? Maybe there is a wrapper for org.w3c.dom? I believe the objects in the DOM representation are actually Batik subclasses, so I can't convert to another representation and back unless I want to re-render the entire SVG.

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

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

发布评论

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

评论(1

辞慾 2025-01-11 06:14:10

dom 库并不难使用。您需要了解工厂模式,然后它们就非常简单了。有点冗长,但很简单。
编写一些适合您需要的辅助函数也相当简单,例如仅生成线条元素的 drawLine 函数等。

尝试一下,并练习您的 DOM 技能。您知道,所有 Web 浏览器也都使用 DOM。

据我所知,Batik 会用渲染树来“注释”文档。但我不会尝试直接操作渲染树。

哦,并确保将所有更改包装在更新队列中。就像您对 Java 上的 Swing/AWT 的 EDT 所做的那样。

The dom libraries are not that hard to use. You need to understand the factory pattern, and then they are pretty much straightforward. A bit verbose, but straightforward.
It's also fairly simple to write a number of helper functions that suit your needs, such as a drawLine function that just produces a line element etc.

Give it a try, and practise your DOM skills. You know, all the web browsers use DOM, too.

As far as I know, Batik will "annotate" the document with a rendering tree. But I'd not try to manipulate the rendering tree directly.

Oh, and make sure to wrap any changes in the update queue. Just like you'd do with the EDT for Swing/AWT on Java.

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