equal
deleted
inserted
replaced
13 _init: function() { |
13 _init: function() { |
14 this.renderer.edge_layer.activate(); |
14 this.renderer.edge_layer.activate(); |
15 this.type = "Edge"; |
15 this.type = "Edge"; |
16 this.hidden = false; |
16 this.hidden = false; |
17 this.ghost = false; |
17 this.ghost = false; |
|
18 this.highlighted = false; |
18 this.from_representation = this.renderer.getRepresentationByModel(this.model.get("from")); |
19 this.from_representation = this.renderer.getRepresentationByModel(this.model.get("from")); |
19 this.to_representation = this.renderer.getRepresentationByModel(this.model.get("to")); |
20 this.to_representation = this.renderer.getRepresentationByModel(this.model.get("to")); |
20 this.bundle = this.renderer.addToBundles(this); |
21 this.bundle = this.renderer.addToBundles(this); |
21 this.line = new paper.Path(); |
22 this.line = new paper.Path(); |
22 this.line.add([0,0],[0,0],[0,0]); |
23 this.line.add([0,0],[0,0],[0,0]); |
71 var thickness = (this.model.has('style') && this.model.get('style').thickness) || 1; |
72 var thickness = (this.model.has('style') && this.model.get('style').thickness) || 1; |
72 return 1 + (thickness-1) * ((this.options.edge_arrow_max_width / this.options.edge_arrow_width) - 1) / (this.options.edge_stroke_witdh_scale-1); |
73 return 1 + (thickness-1) * ((this.options.edge_arrow_max_width / this.options.edge_arrow_width) - 1) / (this.options.edge_stroke_witdh_scale-1); |
73 }, |
74 }, |
74 redraw: function() { |
75 redraw: function() { |
75 var from = this.model.get("from"), |
76 var from = this.model.get("from"), |
76 to = this.model.get("to"); |
77 to = this.model.get("to"); |
77 if (!from || !to || (this.hidden && !this.ghost)) { |
78 if (!from || !to || (this.hidden && !this.ghost)) { |
78 return; |
79 return; |
79 } |
80 } |
80 this.from_representation = this.renderer.getRepresentationByModel(from); |
81 this.from_representation = this.renderer.getRepresentationByModel(from); |
81 this.to_representation = this.renderer.getRepresentationByModel(to); |
82 this.to_representation = this.renderer.getRepresentationByModel(to); |
98 _p0b = _p0a.add(_delta), /* Adding a 4 px difference */ |
99 _p0b = _p0a.add(_delta), /* Adding a 4 px difference */ |
99 _p1b = _p1a.add(_delta), /* to differentiate bundled links */ |
100 _p1b = _p1a.add(_delta), /* to differentiate bundled links */ |
100 _a = _v.angle, |
101 _a = _v.angle, |
101 _textdelta = _ortho.multiply(this.options.edge_label_distance + 0.5 * _arrow_scale * this.options.edge_arrow_width), |
102 _textdelta = _ortho.multiply(this.options.edge_label_distance + 0.5 * _arrow_scale * this.options.edge_arrow_width), |
102 _handle = _v.divide(3), |
103 _handle = _v.divide(3), |
103 _color = (this.model.has("style") && this.model.get("style").color) || (this.model.get("created_by") || Utils._USER_PLACEHOLDER(this.renkan)).get("color"), |
104 _color = (this.highlighted && this.options.highlighted_edge_color) || |
|
105 (this.model.has("style") && this.model.get("style").color) || |
|
106 (this.model.get("created_by") || Utils._USER_PLACEHOLDER(this.renkan)).get("color"), |
104 _dash = (this.model.has("style") && this.model.get("style").dash) ? this.options.default_dash_array : null, |
107 _dash = (this.model.has("style") && this.model.get("style").dash) ? this.options.default_dash_array : null, |
105 _opacity; |
108 _opacity; |
106 |
109 |
107 if (this.model.get("delete_scheduled") || this.from_representation.model.get("delete_scheduled") || this.to_representation.model.get("delete_scheduled")) { |
110 if (this.model.get("delete_scheduled") || this.from_representation.model.get("delete_scheduled") || this.to_representation.model.get("delete_scheduled")) { |
108 _opacity = 0.5; |
111 _opacity = 0.5; |
156 _a += 180; |
159 _a += 180; |
157 _textdelta = _textdelta.multiply(-1); |
160 _textdelta = _textdelta.multiply(-1); |
158 } |
161 } |
159 var _text = this.model.get("title") || this.renkan.translate(this.options.label_untitled_edges) || ""; |
162 var _text = this.model.get("title") || this.renkan.translate(this.options.label_untitled_edges) || ""; |
160 _text = Utils.shortenText(_text, this.options.node_label_max_length); |
163 _text = Utils.shortenText(_text, this.options.node_label_max_length); |
161 this.text.text(_text); |
164 if (typeof this.highlighted === "object") { |
|
165 this.text.html(this.highlighted.replace(_(_text).escape(),'<span class="Rk-Highlighted">$1</span>')); |
|
166 } else { |
|
167 this.text.text(_text); |
|
168 } |
162 var _textpos = this.paper_coords.add(_textdelta); |
169 var _textpos = this.paper_coords.add(_textdelta); |
163 this.text.css({ |
170 this.text.css({ |
164 left: _textpos.x, |
171 left: _textpos.x, |
165 top: _textpos.y, |
172 top: _textpos.y, |
166 transform: "rotate(" + _a + "deg)", |
173 transform: "rotate(" + _a + "deg)", |
274 } |
281 } |
275 } else { |
282 } else { |
276 this.renderer.paperShift(_delta); |
283 this.renderer.paperShift(_delta); |
277 } |
284 } |
278 }, |
285 }, |
|
286 highlight: function(textToReplace) { |
|
287 var hlvalue = textToReplace || true; |
|
288 if (this.highlighted === hlvalue) { |
|
289 return; |
|
290 } |
|
291 this.highlighted = hlvalue; |
|
292 this.redraw(); |
|
293 this.renderer.throttledPaperDraw(); |
|
294 }, |
|
295 unhighlight: function() { |
|
296 if (!this.highlighted) { |
|
297 return; |
|
298 } |
|
299 this.highlighted = false; |
|
300 this.redraw(); |
|
301 this.renderer.throttledPaperDraw(); |
|
302 }, |
279 destroy: function() { |
303 destroy: function() { |
280 this._super("destroy"); |
304 this._super("destroy"); |
281 this.line.remove(); |
305 this.line.remove(); |
282 this.arrow.remove(); |
306 this.arrow.remove(); |
283 this.text.remove(); |
307 this.text.remove(); |