Reverted unstable changes from db74c63943

This commit is contained in:
Gonzalo Bellver
2012-01-20 11:07:44 -03:00
parent e98d7f8147
commit c7dcf9faf8
5 changed files with 41 additions and 55 deletions

View File

@@ -20,17 +20,13 @@ mindplot.DragPivot = new Class({
initialize:function() {
this._position = new core.Point();
this._size = mindplot.DragTopic.PIVOT_SIZE;
this._line = null;
this._straightLine = this._buildStraightLine();
this._curvedLine = this._buildCurvedLine();
this._dragPivot = this._buildRect();
this._connectRect = this._buildRect();
this._targetTopic = null;
this._isVisible = false;
},
isVisible:function() {
return this._isVisible;
},
getTargetTopic : function() {
@@ -69,7 +65,7 @@ mindplot.DragPivot = new Class({
// Calculate pivot connection point ...
var size = this._size;
var targetPosition = targetTopic.getPosition();
var line = this._getConnectionLine();
var line = this._line;
// Update Line position.
var isAtRight = mindplot.util.Shape.isAtRight(targetPosition, position);
@@ -81,10 +77,14 @@ mindplot.DragPivot = new Class({
var cy = position.y - (parseInt(size.height) / 2);
pivotRect.setPosition(cx, cy);
// Make line visible only when the position has been already changed.
// This solve several strange effects ;)
var targetPoint = targetTopic.workoutIncomingConnectionPoint(pivotPoint);
line.setTo(targetPoint.x, targetPoint.y);
// Display elements if it's required...
if (!pivotRect.isVisible()) {
// Make line visible only when the position has been already changed.
// This solve several strange effects ;)
var targetPoint = targetTopic.workoutIncomingConnectionPoint(pivotPoint);
line.setTo(targetPoint.x, targetPoint.y);
this.setVisibility(true);
}
},
setPosition : function(point) {
@@ -114,36 +114,16 @@ mindplot.DragPivot = new Class({
},
setVisibility : function(value) {
if (this.isVisible() != value) {
var pivotRect = this._getPivotRect();
pivotRect.setVisibility(value);
var pivotRect = this._getPivotRect();
pivotRect.setVisibility(value);
var connectRect = this._connectRect;
connectRect.setVisibility(value);
var line = this._getConnectionLine();
if (line) {
line.setVisibility(value);
}
this._isVisible = value;
var connectRect = this._connectRect;
connectRect.setVisibility(value);
if (this._line) {
this._line.setVisibility(value);
}
},
// If the node is connected, validate that there is a line connecting both...
_getConnectionLine : function() {
var result = null;
var parentTopic = this._targetTopic;
if (parentTopic) {
if (parentTopic.getType() == mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE) {
result = this._straightLine;
} else {
result = this._curvedLine;
}
}
return result;
},
addToWorkspace : function(workspace) {
var pivotRect = this._getPivotRect();
workspace.appendChild(pivotRect);
@@ -193,7 +173,14 @@ mindplot.DragPivot = new Class({
$assert(targetTopic, 'parent can not be null');
this._position = position;
this._targetTopic = targetTopic;
if (targetTopic.getType() == mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE) {
this._line = this._straightLine;
} else {
this._line = this._curvedLine;
}
this._line.setVisibility(true);
// Connected to Rect ...
var connectRect = this._connectRect;
@@ -224,5 +211,6 @@ mindplot.DragPivot = new Class({
this.setVisibility(false);
this._targetTopic = null;
this._line = null;
}
});