Gangmax Blog

Gliffy & PlantUML

Two diagram tools are introduced in this post.

Gliffy Diagram is a diagram tool with which you can draw many types of diagrams. You can install a free version from chrome web store. I think it can satisfy daily requirements about creating most diagrams.

PlantUML is another interesting diagram tool. THe core of PlantUML is a DSL to describe diagrams like sequence diagram, class diagram, Gantt diagram and so on. You can use the DSL to create your diagram in text. After that you can use the tool provided by PlantUML to render the text into an image. This is great because with the text it’s very easy to describe and maintain(especially in a version control system), and your focus is not the shapes, fonts or lines, but the topology of the elements in the diagram. PlantUML also provides plug-ins for IDEs like IntelliJ IDEA, Eclipse and etc.

Here is an example. You can create a diagram with text below:

1
2
3
4
5
6
7
8
9
10
11
12
@startuml test.puml
Bob->Alice: Hello!
Alice->Max: Who is he?
@enduml
```

The generated diagram is:

![PlantUML](/images/posts/20180601_plantuml.png)

The AscII Art format looks like below:

 ┌───┐          ┌─────┐          ┌───┐
 │Bob│          │Alice│          │Max│
 └─┬─┘          └──┬──┘          └─┬─┘
   │    Hello!     │               │  
   │──────────────>│               │  
   │               │               │  
   │               │  Who is he?   │  
   │               │──────────────>│  
 ┌─┴─┐          ┌──┴──┐          ┌─┴─┐
 │Bob│          │Alice│          │Max│
 └───┘          └─────┘          └───┘
1
2
3
4
5
6
7

You can found the language spec of PlantUML [here](http://plantuml.com/sitemap-language-specification) and the [reference guide](http://plantuml.com/PlantUML_Language_Reference_Guide.pdf).

If you want to generate the diagram image from your local machine, please download the "[plantuml.jar](http://sourceforge.net/projects/plantuml/files/plantuml.jar/download)" file, make sure you have Java installed(in my case it's JDK 8), "[graphviz](http://www.graphviz.org/)" installed(in my case I installed it with command "sudo apt-get install graphviz" on my Ubuntu, for other OS please read the instructions [here](http://plantuml.com/graphviz-dot)). You can put the "test.puml" file and the "plantuml.jar" files in the same directory and run the following command:

```bash
java -jar plantuml.jar

The PlantUML application will start with a GUI interface, and a “test.png” file is generated in the directory automatically.

Comments