# all files / diagram-js/lib/layout/ BaseLayouter.js

33.33% Statements 1/3
0% Branches 0/10
0% Functions 0/2
33.33% Lines 1/3

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38

    1×

     import {
      getMid
    } from './LayoutUtil';

    /**
     * A base connection layouter implementation
     * that layouts the connection by directly connecting
     * mid(source) + mid(target).
     */
    export default function BaseLayouter() {}

    /**
     * Return the new layouted waypoints for the given connection.
     *
     * The connection passed is still unchanged; you may figure out about
     * the new connection start / end via the layout hints provided.
     *
     * @param {djs.model.Connection} connection
     * @param {Object} [hints]
     * @param {Point} [hints.connectionStart]
     * @param {Point} [hints.connectionEnd]
     * @param {Point} [hints.source]
     * @param {Point} [hints.target]
     *
     * @return {Array<Point>} the layouted connection waypoints
     */
    BaseLayouter.prototype.layoutConnection = function(connection, hints) {

      hints = hints || {};

      return [
        hints.connectionStart || getMid(hints.source || connection.source),
        hints.connectionEnd || getMid(hints.target || connection.target)
      ];
    };