esteinberg / plantuml4idea

Intellij IDEA plugin for PlantUML
Apache License 2.0
629 stars 114 forks source link

skinparam Dpi causes exception #343

Closed patrickp-at-work closed 2 years ago

patrickp-at-work commented 2 years ago

How to reproduce

@startuml
skinparam Dpi 100

try to change 100 to 200 by first deleting the 1 and then typing the 2.

Observed outcome

After deletion of the 1, an org.apache.batik.transcoder.TranscoderException is thrown. IntelliJ reports this as a plugin error ("IDE Fatal Errors: Exception in plugin...)".

Stack trace

org.apache.batik.transcoder.TranscoderException: null Enclosed Exception:

Width (0) and height (0) cannot be <= 0
    at org.plantuml.idea.preview.image.svg.batik.MySvgTranscoder$Companion.createImage(MySvgTranscoder.kt:110)
    at org.plantuml.idea.preview.image.svg.batik.MySvgTranscoder$Companion.createImage$default(MySvgTranscoder.kt:73)
    at org.plantuml.idea.preview.image.svg.batik.MySvgTranscoder$Companion.createImage(MySvgTranscoder.kt)
    at org.plantuml.idea.preview.image.svg.batik.MySvgTranscoder.createImage(MySvgTranscoder.kt)
    at org.plantuml.idea.preview.image.svg.MyImageEditorImpl$MyScaledImageProvider.createImage(MyImageEditorImpl.java:247)
    at org.plantuml.idea.preview.image.svg.MyImageEditorImpl$MyScaledImageProvider.apply(MyImageEditorImpl.java:210)
    at org.plantuml.idea.preview.image.svg.MyImageEditorImpl$MyScaledImageProvider.apply(MyImageEditorImpl.java:187)
    at org.intellij.images.ui.ImageComponent$ImageDocumentImpl.lambda$setValue$2(ImageComponent.java:308)
    at org.intellij.images.ui.ImageComponent$ImageDocumentImpl.getValue(ImageComponent.java:295)
    at org.intellij.images.ui.ImageComponent$ImageDocumentImpl.getValue(ImageComponent.java:290)
    at org.plantuml.idea.preview.image.svg.MyImageEditorUI$DocumentChangeListener.stateChanged(MyImageEditorUI.java:654)
    at org.intellij.images.ui.ImageComponent$ImageDocumentImpl.fireChangeEvent(ImageComponent.java:329)
    at org.intellij.images.ui.ImageComponent$ImageDocumentImpl.setFormat(ImageComponent.java:324)
    at org.plantuml.idea.preview.image.svg.MyImageEditorUI.setImageProvider(MyImageEditorUI.java:283)
    at org.plantuml.idea.preview.image.svg.MyImageEditorImpl.setValue(MyImageEditorImpl.java:95)
    at org.plantuml.idea.preview.image.svg.MyImageEditorImpl.<init>(MyImageEditorImpl.java:89)
    at org.plantuml.idea.preview.image.ImageContainerSvg.initEditor(ImageContainerSvg.java:155)
    at org.plantuml.idea.rendering.ImageItem.initImage(ImageItem.java:186)
    at org.plantuml.idea.rendering.RenderCommand.lambda$displayResult$0(RenderCommand.java:173)
    at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
[...]
Caused by: java.lang.IllegalArgumentException: Width (0) and height (0) cannot be <= 0
    at java.desktop/java.awt.image.DirectColorModel.createCompatibleWritableRaster(DirectColorModel.java:1016)
    at java.desktop/java.awt.image.BufferedImage.<init>(BufferedImage.java:333)
    at org.plantuml.idea.preview.image.svg.batik.MyBufferedImage.<init>(MyBufferedImage.java:15)
    at org.plantuml.idea.preview.image.svg.batik.MySvgTranscoderKt.render(MySvgTranscoder.kt:277)
    at org.plantuml.idea.preview.image.svg.batik.MySvgTranscoderKt.access$render(MySvgTranscoder.kt:1)
    at org.plantuml.idea.preview.image.svg.batik.MySvgTranscoder$Companion.createImage(MySvgTranscoder.kt:100)
    ... 52 more

Reproducible: yes IntelliJ IDEA 2021.3 (Ultimate Edition) Plugin version: 5.10.0

I can provide a screenshot if needed.

Expected outcome

krasa commented 2 years ago

It seems to me that it is more a Plantuml bug, it should not generate such things

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg xmlns="http://www.w3.org/2000/svg" contentScriptType="application/ecmascript" contentStyleType="text/css"
     height="0px" preserveAspectRatio="none" style="width:0px;height:0px;background:#FFFFFF;" version="1.1"
     viewBox="0 0 0 0" width="0px" zoomAndPan="magnify">
    <defs>
        <filter height="300%" id="fnoog7zpba7jr" width="300%" x="-1" y="-1">
            <feGaussianBlur result="blurOut" stdDeviation="0.0"/>
            <feColorMatrix in="blurOut" result="blurOut2" type="matrix"
                           values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .4 0"/>
            <feOffset dx="0.0" dy="0.0" in="blurOut2" result="blurOut3"/>
            <feBlend in="SourceGraphic" in2="blurOut3" mode="normal"/>
        </filter>
    </defs>
    <g>
        <line style="stroke:#A80036;stroke-width:0.0;stroke-dasharray:5.0,5.0;" x1="0" x2="0" y1="0" y2="0"/>
        <line style="stroke:#A80036;stroke-width:0.0;stroke-dasharray:5.0,5.0;" x1="0" x2="0" y1="0" y2="0"/>
        <rect fill="#FEFECE" filter="url(#fnoog7zpba7jr)" height="0" style="stroke:#A80036;stroke-width:0.0;" width="0"
              x="0" y="0"/>
        <text fill="#000000" font-family="sans-serif" font-size="0" lengthAdjust="spacing" textLength="0" x="0" y="0">
            Alice
        </text>
        <rect fill="#FEFECE" filter="url(#fnoog7zpba7jr)" height="0" style="stroke:#A80036;stroke-width:0.0;" width="0"
              x="0" y="0"/>
        <text fill="#000000" font-family="sans-serif" font-size="0" lengthAdjust="spacing" textLength="0" x="0" y="0">
            Alice
        </text>
        <rect fill="#FEFECE" filter="url(#fnoog7zpba7jr)" height="0" style="stroke:#A80036;stroke-width:0.0;" width="0"
              x="0" y="0"/>
        <text fill="#000000" font-family="sans-serif" font-size="0" lengthAdjust="spacing" textLength="0" x="0" y="0">
            Bob
        </text>
        <rect fill="#FEFECE" filter="url(#fnoog7zpba7jr)" height="0" style="stroke:#A80036;stroke-width:0.0;" width="0"
              x="0" y="0"/>
        <text fill="#000000" font-family="sans-serif" font-size="0" lengthAdjust="spacing" textLength="0" x="0" y="0">
            Bob
        </text>
        <polygon fill="#A80036" points="0,0,0,0,0,0,0,0" style="stroke:#A80036;stroke-width:0.0;"/>
        <line style="stroke:#A80036;stroke-width:0.0;" x1="0" x2="0" y1="0" y2="0"/>
        <text fill="#000000" font-family="sans-serif" font-size="0" font-weight="bold" lengthAdjust="spacing"
              textLength="0" x="0" y="0">1
        </text>
        <text fill="#000000" font-family="sans-serif" font-size="0" lengthAdjust="spacing" textLength="0" x="0" y="0">
            Authentication Request
        </text>
        <polygon fill="#A80036" points="0,0,0,0,0,0,0,0" style="stroke:#A80036;stroke-width:0.0;"/>
        <line style="stroke:#A80036;stroke-width:0.0;stroke-dasharray:2.0,2.0;" x1="0" x2="0" y1="0" y2="0"/>
        <text fill="#000000" font-family="sans-serif" font-size="0" font-weight="bold" lengthAdjust="spacing"
              textLength="0" x="0" y="0">2
        </text>
        <text fill="#000000" font-family="sans-serif" font-size="0" lengthAdjust="spacing" textLength="0" x="0" y="0">
            Authentication Response
        </text>
        <polygon fill="#A80036" points="0,0,0,0,0,0,0,0" style="stroke:#A80036;stroke-width:0.0;"/>
        <line style="stroke:#A80036;stroke-width:0.0;" x1="0" x2="0" y1="0" y2="0"/>
        <text fill="#000000" font-family="sans-serif" font-size="0" font-weight="bold" lengthAdjust="spacing"
              textLength="0" x="0" y="0">3
        </text>
        <text fill="#000000" font-family="sans-serif" font-size="0" lengthAdjust="spacing" textLength="0" x="0" y="0">
            Another authentication Request
        </text>
        <polygon fill="#A80036" points="0,0,0,0,0,0,0,0" style="stroke:#A80036;stroke-width:0.0;"/>
        <line style="stroke:#A80036;stroke-width:0.0;stroke-dasharray:2.0,2.0;" x1="0" x2="0" y1="0" y2="0"/>
        <text fill="#000000" font-family="sans-serif" font-size="0" font-weight="bold" lengthAdjust="spacing"
              textLength="0" x="0" y="0">4
        </text>
        <text fill="#000000" font-family="sans-serif" font-size="0" lengthAdjust="spacing" textLength="0" x="0" y="0">
            another authentication Response
        </text><!--MD5=[04c50b002c175ba1fddf4cc537fe45da]
@startuml
%set_variable_value("RELATIVE_INCLUDE", "C:\Users\vojtisek\IdeaProjects\C4-PlantUML")
skinparam Dpi 00
'https://plantuml.com/sequence-diagram

autonumber

Alice -> Bob: Authentication Request
Bob - -> Alice: Authentication Response

Alice -> Bob: Another authentication Request
Alice <- - Bob: another authentication Response
@enduml

@startuml

skinparam Dpi 00

autonumber

Alice -> Bob: Authentication Request
Bob - -> Alice: Authentication Response

Alice -> Bob: Another authentication Request
Alice <- - Bob: another authentication Response
@enduml

PlantUML version 1.2022.0(Tue Jan 11 17:16:42 CET 2022)
(GPL source distribution)
Java Runtime: OpenJDK Runtime Environment
JVM: OpenJDK 64-Bit Server VM
Default Encoding: Cp1250
Language: en
Country: US
-->
    </g>
</svg>
patrickp-at-work commented 2 years ago

The PlantUML online server confirms what you say.