updating icons position when changeing font size

This commit is contained in:
Pablo Luna 2011-02-09 16:50:33 +01:00
parent df0a9a4496
commit 98c1c9428d
2 changed files with 22 additions and 11 deletions

View File

@ -18,23 +18,16 @@
mindplot.IconGroup = function(topic) { mindplot.IconGroup = function(topic) {
var offset = topic.getOffset(); var offset = topic.getOffset();
var text = topic.getTextShape();
var yOffset = text.getPosition().y;
var shape = topic.getShapeType();
if(shape==mindplot.NodeModel.SHAPE_TYPE_ELIPSE){
yOffset +=2;
} else if( shape == mindplot.NodeModel.SHAPE_TYPE_LINE){
yOffset -=2;
}
this.options = { this.options = {
width:0, width:0,
height:0, height:0,
x:offset / 2, x:offset.x / 2,
y:yOffset, y:offset.y,
icons:[], icons:[],
topic:topic, topic:topic,
nativeElem:new web2d.Group({width: 2, height:2,x: offset / 2, y:yOffset, coordSizeWidth:1,coordSizeHeight:1}) nativeElem:new web2d.Group({width: 2, height:2,x: offset, y:offset, coordSizeWidth:1,coordSizeHeight:1})
}; };
this.updateIconGroupPosition();
this.registerListeners(); this.registerListeners();
}; };
@ -187,4 +180,19 @@ mindplot.IconGroup.prototype.registerListeners = function() {
}; };
mindplot.IconGroup.prototype.getTopic = function() { mindplot.IconGroup.prototype.getTopic = function() {
return this.options.topic; return this.options.topic;
};
mindplot.IconGroup.prototype.updateIconGroupPosition = function() {
var offsets = this._calculateOffsets();
this.setPosition(offsets.x, offsets.y);
};
mindplot.IconGroup.prototype._calculateOffsets = function() {
var offset = this.options.topic.getOffset();
var text = this.options.topic.getTextShape();
var sizeHeight = text.getHtmlFontSize();
var yOffset = offset;
var shape = this.options.topic.getShapeType();
yOffset = text.getPosition().y + (sizeHeight - 18)/2;
return {x:offset, y:yOffset};
}; };

View File

@ -1313,5 +1313,8 @@ mindplot.Topic.prototype.updateNode = function()
// Positionate node ... // Positionate node ...
textShape.setPosition(iconOffset+this._offset, pos); textShape.setPosition(iconOffset+this._offset, pos);
textShape.setTextSize(sizeWidth, sizeHeight); textShape.setTextSize(sizeWidth, sizeHeight);
var iconGroup = this.getIconGroup();
if(core.Utils.isDefined(iconGroup))
iconGroup.updateIconGroupPosition();
} }
}; };