mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-11-22 06:07:57 +01:00
Fix relationship central node positioning problem ...
This commit is contained in:
parent
f8a6607de9
commit
fc6d91f59e
@ -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();
|
||||
|
@ -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) {
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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;
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user