Giter Club home page Giter Club logo

dot-diagram's Introduction

dot-diagram

A simple Java wrapper on top of Graphviz dot tool. It offers two basic layers of functionalities.

API on top of the Dot Syntax

This project provides a convenient API (DotGraph) to create graphs, including sub-graphs (clusters), that are then rendered into .dot syntax text.

For example:

final DotGraph graph = new DotGraph("simple test");
final Digraph digraph = graph.getDigraph();
digraph.addNode("Car").setLabel("My Car").setComment("This is BMW").setOptions(STUB_NODE_OPTIONS);
digraph.addNode("Wheel").setLabel("Its wheels").setComment("The wheels of my car");
digraph.addAssociation("Car", "Wheel").setLabel("4*").setComment("There are 4 wheels").setOptions(ASSOCIATION_EDGE_STYLE);

Would generate the dot syntax:

# Class diagram simple test
digraph G {
	graph [labelloc=top,label="simple test",fontname="Verdana",fontsize=12];
	edge [fontname="Verdana",fontsize=9,labelfontname="Verdana",labelfontsize=9];
	node [fontname="Verdana",fontsize=9,shape=record];
//This is BMW
	c0 [label="My Car", color=grey,fontcolor=grey,fontname="Verdana",fontsize=9]
//The wheels of my car
	c1 [label="Its wheels"]
	// There are 4 wheels
	c0 -> c1 [label="4*"  , arrowhead=open];
}

Convenience on top of the Graphviz tool

This project also offers for convenience a DotWriter that launches Graphviz to render the dot file into an image file. This requires Graphviz to be installed on the machine, along with read/write access to the disk for temporary .dot files.

For example, calling dot on the simple graph above would generate this image:

Rendered to .png

And the clustering example would generate this image:

Rendered to .png

Please look at the tests for more examples.

Get it!

From the Maven Central Repository

<!-- https://mvnrepository.com/artifact/io.github.livingdocumentation/dot-diagram -->
<dependency>
    <groupId>io.github.livingdocumentation</groupId>
    <artifactId>dot-diagram</artifactId>
    <version>1.1</version>
</dependency>

See

http://www.graphviz.org

dot-diagram's People

Contributors

binout avatar cyriux avatar javathought avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

dot-diagram's Issues

tests failing

mvn install fails:

Running org.livingdocumentation.dotdiagram.DotWriterTest
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.062 sec <<< FAILURE!
Running org.livingdocumentation.dotdiagram.DotGraphTest
Tests run: 3, Failures: 0, Errors: 3, Skipped: 0, Time elapsed: 0.025 sec <<< FAILURE!

Results :

Tests in error: 
  render(org.livingdocumentation.dotdiagram.DotWriterTest)
  test_simple_preloadNodes(org.livingdocumentation.dotdiagram.DotGraphTest)
  test_cluster(org.livingdocumentation.dotdiagram.DotGraphTest)
  test_simple(org.livingdocumentation.dotdiagram.DotGraphTest)

Tests run: 4, Failures: 0, Errors: 4, Skipped: 0

Double association between node is not supported

Class diagram Domain

digraph G {
graph [labelloc=top,label="Domain",fontname="Verdana",fontsize=12];
edge [fontname="Verdana",fontsize=9,labelfontname="Verdana",labelfontsize=9];
node [fontname="Verdana",fontsize=9,shape=record];
c1 [label="Quantity"]
c2 [label="Size"]
c1 -> c2 [label="size" , ];

// with API it's not possible to add a 2nd association between c1 and c2 with another label ...
c1 -> c2 [label="mainSize"  , ];

}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.