guru.nidi.graphviz.engine.Graphviz Java Examples
The following examples show how to use
guru.nidi.graphviz.engine.Graphviz.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GraphvizjView.java From jig with Apache License 2.0 | 6 votes |
@Override public void render(T model, JigDocumentWriter jigDocumentWriter) { DiagramSources diagramSources = editor.edit(model); if (diagramSources.noEntity()) { jigDocumentWriter.skip(); return; } // コマンドラインのみにする GraphvizCmdLineEngine graphvizCmdLineEngine = new GraphvizCmdLineEngine(); confirmInstalledGraphviz(graphvizCmdLineEngine); Graphviz.useEngine(graphvizCmdLineEngine); diagramSources.each(element -> writeDocument(jigDocumentWriter, element)); }
Example #2
Source File: GraphvizjView.java From jig with Apache License 2.0 | 6 votes |
private void writeDocument(JigDocumentWriter jigDocumentWriter, DiagramSource diagramSource) { DocumentName documentName = diagramSource.documentName(); jigDocumentWriter.write( outputStream -> Graphviz.fromString(diagramSource.text()) .render(diagramFormat.graphvizjFormat()) .toOutputStream(outputStream), documentName.withExtension(diagramFormat.extension())); AdditionalText additionalText = diagramSource.additionalText(); if (additionalText.enable()) { jigDocumentWriter.write( outputStream -> { try (OutputStreamWriter writer = new OutputStreamWriter(outputStream)) { writer.write(additionalText.value()); } }, documentName.withExtension("additional.txt") ); } }
Example #3
Source File: PerformanceTest.java From graphviz-java with Apache License 2.0 | 6 votes |
void ex2() { final Node init = node("init"), execute = node("execute"), compare = node("compare").with(Shape.RECTANGLE, Style.FILLED, Color.hsv(.7, .3, 1.0)), make_string = node("make_string"), printf = node("printf"); final Graph g = graph("ex2").directed().with( node("main").with(Shape.RECTANGLE).link( to(node("parse").link(execute)).with(LinkAttr.weight(8)), to(init).with(Style.DOTTED), node("cleanup"), to(printf).with(Style.BOLD, Label.of("100 times"), Color.RED)), execute.link(graph().with(make_string, printf), to(compare).with(Color.RED)), init.link(make_string.with(Label.of("make a\nstring")))); Graphviz.fromGraph(g).render(SVG).toString(); }
Example #4
Source File: PerformanceTest.java From graphviz-java with Apache License 2.0 | 6 votes |
void ex7() { final Graph g = graph("ex7").directed() .with( graph().cluster() .nodeAttr().with(Style.FILLED, Color.WHITE) .graphAttr().with(Style.FILLED, Color.LIGHTGREY, Label.of("process #1")) .with(node("a0").link(node("a1").link(node("a2").link(node("a3"))))), graph("x").cluster() .nodeAttr().with(Style.FILLED) .graphAttr().with(Color.BLUE, Label.of("process #2")) .with(node("b0").link(node("b1").link(node("b2").link(node("b3"))))), node("start").with(Shape.M_DIAMOND).link("a0", "b0"), node("a1").link("b3"), node("b2").link("a3"), node("a3").link("a0"), node("a3").link("end"), node("b3").link("end"), node("end").with(Shape.M_SQUARE) ); Graphviz.fromGraph(g).render(SVG).toString(); }
Example #5
Source File: FontTools.java From graphviz-java with Apache License 2.0 | 5 votes |
public static void availableFontNamesGraph(File output) throws IOException { final MutableGraph g = mutGraph() .graphAttrs().add(Rank.dir(LEFT_TO_RIGHT)) .nodeAttrs().add(Size.mode(Size.Mode.MINIMUM).margin(.1, .1).size(0, 0), Shape.RECTANGLE); final List<String> fonts = availableFontNames(); fonts.sort(Comparator.reverseOrder()); for (final String f : fonts) { g.add(node(f + "2").with(of("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz")).with(Font.name(f))); g.add(node(f + "3").with(of("ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ")).with(Font.name(f))); g.add(node(f).with(Font.name(f))); } Graphviz.fromGraph(g).render(PNG).toFile(output); }
Example #6
Source File: FontTools.java From graphviz-java with Apache License 2.0 | 5 votes |
public static void main(String[] args) throws IOException { Graphviz.useEngine(new GraphvizV8Engine()); System.out.println("Available fonts: " + availableFontNames()); final String fontShow = "font-show.png"; System.out.println("Creating image with all fonts '" + fontShow + "'."); availableFontNamesGraph(new File(fontShow)); if (args.length < 2) { System.out.println("Usage: FontTools <font name> <font adjust>"); System.exit(0); } }
Example #7
Source File: PerformanceTest.java From graphviz-java with Apache License 2.0 | 5 votes |
public static void main(String[] args) { final long a = System.nanoTime(); Graphviz.useEngine(new GraphvizV8Engine()); // Graphviz.useEngine(new GraphvizJdkEngine()); Graphviz.fromString("graph {a--b}").render(SVG).toString(); final long b = System.nanoTime(); System.out.printf("init %.0f ms%n", (b - a) / 1e6); final PerformanceTest pt = new PerformanceTest(); print(pt.test()); for (int k = 0; k < 10; k++) { print(pt.test()); } print(pt.test(50)); }
Example #8
Source File: PerformanceTest.java From graphviz-java with Apache License 2.0 | 5 votes |
public void ex1() { final Graph g = CreationContext.use(ctx -> graph("ex1").directed().with( node("main").link( node("parse"), node("init"), node("cleanup"), node("printf")), node("parse").link( node("execute")), node("execute").link( node("make_string"), node("printf"), node("compare")), node("init").link( node("make_string")))); Graphviz.fromGraph(g).render(SVG).toString(); }
Example #9
Source File: PerformanceTest.java From graphviz-java with Apache License 2.0 | 5 votes |
void ex3() { final Node a = node("a").with(Shape.polygon(5).rotation(10), attr("peripheries", 3), Color.LIGHTBLUE, Style.FILLED), c = node("c").with(Shape.polygon(4).skew(.4), Label.of("hello world")), d = node("d").with(Shape.INV_TRIANGLE), e = node("e").with(Shape.polygon(4).distortion(.7)); final Graph g = graph("ex3").directed().with( a.link(node("b").link(c, d)), e); Graphviz.fromGraph(g).render(SVG).toString(); }
Example #10
Source File: PerformanceTest.java From graphviz-java with Apache License 2.0 | 5 votes |
void ex4() { final Node struct1 = node("struct1").with(Records.label("<f0> left|<f1> mid\\ dle|<f2> right")), struct2 = node("struct2").with(Records.label("<f0> one|<f1> two")), struct3 = node("struct3").with(Records.label("hello\nworld |{ b |{c|<here> d|e}| f}| g | h")); final Graph g = graph("ex41").directed().with( struct1.link( between(port("f1"), struct2.port("f0")), between(port("f2"), struct3.port("here")))); Graphviz.fromGraph(g).render(SVG).toString(); }
Example #11
Source File: PerformanceTest.java From graphviz-java with Apache License 2.0 | 5 votes |
void ex6() { final Node node0 = node("node0").with(Records.of(rec("f0", ""), rec("f1", ""), rec("f2", ""), rec("f3", ""), rec("f4", ""), rec("f5", ""), rec("f6", ""))), node1 = node("node1").with(Records.of(turn(rec("n", "n14"), rec("719"), rec("p", "")))), node2 = node("node2").with(Records.of(turn(rec("n", "a1"), rec("805"), rec("p", "")))), node3 = node("node3").with(Records.of(turn(rec("n", "i9"), rec("718"), rec("p", "")))), node4 = node("node4").with(Records.of(turn(rec("n", "e5"), rec("989"), rec("p", "")))), node5 = node("node5").with(Records.of(turn(rec("n", "t20"), rec("959"), rec("p", "")))), node6 = node("node6").with(Records.of(turn(rec("n", "o15"), rec("794"), rec("p", "")))), node7 = node("node7").with(Records.of(turn(rec("n", "s19"), rec("659"), rec("p", "")))); final Graph g = graph("ex6").directed() .graphAttr().with(Rank.dir(LEFT_TO_RIGHT)) .with( node0.link( between(port("f0"), node1.port(WEST)), between(port("f1"), node2.port(WEST)), between(port("f2"), node3.port(WEST)), between(port("f5"), node4.port(WEST)), between(port("f6"), node5.port(WEST))), node2.link(between(port("p"), node6.port(WEST))), node4.link(between(port("p"), node7.port(WEST)))); Graphviz.fromGraph(g).render(SVG).toString(); }
Example #12
Source File: GraphvizTaglet.java From graphviz-java with Apache License 2.0 | 5 votes |
@Override public String toString(Tag tag) { try { final File file = new File(packageOf(tag), imageNameOf(tag)); final File output = Graphviz.fromString(tag.text()).render(Format.PNG).toFile(file); return "<img title='" + imageTitleOf(tag) + "' src='" + output.getName() + "'></img>"; } catch (IOException e) { throw new RuntimeException("Problem writing graphviz file", e); } }