Fixing minor bug with line shapes not being hidden, and changing first child line type to curved

This commit is contained in:
Pablo Luna 2011-02-06 14:10:12 +01:00
parent c4858265b1
commit 0b742f2577
2 changed files with 31 additions and 3 deletions

View File

@ -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;

View File

@ -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)