PlantUML 繪製工具

1 篇文章 / 0 new
author
PlantUML 繪製工具
PlantUML 是一款 UML 的繪製工具, 也包含 Chart
   
►編輯工具
PlantUML QEditor 仍是文字輸入模式
線上工具 CodeUML , 比較不錯的一個, 有些輔助功

►Local 執行
1. 下載 PlantUML.jar , GraphViz 2.28 ,
2. 安裝 graphviz, 然後加入系統環境變數 GRAPHVIZ_DOT = c:\graphviz\bin\dot.exe 參考
3. CMD 下測試是否正常 java -jar plantuml.jar -testdot
4. 若無安裝 garphviz 則僅能使用 sequence Modal

►PHP 線上繪製
$img = "<img src=http://www.plantuml.com/plantuml/png/";
$img .= encodep('
    Alice -> Bob: Authentication Request
    Bob --> Alice: Authentication Response
');
$img .= ">";  
echo $img;
 
function encodep($text) {
     $data = utf8_encode($text);
     $compressed = gzdeflate($data, 9);
     return encode64($compressed);
}
function encode6bit($b) {
     if ($b < 10) {          return chr(48 + $b);     }
     $b -= 10;
     if ($b < 26) {          return chr(65 + $b);     }
     $b -= 26;
     if ($b < 26) {          return chr(97 + $b);     }
     $b -= 26;
     if ($b == 0) {          return '-';     }
     if ($b == 1) {          return '_';     }
     return '?';
}
function append3bytes($b1, $b2, $b3) {
     $c1 = $b1 >> 2;
     $c2 = (($b1 & 0x3) << 4) | ($b2 >> 4);
     $c3 = (($b2 & 0xF) << 2) | ($b3 >> 6);
     $c4 = $b3 & 0x3F;
     $r = "";
     $r .= encode6bit($c1 & 0x3F);
     $r .= encode6bit($c2 & 0x3F);
     $r .= encode6bit($c3 & 0x3F);
     $r .= encode6bit($c4 & 0x3F);
     return $r;
}
function encode64($c) {
     $str = "";
     $len = strlen($c);
     for ($i = 0; $i < $len; $i+=3) {
            if ($i+2==$len) {
                  $str .= append3bytes(ord(substr($c, $i, 1)), ord(substr($c, $i+1, 1)), 0);
            } else if ($i+1==$len) {
                  $str .= append3bytes(ord(substr($c, $i, 1)), 0, 0);
            } else {
                  $str .= append3bytes(ord(substr($c, $i, 1)), ord(substr($c, $i+1, 1)), ord(substr($c, $i+2, 1)));
            }
     }
     return $str;
} 
呈現結果
關鍵字: 
Free Web Hosting