Gangmax Blog

自由之思想,独立之精神

Gliffy & PlantUML

| Comments

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
@startuml test.puml
Bob->Alice: Hello!
Alice->Max: Who is he?
@enduml

The generated diagram is:

PlantUML

The AscII Art format looks like below:

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

You can found the language spec of PlantUML here and the reference guide.

If you want to generate the diagram image from your local machine, please download the ”plantuml.jar” file, make sure you have Java installed(in my case it’s JDK 8), ”graphviz” 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). You can put the “test.puml” file and the “plantuml.jar” files in the same directory and run the following command:

1
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