Search code examples
javascriptdraw2d-js

How to properly make one figure child on another in Draw2D Touch


I'm using Draw2D to render diagram. I'm rendering parent rectangles and child rectangles:

var parent = new draw2d.shape.basic.Rectangle(90, 30);

var child1 = new draw2d.shape.basic.Rectangle(30, 30);
var child2 = new draw2d.shape.basic.Rectangle(30, 30);
var child3 = new draw2d.shape.basic.Rectangle(30, 30);

parent.addFigure(child1, new draw2d.layout.locator.CenterLocator(parent));
parent.addFigure(child2, new draw2d.layout.locator.CenterLocator(parent));
parent.addFigure(child3, new draw2d.layout.locator.CenterLocator(parent));

However, according to the documentation,

Add a child figure to the figure. The hands over figure doesn't support drag&drop operations. It's only a decorator for the connection. Mainly for labels or other fancy decorations :-)

Besides, Figure object has no methods insertFigure and removeFigure.

How to properly wrap one figure by another in Draw2D?


Solution

  • Seems, I should use draw2d.shape.layout.VerticalLayout or draw2d.shape.layout.HorizontalLayout to unite figures, but these classes still have no methods for inserting or deleting child nodes.