Создание двух независимых деревьев в mxCompactTreeLayout в mxgraph

Пытаюсь создать два независимых дерева в mxGraph, с разными направлениями ветвей, как на картинке нижевведите сюда описание изображения.

Для изменения направления ветвей, надо внести изменения в mxCompactTreeLayout, функцию attachParent:

mxCompactTreeLayout.prototype.attachParentLeft = function(node, height)
{
    var x = this.nodeDistance + this.levelDistance;
    var y2 = (height - node.width) / 2 - this.nodeDistance;
    var y1 = y2 + node.width + 2 * this.nodeDistance - height;
    var direction = -1;
    
    node.child.offsetX = (direction) * (x + node.height);
    node.child.offsetY = y1;
    
    node.contour.upperHead = this.createLine(node.height, 0,
        this.createLine(x, y1, node.contour.upperHead));
    node.contour.lowerHead = this.createLine(node.height, 0,
        this.createLine(x, y2, node.contour.lowerHead));
};

mxCompactTreeLayout.prototype.attachParent = function(node, height)
{
    var x = this.nodeDistance + this.levelDistance;
    var y2 = (height - node.width) / 2 - this.nodeDistance;
    var y1 = y2 + node.width + 2 * this.nodeDistance - height;
    
    node.child.offsetX = x + node.height;
    node.child.offsetY = y1;
    
    node.contour.upperHead = this.createLine(node.height, 0,
        this.createLine(x, y1, node.contour.upperHead));
    node.contour.lowerHead = this.createLine(node.height, 0,
        this.createLine(x, y2, node.contour.lowerHead));
};

Но я не до конца понимаю, как привязать новую функцию attachParentLeft ко второму дереву, чтобы новые блоки создавалась независимо от первого дерева.


Ответы (0 шт):