nidi3 / graphviz-java

Use graphviz with pure java
Apache License 2.0
934 stars 106 forks source link

Exception when using multiple colors on a node #186

Closed arminkz closed 3 years ago

arminkz commented 3 years ago

Hello and thanks for your amazing job developing this helpful open-source project.

I am using your library in one of my projects and I've encountered a problem. I was trying to use the wedged style for my nodes and of course, with wedged style nodes you must pass multiple colors. for specifying multiple colors you can just separate them using: for example green:blue this is the code I've used:

MutableNode vgv = mutNode("example");
vgv.attrs().add("shape", "circle");
vgv.attrs().add("style","wedged");
vgv.attrs().add("color","green:blue");

and actually, it worked and printed the desired graph but there are some exceptions popping up, and it's somehow annoying. here is the exception:

Nov 15, 2020 8:17:54 PM com.kitfox.svg.SVGUniverse getElement
WARNING: Could not parse path blue:green
java.net.MalformedURLException: unknown protocol: blue
    at java.base/java.net.URL.<init>(URL.java:675)
    at java.base/java.net.URL.fromURI(URL.java:742)
    at java.base/java.net.URI.toURL(URI.java:1139)
    at com.kitfox.svg.SVGUniverse.getElement(SVGUniverse.java:343)
    at com.kitfox.svg.SVGUniverse.getElement(SVGUniverse.java:308)
    at com.kitfox.svg.ShapeElement.renderShape(ShapeElement.java:206)
    at com.kitfox.svg.Ellipse.render(Ellipse.java:105)
    at com.kitfox.svg.Group.render(Group.java:205)
    at com.kitfox.svg.Group.render(Group.java:205)
    at com.kitfox.svg.Group.render(Group.java:205)
    at com.kitfox.svg.SVGRoot.render(SVGRoot.java:335)
    at com.kitfox.svg.SVGRoot.renderToViewport(SVGRoot.java:266)
    at com.kitfox.svg.SVGDiagram.render(SVGDiagram.java:111)
    at guru.nidi.graphviz.engine.SalamanderRasterizer.renderDiagram(SalamanderRasterizer.java:51)
    at guru.nidi.graphviz.engine.SalamanderRasterizer.doRasterize(SalamanderRasterizer.java:37)
    at guru.nidi.graphviz.engine.SvgRasterizer.rasterize(SvgRasterizer.java:39)
    at guru.nidi.graphviz.engine.Renderer.toImage(Renderer.java:123)
    at guru.nidi.graphviz.engine.EngineResult.map(EngineResult.java:58)
    at guru.nidi.graphviz.engine.Renderer.toImage(Renderer.java:114)
    at guru.nidi.graphviz.engine.Renderer.toImage(Renderer.java:110)
    at visual.GraphPainter.viewGraph(GraphPainter.java:90)
    at visual.GraphPanel.<init>(GraphPanel.java:16)
    at visual.ShowGraph.showGraph(ShowGraph.java:12)
    at optimization.FHS.solve(FHS.java:156)
    at GUI.<init>(GUI.java:25)
    at GUI.run(GUI.java:41)
    at Main.main(Main.java:18)

and this is the printed graph:

image

thanks for your attention

nidi3 commented 3 years ago

fixed with 0.18.0