in code/library/src/main/kotlin/org/fbme/lib/iec61499/parser/FBNetworkConverter.kt [112:150]
protected open fun extractConnectionPath(connectionElement: Element): ConnectionPath {
val dx1Attriubte = connectionElement.getAttribute("dx1")
val dyAttriubte = connectionElement.getAttribute("dy")
val dx2Attriubte = connectionElement.getAttribute("dx2")
return try {
var kind = ConnectionPath.Kind.Straight
var dx1 = 0
var dy = 0
var dx2 = 0
if (dx1Attriubte != null && dyAttriubte != null && dx2Attriubte != null) {
kind = ConnectionPath.Kind.FourAngles
dx1 = dx1Attriubte.floatValue.toInt()
dy = dyAttriubte.floatValue.toInt()
dx2 = dx2Attriubte.floatValue.toInt()
} else if (dx1Attriubte != null) {
kind = ConnectionPath.Kind.TwoAngles
dx1 = dx1Attriubte.floatValue.toInt()
}
val bendPointsElement = connectionElement.getChild("BendPoints")
if (bendPointsElement != null) {
val bendPointsElementChildren = bendPointsElement.getChildren("BendPoint")
try {
val bendPoints: MutableList<Point> = ArrayList()
for (bendPointElement in bendPointsElementChildren) {
val x = bendPointElement.getAttributeValue("x").toFloat().toInt()
val y = bendPointElement.getAttributeValue("y").toFloat().toInt()
val bendPoint = Point(x, y)
bendPoints.add(bendPoint)
}
return LongConnectionPath(dx1, dy, dx2, bendPoints)
} catch (e: NumberFormatException) {
// ignore
}
}
ConnectionPath(kind, dx1, dy, dx2)
} catch (e: DataConversionException) {
ConnectionPath()
}
}