Git Product home page Git Product logo

smetana's Introduction

Smetana is a partial translation of Graphviz/Dot sources from C to Java. More precisely, the intent is to create a Java library (and not a program) like http://www.graphviz.org/doc/libguide/libguide.pdf .

The idea is to translate each C function to a Java static method. Each C struct is also translated to a Java class. If it works in C, it should work in Java (that’s the theory). A special thanks to Peter Kümmel which provide a CMake friendly version of libcgraphviz (https://github.com/syntheticpp/libcgraphviz)!

Because even if C and Java syntaxes are somehow close, many C features do not exist in Java. A low layer has then been written to mimic/emulate some C features (pointer arithmetic, casting...). This layer is far from perfect (for example, it does treat union as struct, which is not correct), but it seems close enough to give working results with Graphviz/dot.

Even if this is a library, a minimal program is included to demonstrate the capabilities of the library. You can invoke the program on the command line: java -jar jdot.jar

Example:java -jar jdot.jar foo1.dot foo1.png

foo1.dotbeeing the following file:

digraph foo {
 subgraph cluster02 {
 cl1 [shape=box, width=2.9, height=1.7];
 cl2;
 cl4 [width=0.6, height=0.6];
 cl2->cl1;
 cl1->cl4;
 cl2->cl4;
 }
 subgraph cluster01 {
   in1;
   in2;
   in1 -> in2 [minlen=0];
 }
 N1;
 N2;
 N3;
 N1->N2 [minlen=0];
 N2->N3;
}

The input file is a regular DOT language file, although only a tiny portion of DOT language is supported. The included parser is really simple (and again just written for demonstration).

As you can see, output from regular GraphViz/Dot and Smetana library are close: Smetana output Graphviz output

Right now, only few attributes for edges and nodes are implemented: shape (with only box and ellipse values allowed), width, height and minlen. You can also have clusters. But labels and decorations on edges are not supported yet. So few features... but it works!

Performance is quite bad because C structures are interpreted in Java and that slows down the whole execution. Another reason is that the standard "qsort" function has been implemented as a bubble sort (for simplicity, but this could and will be easily change to the standard Collections.sort() method in some future version).

Some refactoring will be started in some future when the translation will be complete enough. The idea is to have regular Java class and to throw away the C emulation layer.

Stay tuned!

smetana's People

Contributors

arnaudroques avatar

Watchers

 avatar James Cloos avatar

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.