java - IllegalArgumentException的原因是什么:kabeja中的负宽度

请解释一下在使用kabeja包时引发异常的原因。
这是我得到的错误堆栈:

    java.lang.IllegalArgumentException: negative width
    at java.awt.BasicStroke.<init>(BasicStroke.java:181)
    at org.apache.batik.bridge.PaintServer.convertStroke(Unknown Source)
    at org.apache.batik.bridge.PaintServer.convertStrokePainter(Unknown Source)
    at org.apache.batik.bridge.SVGLineElementBridge.createFillStrokePainter(Unknown Source)
    at org.apache.batik.bridge.SVGDecoratedShapeElementBridge.createShapePainter(Unknown Source)
    at org.apache.batik.bridge.SVGShapeElementBridge.buildGraphicsNode(Unknown Source)
    at org.apache.batik.bridge.GVTBuilder.buildGraphicsNode(Unknown Source)
    at org.apache.batik.bridge.GVTBuilder.buildComposite(Unknown Source)
    at org.apache.batik.bridge.GVTBuilder.build(Unknown Source)
    at org.apache.batik.bridge.SVGUseElementBridge.buildCompositeGraphicsNode(Unknown Source)
    at org.apache.batik.bridge.SVGUseElementBridge.createGraphicsNode(Unknown Source)
    at org.apache.batik.bridge.GVTBuilder.buildGraphicsNode(Unknown Source)
    at org.apache.batik.bridge.GVTBuilder.buildComposite(Unknown Source)
    at org.apache.batik.bridge.GVTBuilder.buildGraphicsNode(Unknown Source)
    at org.apache.batik.bridge.GVTBuilder.buildComposite(Unknown Source)
    at org.apache.batik.bridge.GVTBuilder.buildGraphicsNode(Unknown Source)
    at org.apache.batik.bridge.GVTBuilder.buildComposite(Unknown Source)
    at org.apache.batik.bridge.GVTBuilder.build(Unknown Source)
    at org.apache.batik.transcoder.SVGAbstractTranscoder.transcode(Unknown Source)
    at org.apache.batik.transcoder.image.ImageTranscoder.transcode(Unknown Source)
    at org.apache.batik.transcoder.XMLAbstractTranscoder.transcode(Unknown Source)
    at org.apache.batik.transcoder.SVGAbstractTranscoder.transcode(Unknown Source)
    at org.kabeja.batik.tools.AbstractSAXSerializer.transcode(AbstractSAXSerializer.java:214)
    at org.kabeja.batik.tools.AbstractSAXSerializer.endDocument(AbstractSAXSerializer.java:156)
    at org.kabeja.svg.SVGGenerator.generateSAX(SVGGenerator.java:361)
    at org.kabeja.svg.SVGGenerator.generate(SVGGenerator.java:88)
    at org.kabeja.xml.AbstractSAXGenerator.generate(AbstractSAXGenerator.java:37)
    at BasicFunc.DXFFileLoad.parseFile(DXFFileLoad.java:54)
    at desktopapplication3.Foundation_details.jButton1ActionPerformed(Foundation_details.java:450)
    at desktopapplication3.Foundation_details.access$200(Foundation_details.java:12)
    at desktopapplication3.Foundation_details$3.actionPerformed(Foundation_details.java:147)
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
    at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
    at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
    at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
    at java.awt.Component.processMouseEvent(Component.java:6263)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
    at java.awt.Component.processEvent(Component.java:6028)
    at java.awt.Container.processEvent(Container.java:2041)
    at java.awt.Component.dispatchEventImpl(Component.java:4630)
    at java.awt.Container.dispatchEventImpl(Container.java:2099)
    at java.awt.Component.dispatchEvent(Component.java:4460)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4574)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4238)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4168)
    at java.awt.Container.dispatchEventImpl(Container.java:2085)
    at java.awt.Window.dispatchEventImpl(Window.java:2475)
    at java.awt.Component.dispatchEvent(Component.java:4460)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

有人能解释一下这个例外的原因吗?

最佳答案

从stacktrace来看,当试图使用负宽度绘制形状的笔划时,似乎会触发错误。当然,这是不正确的,因为不能有负宽度的笔划。svg规范甚至mentions that a negative width is an error
我认为dxf输入文件是错误的。它在autodesk中渲染得好吗?你能找到笔划错误的元素,看看它是如何显示的吗?
解决方案是向kabeja项目提交一个bug报告,请求修复。根据该元素在Autodesk中的显示方式,负笔划宽度可以是:
如果不应显示笔划,则设置为0
如果忽略符号,则设置为abs绝对值,并且-1mm的宽度应与1mm相同。

本文翻译自 https://stackoverflow.com/questions/12086686/

网站遵循 CC BY-SA 4.0 协议,转载或引用请注明出处。

标签 java exception svg dxf


相关文章:

html - 创建绘画效果

css - 将鼠标悬停在SVG上

java - 在部署到tomcat之前(或之中),如何管理.war文件中的库版本?

android - WebView导致SQLiteDiskIOException

java - 限制嵌入式Jetty中的上传大小

python - Python多个非托管资源和异常安全

python - Python __del__未在异常上调用

javascript - 如何翻转SVG坐标?

java - 如何在调试期间使用IntelliJ计算断点命中数

java - Logback一次创建一个文件并写入该文件,即使它是过去的一天