Making curved line control point relative and Importing Freemind relationship lines curve control points

This commit is contained in:
Pablo Luna
2011-01-14 14:10:15 -03:00
parent 8db75a940d
commit 4777ccf6fb
13 changed files with 124 additions and 48 deletions

View File

@@ -52,14 +52,14 @@ mindplot.ControlPoint.prototype.setLine= function(line) {
mindplot.ControlPoint.prototype._createControlPoint = function() {
this._controls= this._line.getLine().getControlPoints();
this._controlPointsController[0].setPosition(this._controls[mindplot.ControlPoint.FROM].x, this._controls[mindplot.ControlPoint.FROM].y-3);
this._controlPointsController[1].setPosition(this._controls[mindplot.ControlPoint.TO].x, this._controls[mindplot.ControlPoint.TO].y-3);
var pos = this._line.getLine().getFrom();
this._controlPointsController[0].setPosition(this._controls[mindplot.ControlPoint.FROM].x+pos.x, this._controls[mindplot.ControlPoint.FROM].y+pos.y-3);
this._controlLines[0].setFrom(pos.x, pos.y);
this._controlLines[0].setTo(this._controls[mindplot.ControlPoint.FROM].x+3, this._controls[mindplot.ControlPoint.FROM].y);
this._controlLines[0].setTo(this._controls[mindplot.ControlPoint.FROM].x+pos.x+3, this._controls[mindplot.ControlPoint.FROM].y+pos.y);
pos = this._line.getLine().getTo();
this._controlLines[1].setFrom(pos.x, pos.y);
this._controlLines[1].setTo(this._controls[mindplot.ControlPoint.TO].x+3, this._controls[mindplot.ControlPoint.TO].y);
this._controlLines[1].setTo(this._controls[mindplot.ControlPoint.TO].x+pos.x+3, this._controls[mindplot.ControlPoint.TO].y+pos.y);
this._controlPointsController[1].setPosition(this._controls[mindplot.ControlPoint.TO].x+pos.x, this._controls[mindplot.ControlPoint.TO].y+pos.y-3);
};
@@ -91,8 +91,8 @@ mindplot.ControlPoint.prototype._mouseMove = function(event, point) {
var cords = core.Utils.calculateRelationShipPointCoordinates(this._line.getTargetTopic(),pos);
this._line.getLine().setTo(cords.x, cords.y);
}
this._controls[point].x=pos.x;
this._controls[point].y=pos.y;
this._controls[point].x=(pos.x - cords.x);
this._controls[point].y=(pos.y - cords.y);
this._controlPointsController[point].setPosition(pos.x-5,pos.y-3);
this._controlLines[point].setFrom(cords.x, cords.y);
this._controlLines[point].setTo(pos.x-2,pos.y);

View File

@@ -30,14 +30,20 @@ mindplot.RelationshipLine.prototype.redraw = function()
this._line2d.setStroke(2);
var ctrlPoints = this._line2d.getControlPoints();
if(!core.Utils.isDefined(ctrlPoints[0].x) || !core.Utils.isDefined(ctrlPoints[1].x)){
var defaultPoints = core.Utils.calculateDefaultControlPoints(sourceTopic.getPosition(), targetTopic.getPosition());
ctrlPoints[0].x=defaultPoints[0].x;
ctrlPoints[0].y=defaultPoints[0].y;
ctrlPoints[1].x=defaultPoints[1].x;
ctrlPoints[1].y=defaultPoints[1].y;
var defaultPoints = core.Utils.calculateDefaultControlPoints(sourcePosition, targetPosition);
ctrlPoints[0].x=sourcePosition.x - defaultPoints[0].x;
ctrlPoints[0].y=sourcePosition.y - defaultPoints[0].y;
ctrlPoints[1].x=targetPosition.x - defaultPoints[1].x;
ctrlPoints[1].y=targetPosition.y - defaultPoints[1].y;
}
sPos = core.Utils.calculateRelationShipPointCoordinates(sourceTopic,ctrlPoints[0]);
tPos = core.Utils.calculateRelationShipPointCoordinates(targetTopic,ctrlPoints[1]);
var spoint = new core.Point();
spoint.x=parseInt(ctrlPoints[0].x)+parseInt(sourcePosition.x);
spoint.y=parseInt(ctrlPoints[0].y)+parseInt(sourcePosition.y);
var tpoint = new core.Point();
tpoint.x=parseInt(ctrlPoints[1].x)+parseInt(targetPosition.x);
tpoint.y=parseInt(ctrlPoints[1].y)+parseInt(targetPosition.y);
sPos = core.Utils.calculateRelationShipPointCoordinates(sourceTopic,spoint);
tPos = core.Utils.calculateRelationShipPointCoordinates(targetTopic,tpoint);
line2d.setFrom(sPos.x, sPos.y);
line2d.setTo(tPos.x, tPos.y);

View File

@@ -10,6 +10,7 @@ mindplot.RelationshipModel = function(fromNode, toNode)
this._srcCtrlPoint=null;
this._destCtrlPoint=null;
this._endArrow=true;
this._ctrlPointRelative=false;
};