wisemapping-open-source/mindplot/src/main/javascript/CentralTopic.js

119 lines
3.3 KiB
JavaScript
Raw Normal View History

/*
2011-07-28 19:07:01 +02:00
* Copyright [2011] [wisemapping]
*
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
* It is basically the Apache License, Version 2.0 (the "License") plus the
* "powered by wisemapping" text requirement on every single page;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the license at
*
* http://www.wisemapping.org/license
*
* 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.
*/
mindplot.CentralTopic = new Class({
Extends:mindplot.Topic,
2011-09-02 07:31:03 +02:00
initialize: function(model, options) {
this.parent(model, options);
2011-08-15 14:27:31 +02:00
},
_registerEvents : function() {
this.parent();
2011-08-15 14:27:31 +02:00
// This disable the drag of the central topic. But solves the problem of deselecting the nodes when the screen is clicked.
2011-08-21 17:42:00 +02:00
this.addEvent('mousedown', function(event) {
2011-08-15 14:27:31 +02:00
event.stopPropagation();
});
2011-07-28 19:07:01 +02:00
},
workoutIncomingConnectionPoint : function(sourcePosition) {
return this.getPosition();
},
2011-09-02 07:31:03 +02:00
_getInnerPadding : function() {
2011-09-04 20:26:42 +02:00
return 11;
2011-09-02 07:31:03 +02:00
},
2011-07-28 19:07:01 +02:00
getTopicType : function() {
return mindplot.model.NodeModel.CENTRAL_TOPIC_TYPE;
2011-07-28 19:07:01 +02:00
},
setCursor : function(type) {
type = (type == 'move') ? 'default' : type;
2011-07-30 10:22:57 +02:00
this.parent(type);
2011-07-28 19:07:01 +02:00
},
isConnectedToCentralTopic : function() {
return false;
},
createChildModel : function(prepositionate) {
// Create a new node ...
var model = this.getModel();
var mindmap = model.getMindmap();
var childModel = mindmap.createNode(mindplot.model.NodeModel.MAIN_TOPIC_TYPE);
2011-07-28 19:07:01 +02:00
if (prepositionate) {
if (!$defined(this.___siblingDirection)) {
this.___siblingDirection = 1;
}
// Position following taking into account this internal flag ...
if (this.___siblingDirection == 1) {
childModel.setPosition(150, 0);
} else {
childModel.setPosition(-150, 0);
}
this.___siblingDirection = -this.___siblingDirection;
2011-04-12 14:59:03 +02:00
}
2011-07-28 19:07:01 +02:00
// Create a new node ...
childModel.setOrder(0);
2009-06-07 20:59:43 +02:00
2011-07-28 19:07:01 +02:00
return childModel;
},
2009-06-07 20:59:43 +02:00
2011-07-28 19:07:01 +02:00
_defaultShapeType : function() {
return mindplot.model.NodeModel.SHAPE_TYPE_ROUNDED_RECT;
2011-07-28 19:07:01 +02:00
},
updateTopicShape : function() {
},
_updatePositionOnChangeSize : function(oldSize, newSize, updatePosition) {
// Center main topic ...
var zeroPoint = new core.Point(0, 0);
this.setPosition(zeroPoint);
},
_defaultText : function() {
return "Central Topic";
},
_defaultBackgroundColor : function() {
return "#f7f7f7";
},
_defaultBorderColor : function() {
return "#023BB9";
},
_defaultFontStyle : function() {
return {
font:"Verdana",
size: 10,
style:"normal",
weight:"bold",
color:"#023BB9"
};
2009-06-07 20:59:43 +02:00
}
2011-07-28 19:07:01 +02:00
});