107 lines
3.1 KiB
JavaScript
Raw Normal View History

2009-06-07 18:59:43 +00:00
/*
2012-10-04 20:48:01 -03:00
* Copyright [2012] [wisemapping]
2011-07-26 15:07:53 -03:00
*
* 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 15:07:53 -03:00
ellipse.setSize(mindplot.Topic.CONNECTOR_WIDTH, mindplot.Topic.CONNECTOR_WIDTH);
ellipse.addEvent('click', function(event) {
2011-07-26 15:07:53 -03:00
var model = topic.getModel();
var collapse = !model.areChildrenShrunken();
2011-07-26 15:07:53 -03:00
var topicId = topic.getId();
2011-08-30 14:21:55 -03:00
var actionDispatcher = mindplot.ActionDispatcher.getInstance();
actionDispatcher.shrinkBranch([topicId], collapse);
2011-07-26 15:07:53 -03:00
2011-08-30 14:21:55 -03:00
event.stopPropagation();
2011-07-26 15:07:53 -03:00
});
ellipse.addEvent('mousedown', function(event) {
2011-07-26 15:07:53 -03:00
// Avoid node creation ...
2011-08-30 14:21:55 -03:00
event.stopPropagation();
2011-07-26 15:07:53 -03:00
});
ellipse.addEvent('dblclick', function(event) {
2011-07-26 15:07:53 -03:00
// Avoid node creation ...
2011-08-30 14:21:55 -03:00
event.stopPropagation();
2011-07-26 15:07:53 -03:00
});
ellipse.addEvent('mouseover', function(event) {
2011-08-21 12:42:00 -03:00
ellipse.setFill('rgb(153, 0, 255)');
2011-07-26 15:07:53 -03:00
});
ellipse.addEvent('mouseout', function(event) {
2011-07-26 15:07:53 -03:00
var color = topic.getBackgroundColor();
this.setFill(color);
2011-09-02 02:31:03 -03:00
}.bind(this));
2011-07-26 15:07:53 -03:00
ellipse.setCursor('default');
2011-07-26 15:07:53 -03:00
this._fillColor = '#f7f7f7';
2009-06-07 18:59:43 +00:00
var model = topic.getModel();
this.changeRender(model.areChildrenShrunken());
2011-07-26 15:07:53 -03:00
},
2011-07-26 15:07:53 -03:00
changeRender: function(isShrink) {
var elipse = this._ellipse;
2011-07-26 15:07:53 -03:00
if (isShrink) {
elipse.setStroke('2', 'solid');
} else {
elipse.setStroke('1', 'solid');
}
},
setVisibility: function(value) {
this._ellipse.setVisibility(value);
2011-07-26 15:07:53 -03:00
},
setOpacity: function(opacity) {
this._ellipse.setOpacity(opacity);
2011-07-26 15:07:53 -03:00
},
setFill: function(color) {
this._fillColor = color;
this._ellipse.setFill(color);
2011-07-26 15:07:53 -03:00
},
setAttribute: function(name, value) {
this._ellipse.setAttribute(name, value);
2011-07-26 15:07:53 -03:00
},
addToWorkspace: function(group) {
2014-03-05 00:14:28 -03:00
group.append(this._ellipse);
2011-07-26 15:07:53 -03:00
},
setPosition: function(x, y) {
this._ellipse.setPosition(x, y);
2011-07-26 15:07:53 -03:00
},
moveToBack: function() {
this._ellipse.moveToBack();
2011-07-26 15:07:53 -03:00
},
moveToFront: function() {
this._ellipse.moveToFront();
2009-06-07 18:59:43 +00:00
}
2011-07-26 15:07:53 -03:00
});