override fun getPath()

in code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FBConnectionPathSynchronizer.kt [21:68]


    override fun getPath(connection: NetworkConnectionView): (Point, Point) -> FBConnectionPath {
        val path = connection.connectionPath
        val dx1 = (scale * path.dX1).toInt()
        val dy = (scale * path.dY).toInt()
        val dx2 = (scale * path.dX2).toInt()
        return { sourcePosition: Point, targetPosition: Point ->
            val x1 = sourcePosition.x + viewpoint.toEditorDimension(dx1)
            val y = sourcePosition.y + viewpoint.toEditorDimension(dy)
            val x2 = targetPosition.x - viewpoint.toEditorDimension(dx2)
            when (path.kind) {
                ConnectionPath.Kind.Straight -> {
                    val fbConnectionPath = FBConnectionPath(sourcePosition, targetPosition)
                    val fbConnectionPathWithOffset = getFBConnectionPathWithOffset(connection, fbConnectionPath)
                    getBrokenConnectionIfNecessary(connection, fbConnectionPathWithOffset)
                }

                ConnectionPath.Kind.TwoAngles -> {
                    val editorBendPoints = mutableListOf(
                        Point(x1, sourcePosition.y),
                        Point(x1, targetPosition.y)
                    )
                    val fbConnectionPath = FBConnectionPath(sourcePosition, targetPosition, editorBendPoints)
                    val fbConnectionPathWithOffset = getFBConnectionPathWithOffset(connection, fbConnectionPath)
                    getBrokenConnectionIfNecessary(connection, fbConnectionPathWithOffset)
                }

                ConnectionPath.Kind.FourAngles -> {
                    val editorBendPoints = mutableListOf(
                        Point(x1, sourcePosition.y),
                        Point(x1, y),
                        Point(x2, y),
                        Point(x2, targetPosition.y)
                    )
                    val fbConnectionPath = FBConnectionPath(sourcePosition, targetPosition, editorBendPoints)
                    val fbConnectionPathWithOffset = getFBConnectionPathWithOffset(connection, fbConnectionPath)
                    getBrokenConnectionIfNecessary(connection, fbConnectionPathWithOffset)
                }

                ConnectionPath.Kind.MoreThanFour -> {
                    check(path is LongConnectionPath)
                    val editorBendPoints = editorBendPoints(path)
                    val fbConnectionPath = FBConnectionPath(sourcePosition, targetPosition, editorBendPoints)
                    val fbConnectionPathWithOffset = getFBConnectionPathWithOffset(connection, fbConnectionPath)
                    getBrokenConnectionIfNecessary(connection, fbConnectionPathWithOffset)
                }
            }
        }
    }