guru.nidi.graphviz.model.Graph Java Examples
The following examples show how to use
guru.nidi.graphviz.model.Graph.
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: GraphvizTest.java From graphviz-java with Apache License 2.0 | 5 votes |
@Test void withTotalMemory() { final Graph graph = graph().with(node("a").link("b")); final String result = Graphviz.fromGraph(graph).totalMemory(32000).render(SVG).toString(); assertThat(result, is("totalMemory=32000;render('graph {\\n\"a\" -- \"b\"\\n}'," + "{format:'svg',engine:'dot',totalMemory:'32000',basedir:'" + new File(".").getAbsolutePath() + "',images:[]});")); }
Example #2
Source File: GraphvizTest.java From graphviz-java with Apache License 2.0 | 5 votes |
@Test void withoutTotalMemory() { final Graph graph = graph().with(node("a").link("b")); final String result = Graphviz.fromGraph(graph).render(SVG).toString(); assertThat(result, is("render('graph {\\n\"a\" -- \"b\"\\n}'," + "{format:'svg',engine:'dot',basedir:'" + new File(".").getAbsolutePath() + "',images:[]});")); }
Example #3
Source File: GraphvizTest.java From graphviz-java with Apache License 2.0 | 5 votes |
@Test void withYInvert() { final Graph graph = graph().with(node("a").link("b")); final String result = Graphviz.fromGraph(graph).yInvert(true).render(SVG).toString(); assertThat(result, is("render('graph {\\n\"a\" -- \"b\"\\n}'," + "{format:'svg',engine:'dot',yInvert:true,basedir:'" + new File(".").getAbsolutePath() + "',images:[]});")); }
Example #4
Source File: GraphvizTest.java From graphviz-java with Apache License 2.0 | 5 votes |
@Test void filter() { final Graph graph = graph().with(node("a").link("b")); final String result = Graphviz.fromGraph(graph) .filter((format, engineResult) -> EngineResult.fromString("hula")) .filter((format, engineResult) -> engineResult.mapString((s) -> s + "2")) .render(SVG).toString(); assertEquals("hula2", result); }
Example #5
Source File: RendererTest.java From graphviz-java with Apache License 2.0 | 5 votes |
@ParameterizedTest @CsvSource({ "target/testFolder/ex1.png, target/testFolder/ex1.png", "target/testFolder/ex1, target/testFolder/ex1.png"}) void testFile(File giveFile, File expectedFile) throws IOException { Files.deleteIfExists(expectedFile.toPath()); Files.deleteIfExists(expectedFile.getParentFile().toPath()); final Graph graph = graph("example1").directed().with(node("a").link(node("b"))); Graphviz.fromGraph(graph).width(200).render(PNG).toFile(giveFile); assertTrue(expectedFile.exists() && expectedFile.isFile()); }
Example #6
Source File: RendererTest.java From graphviz-java with Apache License 2.0 | 5 votes |
@Test void toFileNoParentFolder() throws Exception { final File file = new File("test.png"); Files.deleteIfExists(file.toPath()); try { final Graph graph = graph("example1").directed().with(node("a").link(node("b"))); Graphviz.fromGraph(graph).width(200).render(PNG).toFile(file); assertTrue(file.exists()); } finally { Files.deleteIfExists(file.toPath()); } }
Example #7
Source File: ReadmeTest.java From graphviz-java with Apache License 2.0 | 5 votes |
@Test void simple() throws IOException { //## rough final Graph g = graph("ex1").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")))), graph("x").cluster() .nodeAttr().with(Style.FILLED) .graphAttr().with(Color.BLUE, Label.of("process #2")) .with(node("b0").link(node("b1").link(node("b2")))), node("start").with(Shape.M_DIAMOND).link("a0", "b0"), node("a0").with(Style.FILLED, Color.RED.gradient(Color.BLUE)).link("b1"), node("b1").link("a2"), node("a2").link("end"), node("b2").link("end"), node("end").with(Shape.M_SQUARE) ); Graphviz.fromGraph(g) .filter(new RoughFilter() .bowing(2) .curveStepCount(6) .roughness(1) .fillStyle(FillStyle.hachure().width(2).gap(5).angle(0)) .font("*serif", "Comic Sans MS")) .render(Format.PNG) .toFile(new File("example/ex1-rough.png")); //## end Graphviz.fromGraph(g) .render(Format.PNG) .toFile(new File("example/ex1.png")); assertTrue(new File("example/ex1.png").exists() && new File("example/ex1-rough.png").exists()); }
Example #8
Source File: GraphvizTest.java From graphviz-java with Apache License 2.0 | 4 votes |
@Test void scaleMethodChain() { final Graph graph = graph().with(node("a").link("b")); final Graphviz graphviz = Graphviz.fromGraph(graph).height(20).width(30).scale(3); assertThatGraphvizHasFields(graphviz, 20, 30, 3d); }
Example #9
Source File: GraphvizTest.java From graphviz-java with Apache License 2.0 | 4 votes |
@Test void heightMethodChain() { final Graph graph = graph().with(node("a").link("b")); final Graphviz graphviz = Graphviz.fromGraph(graph).scale(3).width(30).height(20); assertThatGraphvizHasFields(graphviz, 20, 30, 3d); }
Example #10
Source File: GraphvizTest.java From graphviz-java with Apache License 2.0 | 4 votes |
@Test void widthMethodChain() { final Graph graph = graph().with(node("a").link("b")); final Graphviz graphviz = Graphviz.fromGraph(graph).scale(3).height(20).width(30); assertThatGraphvizHasFields(graphviz, 20, 30, 3d); }
Example #11
Source File: GraphvizTest.java From graphviz-java with Apache License 2.0 | 4 votes |
@Test void noRasterizer() { final Graph graph = graph().with(node("a").link("b")); assertThrows(IllegalArgumentException.class, () -> Graphviz.fromGraph(graph).rasterize(NONE)); }