98 lines
3.1 KiB
JavaScript
Raw Normal View History

2011-03-24 18:00:51 +00:00
mindplot.layoutManagers.boards.freeMindBoards.Entry = new Class({
2011-04-08 15:31:40 +01:00
initialize:function(node, useFinalPosition){
2011-03-24 18:00:51 +00:00
this._node = node;
this._DEFAULT_X_GAP = 30;
2011-04-08 15:31:40 +01:00
var pos = node.getModel().getFinalPosition();
2011-04-16 21:41:06 +01:00
if(useFinalPosition && core.Utils.isDefined(pos)){
2011-04-08 15:31:40 +01:00
this.setPosition(pos.x, pos.y);
}
else{
pos = node.getPosition();
2011-04-16 21:41:06 +01:00
if(!core.Utils.isDefined(pos)){
2011-04-08 15:31:40 +01:00
var parent = node.getParent();
pos = parent.getPosition().clone();
var pwidth = parent.getSize().width;
var width = node.getSize().width;
pos.x = pos.x + Math.sign(pos.x) * (this._DEFAULT_X_GAP + pwidth/2 + width/2);
node.setPosition(pos, false);
}
2011-03-24 18:00:51 +00:00
}
this._DEFAULT_GAP = 10;
this.updateMinimumMargin();
2011-04-08 15:31:40 +01:00
this._marginTop = this._minimalMargin;
this._marginBottom = this._minimalMargin;
this._marginTopChildren=0;
this._marginBottomChildren=0;
2011-03-24 18:00:51 +00:00
},
getNode:function(){
return this._node;
},
2011-04-08 15:31:40 +01:00
getId:function(){
return this.getNode().getId();
},
2011-03-24 18:00:51 +00:00
getPosition:function(){
return this._node.getPosition().y;
2011-03-24 18:00:51 +00:00
},
2011-04-08 15:31:40 +01:00
setPosition:function(x,y){
var position = this._node.getPosition().clone();
position.y = y;
if(null != x){
position.x = x;
}
this._node.setPosition(position, false);
2011-03-24 18:00:51 +00:00
},
getMarginTop:function(){
return this._marginTop;
},
setMarginTop:function(value){
2011-04-08 15:31:40 +01:00
if(value >= this._minimalMargin){
2011-03-24 18:00:51 +00:00
this._marginTop = value;
}
},
2011-04-08 15:31:40 +01:00
setMarginBottom:function(value){
if(value >= this._minimalMargin){
this._marginBottom = value;
}
},
2011-03-24 18:00:51 +00:00
getMarginBottom:function(){
2011-04-08 15:31:40 +01:00
return this._marginBottom;
},
getChildrenMarginTop:function(){
return this._marginTopChildren;
},
setChildrenMarginTop:function(value){
if(value >= this._minimalMargin){
this._marginTopChildren = value - this._minimalMargin;
}else{
this._marginTopChildren=0;
}
},
setChildrenMarginBottom:function(value){
if(value >= this._minimalMargin){
this._marginBottomChildren = value - this._minimalMargin;
}else{
this._marginBottomChildren=0;
}
},
getChildrenMarginBottom:function(){
return this._marginBottomChildren;
},
getTotalMarginTop:function(){
2011-04-12 13:59:03 +01:00
return (this._node.areChildrenShrinked()?0:this._marginTopChildren)+this._marginTop;
2011-04-08 15:31:40 +01:00
},
getTotalMarginBottom:function(){
2011-04-12 13:59:03 +01:00
return (this._node.areChildrenShrinked()?0:this._marginBottomChildren) + this._marginBottom;
},
updateMinimumMargin:function(){
var height = this.getNode().getSize().height;
this._minimalMargin = this._DEFAULT_GAP + height/2;
if(this.getMarginTop()<this._minimalMargin){
this.setMarginTop(this._minimalMargin);
}
if(this.getMarginBottom()<this._minimalMargin){
this.setMarginBottom(this._minimalMargin);
}
2011-03-24 18:00:51 +00:00
}
});