mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-11-14 10:47:57 +01:00
changing default shapes to be all lines, and fixing text centering bug
This commit is contained in:
parent
0f496bb4b3
commit
d97121ce87
@ -39,7 +39,12 @@ mindplot.ConnectionLine = function(sourceNode, targetNode, lineType)
|
||||
line.setStroke(1, 'solid', strokeColor);
|
||||
} else
|
||||
{
|
||||
line = this._createLine(lineType,mindplot.ConnectionLine.POLYLINE);
|
||||
line = this._createLine(lineType,mindplot.ConnectionLine.SIMPLE_CURVED);
|
||||
if(line.getType()=="CurvedLine"){
|
||||
var ctrlPoints = this._getCtrlPoints(sourceNode, targetNode);
|
||||
line.setSrcControlPoint(ctrlPoints[0]);
|
||||
line.setDestControlPoint(ctrlPoints[1]);
|
||||
}
|
||||
// line = new web2d.PolyLine();
|
||||
line.setStroke(1, 'solid', strokeColor);
|
||||
}
|
||||
@ -48,14 +53,10 @@ mindplot.ConnectionLine = function(sourceNode, targetNode, lineType)
|
||||
};
|
||||
|
||||
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)];
|
||||
var srcPos = sourceNode.workoutOutgoingConnectionPoint(targetNode.getPosition());
|
||||
var destPos = targetNode.workoutIncomingConnectionPoint(sourceNode.getPosition());
|
||||
var deltaX = (srcPos.x -destPos.x)/3;
|
||||
return [new core.Point(deltaX, 0), new core.Point(-deltaX, 0)];
|
||||
};
|
||||
|
||||
mindplot.ConnectionLine.prototype._createLine = function(lineType, defaultStyle){
|
||||
@ -118,6 +119,11 @@ mindplot.ConnectionLine.prototype.redraw = function()
|
||||
line2d.setFrom(tPos.x, tPos.y);
|
||||
line2d.setTo(sPos.x, sPos.y);
|
||||
|
||||
if(line2d.getType()=="CurvedLine"){
|
||||
var ctrlPoints = this._getCtrlPoints(this._sourceTopic, this._targetTopic);
|
||||
line2d.setSrcControlPoint(ctrlPoints[0]);
|
||||
line2d.setDestControlPoint(ctrlPoints[1]);
|
||||
}
|
||||
line2d.moveToBack();
|
||||
|
||||
// Add connector ...
|
||||
|
@ -193,6 +193,6 @@ mindplot.IconGroup.prototype._calculateOffsets = function() {
|
||||
var sizeHeight = text.getHtmlFontSize();
|
||||
var yOffset = offset;
|
||||
var shape = this.options.topic.getShapeType();
|
||||
yOffset = text.getPosition().y + (sizeHeight - 18)/2;
|
||||
yOffset = text.getPosition().y + (sizeHeight - 18)/2 + 1;
|
||||
return {x:offset, y:yOffset};
|
||||
};
|
@ -110,23 +110,7 @@ mindplot.MainTopic.prototype._buildDragShape = function()
|
||||
|
||||
mindplot.MainTopic.prototype._defaultShapeType = function()
|
||||
{
|
||||
var targetTopic = this.getOutgoingConnectedTopic();
|
||||
var result;
|
||||
if (targetTopic)
|
||||
{
|
||||
if (targetTopic.getType() != mindplot.NodeModel.CENTRAL_TOPIC_TYPE)
|
||||
{
|
||||
result = mindplot.NodeModel.SHAPE_TYPE_LINE;
|
||||
|
||||
} else
|
||||
{
|
||||
result = mindplot.NodeModel.SHAPE_TYPE_ROUNDED_RECT;
|
||||
}
|
||||
} else
|
||||
{
|
||||
result = mindplot.NodeModel.SHAPE_TYPE_ROUNDED_RECT;
|
||||
}
|
||||
return result;
|
||||
return mindplot.NodeModel.SHAPE_TYPE_LINE;
|
||||
};
|
||||
|
||||
mindplot.MainTopic.prototype.updateTopicShape = function(targetTopic, workspace)
|
||||
@ -140,15 +124,8 @@ mindplot.MainTopic.prototype.updateTopicShape = function(targetTopic, workspace)
|
||||
{
|
||||
// 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);
|
||||
|
||||
this._setShapeType(shapeType, false);
|
||||
}
|
||||
} else {
|
||||
var innerShape = this.getInnerShape();
|
||||
innerShape.setVisibility(true);
|
||||
}
|
||||
this._helpers.forEach(function(helper){
|
||||
helper.moveToFront();
|
||||
@ -245,25 +222,25 @@ mindplot.MainTopic.prototype.workoutOutgoingConnectionPoint = function(targetPos
|
||||
var result;
|
||||
if (this.getShapeType() == mindplot.NodeModel.SHAPE_TYPE_LINE)
|
||||
{
|
||||
if (!this.isConnectedToCentralTopic())
|
||||
{
|
||||
// if (!this.isConnectedToCentralTopic())
|
||||
// {
|
||||
result = new core.Point();
|
||||
if (!isAtRight)
|
||||
{
|
||||
result.x = pos.x - (size.width / 2);
|
||||
result.x = pos.x + (size.width / 2);
|
||||
} else
|
||||
{
|
||||
result.x = pos.x + (size.width / 2);
|
||||
result.x = pos.x - (size.width / 2);
|
||||
}
|
||||
result.y = pos.y + (size.height / 2);
|
||||
} else
|
||||
/*} else
|
||||
{
|
||||
// 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){
|
||||
*//*if(result.y>0){
|
||||
result.y+=1;
|
||||
}*/
|
||||
}*//*
|
||||
|
||||
// Correction factor ...
|
||||
if (!isAtRight)
|
||||
@ -274,7 +251,7 @@ mindplot.MainTopic.prototype.workoutOutgoingConnectionPoint = function(targetPos
|
||||
result.x = result.x - 2;
|
||||
}
|
||||
|
||||
}
|
||||
}*/
|
||||
} else
|
||||
{
|
||||
result = mindplot.util.Shape.calculateRectConnectionPoint(pos, size, isAtRight, true);
|
||||
|
@ -238,8 +238,8 @@ mindplot.TextEditor.prototype.init = function (nodeGraph)
|
||||
iconGroupSize = {width:0, height:0};
|
||||
}
|
||||
var position = {x:0,y:0};
|
||||
position.x = pos.x - ((textWidth * scale.width) / 2) + ((iconGroupSize.width * scale.width)/2);
|
||||
var fixError = 4;
|
||||
position.x = pos.x - ((textWidth * scale.width) / 2) + (((iconGroupSize.width) * scale.width)/2);
|
||||
var fixError =1;
|
||||
position.y = pos.y - ((textHeight * scale.height) / 2) - fixError;
|
||||
|
||||
editor.setEditorSize(elemSize.width, elemSize.height, scale);
|
||||
|
@ -86,11 +86,6 @@ mindplot.Topic.prototype._setShapeType = function(type, updateModel)
|
||||
innerShape.addEventListener('mousedown', dispatcher._listeners[i]);
|
||||
}
|
||||
}
|
||||
if (!this.isConnectedToCentralTopic() && type == mindplot.NodeModel.SHAPE_TYPE_LINE)
|
||||
{
|
||||
// In this case, The normal connection line is not used.
|
||||
innerShape.setVisibility(false);
|
||||
}
|
||||
|
||||
// Update figure size ...
|
||||
var size = model.getSize();
|
||||
@ -183,7 +178,7 @@ mindplot.Topic.prototype.buildShape = function(attributes, type)
|
||||
}
|
||||
else if (type == mindplot.NodeModel.SHAPE_TYPE_LINE)
|
||||
{
|
||||
result = new web2d.Line();
|
||||
result = new web2d.Line({strokeWidth:1, strokeOpacity:1});
|
||||
result.setSize = function(width, height)
|
||||
{
|
||||
this.size = {width:width, height:height};
|
||||
@ -1360,8 +1355,8 @@ mindplot.Topic.prototype.updateNode = function(updatePosition)
|
||||
var font = textShape.getFont();
|
||||
var iconOffset = this.getIconOffset();
|
||||
var height = sizeHeight + this._offset;
|
||||
var width = sizeWidth + this._offset*2 + iconOffset;
|
||||
var pos = this._offset /2;
|
||||
var width = sizeWidth + this._offset*2 + iconOffset +2;
|
||||
var pos = this._offset /2 -1;
|
||||
if(this.getShapeType()==mindplot.NodeModel.SHAPE_TYPE_ELIPSE){
|
||||
var factor = 0.25;
|
||||
height = (width*factor<height?height:width*factor);
|
||||
@ -1372,7 +1367,7 @@ mindplot.Topic.prototype.updateNode = function(updatePosition)
|
||||
this.setSize(newSize, false, updatePosition);
|
||||
|
||||
// Positionate node ...
|
||||
textShape.setPosition(iconOffset+this._offset, pos);
|
||||
textShape.setPosition(iconOffset+this._offset+2, pos);
|
||||
textShape.setTextSize(sizeWidth, sizeHeight);
|
||||
var iconGroup = this.getIconGroup();
|
||||
if(core.Utils.isDefined(iconGroup))
|
||||
|
@ -22,7 +22,7 @@ mindplot.util.Shape =
|
||||
{
|
||||
core.assert(sourcePoint, "Source can not be null");
|
||||
core.assert(targetPoint, "Target can not be null");
|
||||
return (targetPoint.x - sourcePoint.x) > 0;
|
||||
return sourcePoint.x < targetPoint.x;
|
||||
},
|
||||
workoutDistance: function(sourceNode, targetNode)
|
||||
{
|
||||
|
@ -19,7 +19,7 @@
|
||||
web2d.Line = function(attributes)
|
||||
{
|
||||
var peer = web2d.peer.Toolkit.createLine();
|
||||
var defaultAttributes = {strokeColor:'#495879',strokeWidth:1};
|
||||
var defaultAttributes = {strokeColor:'#495879',strokeWidth:1, strokeOpacity:1};
|
||||
for (var key in attributes)
|
||||
{
|
||||
defaultAttributes[key] = attributes[key];
|
||||
|
@ -62,8 +62,11 @@ web2d.peer.svg.TextPeer.prototype.getText = function()
|
||||
web2d.peer.svg.TextPeer.prototype.setPosition = function(x, y)
|
||||
{
|
||||
this._position = {x:x, y:y};
|
||||
var size = parseInt(this._font.getSize());
|
||||
this._native.setAttribute('y', y + size);
|
||||
var height = this._font.getSize();
|
||||
if(this._parent && this._native.getBBox)
|
||||
height = this.getHeight();
|
||||
var size = parseInt(height);
|
||||
this._native.setAttribute('y', y+size*3/4);
|
||||
//y+size/2
|
||||
this._native.setAttribute('x', x);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user