Multilingual Wiki Documentation

You are currently using syntax.
In an attempt to improve PlantUML documentation...
Please do not use this website for your own diagrams.
You can click here and use the online server here for your own documentation.

Back to page content

Changes

Japanese version English version
===== 圧縮 =====

以下の圧縮アルゴリズムが利用可能です:

- [[http://en.wikipedia.org/wiki/DEFLATE|Deflateアルゴリズム]]は小さい図の場合に有効です。
- バージョン1.2017.20以降のPlantUMLでは、[[https://en.wikipedia.org/wiki/Brotli|Brotliアルゴリズム]]を利用することもできます。(issue [[https://github.com/plantuml/plantuml/issues/117|#117]])こちらは大きい図の場合に有効です。Brotliアルゴリズムであることを表すために、エンコード後の文字列の最初に''0''が追加されます(Deflateで''0''で始まるデータが生成されることはありません)。
- 単純な16進数(HEX)エンコーディングを使用することもできます。この場合、先頭に''~h''が追加されます。

**原理**

例えば、次のようなUMLのテキスト記述があった場合:

<code>
@startuml
Alice -> Bob: Authentication Request
Bob --> Alice: Authentication Response
@enduml
</code>

このように[[http://www.plantuml.com/plantuml/uml/Syp9J4vLqBLJSCfFib9mB2t9ICqhoKnEBCdCprC8IYqiJIqkuGBAAUW2rO0LOr5LN92VLvpA1G00|エンコード]]されます:

<code>
Syp9J4vLqBLJSCfFib9mB2t9ICqhoKnEBCdCprC8IYqiJIqkuGBAAUW2rO0LOr5LN92VLvpA1G00
</code>


この結果を得るには次の処理を行います:

- テキストをUTF-8でエンコードします。
- [[http://en.wikipedia.org/wiki/DEFLATE|Deflate]]または[[https://en.wikipedia.org/wiki/Brotli|Brotli]]アルゴリズムで圧縮します。
- [[http://en.wikipedia.org/wiki/Base64|Base64]]に類似したアルゴリズムを使って、ASCIIに再エンコーディングします。


**Base64ではない理由**

大きな理由は歴史的なものです。このフォーマットは最初、公開を目的としていませんでした。これを変更するのは今となっては遅すぎます。しかし、その差異は、使用する文字の順番のみです。

Base64は0~63の値を、次の配列に対応させます:
<code>
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/
</code>

PlantUMLでは、0~63の値を、次の配列に対応させます:
<code>
0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_
</code>


**圧縮の比較**

次の図をエンコードすると、

<plantuml>
@startuml
skinparam backgroundColor #EEEBDC
skinparam handwritten true

skinparam sequenceArrowColor DeepSkyBlue
skinparam sequenceActorBorderColor DeepSkyBlue
skinparam sequenceLifeLineBorderColor blue
skinparam sequenceLifeLineBackgroundColor #A9DCDF
skinparam sequenceParticipantBorderColor DeepSkyBlue
skinparam sequenceParticipantBackgroundColor DodgerBlue
skinparam sequenceParticipantFontName Impact
skinparam sequenceParticipantFontSize 17
skinparam sequenceParticipantFontColor #A9DCDF
skinparam sequenceActorBackgroundColor aqua
skinparam sequenceActorFontColor DeepSkyBlue
skinparam sequenceActorFontSize 17
skinparam sequenceActorFontName Aapex

actor User
participant "First Class" as ParticipantA
participant "Second Class" as ParticipantB
participant "Last Class" as ParticipantC

User -> ParticipantA: DoWork
activate ParticipantA

ParticipantA -> ParticipantB: Create Request
activate ParticipantB

ParticipantB -> ParticipantC: DoWork
activate ParticipantC
ParticipantC --> ParticipantB: WorkDone
destroy ParticipantC

ParticipantB --> ParticipantA: Request Created
deactivate ParticipantB

ParticipantA --> User: Done
deactivate ParticipantA
@enduml
</plantuml>

* [[http://www.plantuml.com/plantuml/uml/ZP4zRy8m48Pt_ueJdHawLMMe53iWLK9LLLHrFk8hM04xd9rI-kiR0u8a1CAG8SdpVja-DxP0nZNCCSiNx4ghbLivXeVnU2nJ9Vo9MABLMpOXa8N09OdQFq-Racn62RFR7WnIecAMx-Ig8Zl0B3YMZZNnFVZKV5UFfRfYteEs1oNFgKed7Oftv60oKw0DzpUgYrf9gTCBudxTnDdmXck2rtM1MUY7P-QFuF6f7-nRV3ZzLctSb7YDFPlUSQstgvwG_VG42_eL0kD7-FJ4eZXFWS74i0-WLkZz0D13RMVI96UKEQkxKTb4ftZDKmaHEy3mfP4qggxqot4UQveV3DJi8UflBQqSWMAAae-utuTE3zdma2qFTJDVrQKAXXVvKPawIq9NyUnshS7Du8lbnzh75ReowH-Gx7tYISRc--JEa_i7|Deflateを使うと428文字]]
* [[http://www.plantuml.com/plantuml/uml/06tq404I5ENsC6cXKT6xxgxaBDG3o_tzkTRbkDJuRa4mYLIoIEFVZsapwhAr5NDHB0jrZfWK5MOp8y53KKy_J2adzUr-HCAJ8bVfEA7x6qMwXhNtcUJYCT4gMZV_c2gzJk9gimqo81bOfXLN-tkYpiaWi3aabF_wrItuxPLX5NINL6FKhAboWjmXbI8jiBfIRnXs0h40re09D-HpekC83iDO8GEXFHTCMoPlXmKCx05mLK_fTdsZCJY1geDzQhs6aar6qIIfU1V5QYHQ5wvIFj8v6xZE0zWeZksK6S5mgnjDR9L1ao9uZg7-gFLepB1EeGVeUILgETgbkEtuAelaPmmGV7kEDjEioz1d6D_0WvvYzGbScBwP8CnA9ZosEQ2vGlBk_7W00|Brotliを使うと393文字]]
となります。
===== Compression =====

The following compression algorithms are available:

- First was is the [[http://en.wikipedia.org/wiki/DEFLATE|Deflate algorithm]] that gives good results for short diagrams.
- Starting in version 1.2017.20, PlantUML also supports the [[https://en.wikipedia.org/wiki/Brotli|Brotli algorithm]] (issue [[https://github.com/plantuml/plantuml/issues/117|#117]]) that gives better results for larger diagrams. An initial ''0'' character is added to the encoded string to indicate Brotli (Deflated data never starts with ''0'').
- You can also use simple HEX encoding, see below. An initial ''~h'' is added to indicate this encoding.

**Principle**

For example, the following uml text description:

<code>
@startuml
Alice -> Bob: Authentication Request
Bob --> Alice: Authentication Response
@enduml
</code>

is [[http://www.plantuml.com/plantuml/uml/Syp9J4vLqBLJSCfFib9mB2t9ICqhoKnEBCdCprC8IYqiJIqkuGBAAUW2rO0LOr5LN92VLvpA1G00|encoded as]]:

<code>
Syp9J4vLqBLJSCfFib9mB2t9ICqhoKnEBCdCprC8IYqiJIqkuGBAAUW2rO0LOr5LN92VLvpA1G00
</code>


To achieve such encoding, the text diagram is:

- Encoded in UTF-8
- Compressed using [[http://en.wikipedia.org/wiki/DEFLATE|Deflate]] or [[https://en.wikipedia.org/wiki/Brotli|Brotli]] algorithm
- Reencoded in ASCII using a transformation //close// to [[http://en.wikipedia.org/wiki/Base64|base64]]


**Why not use Base64?**

The main reason is historic: this format was not created to be public at first. Now, it's too late to change it. However, the only difference is in character order.

Where in base64 the mapping array for values 0-63 is:
<code>
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/
</code>

For PlantUML, the mapping array for values 0-63 is:
<code>
0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_
</code>


**Compression comparison **

The following diagram:

<plantuml>
@startuml
skinparam backgroundColor #EEEBDC
skinparam handwritten true

skinparam sequenceArrowColor DeepSkyBlue
skinparam sequenceActorBorderColor DeepSkyBlue
skinparam sequenceLifeLineBorderColor blue
skinparam sequenceLifeLineBackgroundColor #A9DCDF
skinparam sequenceParticipantBorderColor DeepSkyBlue
skinparam sequenceParticipantBackgroundColor DodgerBlue
skinparam sequenceParticipantFontName Impact
skinparam sequenceParticipantFontSize 17
skinparam sequenceParticipantFontColor #A9DCDF
skinparam sequenceActorBackgroundColor aqua
skinparam sequenceActorFontColor DeepSkyBlue
skinparam sequenceActorFontSize 17
skinparam sequenceActorFontName Aapex

actor User
participant "First Class" as ParticipantA
participant "Second Class" as ParticipantB
participant "Last Class" as ParticipantC

User -> ParticipantA: DoWork
activate ParticipantA

ParticipantA -> ParticipantB: Create Request
activate ParticipantB

ParticipantB -> ParticipantC: DoWork
activate ParticipantC
ParticipantC --> ParticipantB: WorkDone
destroy ParticipantC

ParticipantB --> ParticipantA: Request Created
deactivate ParticipantB

ParticipantA --> User: Done
deactivate ParticipantA
@enduml
</plantuml>

is compressed to a

* [[http://www.plantuml.com/plantuml/uml/ZP4zRy8m48Pt_ueJdHawLMMe53iWLK9LLLHrFk8hM04xd9rI-kiR0u8a1CAG8SdpVja-DxP0nZNCCSiNx4ghbLivXeVnU2nJ9Vo9MABLMpOXa8N09OdQFq-Racn62RFR7WnIecAMx-Ig8Zl0B3YMZZNnFVZKV5UFfRfYteEs1oNFgKed7Oftv60oKw0DzpUgYrf9gTCBudxTnDdmXck2rtM1MUY7P-QFuF6f7-nRV3ZzLctSb7YDFPlUSQstgvwG_VG42_eL0kD7-FJ4eZXFWS74i0-WLkZz0D13RMVI96UKEQkxKTb4ftZDKmaHEy3mfP4qggxqot4UQveV3DJi8UflBQqSWMAAae-utuTE3zdma2qFTJDVrQKAXXVvKPawIq9NyUnshS7Du8lbnzh75ReowH-Gx7tYISRc--JEa_i7|428-char string length using Deflate]]
* [[http://www.plantuml.com/plantuml/uml/06tq404I5ENsC6cXKT6xxgxaBDG3o_tzkTRbkDJuRa4mYLIoIEFVZsapwhAr5NDHB0jrZfWK5MOp8y53KKy_J2adzUr-HCAJ8bVfEA7x6qMwXhNtcUJYCT4gMZV_c2gzJk9gimqo81bOfXLN-tkYpiaWi3aabF_wrItuxPLX5NINL6FKhAboWjmXbI8jiBfIRnXs0h40re09D-HpekC83iDO8GEXFHTCMoPlXmKCx05mLK_fTdsZCJY1geDzQhs6aar6qIIfU1V5QYHQ5wvIFj8v6xZE0zWeZksK6S5mgnjDR9L1ao9uZg7-gFLepB1EeGVeUILgETgbkEtuAelaPmmGV7kEDjEioz1d6D_0WvvYzGbScBwP8CnA9ZosEQ2vGlBk_7W00|393-char string length using Brotli]]


Please report any bugs to plantuml@gmail.com or here.
This website is still in beta testing.