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

107 lines
3.1 KiB
JavaScript
Raw Normal View History

2009-06-07 20:59:43 +02:00
/*
2011-07-26 20:07:53 +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.ShirinkConnector = new Class({
initialize: function(topic) {
var ellipse = new web2d.Elipse(mindplot.Topic.prototype.INNER_RECT_ATTRIBUTES);
this._ellipse = ellipse;
ellipse.setFill('rgb(62,118,179)');
2011-07-26 20:07:53 +02:00
ellipse.setSize(mindplot.Topic.CONNECTOR_WIDTH, mindplot.Topic.CONNECTOR_WIDTH);
ellipse.addEvent('click', function(event) {
2011-07-26 20:07:53 +02:00
var model = topic.getModel();
var collapse = !model.areChildrenShrunken();
2011-07-26 20:07:53 +02:00
var topicId = topic.getId();
2011-08-30 19:21:55 +02:00
var actionDispatcher = mindplot.ActionDispatcher.getInstance();
actionDispatcher.shrinkBranch([topicId], collapse);
2011-07-26 20:07:53 +02:00
2011-08-30 19:21:55 +02:00
event.stopPropagation();
2011-07-26 20:07:53 +02:00
});
ellipse.addEvent('mousedown', function(event) {
2011-07-26 20:07:53 +02:00
// Avoid node creation ...
2011-08-30 19:21:55 +02:00
event.stopPropagation();
2011-07-26 20:07:53 +02:00
});
ellipse.addEvent('dblclick', function(event) {
2011-07-26 20:07:53 +02:00
// Avoid node creation ...
2011-08-30 19:21:55 +02:00
event.stopPropagation();
2011-07-26 20:07:53 +02:00
});
ellipse.addEvent('mouseover', function(event) {
2011-08-21 17:42:00 +02:00
ellipse.setFill('rgb(153, 0, 255)');
2011-07-26 20:07:53 +02:00
});
ellipse.addEvent('mouseout', function(event) {
2011-07-26 20:07:53 +02:00
var color = topic.getBackgroundColor();
this.setFill(color);
2011-09-02 07:31:03 +02:00
}.bind(this));
2011-07-26 20:07:53 +02:00
ellipse.setCursor('default');
2011-07-26 20:07:53 +02:00
this._fillColor = '#f7f7f7';
2009-06-07 20:59:43 +02:00
var model = topic.getModel();
this.changeRender(model.areChildrenShrunken());
2011-07-26 20:07:53 +02:00
},
2011-07-26 20:07:53 +02:00
changeRender: function(isShrink) {
var elipse = this._ellipse;
2011-07-26 20:07:53 +02:00
if (isShrink) {
elipse.setStroke('2', 'solid');
} else {
elipse.setStroke('1', 'solid');
}
},
setVisibility: function(value) {
this._ellipse.setVisibility(value);
2011-07-26 20:07:53 +02:00
},
setOpacity: function(opacity) {
this._ellipse.setOpacity(opacity);
2011-07-26 20:07:53 +02:00
},
setFill: function(color) {
this._fillColor = color;
this._ellipse.setFill(color);
2011-07-26 20:07:53 +02:00
},
setAttribute: function(name, value) {
this._ellipse.setAttribute(name, value);
2011-07-26 20:07:53 +02:00
},
addToWorkspace: function(group) {
group.appendChild(this._ellipse);
2011-07-26 20:07:53 +02:00
},
setPosition: function(x, y) {
this._ellipse.setPosition(x, y);
2011-07-26 20:07:53 +02:00
},
moveToBack: function() {
this._ellipse.moveToBack();
2011-07-26 20:07:53 +02:00
},
moveToFront: function() {
this._ellipse.moveToFront();
2009-06-07 20:59:43 +02:00
}
2011-07-26 20:07:53 +02:00
});