fun getPathFactory()

in code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FBConnectionUtils.kt [17:34]


    fun getPathFactory(style: Style): BiFunction<Point, Point, FBConnectionPath> {
        return BiFunction { source: Point, target: Point ->
            if (target.x - source.x < 2 * padding(style)) {
                var y = (source.y + target.y) / 2
                if (y >= source.y && y - padding(style) < source.y) {
                    y = source.y + padding(style)
                } else if (y < source.y && y + padding(style) > source.y) {
                    y = source.y - padding(style)
                }
                val x1 = source.x + padding(style)
                val x2 = target.x - padding(style)
                FBConnectionPath(source, target, ConnectionPath.Kind.FourAngles, x1, y, x2)
            } else {
                val x1 = (source.x + target.x) / 2
                FBConnectionPath(source, target, ConnectionPath.Kind.TwoAngles, x1, 0, 0)
            }
        }
    }