ライブラリに付属する例のコレクションを調べましたが、残念ながら、合成図に特化したすべての例は、json ファイルの解析に基づいています。
reader.unmarshal(canvas, jsonDocument);
ただし、私が見たいのは、次のような基本的な図から複合図を作成する方法です。
var figure_1 = new draw2d.shape.basic.Rectangle(....);
var figure_1 = new draw2d.shape.basic.Diamond(....);
... then do something, so that figure_1 and figure_2 are now part of
... a composite figure
PS。必要なのはStrongCompositeだと思いますが、使い方がわかりません。誰かが助けてくれることを願っています!
編集
これは私が試したものです:
var baseRectangle = new draw2d.shape.composite.StrongComposite({width: 200, height: 200, x: conf.x, y: conf.y});
var top = new draw2d.shape.basic.Oval({width: 120, height: 40, x: conf.x, y: conf.y});
var bottom = new draw2d.shape.basic.Oval({width: 120, height: 40, x: conf.x, y: conf.y + 60});
baseRectangle.assignFigure(top);
baseRectangle.assignFigure(bottom);
canvas.add(baseRectangle);
しかし、うまくいきません。灰色のボックスしか見えません。私もこれを試しました:
var baseRectangle = new draw2d.shape.composite.StrongComposite({width: 200, height: 200, x: conf.x, y: conf.y});
var top = new draw2d.shape.basic.Oval({width: 120, height: 40, x: conf.x, y: conf.y});
var bottom = new draw2d.shape.basic.Oval({width: 120, height: 40, x: conf.x, y: conf.y + 60});
baseRectangle.assignFigure(top);
baseRectangle.assignFigure(bottom);
canvas.add(top);
canvas.add(bottom);
しかし、その結果、完全に独立した楕円形が得られました。