Relationship lines can now be selected and deleted

This commit is contained in:
Pablo Luna 2010-12-22 19:34:24 -03:00
parent 67c4968aca
commit ae64037f3a
20 changed files with 400 additions and 207 deletions

View File

@ -1,21 +1,21 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* $Id: file 64488 2006-03-10 17:32:09Z paulo $
*/
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* $Id: file 64488 2006-03-10 17:32:09Z paulo $
*/
mindplot.ConnectionLine = function(sourceNode, targetNode, lineType)
{
@ -25,19 +25,18 @@ mindplot.ConnectionLine = function(sourceNode, targetNode, lineType)
this._targetTopic = targetNode;
this._sourceTopic = sourceNode;
this._isRelationship=false;
var strokeColor = mindplot.ConnectionLine.getStrokeColor();
var line;
if (targetNode.getType() == mindplot.NodeModel.CENTRAL_TOPIC_TYPE)
{
line = this._createLine(lineType,mindplot.ConnectionLine.SIMPLE);
// line = new web2d.Line();
// line = new web2d.Line();
line.setStroke(1, 'solid', strokeColor);
} else
{
line = this._createLine(lineType,mindplot.ConnectionLine.POLYLINE);
// line = new web2d.PolyLine();
// line = new web2d.PolyLine();
line.setStroke(1, 'solid', strokeColor);
}
@ -90,26 +89,10 @@ mindplot.ConnectionLine.prototype.redraw = function()
var targetPosition = targetTopic.getPosition();
var sPos,tPos;
if(this._isRelationship){
this._line2d.setStroke(2);
var ctrlPoints = this._line2d.getControlPoints();
if(!core.Utils.isDefined(ctrlPoints[0].x) || !core.Utils.isDefined(ctrlPoints[1].x)){
var defaultPoints = core.Utils.calculateDefaultControlPoints(sourceTopic.getPosition(), targetTopic.getPosition());
ctrlPoints[0].x=defaultPoints[0].x;
ctrlPoints[0].y=defaultPoints[0].y;
ctrlPoints[1].x=defaultPoints[1].x;
ctrlPoints[1].y=defaultPoints[1].y;
}
sPos = core.Utils.calculateRelationShipPointCoordinates(sourceTopic,ctrlPoints[0]);
tPos = core.Utils.calculateRelationShipPointCoordinates(targetTopic,ctrlPoints[1]);
}else{
sPos = sourceTopic.workoutOutgoingConnectionPoint(targetPosition, false);
tPos = targetTopic.workoutIncomingConnectionPoint(sourcePosition, false);
}
// console.log("source:"+sPos.x+":"+sPos.y);
sPos = sourceTopic.workoutOutgoingConnectionPoint(targetPosition, false);
tPos = targetTopic.workoutIncomingConnectionPoint(sourcePosition, false);
line2d.setFrom(sPos.x, sPos.y);
// console.log("target:"+tPos.x+":"+tPos.y);
line2d.setTo(tPos.x, tPos.y);
line2d.moveToBack();
@ -156,14 +139,6 @@ mindplot.ConnectionLine.prototype.setStroke = function(color, style, opacity)
mindplot.ConnectionLine.prototype.addToWorkspace = function(workspace)
{
if(this._line2d.getType() == "CurvedLine"){
this._line2d.addEventListener('click',function(event){
var controlPoints = workspace.getLineControlPoints();
controlPoints.setLine(this);
controlPoints.setVisibility(true);
event.stopPropagation();
}.bind(this));
}
workspace.appendChild(this._line2d);
};
@ -198,12 +173,12 @@ mindplot.ConnectionLine.prototype.setModel = function(model){
this._model = model;
};
mindplot.ConnectionLine.prototype.setIsRelationship = function(isRelationship){
this._isRelationship=isRelationship;
mindplot.ConnectionLine.prototype.getType = function(){
return "ConnectionLine";
};
mindplot.ConnectionLine.prototype.isRelationship = function(){
return this._isRelationship;
mindplot.ConnectionLine.prototype.getId = function(){
return this._model.getId();
};
mindplot.ConnectionLine.SIMPLE=0;

View File

@ -19,18 +19,17 @@
mindplot.ControlPoint = function()
{
this._controlPoints= [new web2d.Elipse({width:6, height:6, stroke:'1 solid #6589de',fillColor:'gray', visibility:false}),
this._controlPointsController= [new web2d.Elipse({width:6, height:6, stroke:'1 solid #6589de',fillColor:'gray', visibility:false}),
new web2d.Elipse({width:6, height:6, stroke:'1 solid #6589de',fillColor:'gray', visibility:false})];
this._controlLines=[new web2d.Line({strokeColor:"#6589de", strokeWidth:1, opacity:0.3}),
new web2d.Line({strokeColor:"#6589de", strokeWidth:1, opacity:0.3})];
this._isBinded=false;
this._controlPoints[0].addEventListener('mousedown',this._mouseDown.bindWithEvent(this, mindplot.ControlPoint.FROM));
this._controlPoints[0].addEventListener('click',this._mouseClick.bindWithEvent(this));
this._controlPoints[0].addEventListener('dblclick',this._mouseClick.bindWithEvent(this));
this._controlPoints[1].addEventListener('mousedown',this._mouseDown.bindWithEvent(this,mindplot.ControlPoint.TO));
this._controlPoints[1].addEventListener('click',this._mouseClick.bindWithEvent(this));
this._controlPoints[1].addEventListener('dblclick',this._mouseClick.bindWithEvent(this));
this._mouseClickOnBackgroundFunction = this._mouseClickOnBackground.bind(this);
this._controlPointsController[0].addEventListener('mousedown',this._mouseDown.bindWithEvent(this, mindplot.ControlPoint.FROM));
this._controlPointsController[0].addEventListener('click',this._mouseClick.bindWithEvent(this));
this._controlPointsController[0].addEventListener('dblclick',this._mouseClick.bindWithEvent(this));
this._controlPointsController[1].addEventListener('mousedown',this._mouseDown.bindWithEvent(this,mindplot.ControlPoint.TO));
this._controlPointsController[1].addEventListener('click',this._mouseClick.bindWithEvent(this));
this._controlPointsController[1].addEventListener('dblclick',this._mouseClick.bindWithEvent(this));
};
mindplot.ControlPoint.prototype.setSide= function(side) {
@ -43,12 +42,18 @@ mindplot.ControlPoint.prototype.setLine= function(line) {
}
this._line= line;
this._createControlPoint();
this._endPoint = [];
this._orignalCtrlPoint = [];
this._orignalCtrlPoint[0] = this._controls[0].clone();
this._orignalCtrlPoint[1] = this._controls[1].clone();
this._endPoint[0] = this._line.getLine().getFrom().clone();
this._endPoint[1] = this._line.getLine().getTo().clone();
};
mindplot.ControlPoint.prototype._createControlPoint = function() {
this._controls= this._line.getLine().getControlPoints();
this._controlPoints[0].setPosition(this._controls[mindplot.ControlPoint.FROM].x, this._controls[mindplot.ControlPoint.FROM].y-3);
this._controlPoints[1].setPosition(this._controls[mindplot.ControlPoint.TO].x, this._controls[mindplot.ControlPoint.TO].y-3);
this._controlPointsController[0].setPosition(this._controls[mindplot.ControlPoint.FROM].x, this._controls[mindplot.ControlPoint.FROM].y-3);
this._controlPointsController[1].setPosition(this._controls[mindplot.ControlPoint.TO].x, this._controls[mindplot.ControlPoint.TO].y-3);
var pos = this._line.getLine().getFrom();
this._controlLines[0].setFrom(pos.x, pos.y);
this._controlLines[0].setTo(this._controls[mindplot.ControlPoint.FROM].x+3, this._controls[mindplot.ControlPoint.FROM].y);
@ -88,7 +93,7 @@ mindplot.ControlPoint.prototype._mouseMove = function(event, point) {
}
this._controls[point].x=pos.x;
this._controls[point].y=pos.y;
this._controlPoints[point].setPosition(pos.x-5,pos.y-3);
this._controlPointsController[point].setPosition(pos.x-5,pos.y-3);
this._controlLines[point].setFrom(cords.x, cords.y);
this._controlLines[point].setTo(pos.x-2,pos.y);
this._line.getLine().updateLine(point);
@ -114,42 +119,46 @@ mindplot.ControlPoint.prototype._mouseClick = function(event){
return false;
};
mindplot.ControlPoint.prototype._mouseClickOnBackground = function(event){
this.setVisibility(false);
};
mindplot.ControlPoint.prototype.setVisibility = function(visible){
if(visible){
this._workspace.getScreenManager().addEventListener('mousedown',this._mouseClickOnBackgroundFunction);
this._controlLines[0].moveToFront();
this._controlLines[1].moveToFront();
this._controlPoints[0].moveToFront();
this._controlPoints[1].moveToFront();
this._controlPointsController[0].moveToFront();
this._controlPointsController[1].moveToFront();
}
else{
this._workspace.getScreenManager().removeEventListener('mousedown',this._mouseClickOnBackgroundFunction);
}
this._controlPoints[0].setVisibility(visible);
this._controlPoints[1].setVisibility(visible);
this._controlPointsController[0].setVisibility(visible);
this._controlPointsController[1].setVisibility(visible);
this._controlLines[0].setVisibility(visible);
this._controlLines[1].setVisibility(visible);
};
mindplot.ControlPoint.prototype.addToWorkspace = function(workspace){
this._workspace = workspace;
workspace.appendChild(this._controlPoints[0]);
workspace.appendChild(this._controlPoints[1]);
workspace.appendChild(this._controlPointsController[0]);
workspace.appendChild(this._controlPointsController[1]);
workspace.appendChild(this._controlLines[0]);
workspace.appendChild(this._controlLines[1]);
};
mindplot.ControlPoint.prototype.removeFromWorkspace = function(workspace){
this._workspace = null;
workspace.removeChild(this._controlPoints[0]);
workspace.removeChild(this._controlPoints[1]);
workspace.removeChild(this._controlPointsController[0]);
workspace.removeChild(this._controlPointsController[1]);
workspace.removeChild(this._controlLines[0]);
workspace.removeChild(this._controlLines[1]);
};
mindplot.ControlPoint.prototype.getControlPoint = function(index){
return this._controls[index];
};
mindplot.ControlPoint.prototype.getOriginalEndPoint = function(index){
return this._endPoint[index];
};
mindplot.ControlPoint.prototype.getOriginalCtrlPoint = function(index){
return this._orignalCtrlPoint[index];
};
mindplot.ControlPoint.FROM = 0;
mindplot.ControlPoint.TO = 1;

View File

@ -100,7 +100,7 @@ mindplot.CommandContext = new Class({
// @todo: Is this required ?
var designer = this._designer;
designer.onNodeFocusEvent.attempt(topic, designer);
designer.onObjectFocusEvent.attempt(topic, designer);
return topic;
},
@ -125,6 +125,16 @@ mindplot.CommandContext = new Class({
},
removeRelationship:function(model) {
this._designer.removeRelationship(model);
},
findRelationships:function(lineIds){
var result = [];
lineIds.forEach(function(lineId, index){
var line = this._designer._relationships[lineId];
if(core.Utils.isDefined(line)){
result.push(line);
}
}.bind(this));
return result;
}
});

View File

@ -46,9 +46,6 @@ mindplot.MindmapDesigner = function(profile, divElement)
// Register handlers..
this._registerEvents();
// Selected node
this._nodeOnFocus = null;
// Init dragger manager.
this._dragger = this._buildDragManager(workspace);
@ -232,19 +229,19 @@ mindplot.MindmapDesigner.prototype._buildNodeGraph = function(model)
return topic;
};
mindplot.MindmapDesigner.prototype.onNodeFocusEvent = function(topicGraph, event)
mindplot.MindmapDesigner.prototype.onObjectFocusEvent = function(currentObject, event)
{
this.getEditor().lostFocus();
var topics = this._topics;
var selectableObjects = this.getSelectedObjects();
// Disable all nodes on focus but not the current if Ctrl key isn't being pressed
if (!core.Utils.isDefined(event) || event.ctrlKey == false)
{
for (var i = 0; i < topics.length; i++)
for (var i = 0; i < selectableObjects.length; i++)
{
var node = topics[i];
if (node.isOnFocus() && node != topicGraph)
var selectableObject = selectableObjects[i];
if (selectableObject.isOnFocus() && selectableObject != currentObject)
{
node.setOnFocus(false);
selectableObject.setOnFocus(false);
}
}
}
@ -257,7 +254,7 @@ mindplot.MindmapDesigner.prototype._registerListenersOnNode = function(topic)
var topics = this._topics;
topic.addEventListener('onfocus', function(event)
{
elem.onNodeFocusEvent.attempt([topic, event], elem);
elem.onObjectFocusEvent.attempt([topic, event], elem);
});
// Add drag behaviour ...
@ -645,8 +642,7 @@ mindplot.MindmapDesigner.prototype._buildRelationship = function (model) {
}
// Create node graph ...
var relationLine = new mindplot.ConnectionLine(fromTopic, toTopic, model.getLineType());
relationLine.setIsRelationship(true);
var relationLine = new mindplot.RelationshipLine(fromTopic, toTopic, model.getLineType());
if(core.Utils.isDefined(model.getSrcCtrlPoint())){
var srcPoint = model.getSrcCtrlPoint().clone();
relationLine.getLine().setSrcControlPoint(srcPoint);
@ -660,6 +656,14 @@ mindplot.MindmapDesigner.prototype._buildRelationship = function (model) {
relationLine.getLine().setDashed(3,2);
relationLine.getLine().setShowArrow(model.getEndArrow());
relationLine.setModel(model);
//Add Listeners
var elem = this;
relationLine.addEventListener('onfocus', function(event)
{
elem.onObjectFocusEvent.attempt([relationLine, event], elem);
});
// Append it to the workspace ...
this._relationships[model.getId()]=relationLine;
@ -701,14 +705,14 @@ mindplot.MindmapDesigner.prototype._removeNode = function(node)
mindplot.MindmapDesigner.prototype.deleteCurrentNode = function()
{
var validateFunc = function(topic) {
return topic.getTopicType() != mindplot.NodeModel.CENTRAL_TOPIC_TYPE
var validateFunc = function(selectedObject) {
return selectedObject.getType() == mindplot.RelationshipLine.type || selectedObject.getTopicType() != mindplot.NodeModel.CENTRAL_TOPIC_TYPE
};
var validateError = 'Central topic can not be deleted.';
var topicsIds = this._setValidSelectedTopicsIds(validateFunc, validateError);
if (topicsIds.length > 0)
var selectedObjects = this._getValidSelectedObjectsIds(validateFunc, validateError);
if (selectedObjects.nodes.length > 0 || selectedObjects.relationshipLines.length>0)
{
var command = new mindplot.commands.DeleteTopicCommand(topicsIds);
var command = new mindplot.commands.DeleteTopicCommand(selectedObjects);
this._actionRunner.execute(command);
}
@ -716,7 +720,8 @@ mindplot.MindmapDesigner.prototype.deleteCurrentNode = function()
mindplot.MindmapDesigner.prototype.setFont2SelectedNode = function(font)
{
var topicsIds = this._setValidSelectedTopicsIds();
var validSelectedObjects = this._getValidSelectedObjectsIds();
var topicsIds = validSelectedObjects.nodes;
if (topicsIds.length > 0)
{
var commandFunc = function(topic, font)
@ -737,7 +742,8 @@ mindplot.MindmapDesigner.prototype.setFont2SelectedNode = function(font)
mindplot.MindmapDesigner.prototype.setStyle2SelectedNode = function()
{
var topicsIds = this._setValidSelectedTopicsIds();
var validSelectedObjects = this._getValidSelectedObjectsIds();
var topicsIds = validSelectedObjects.nodes;
if (topicsIds.length > 0)
{
var commandFunc = function(topic)
@ -754,7 +760,8 @@ mindplot.MindmapDesigner.prototype.setStyle2SelectedNode = function()
mindplot.MindmapDesigner.prototype.setFontColor2SelectedNode = function(color)
{
var topicsIds = this._setValidSelectedTopicsIds();
var validSelectedObjects = this._getValidSelectedObjectsIds();
var topicsIds = validSelectedObjects.nodes;
if (topicsIds.length > 0)
{
var commandFunc = function(topic, color)
@ -776,7 +783,8 @@ mindplot.MindmapDesigner.prototype.setBackColor2SelectedNode = function(color)
return topic.getShapeType() != mindplot.NodeModel.SHAPE_TYPE_LINE
};
var validateError = 'Color can not be setted to line topics.';
var topicsIds = this._setValidSelectedTopicsIds(validateFunc, validateError);
var validSelectedObjects = this._getValidSelectedObjectsIds(validateFunc, validateError);;
var topicsIds = validSelectedObjects.nodes;
if (topicsIds.length > 0)
{
@ -793,19 +801,20 @@ mindplot.MindmapDesigner.prototype.setBackColor2SelectedNode = function(color)
};
mindplot.MindmapDesigner.prototype._setValidSelectedTopicsIds = function(validate, errorMsg)
mindplot.MindmapDesigner.prototype._getValidSelectedObjectsIds = function(validate, errorMsg)
{
var result = [];
var result = {"nodes":[],"relationshipLines":[]};
var selectedNodes = this._getSelectedNodes();
if (selectedNodes.length == 0)
var selectedRelationshipLines = this.getSelectedRelationshipLines();
if (selectedNodes.length == 0 && selectedRelationshipLines.length == 0)
{
core.Monitor.getInstance().logMessage('At least one topic must be selected to execute this operation.');
core.Monitor.getInstance().logMessage('At least one element must be selected to execute this operation.');
} else
{
var isValid = true;
for (var i = 0; i < selectedNodes.length; i++)
{
var selectedNode = selectedNodes[i];
var isValid = true;
if (validate)
{
isValid = validate(selectedNode);
@ -814,7 +823,21 @@ mindplot.MindmapDesigner.prototype._setValidSelectedTopicsIds = function(validat
// Add node only if it's valid.
if (isValid)
{
result.push(selectedNode.getId());
result.nodes.push(selectedNode.getId());
} else
{
core.Monitor.getInstance().logMessage(errorMsg);
}
}
for( var j = 0; j< selectedRelationshipLines.length; j++){
var selectedLine = selectedRelationshipLines[j];
isValid = true;
if(validate){
isValid = validate(selectedLine);
}
if(isValid){
result.relationshipLines.push(selectedLine.getId());
} else
{
core.Monitor.getInstance().logMessage(errorMsg);
@ -830,7 +853,8 @@ mindplot.MindmapDesigner.prototype.setBorderColor2SelectedNode = function(color)
return topic.getShapeType() != mindplot.NodeModel.SHAPE_TYPE_LINE
};
var validateError = 'Color can not be setted to line topics.';
var topicsIds = this._setValidSelectedTopicsIds(validateFunc, validateError);
var validSelectedObjects = this._getValidSelectedObjectsIds(validateFunc, validateError);;
var topicsIds = validSelectedObjects.nodes;
if (topicsIds.length > 0)
{
@ -848,7 +872,8 @@ mindplot.MindmapDesigner.prototype.setBorderColor2SelectedNode = function(color)
mindplot.MindmapDesigner.prototype.setFontSize2SelectedNode = function(size)
{
var topicsIds = this._setValidSelectedTopicsIds();
var validSelectedObjects = this._getValidSelectedObjectsIds();
var topicsIds = validSelectedObjects.nodes;
if (topicsIds.length > 0)
{
var commandFunc = function(topic, size)
@ -873,7 +898,8 @@ mindplot.MindmapDesigner.prototype.setShape2SelectedNode = function(shape)
return !(topic.getType() == mindplot.NodeModel.CENTRAL_TOPIC_TYPE && shape == mindplot.NodeModel.SHAPE_TYPE_LINE)
};
var validateError = 'Central Topic shape can not be changed to line figure.';
var topicsIds = this._setValidSelectedTopicsIds(validateFunc, validateError);
var validSelectedObjects = this._getValidSelectedObjectsIds(validateFunc, validateError);
var topicsIds = validSelectedObjects.nodes;
if (topicsIds.length > 0)
{
@ -891,7 +917,8 @@ mindplot.MindmapDesigner.prototype.setShape2SelectedNode = function(shape)
mindplot.MindmapDesigner.prototype.setWeight2SelectedNode = function()
{
var topicsIds = this._setValidSelectedTopicsIds();
var validSelectedObjects = this._getValidSelectedObjectsIds();
var topicsIds = validSelectedObjects.nodes;
if (topicsIds.length > 0)
{
var commandFunc = function(topic)
@ -913,8 +940,8 @@ mindplot.MindmapDesigner.prototype.setWeight2SelectedNode = function()
mindplot.MindmapDesigner.prototype.addImage2SelectedNode = function(iconType)
{
var topicsIds = this._setValidSelectedTopicsIds();
var validSelectedObjects = this._getValidSelectedObjectsIds();
var topicsIds = validSelectedObjects.nodes;
if (topicsIds.length > 0)
{
@ -925,7 +952,8 @@ mindplot.MindmapDesigner.prototype.addImage2SelectedNode = function(iconType)
mindplot.MindmapDesigner.prototype.addLink2Node = function(url)
{
var topicsIds = this._setValidSelectedTopicsIds();
var validSelectedObjects = this._getValidSelectedObjectsIds();
var topicsIds = validSelectedObjects.nodes;
if (topicsIds.length > 0)
{
var command = new mindplot.commands.AddLinkToTopicCommand(topicsIds[0], url);
@ -985,7 +1013,8 @@ mindplot.MindmapDesigner.prototype.addLink2SelectedNode = function()
mindplot.MindmapDesigner.prototype.addNote2Node = function(text)
{
var topicsIds = this._setValidSelectedTopicsIds();
var validSelectedObjects = this._getValidSelectedObjectsIds();
var topicsIds = validSelectedObjects.nodes;
if (topicsIds.length > 0)
{
var command = new mindplot.commands.AddNoteToTopicCommand(topicsIds[0], text);
@ -1078,11 +1107,30 @@ mindplot.MindmapDesigner.prototype._getSelectedNodes = function()
return result;
};
mindplot.MindmapDesigner.prototype.getSelectedRelationshipLines = function(){
var result = new Array();
for each (var relationship in this._relationships)
{
if (relationship.isOnFocus())
{
result.push(relationship);
}
}
return result;
};
mindplot.MindmapDesigner.prototype.getSelectedNodes = function()
{
return this._getSelectedNodes();
};
mindplot.MindmapDesigner.prototype.getSelectedObjects = function()
{
var selectedNodes = this.getSelectedNodes();
var selectedRelationships = this.getSelectedRelationshipLines();
selectedRelationships.extend(selectedNodes);
return selectedRelationships;
};
mindplot.MindmapDesigner.prototype.keyEventHandler = function(event)
{
@ -1307,7 +1355,7 @@ mindplot.MindmapDesigner.prototype._goToBrother = function(node, direction)
mindplot.MindmapDesigner.prototype._goToNode = function(node)
{
node.setOnFocus(true);
this.onNodeFocusEvent.attempt(node, this);
this.onObjectFocusEvent.attempt(node, this);
};
mindplot.MindmapDesigner.prototype._goToSideChild = function(node, side)

View File

@ -1,22 +1,22 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* $Id: file 64488 2006-03-10 17:32:09Z paulo $
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* $Id: file 64488 2006-03-10 17:32:09Z paulo $
*/
mindplot.NodeGraph = function(nodeModel)
{
this._mouseEvents = true;

View File

@ -0,0 +1,133 @@
mindplot.RelationshipLine = function(sourceNode, targetNode, lineType)
{
mindplot.ConnectionLine.call(this,sourceNode, targetNode, lineType);
this._isOnfocus = false;
this._focusShape = this._createLine(this.getLineType(), mindplot.ConnectionLine.SIMPLE_CURVED);
this._focusShape.setStroke(2, "solid", "#3f96ff");
var ctrlPoints = this._line2d.getControlPoints();
this._focusShape.setSrcControlPoint(ctrlPoints[0]);
this._focusShape.setDestControlPoint(ctrlPoints[1]);
this._focusShape.setVisibility(false);
this._onFocus = false;
this._isInWorkspace = false;
this._controlPointsController = new mindplot.ControlPoint();
};
objects.extend(mindplot.RelationshipLine, mindplot.ConnectionLine);
mindplot.RelationshipLine.prototype.redraw = function()
{
var line2d = this._line2d;
var sourceTopic = this._sourceTopic;
var sourcePosition = sourceTopic.getPosition();
var targetTopic = this._targetTopic;
var targetPosition = targetTopic.getPosition();
var sPos,tPos;
this._line2d.setStroke(2);
var ctrlPoints = this._line2d.getControlPoints();
if(!core.Utils.isDefined(ctrlPoints[0].x) || !core.Utils.isDefined(ctrlPoints[1].x)){
var defaultPoints = core.Utils.calculateDefaultControlPoints(sourceTopic.getPosition(), targetTopic.getPosition());
ctrlPoints[0].x=defaultPoints[0].x;
ctrlPoints[0].y=defaultPoints[0].y;
ctrlPoints[1].x=defaultPoints[1].x;
ctrlPoints[1].y=defaultPoints[1].y;
}
sPos = core.Utils.calculateRelationShipPointCoordinates(sourceTopic,ctrlPoints[0]);
tPos = core.Utils.calculateRelationShipPointCoordinates(targetTopic,ctrlPoints[1]);
line2d.setFrom(sPos.x, sPos.y);
line2d.setTo(tPos.x, tPos.y);
line2d.moveToBack();
// Add connector ...
this._positionateConnector(targetTopic);
if(this.isOnFocus()){
this._refreshSelectedShape();
}
this._focusShape.moveToBack();
};
mindplot.RelationshipLine.prototype.addToWorkspace = function(workspace)
{
workspace.appendChild(this._focusShape);
workspace.appendChild(this._controlPointsController);
this._controlPointControllerListener =this._initializeControlPointController.bindWithEvent(this,workspace);
this._line2d.addEventListener('click', this._controlPointControllerListener);
this._isInWorkspace = true;
mindplot.RelationshipLine.superClass.addToWorkspace.call(this, workspace);
};
mindplot.RelationshipLine.prototype._initializeControlPointController = function(event,workspace){
this.setOnFocus(true);
};
mindplot.RelationshipLine.prototype.removeFromWorkspace = function(workspace){
workspace.removeChild(this._focusShape);
workspace.removeChild(this._controlPointsController);
this._line2d.removeEventListener('click',this._controlPointControllerListener);
this._isInWorkspace = false;
mindplot.RelationshipLine.superClass.removeFromWorkspace.call(this,workspace);
};
mindplot.RelationshipLine.prototype.getType = function(){
return mindplot.RelationshipLine.type;
};
mindplot.RelationshipLine.prototype.setOnFocus = function(focus){
// Change focus shape
if(focus){
this._refreshSelectedShape();
this._controlPointsController.setLine(this);
}
this._focusShape.setVisibility(focus);
this._controlPointsController.setVisibility(focus);
this._onFocus = focus;
};
mindplot.RelationshipLine.prototype._refreshSelectedShape = function () {
var sPos = this._line2d.getFrom();
var tPos = this._line2d.getTo();
var ctrlPoints = this._line2d.getControlPoints();
this._focusShape.setFrom(sPos.x, sPos.y);
this._focusShape.setTo(tPos.x, tPos.y);
var shapeCtrlPoints = this._focusShape.getControlPoints();
shapeCtrlPoints[0].x = ctrlPoints[0].x;
shapeCtrlPoints[0].y = ctrlPoints[0].y;
shapeCtrlPoints[1].x = ctrlPoints[1].x;
shapeCtrlPoints[1].y = ctrlPoints[1].y;
this._focusShape.updateLine();
//this._focusShape.setSrcControlPoint(ctrlPoints[0]);
//this._focusShape.setDestControlPoint(ctrlPoints[1]);
};
mindplot.RelationshipLine.prototype.addEventListener = function(type, listener){
// Translate to web 2d events ...
if (type == 'onfocus')
{
type = 'mousedown';
}
var line = this._line2d;
line.addEventListener(type, listener);
};
mindplot.RelationshipLine.prototype.isOnFocus = function()
{
return this._onFocus;
};
mindplot.RelationshipLine.prototype.isInWorkspace = function(){
return this._isInWorkspace;
};
mindplot.RelationshipLine.type = "RelationshipLine";

View File

@ -41,9 +41,6 @@ mindplot.Workspace = function(profile, screenManager, zoom)
// Register drag events ...
this._registerDragEvents();
//Create CurvedLineControlPoints
this._createCuvedLineControlPoints();
this._eventsEnabled = true;
};
@ -237,12 +234,3 @@ mindplot.Workspace.prototype._registerDragEvents = function()
screenManager.addEventListener('mousedown', mouseDownListener);
};
mindplot.Workspace.prototype._createCuvedLineControlPoints = function(){
this._lineControlPoints = new mindplot.ControlPoint();
this.appendChild(this._lineControlPoints);
};
mindplot.Workspace.prototype.getLineControlPoints = function(){
return this._lineControlPoints;
};

View File

@ -23,12 +23,12 @@ mindplot.commands.AddIconToTopicCommand = mindplot.Command.extend(
{
core.assert(topicId, 'topicId can not be null');
core.assert(iconType, 'iconType can not be null');
this._topicId = topicId;
this._selectedObjectsIds = topicId;
this._iconType = iconType;
},
execute: function(commandContext)
{
var topic = commandContext.findTopics(this._topicId)[0];
var topic = commandContext.findTopics(this._selectedObjectsIds)[0];
var updated = function() {
var iconImg = topic.addIcon(this._iconType, commandContext._designer);
this._iconModel = iconImg.getModel();
@ -38,7 +38,7 @@ mindplot.commands.AddIconToTopicCommand = mindplot.Command.extend(
},
undoExecute: function(commandContext)
{
var topic = commandContext.findTopics(this._topicId)[0];
var topic = commandContext.findTopics(this._selectedObjectsIds)[0];
var updated = function() {
topic.removeIcon(this._iconModel);
topic.updateNode();

View File

@ -22,13 +22,13 @@ mindplot.commands.AddLinkToTopicCommand = mindplot.Command.extend(
initialize: function(topicId,url)
{
core.assert(topicId, 'topicId can not be null');
this._topicId = topicId;
this._selectedObjectsIds = topicId;
this._url = url;
this._id = mindplot.Command._nextUUID();
},
execute: function(commandContext)
{
var topic = commandContext.findTopics(this._topicId)[0];
var topic = commandContext.findTopics(this._selectedObjectsIds)[0];
var updated = function() {
topic.addLink(this._url,commandContext._designer);
topic.updateNode();
@ -37,7 +37,7 @@ mindplot.commands.AddLinkToTopicCommand = mindplot.Command.extend(
},
undoExecute: function(commandContext)
{
var topic = commandContext.findTopics(this._topicId)[0];
var topic = commandContext.findTopics(this._selectedObjectsIds)[0];
var updated = function() {
topic.removeLink();
}.bind(this);

View File

@ -22,13 +22,13 @@ mindplot.commands.AddNoteToTopicCommand = mindplot.Command.extend(
initialize: function(topicId,text)
{
core.assert(topicId, 'topicId can not be null');
this._topicId = topicId;
this._selectedObjectsIds = topicId;
this._text = text;
this._id = mindplot.Command._nextUUID();
},
execute: function(commandContext)
{
var topic = commandContext.findTopics(this._topicId)[0];
var topic = commandContext.findTopics(this._selectedObjectsIds)[0];
var updated = function() {
topic.addNote(this._text,commandContext._designer);
topic.updateNode();
@ -37,7 +37,7 @@ mindplot.commands.AddNoteToTopicCommand = mindplot.Command.extend(
},
undoExecute: function(commandContext)
{
var topic = commandContext.findTopics(this._topicId)[0];
var topic = commandContext.findTopics(this._selectedObjectsIds)[0];
var updated = function() {
topic.removeNote();
}.bind(this);

View File

@ -24,13 +24,13 @@ mindplot.commands.ChangeIconFromTopicCommand = mindplot.Command.extend(
core.assert(topicId, 'topicId can not be null');
core.assert(iconId, 'iconId can not be null');
core.assert(iconType, 'iconType can not be null');
this._topicId = topicId;
this._selectedObjectsIds = topicId;
this._iconModel = iconId;
this._iconType = iconType;
},
execute: function(commandContext)
{
var topic = commandContext.findTopics(this._topicId)[0];
var topic = commandContext.findTopics(this._selectedObjectsIds)[0];
var updated = function() {
topic.removeIcon(this._iconModel);
topic.updateNode();
@ -39,7 +39,7 @@ mindplot.commands.ChangeIconFromTopicCommand = mindplot.Command.extend(
},
undoExecute: function(commandContext)
{
var topic = commandContext.findTopics(this._topicId)[0];
var topic = commandContext.findTopics(this._selectedObjectsIds)[0];
var updated = function() {
topic.addIcon(this._iconModel, commandContext._designer);
topic.updateNode();

View File

@ -22,7 +22,7 @@ mindplot.commands.DeleteTopicCommand = mindplot.Command.extend(
initialize: function(topicsIds)
{
core.assert(topicsIds, "topicsIds must be defined");
this._topicId = topicsIds;
this._selectedObjectsIds = topicsIds;
this._deletedTopicModels = [];
this._parentTopicIds = [];
this._deletedRelationships = [];
@ -30,7 +30,8 @@ mindplot.commands.DeleteTopicCommand = mindplot.Command.extend(
},
execute: function(commandContext)
{
var topics = commandContext.findTopics(this._topicId);
var topics = commandContext.findTopics(this._selectedObjectsIds.nodes);
if(topics.length>0){
topics.forEach(
function(topic, index)
{
@ -59,12 +60,21 @@ mindplot.commands.DeleteTopicCommand = mindplot.Command.extend(
commandContext.deleteTopic(topic);
}.bind(this)
);
); }
var lines = commandContext.findRelationships(this._selectedObjectsIds.relationshipLines);
if(lines.length>0){
lines.forEach(function(line,index){
if(line.isInWorkspace()){
this._deletedRelationships.push(line.getModel().clone());
commandContext.removeRelationship(line.getModel());
}
}.bind(this));
}
},
undoExecute: function(commandContext)
{
var topics = commandContext.findTopics(this._topicId);
var topics = commandContext.findTopics(this._selectedObjectsIds);
var parent = commandContext.findTopics(this._parentTopicIds);
this._deletedTopicModels.forEach(

View File

@ -22,7 +22,7 @@ mindplot.commands.DragTopicCommand = mindplot.Command.extend(
initialize: function(topicId)
{
core.assert(topicId, "topicId must be defined");
this._topicId = topicId;
this._selectedObjectsIds = topicId;
this._parentTopic = null;
this._position = null;
this._order = null;
@ -31,7 +31,7 @@ mindplot.commands.DragTopicCommand = mindplot.Command.extend(
execute: function(commandContext)
{
var topic = commandContext.findTopics([this._topicId])[0];
var topic = commandContext.findTopics([this._selectedObjectsIds])[0];
// Save old position ...
var origParentTopic = topic.getOutgoingConnectedTopic();

View File

@ -24,7 +24,7 @@ mindplot.commands.GenericFunctionCommand = mindplot.Command.extend(
core.assert(commandFunc, "commandFunc must be defined");
core.assert(topicsIds, "topicsIds must be defined");
this._value = value;
this._topicId = topicsIds;
this._selectedObjectsIds = topicsIds;
this._commandFunc = commandFunc;
this._oldValues = [];
this._id = mindplot.Command._nextUUID();
@ -33,7 +33,7 @@ mindplot.commands.GenericFunctionCommand = mindplot.Command.extend(
{
if (!this.applied)
{
var topics = commandContext.findTopics(this._topicId);
var topics = commandContext.findTopics(this._selectedObjectsIds);
topics.forEach(function(topic)
{
var oldValue = this._commandFunc(topic, this._value);
@ -50,7 +50,7 @@ mindplot.commands.GenericFunctionCommand = mindplot.Command.extend(
{
if (this.applied)
{
var topics = commandContext.findTopics(this._topicId);
var topics = commandContext.findTopics(this._selectedObjectsIds);
topics.forEach(function(topic,index)
{
this._commandFunc(topic, this._oldValues[index]);

View File

@ -1,59 +1,77 @@
mindplot.commands.MoveControlPointCommand = mindplot.Command.extend(
{
initialize: function(ctrlPointControler, point)
initialize: function(ctrlPointController, point)
{
core.assert(ctrlPointControler, 'line can not be null');
this._ctrlPointControler = ctrlPointControler;
core.assert(ctrlPointController, 'line can not be null');
this._ctrlPointControler = ctrlPointController;
this._line = ctrlPointController._line;
var model = this._line.getModel();
this._controlPoint = this._ctrlPointControler.getControlPoint(point).clone();
this._oldControlPoint= this._ctrlPointControler.getOriginalCtrlPoint(point).clone();
this._originalEndPoint = this._ctrlPointControler.getOriginalEndPoint(point).clone();
switch (point){
case 0:
this._wasCustom = this._line.getLine().isSrcControlPointCustom();
this._endPoint = this._line.getLine().getFrom().clone();
break;
case 1:
this._wasCustom = this._line.getLine().isDestControlPointCustom();
this._endPoint = this._line.getLine().getTo().clone();
break;
}
this._id = mindplot.Command._nextUUID();
this._wasCustom=false;
this._point = point;
this._controlPoint = null;
},
execute: function(commandContext)
{
var line = this._ctrlPointControler._line;
var ctrlPoints = line.getLine().getControlPoints();
var model = line.getModel();
var point = null;
var model = this._line.getModel();
switch (this._point){
case 0:
if(core.Utils.isDefined(model.getSrcCtrlPoint())){
this._controlPoint= model.getSrcCtrlPoint().clone();
}
model.setSrcCtrlPoint(ctrlPoints[0].clone());
this._wasCustom = line.getLine().isSrcControlPointCustom();
line.getLine().setIsSrcControlPointCustom(true);
model.setSrcCtrlPoint(this._controlPoint.clone());
this._line.getLine().setFrom(this._endPoint.x, this._endPoint.y);
this._line.getLine().setIsSrcControlPointCustom(true);
this._line.getLine().setSrcControlPoint(this._controlPoint.clone());
break;
case 1:
if(core.Utils.isDefined(model.getDestCtrlPoint())){
this._controlPoint = model.getDestCtrlPoint().clone();
}
model.setDestCtrlPoint(ctrlPoints[1].clone());
this._wasCustom = line.getLine().isDestControlPointCustom();
line.getLine().setIsDestControlPointCustom(true);
model.setDestCtrlPoint(this._controlPoint.clone());
this._wasCustom = this._line.getLine().isDestControlPointCustom();
this._line.getLine().setTo(this._endPoint.x, this._endPoint.y);
this._line.getLine().setIsDestControlPointCustom(true);
this._line.getLine().setDestControlPoint(this._controlPoint.clone());
break;
}
if(this._line.isOnFocus()){
this._line._refreshSelectedShape();
this._ctrlPointControler.setLine(this._line);
}
this._line.getLine().updateLine(this._point);
},
undoExecute: function(commandContext)
{
var line = this._ctrlPointControler._line;
var line = this._line;
var model = line.getModel();
switch (this._point){
case 0:
if(core.Utils.isDefined(this._controlPoint)){
model.setSrcCtrlPoint(this._controlPoint.clone());
line.getLine().setSrcControlPoint(this._controlPoint.clone());
if(core.Utils.isDefined(this._oldControlPoint)){
line.getLine().setFrom(this._originalEndPoint.x, this._originalEndPoint.y);
model.setSrcCtrlPoint(this._oldControlPoint.clone());
line.getLine().setSrcControlPoint(this._oldControlPoint.clone());
line.getLine().setIsSrcControlPointCustom(this._wasCustom);
}
break;
case 1:
if(core.Utils.isDefined(this._controlPoint)){
model.setDestCtrlPoint(this._controlPoint.clone());
line.getLine().setDestControlPoint(this._controlPoint.clone());
if(core.Utils.isDefined(this._oldControlPoint)){
line.getLine().setTo(this._originalEndPoint.x, this._originalEndPoint.y);
model.setDestCtrlPoint(this._oldControlPoint.clone());
line.getLine().setDestControlPoint(this._oldControlPoint.clone());
line.getLine().setIsDestControlPointCustom(this._wasCustom);
}
break;
}
this._ctrlPointControler.setLine(line);
this._line.getLine().updateLine(this._point);
if(this._line.isOnFocus()){
this._ctrlPointControler.setLine(line);
line._refreshSelectedShape();
}
}
});

View File

@ -23,12 +23,12 @@ mindplot.commands.RemoveIconFromTopicCommand = mindplot.Command.extend(
{
core.assert(topicId, 'topicId can not be null');
core.assert(iconModel, 'iconId can not be null');
this._topicId = topicId;
this._selectedObjectsIds = topicId;
this._iconModel = iconModel;
},
execute: function(commandContext)
{
var topic = commandContext.findTopics(this._topicId)[0];
var topic = commandContext.findTopics(this._selectedObjectsIds)[0];
var updated = function() {
topic.removeIcon(this._iconModel);
topic.updateNode();
@ -37,7 +37,7 @@ mindplot.commands.RemoveIconFromTopicCommand = mindplot.Command.extend(
},
undoExecute: function(commandContext)
{
var topic = commandContext.findTopics(this._topicId)[0];
var topic = commandContext.findTopics(this._selectedObjectsIds)[0];
var updated = function() {
var iconType = this._iconModel.getIconType();
var iconImg = topic.addIcon(iconType, commandContext._designer);

View File

@ -22,11 +22,11 @@ mindplot.commands.RemoveLinkFromTopicCommand = mindplot.Command.extend(
initialize: function(topicId)
{
core.assert(topicId, 'topicId can not be null');
this._topicId = topicId;
this._selectedObjectsIds = topicId;
},
execute: function(commandContext)
{
var topic = commandContext.findTopics(this._topicId)[0];
var topic = commandContext.findTopics(this._selectedObjectsIds)[0];
this._url = topic._link.getUrl();
var updated = function() {
topic.removeLink();
@ -35,7 +35,7 @@ mindplot.commands.RemoveLinkFromTopicCommand = mindplot.Command.extend(
},
undoExecute: function(commandContext)
{
var topic = commandContext.findTopics(this._topicId)[0];
var topic = commandContext.findTopics(this._selectedObjectsIds)[0];
var updated = function() {
topic.addLink(this._url,commandContext._designer);
topic.updateNode();

View File

@ -22,11 +22,11 @@ mindplot.commands.RemoveNoteFromTopicCommand = mindplot.Command.extend(
initialize: function(topicId)
{
core.assert(topicId, 'topicId can not be null');
this._topicId = topicId;
this._selectedObjectsIds = topicId;
},
execute: function(commandContext)
{
var topic = commandContext.findTopics(this._topicId)[0];
var topic = commandContext.findTopics(this._selectedObjectsIds)[0];
this._text = topic._note.getText();
var updated = function() {
topic.removeNote();
@ -35,7 +35,7 @@ mindplot.commands.RemoveNoteFromTopicCommand = mindplot.Command.extend(
},
undoExecute: function(commandContext)
{
var topic = commandContext.findTopics(this._topicId)[0];
var topic = commandContext.findTopics(this._selectedObjectsIds)[0];
var updated = function() {
topic.addNote(this._text,commandContext._designer);
topic.updateNode();

View File

@ -216,6 +216,8 @@ TOPIC_ICON=Add Icon
ICON=Icon
TOPIC_LINK=Add Link
LINK=Link
TOPIC_RELATIONSHIP=Relationship
RELATION=Relationship
TOPIC_NOTE=Add Note
NOTE=Note
@ -322,4 +324,4 @@ HISTORY_INFO = Here is the list of the last revisions of you map.
REVERT=revert
SAMPLE_MAPS=Sample Maps
INVALID_EMAIL_ERROR = The e-mail was not verified
INVALID_EMAIL_ERROR = The e-mail was not verified

View File

@ -70,8 +70,8 @@ YES=Si
NO=No
EDITOR.LOADING=Cargando...
SITE.TITLE=WiseMapping
SITE.SLOGAN=Visual Thinking Evolution
SITE.TITLE=Thinkmapping
SITE.SLOGAN=pensando en mapping
SAVE=Guardar
DISCARD_CHANGES=Descartar cambios
ABOUT=Acerca