From 9a94326469eeebf99f41f880dec9088d892088eb Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Tue, 4 Sep 2012 23:29:24 -0300 Subject: [PATCH] - Minor improvement on relationship. Show arrow. --- .../src/main/javascript/ConnectionLine.js | 2 +- .../src/main/javascript/RelationshipPivot.js | 26 ++++++++++++++++--- mindplot/src/main/javascript/Topic.js | 2 +- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/mindplot/src/main/javascript/ConnectionLine.js b/mindplot/src/main/javascript/ConnectionLine.js index 83efabc5..79041834 100644 --- a/mindplot/src/main/javascript/ConnectionLine.js +++ b/mindplot/src/main/javascript/ConnectionLine.js @@ -20,7 +20,7 @@ mindplot.ConnectionLine = new Class({ initialize:function (sourceNode, targetNode, lineType) { $assert(targetNode, 'parentNode node can not be null'); $assert(sourceNode, 'childNode node can not be null'); - $assert(sourceNode != targetNode, 'Cilcular connection'); + $assert(sourceNode != targetNode, 'Circular connection'); this._targetTopic = targetNode; this._sourceTopic = sourceNode; diff --git a/mindplot/src/main/javascript/RelationshipPivot.js b/mindplot/src/main/javascript/RelationshipPivot.js index 933f485a..cd3901c8 100644 --- a/mindplot/src/main/javascript/RelationshipPivot.js +++ b/mindplot/src/main/javascript/RelationshipPivot.js @@ -39,13 +39,24 @@ mindplot.RelationshipPivot = new Class({ this._workspace.enableWorkspaceEvents(false); var sourcePos = sourceTopic.getPosition(); + var strokeColor = mindplot.Relationship.getStrokeColor(); + this._pivot = new web2d.CurvedLine(); this._pivot.setStyle(web2d.CurvedLine.SIMPLE_LINE); - this._pivot.setDashed(2, 2); this._pivot.setFrom(sourcePos.x, sourcePos.y); - this._pivot.setTo(targetPos.x, targetPos.y); - this._workspace.appendChild(this._pivot); + this._pivot.setTo(targetPos.x, targetPos.y); + this._pivot.setStroke(2, 'solid', strokeColor); + this._pivot.setDashed(4, 2); + + this._startArrow = new web2d.Arrow(); + this._startArrow.setStrokeColor(strokeColor); + this._startArrow.setStrokeWidth(2); + this._startArrow.setFrom(sourcePos.x, sourcePos.y); + + + this._workspace.appendChild(this._pivot); + this._workspace.appendChild(this._startArrow); this._workspace.addEvent('mousemove', this._mouseMoveEvent); this._workspace.addEvent('click', this._onClickEvent); @@ -74,10 +85,12 @@ mindplot.RelationshipPivot = new Class({ }.bind(this)); workspace.removeChild(this._pivot); + workspace.removeChild(this._startArrow); workspace.enableWorkspaceEvents(true); this._sourceTopic = null; this._pivot = null; + this._startArrow = null; } }, @@ -85,7 +98,12 @@ mindplot.RelationshipPivot = new Class({ var screen = this._workspace.getScreenManager(); var pos = screen.getWorkspaceMousePosition(event); - this._pivot.setTo(pos.x - 1, pos.y - 1); + var gapDistance = Math.sign(pos.x - this._sourceTopic.getPosition().x) * 5; + this._pivot.setTo(pos.x - gapDistance, pos.y); + var controlPoints = this._pivot.getControlPoints(); + this._startArrow.setFrom(pos.x - gapDistance, pos.y); + this._startArrow.setControlPoint(controlPoints[1]); + event.stopPropagation(); return false; }, diff --git a/mindplot/src/main/javascript/Topic.js b/mindplot/src/main/javascript/Topic.js index b19f2b15..811b16ee 100644 --- a/mindplot/src/main/javascript/Topic.js +++ b/mindplot/src/main/javascript/Topic.js @@ -1025,7 +1025,7 @@ mindplot.Topic = new Class({ connectTo:function (targetTopic, workspace, isVisible) { $assert(!this._outgoingLine, 'Could not connect an already connected node'); - $assert(targetTopic != this, 'Cilcular connection are not allowed'); + $assert(targetTopic != this, 'Circular connection are not allowed'); $assert(targetTopic, 'Parent Graph can not be null'); $assert(workspace, 'Workspace can not be null');