2014-11-30 19:10:27 +00:00
|
|
|
export default {
|
|
|
|
render_label(container, text) {
|
|
|
|
var group = container.group();
|
|
|
|
|
2014-12-04 01:02:56 +00:00
|
|
|
group.rect();
|
2014-11-30 19:10:27 +00:00
|
|
|
|
|
|
|
group.text().attr({
|
|
|
|
text: text
|
|
|
|
});
|
|
|
|
|
|
|
|
return group;
|
|
|
|
},
|
|
|
|
|
|
|
|
position_label(group) {
|
|
|
|
var text = group.select('text'),
|
|
|
|
rect = group.select('rect'),
|
|
|
|
box = text.getBBox(),
|
|
|
|
margin = 5;
|
|
|
|
|
|
|
|
text.transform(Snap.matrix()
|
|
|
|
.translate(margin, box.height + margin));
|
|
|
|
|
|
|
|
rect.attr({
|
|
|
|
width: box.width + 2 * margin,
|
|
|
|
height: box.height + 2 * margin
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2014-11-30 20:36:53 +00:00
|
|
|
render_bbox(container, box) {
|
2014-12-03 00:15:19 +00:00
|
|
|
container.path(box.path)
|
2014-11-30 20:36:53 +00:00
|
|
|
.attr({
|
2014-12-03 00:15:19 +00:00
|
|
|
'class': 'bounding-box'
|
|
|
|
});
|
2014-11-30 20:36:53 +00:00
|
|
|
},
|
|
|
|
|
2014-12-03 23:59:59 +00:00
|
|
|
render() {
|
|
|
|
this.container.attr({ 'class': 'placeholder' });
|
2014-11-30 19:10:27 +00:00
|
|
|
|
2014-12-03 23:59:59 +00:00
|
|
|
this.label = this.render_label(this.container, this.textValue);
|
2014-12-04 01:02:56 +00:00
|
|
|
|
|
|
|
this.label.select('rect').attr({
|
|
|
|
rx: 10,
|
|
|
|
ry: 10
|
|
|
|
});
|
2014-11-30 19:10:27 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
position() {
|
|
|
|
this.position_label(this.label);
|
|
|
|
}
|
|
|
|
};
|