nidi3 / graphviz-java

Use graphviz with pure java
Apache License 2.0
937 stars 107 forks source link

Issue performing BufferedImage #145

Closed paulagaitan97 closed 4 years ago

paulagaitan97 commented 4 years ago

This is my code

import java.io.File; import java.io.IOException; import guru.nidi.graphviz.attribute.Color; import guru.nidi.graphviz.attribute.Rank; import guru.nidi.graphviz.attribute.Style; import guru.nidi.graphviz.engine.Format; import guru.nidi.graphviz.engine.Graphviz; import guru.nidi.graphviz.model.Graph; import static guru.nidi.graphviz.attribute.Rank.RankDir.LEFT_TO_RIGHT; import static guru.nidi.graphviz.model.Factory.graph; import static guru.nidi.graphviz.model.Factory.node; import static guru.nidi.graphviz.model.Link.to; import static guru.nidi.graphviz.model.Factory.*;

public class Example {

public void exampleView(){
    try {
    Graph g = graph("example1").directed()
            .graphAttr().with(Rank.dir(LEFT_TO_RIGHT))
            .with(
                    node("a").with(Color.RED).link(node("b")),
                    node("b").link(to(node("c")).with(Style.DASHED))
            );

        Graphviz.fromGraph(g).height(100).render(Format.PNG).toFile(new File("example/ex1.png"));
    } catch (IOException e) {
        e.printStackTrace();
    }
}

}

The error that appears to me is the following:

image

nidi3 commented 4 years ago

Which platform are you using? Which java version?

paulagaitan97 commented 4 years ago

Platform : Android studio Java version: 1.8 JDK I also tried it with the default setting of android studio: JRE

nidi3 commented 4 years ago

This projects relies a lot on java.awt classes which are not availavle on android. So currently, it wont work on android. However there are some svg rendering libraries for androud which could work. I will have a look at it, but for the moment, android is not supported :(

nidi3 commented 4 years ago

Closing this issue, but see #148