From 314df3ca681e80fde66850148897eb5d5439b69d Mon Sep 17 00:00:00 2001 From: Pablo Luna Date: Mon, 24 Jan 2011 10:55:06 -0300 Subject: [PATCH] fixing arrows and curved lines default control points --- core-js/src/main/javascript/Utils.js | 2 +- mindplot/src/main/javascript/ControlPoint.js | 2 + .../src/main/javascript/MindmapDesigner.js | 4 +- .../src/main/javascript/RelationshipLine.js | 39 +++++++++++++++-- .../commands/MoveControlPointCommand.js | 24 +++++------ .../javascript/peer/svg/CurvedLinePeer.js | 43 ------------------- wise-webapp/src/main/webapp/css/editor.css | 13 +++++- .../src/main/webapp/jsp/mindmapEditor.jsp | 2 +- 8 files changed, 65 insertions(+), 64 deletions(-) diff --git a/core-js/src/main/javascript/Utils.js b/core-js/src/main/javascript/Utils.js index 1fa6518d..c9ac70f2 100644 --- a/core-js/src/main/javascript/Utils.js +++ b/core-js/src/main/javascript/Utils.js @@ -269,5 +269,5 @@ core.Utils.calculateDefaultControlPoints = function(srcPos, tarPos){ var x2 = tarPos.x + Math.sqrt(l*l/(1+(m*m)))*fix*-1; var y2= m*(x2-tarPos.x)+tarPos.y; - return [new core.Point(x1,y1),new core.Point(x2,y2)]; + return [new core.Point(-srcPos.x + x1,-srcPos.y + y1),new core.Point(-tarPos.x + x2,-tarPos.y + y2)]; }; \ No newline at end of file diff --git a/mindplot/src/main/javascript/ControlPoint.js b/mindplot/src/main/javascript/ControlPoint.js index e706803a..1032213a 100644 --- a/mindplot/src/main/javascript/ControlPoint.js +++ b/mindplot/src/main/javascript/ControlPoint.js @@ -91,9 +91,11 @@ mindplot.ControlPoint.prototype._mouseMove = function(event, point) { if(point==0){ var cords = core.Utils.calculateRelationShipPointCoordinates(this._line.getSourceTopic(),pos); this._line.setFrom(cords.x, cords.y); + this._line.setSrcControlPoint(new core.Point(pos.x - cords.x,pos.y - cords.y)); }else{ var cords = core.Utils.calculateRelationShipPointCoordinates(this._line.getTargetTopic(),pos); this._line.setTo(cords.x, cords.y); + this._line.setDestControlPoint(new core.Point(pos.x - cords.x,pos.y - cords.y)); } this._controls[point].x=(pos.x - cords.x); this._controls[point].y=(pos.y - cords.y); diff --git a/mindplot/src/main/javascript/MindmapDesigner.js b/mindplot/src/main/javascript/MindmapDesigner.js index 36063f15..94385da4 100644 --- a/mindplot/src/main/javascript/MindmapDesigner.js +++ b/mindplot/src/main/javascript/MindmapDesigner.js @@ -644,11 +644,11 @@ mindplot.MindmapDesigner.prototype._buildRelationship = function (model) { var relationLine = new mindplot.RelationshipLine(fromTopic, toTopic, model.getLineType()); if(core.Utils.isDefined(model.getSrcCtrlPoint())){ var srcPoint = model.getSrcCtrlPoint().clone(); - relationLine.getLine().setSrcControlPoint(srcPoint); + relationLine.setSrcControlPoint(srcPoint); } if(core.Utils.isDefined(model.getDestCtrlPoint())){ var destPoint = model.getDestCtrlPoint().clone(); - relationLine.getLine().setDestControlPoint(destPoint); + relationLine.setDestControlPoint(destPoint); } diff --git a/mindplot/src/main/javascript/RelationshipLine.js b/mindplot/src/main/javascript/RelationshipLine.js index cbe3f08e..0b6d5d3c 100644 --- a/mindplot/src/main/javascript/RelationshipLine.js +++ b/mindplot/src/main/javascript/RelationshipLine.js @@ -61,10 +61,10 @@ mindplot.RelationshipLine.prototype.redraw = function() var ctrlPoints = this._line2d.getControlPoints(); if(!core.Utils.isDefined(ctrlPoints[0].x) || !core.Utils.isDefined(ctrlPoints[1].x)){ 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; + 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 spoint = new core.Point(); spoint.x=parseInt(ctrlPoints[0].x)+parseInt(sourcePosition.x); @@ -233,4 +233,35 @@ mindplot.RelationshipLine.prototype.setTo = function(x,y){ this._endArrow.setFrom(x,y); }; +mindplot.RelationshipLine.prototype.setSrcControlPoint = function(control){ + this._line2d.setSrcControlPoint(control); + this._startArrow.setControlPoint(control); +}; + +mindplot.RelationshipLine.prototype.setDestControlPoint = function(control){ + this._line2d.setDestControlPoint(control); + this._endArrow.setControlPoint(control); +}; + +mindplot.RelationshipLine.prototype.getControlPoints = function(){ + return this._line2d.getControlPoints(); +}; + +mindplot.RelationshipLine.prototype.isSrcControlPointCustom = function(){ + return this._line2d..isSrcControlPointCustom(); +}; + +mindplot.RelationshipLine.prototype.isDestControlPointCustom = function(){ + return this._line2d.isDestControlPointCustom(); +}; + +mindplot.RelationshipLine.prototype.setIsSrcControlPointCustom = function(isCustom){ + this._line2d.setIsSrcControlPointCustom(isCustom); +}; + +mindplot.RelationshipLine.prototype.setIsDestControlPointCustom = function(isCustom){ + this._line2d.setIsDestControlPointCustom(isCustom); +}; + + mindplot.RelationshipLine.type = "RelationshipLine"; \ No newline at end of file diff --git a/mindplot/src/main/javascript/commands/MoveControlPointCommand.js b/mindplot/src/main/javascript/commands/MoveControlPointCommand.js index 5ea45d93..2dbf2313 100644 --- a/mindplot/src/main/javascript/commands/MoveControlPointCommand.js +++ b/mindplot/src/main/javascript/commands/MoveControlPointCommand.js @@ -45,16 +45,16 @@ mindplot.commands.MoveControlPointCommand = mindplot.Command.extend( switch (this._point){ case 0: model.setSrcCtrlPoint(this._controlPoint.clone()); - this._line.getLine().setFrom(this._endPoint.x, this._endPoint.y); - this._line.getLine().setIsSrcControlPointCustom(true); - this._line.getLine().setSrcControlPoint(this._controlPoint.clone()); + this._line.setFrom(this._endPoint.x, this._endPoint.y); + this._line.setIsSrcControlPointCustom(true); + this._line.setSrcControlPoint(this._controlPoint.clone()); break; case 1: model.setDestCtrlPoint(this._controlPoint.clone()); this._wasCustom = this._line.getLine().isDestControlPointCustom(); - this._line.getLine().setTo(this._endPoint.x, this._endPoint.y); - this._line.getLine().setIsDestControlPointCustom(true); - this._line.getLine().setDestControlPoint(this._controlPoint.clone()); + this._line.setTo(this._endPoint.x, this._endPoint.y); + this._line.setIsDestControlPointCustom(true); + this._line.setDestControlPoint(this._controlPoint.clone()); break; } if(this._line.isOnFocus()){ @@ -70,18 +70,18 @@ mindplot.commands.MoveControlPointCommand = mindplot.Command.extend( switch (this._point){ case 0: if(core.Utils.isDefined(this._oldControlPoint)){ - line.getLine().setFrom(this._originalEndPoint.x, this._originalEndPoint.y); + line.setFrom(this._originalEndPoint.x, this._originalEndPoint.y); model.setSrcCtrlPoint(this._oldControlPoint.clone()); - line.getLine().setSrcControlPoint(this._oldControlPoint.clone()); - line.getLine().setIsSrcControlPointCustom(this._wasCustom); + line.setSrcControlPoint(this._oldControlPoint.clone()); + line.setIsSrcControlPointCustom(this._wasCustom); } break; case 1: if(core.Utils.isDefined(this._oldControlPoint)){ - line.getLine().setTo(this._originalEndPoint.x, this._originalEndPoint.y); + line.setTo(this._originalEndPoint.x, this._originalEndPoint.y); model.setDestCtrlPoint(this._oldControlPoint.clone()); - line.getLine().setDestControlPoint(this._oldControlPoint.clone()); - line.getLine().setIsDestControlPointCustom(this._wasCustom); + line.setDestControlPoint(this._oldControlPoint.clone()); + line.setIsDestControlPointCustom(this._wasCustom); } break; } diff --git a/web2d/src/main/javascript/peer/svg/CurvedLinePeer.js b/web2d/src/main/javascript/peer/svg/CurvedLinePeer.js index 6830c082..a2c793c7 100644 --- a/web2d/src/main/javascript/peer/svg/CurvedLinePeer.js +++ b/web2d/src/main/javascript/peer/svg/CurvedLinePeer.js @@ -153,49 +153,6 @@ web2d.peer.svg.CurvedLinePeer.prototype.isShowStartArrow = function(){ web2d.peer.svg.CurvedLinePeer.prototype._updatePath = function(avoidControlPointFix) { this._calculateAutoControlPoints(avoidControlPointFix); - var x,y, xp, yp; - if(this._showEndArrow){ - if(this._control2.y == 0) - this._control2.y=1; - var y0 = this._control2.y; - var x0 = this._control2.x; - var x2=x0+y0; - var y2 = y0-x0; - var x3 = x0-y0; - var y3 = y0+x0; - var m = y2/x2; - var mp = y3/x3; - var l = 6; - var pow = Math.pow; - x = (x2==0?0:Math.sqrt(pow(l,2)/(1+pow(m,2)))); - x *=Math.sign(x2); - y = (x2==0?l*Math.sign(y2):m*x); - xp = (x3==0?0:Math.sqrt(pow(l,2)/(1+pow(mp,2)))); - xp *=Math.sign(x3); - yp = (x3==0?l*Math.sign(y3):mp*xp); - } - var xs2,ys2, xp2, yp2; - if(this._showStartArrow){ - if(this._control1.y == 0) - this._control1.y=1; - var y02 = this._control1.y; - var x02 = this._control1.x; - var x22=x02+y02; - var y22 = y02-x02; - var x32 = x02-y02; - var y32 = y02+x02; - var m2 = y22/x22; - var mp2 = y32/x32; - var l2 = 6; - var pow2 = Math.pow; - xs2 = (x22==0?0:Math.sqrt(pow2(l2,2)/(1+pow2(m2,2)))); - xs2 *=Math.sign(x22); - ys2 = (x22==0?l2*Math.sign(y22):m2*xs2); - xp2 = (x32==0?0:Math.sqrt(pow2(l2,2)/(1+pow2(mp2,2)))); - xp2 *=Math.sign(x32); - yp2 = (x32==0?l2*Math.sign(y32):mp2*xp2); - } - var path = "M"+this._x1+","+this._y1 +" C"+(this._control1.x+this._x1)+","+(this._control1.y+this._y1)+" " +(this._control2.x+this._x2)+","+(this._control2.y+this._y2)+" " diff --git a/wise-webapp/src/main/webapp/css/editor.css b/wise-webapp/src/main/webapp/css/editor.css index 6407d074..85b32a95 100644 --- a/wise-webapp/src/main/webapp/css/editor.css +++ b/wise-webapp/src/main/webapp/css/editor.css @@ -645,7 +645,7 @@ ol#toc span { } #workspaceContainer { - /*background: url(../images/grid.gif) bottom left repeat !important;*/ + background: url(../images/grid.gif) bottom left repeat !important; } div#mapInfo { @@ -757,3 +757,14 @@ div#toolbar .topicRelation { behavior: url(../css/iepngfix.htc); z-index: 4; } + +div#toolbar .topicRelation:hover { + width:56px; + background: url(../images/topic_relationship.png) no-repeat center top; + behavior: url(../css/iepngfix.htc); + z-index: 4; +} + +div#toolbar .relationshiplabel{ + width:56px; +} diff --git a/wise-webapp/src/main/webapp/jsp/mindmapEditor.jsp b/wise-webapp/src/main/webapp/jsp/mindmapEditor.jsp index 4dba1124..639da6e8 100644 --- a/wise-webapp/src/main/webapp/jsp/mindmapEditor.jsp +++ b/wise-webapp/src/main/webapp/jsp/mindmapEditor.jsp @@ -193,7 +193,7 @@

"> -

+