diff --git a/mindplot/src/main/javascript/ConnectionLine.js b/mindplot/src/main/javascript/ConnectionLine.js index 80d6c2a2..bcf9c1ac 100644 --- a/mindplot/src/main/javascript/ConnectionLine.js +++ b/mindplot/src/main/javascript/ConnectionLine.js @@ -29,16 +29,12 @@ mindplot.ConnectionLine = new Class({ var ctrlPoints = this._getCtrlPoints(sourceNode, targetNode); if (targetNode.getType() == mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE) { line = this._createLine(lineType, mindplot.ConnectionLine.CURVED); - if (line.getType() == "CurvedLine") { - line.setSrcControlPoint(ctrlPoints[0]); - line.setDestControlPoint(ctrlPoints[1]); - } + line.setSrcControlPoint(ctrlPoints[0]); + line.setDestControlPoint(ctrlPoints[1]); } else { line = this._createLine(lineType, mindplot.ConnectionLine.SIMPLE_CURVED); - if (line.getType() == "CurvedLine") { - line.setSrcControlPoint(ctrlPoints[0]); - line.setDestControlPoint(ctrlPoints[1]); - } + line.setSrcControlPoint(ctrlPoints[0]); + line.setDestControlPoint(ctrlPoints[1]); } // Set line styles ... var strokeColor = mindplot.ConnectionLine.getStrokeColor(); diff --git a/mindplot/src/main/javascript/MainTopic.js b/mindplot/src/main/javascript/MainTopic.js index ff50fd0d..d4174b7f 100644 --- a/mindplot/src/main/javascript/MainTopic.js +++ b/mindplot/src/main/javascript/MainTopic.js @@ -98,28 +98,7 @@ mindplot.MainTopic = new Class({ }, workoutIncomingConnectionPoint:function (sourcePosition) { - $assert(sourcePosition, 'sourcePoint can not be null'); - var pos = this.getPosition(); - var size = this.getSize(); - - var isAtRight = mindplot.util.Shape.isAtRight(sourcePosition, pos); - var result = mindplot.util.Shape.calculateRectConnectionPoint(pos, size, isAtRight); - if (this.getShapeType() == mindplot.model.TopicShape.LINE) { - result.y = result.y + (this.getSize().height / 2); - } - - // Move a little the position... - var offset = mindplot.Topic.CONNECTOR_WIDTH / 2; - if (this.getPosition().x > 0) { - result.x = result.x + offset; - } else { - result.x = result.x - offset; - } - - result.x = Math.ceil(result.x); - result.y = Math.ceil(result.y); - return result; - + return mindplot.util.Shape.workoutIncomingConnectionPoint(this, sourcePosition); }, workoutOutgoingConnectionPoint:function (targetPosition) { diff --git a/mindplot/src/main/javascript/Relationship.js b/mindplot/src/main/javascript/Relationship.js index 105cd73e..0ee7e73e 100644 --- a/mindplot/src/main/javascript/Relationship.js +++ b/mindplot/src/main/javascript/Relationship.js @@ -83,14 +83,19 @@ mindplot.Relationship = new Class({ var targetTopic = this._targetTopic; var targetPosition = targetTopic.getPosition(); + if (targetTopic.getType() == mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE) { + targetPosition = mindplot.util.Shape.workoutIncomingConnectionPoint(targetTopic, sourcePosition); + } var sPos, tPos; this._line2d.setStroke(2); var ctrlPoints = this._line2d.getControlPoints(); if (!this._line2d.isDestControlPointCustom() && !this._line2d.isSrcControlPointCustom()) { + var defaultPoints = mindplot.util.Shape.calculateDefaultControlPoints(sourcePosition, targetPosition); ctrlPoints[0].x = defaultPoints[0].x; ctrlPoints[0].y = defaultPoints[0].y; + ctrlPoints[1].x = defaultPoints[1].x; ctrlPoints[1].y = defaultPoints[1].y; } @@ -101,6 +106,7 @@ mindplot.Relationship = new Class({ var tpoint = new core.Point(); tpoint.x = parseInt(ctrlPoints[1].x) + parseInt(targetPosition.x); tpoint.y = parseInt(ctrlPoints[1].y) + parseInt(targetPosition.y); + sPos = mindplot.util.Shape.calculateRelationShipPointCoordinates(sourceTopic, spoint); tPos = mindplot.util.Shape.calculateRelationShipPointCoordinates(targetTopic, tpoint); diff --git a/mindplot/src/main/javascript/util/Shape.js b/mindplot/src/main/javascript/util/Shape.js index 7abfabe4..121c4064 100644 --- a/mindplot/src/main/javascript/util/Shape.js +++ b/mindplot/src/main/javascript/util/Shape.js @@ -97,6 +97,31 @@ mindplot.util.Shape = var y2 = m * (x2 - tarPos.x) + tarPos.y; return [new core.Point(-srcPos.x + x1, -srcPos.y + y1), new core.Point(-tarPos.x + x2, -tarPos.y + y2)]; + }, + + workoutIncomingConnectionPoint:function (targetNode, sourcePosition) { + $assert(sourcePosition, 'sourcePoint can not be null'); + var pos = targetNode.getPosition(); + var size = targetNode.getSize(); + + var isAtRight = mindplot.util.Shape.isAtRight(sourcePosition, pos); + var result = mindplot.util.Shape.calculateRectConnectionPoint(pos, size, isAtRight); + if (targetNode.getShapeType() == mindplot.model.TopicShape.LINE) { + result.y = result.y + (targetNode.getSize().height / 2); + } + + // Move a little the position... + var offset = mindplot.Topic.CONNECTOR_WIDTH / 2; + if (!isAtRight) { + result.x = result.x + offset; + } else { + result.x = result.x - offset; + } + + result.x = Math.ceil(result.x); + result.y = Math.ceil(result.y); + return result; + } };