From 0b742f257742a920da9440169e395cd21c9c5099 Mon Sep 17 00:00:00 2001 From: Pablo Luna Date: Sun, 6 Feb 2011 14:10:12 +0100 Subject: [PATCH] Fixing minor bug with line shapes not being hidden, and changing first child line type to curved --- mindplot/src/main/javascript/ConnectionLine.js | 18 +++++++++++++++++- mindplot/src/main/javascript/MainTopic.js | 16 ++++++++++++++-- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/mindplot/src/main/javascript/ConnectionLine.js b/mindplot/src/main/javascript/ConnectionLine.js index 5bb621fc..089d81c4 100644 --- a/mindplot/src/main/javascript/ConnectionLine.js +++ b/mindplot/src/main/javascript/ConnectionLine.js @@ -29,8 +29,13 @@ mindplot.ConnectionLine = function(sourceNode, targetNode, lineType) var line; if (targetNode.getType() == mindplot.NodeModel.CENTRAL_TOPIC_TYPE) { - line = this._createLine(lineType,mindplot.ConnectionLine.SIMPLE); + line = this._createLine(lineType,mindplot.ConnectionLine.SIMPLE_CURVED); // line = new web2d.Line(); + if(line.getType()=="CurvedLine"){ + var ctrlPoints = this._getCtrlPoints(sourceNode, targetNode); + line.setSrcControlPoint(ctrlPoints[0]); + line.setDestControlPoint(ctrlPoints[1]); + } line.setStroke(1, 'solid', strokeColor); } else { @@ -42,6 +47,17 @@ mindplot.ConnectionLine = function(sourceNode, targetNode, lineType) this._line2d = line; }; +mindplot.ConnectionLine.prototype._getCtrlPoints = function(sourceNode, targetNode){ + var srcPos = sourceNode.getPosition(); + var destPos = targetNode.getPosition(); + var deltaX = Math.abs(Math.abs(srcPos.x) - Math.abs(destPos.x))/3; + var fix = 1; + if(mindplot.util.Shape.isAtRight(srcPos, destPos)){ + fix=-1; + } + return [new core.Point(deltaX*fix, 0), new core.Point(deltaX*-fix, 0)]; +}; + mindplot.ConnectionLine.prototype._createLine = function(lineType, defaultStyle){ if(!core.Utils.isDefined(lineType)){ lineType = defaultStyle; diff --git a/mindplot/src/main/javascript/MainTopic.js b/mindplot/src/main/javascript/MainTopic.js index 4fc2e56b..52e78a74 100644 --- a/mindplot/src/main/javascript/MainTopic.js +++ b/mindplot/src/main/javascript/MainTopic.js @@ -133,16 +133,23 @@ mindplot.MainTopic.prototype._defaultShapeType = function() mindplot.MainTopic.prototype.updateTopicShape = function(targetTopic, workspace) { // Change figure based on the connected topic ... + var model = this.getModel(); + var shapeType = model.getShapeType(); if (targetTopic.getType() != mindplot.NodeModel.CENTRAL_TOPIC_TYPE) { - var model = this.getModel(); - var shapeType = model.getShapeType(); if (!shapeType) { // Get the real shape type ... shapeType = this.getShapeType(); this._setShapeType(mindplot.NodeModel.SHAPE_TYPE_LINE, false); + }else if(shapeType==mindplot.NodeModel.SHAPE_TYPE_LINE){ + var innerShape = this.getInnerShape(); + innerShape.setVisibility(false); + } + } else { + var innerShape = this.getInnerShape(); + innerShape.setVisibility(true); } }; @@ -159,6 +166,8 @@ mindplot.MainTopic.prototype.disconnect = function(workspace) shapeType = this.getShapeType(); this._setShapeType(mindplot.NodeModel.SHAPE_TYPE_ROUNDED_RECT, false); } + var innerShape = this.getInnerShape(); + innerShape.setVisibility(true); }; mindplot.MainTopic.prototype.getTopicType = function() @@ -252,6 +261,9 @@ mindplot.MainTopic.prototype.workoutOutgoingConnectionPoint = function(targetPos // In this case, connetion line is not used as shape figure. result = mindplot.util.Shape.calculateRectConnectionPoint(pos, size, isAtRight, true); result.y = pos.y + (size.height / 2); + if(result.y>0){ + result.y+=1; + } // Correction factor ... if (!isAtRight)