描画スクリプトの作成

<< 目次を表示 >>

ページ位置:  Enterprise Architectの拡張(SDK) > 描画スクリプト >

描画スクリプトの作成

この章では、描画スクリプトの作成に必要な情報を紹介しています。描画スクリプトを作成する場合には、「はじめに」 および 「サンプルスクリプト」 のページも役立ちます。

 

要素や接続に対して、独自の外見を定義して適用するためには、描画スクリプトを利用して描画内容・大きさ・色などを定義する必要があります。描画スクリプト内では、複数の項目に分けて記述することができます。例えば、要素の場合には以下のような内容を含めることができます。

 

 

接続の場合には、以下の内容を定義できます。

 

 

描画スクリプトは、既定の描画内容を差し替えあるいは上書きする形になります。

 

 

描画スクリプトの中では、C言語のスタイルのコメントを利用することもできます。

 

// C Style Single Line comment

/* Multi Line

comment supported */

 

描画スクリプト内では、大文字小文字は区別されません。

 

 

描画スクリプトの構成

項目

説明

要素の場合の描画スクリプトの構成例

shape main

{

  // draw the object

}

 

shape label

{

    // draw a floating text label

}

 

decoration <identifier>

{

     // draw a 16x16 decoration inside the object

}

 

<identifier> はアルファベットで指定する名前です。

接続の場合の描画スクリプトの構成例

shape main

{

     // draw the line

}

 

shape target

{

     // draw the shape at the target end

}

 

shape source

{

     // draw the shape at the source end

}

 

label <positionLabel>

{

     // define the text for the label

}

 

<positionLabel>は以下のいずれかになります。

  • lefttoplabel
  • leftbottomlabel
  • middletoplabel
  • middlebottomlabel
  • righttoplabel
  • rightbottomlabel

サブシェイプ

描画スクリプト内では、サブシェイプという形で、別のスクリプト群を定義し、呼び出すことができます。以下の内容はサブシェイプの定義の例です。

 

shape main

{

// Initialisation Attributes - these must be

// before drawing commands

noshadow = "true";

h_align = "center";

 

//drawing commands (Methods)

rectangle(0,0,100,100);

println("foo bar");

 

// call the sub-shape

addsubshape("red",   20,  70);

 

// definition of a sub-shape

shape red

{

        setfillcolor(200, 50, 100);

        rectangle(50,50,100,100);

}

}

 

//definition of a label

shape label

{

setOrigin("SW",0,0);

println("Object: #NAME#");

}

 

//definition of a Decoration

decoration triangle

{

 

// Draw a triangle for the decoration

startpath();

moveto(0,30);

lineto(50,100);

lineto(100,0);

 

endpath();

setfillcolor(153,204,255);

fillandstrokepath();

 

}

 

 

上記の内容の描画結果は以下のようになります。

内容の順序

描画スクリプト内では、属性定義・コマンド呼び出し・サブシェイプの定義が含まれます。これらの順序については、属性定義・コマンド呼び出し・サブシェイプの定義の順番でなければなりません。

 

 

参照: