# HG changeset patch # User veltr # Date 1346771693 -7200 # Node ID b7e236e4ec1c847a6f76116fca9fb21693543c8b # Parent fb5ac4ca3c69f7f3dfdbfd162f7f9d05fae79515 renkan updates (for multi-link compatibility) diff -r fb5ac4ca3c69 -r b7e236e4ec1c src/js/libs/renkan-publish.js --- a/src/js/libs/renkan-publish.js Tue Sep 04 17:14:10 2012 +0200 +++ b/src/js/libs/renkan-publish.js Tue Sep 04 17:14:53 2012 +0200 @@ -452,8 +452,9 @@ this.type = "Edge"; this.from_representation = this.renderer.getRepresentationByModel(this.model.get("from")); this.to_representation = this.renderer.getRepresentationByModel(this.model.get("to")); + this.bundle = this.renderer.addToBundles(this); this.line = new paper.Path(); - this.line.add([0,0],[0,0]); + this.line.add([0,0],[0,0],[0,0]); this.line.__representation = this; this.arrow = new paper.Path(); this.arrow.add([0,0],[Rkns.Renderer._ARROW_LENGTH,Rkns.Renderer._ARROW_WIDTH / 2],[0,Rkns.Renderer._ARROW_WIDTH]); @@ -470,20 +471,25 @@ } Rkns.Renderer.Edge.prototype.redraw = function() { - var _p0o = this.from_representation.paper_coords, - _p1o = this.to_representation.paper_coords, - _v = _p1o.subtract(_p0o), + var _p0a = this.from_representation.paper_coords, + _p1a = this.to_representation.paper_coords, + _v = _p1a.subtract(_p0a), _r = _v.length, _u = _v.divide(_r), - _delta = new paper.Point([- _u.y, _u.x]).multiply( 4 ), - _p0 = _p0o.add(_delta), /* Adding a 4 px difference */ - _p1 = _p1o.add(_delta), /* to differentiate inbound and outbound links */ + _group_pos = this.bundle.getPosition(this), + _delta = new paper.Point([- _u.y, _u.x]).multiply( 12 * _group_pos ), + _p0b = _p0a.add(_delta), /* Adding a 4 px difference */ + _p1b = _p1a.add(_delta), /* to differentiate inbound and outbound links */ _a = _v.angle, + _handle = _v.divide(3), _color = this.model.get("created_by").get("color"); - this.paper_coords = _p0.add(_p1).divide(2); + this.paper_coords = _p0b.add(_p1b).divide(2); this.line.strokeColor = _color; - this.line.segments[0].point = _p0; - this.line.segments[1].point = _p1; + this.line.segments[0].point = _p0a; + this.line.segments[1].point = this.paper_coords; + this.line.segments[1].handleIn = _handle.multiply(-1); + this.line.segments[1].handleOut = _handle; + this.line.segments[2].point = _p1a; this.arrow.rotate(_a - this.arrow_angle); this.arrow.fillColor = _color; this.arrow.position = this.paper_coords.subtract(_u.multiply(4)); @@ -531,6 +537,10 @@ this.line.remove(); this.arrow.remove(); this.text.remove(); + var _this = this; + this.bundle.edges = Rkns._(this.bundle.edges).reject(function(_edge) { + return _edge === _this; + }); } /* */ @@ -664,6 +674,7 @@ this.edge_layer = new paper.Layer(); this.node_layer = new paper.Layer(); this.overlay_layer = new paper.Layer(); + this.bundles = []; var _tool = new paper.Tool(), _this = this; _tool.minDistance = Rkns.Renderer._MIN_DRAG_DISTANCE; @@ -728,6 +739,30 @@ + '' ); +Rkns.Renderer.Scene.prototype.addToBundles = function(_edgeRepr) { + var _bundle = Rkns._(this.bundles).find(function(_bundle) { + return ( + ( _bundle.from === _edgeRepr.from_representation && _bundle.to === _edgeRepr.to_representation ) + || ( _bundle.from === _edgeRepr.to_representation && _bundle.to === _edgeRepr.from_representation ) + ); + }); + if (typeof _bundle !== "undefined") { + _bundle.edges.push(_edgeRepr) + } else { + _bundle = { + from: _edgeRepr.from_representation, + to: _edgeRepr.to_representation, + edges: [ _edgeRepr ], + getPosition: function(_er) { + var _dir = (_er.from_representation === this.from) ? 1 : -1; + return _dir * ( Rkns._(this.edges).indexOf(_er) - (this.edges.length - 1) / 2 ); + } + } + this.bundles.push(_bundle); + } + return _bundle; +} + Rkns.Renderer.Scene.prototype.autoScale = function() { if (this.renkan.project.get("nodes").length) { var _xx = this.renkan.project.get("nodes").map(function(_node) { return _node.get("position").x }), diff -r fb5ac4ca3c69 -r b7e236e4ec1c src/widgets/Renkan.js --- a/src/widgets/Renkan.js Tue Sep 04 17:14:10 2012 +0200 +++ b/src/widgets/Renkan.js Tue Sep 04 17:14:53 2012 +0200 @@ -80,7 +80,7 @@ _this.player.popcorn.trigger("IriSP.search.triggeredSearch",_tagmatch[1]); }) _node.on("unselect", function() { - _this.player.popcorn.trigger("IriSP.search.triggeredSearch",""); + _this.player.popcorn.trigger("IriSP.search.cleared"); }) } }); diff -r fb5ac4ca3c69 -r b7e236e4ec1c test/json/renkan.json --- a/test/json/renkan.json Tue Sep 04 17:14:10 2012 +0200 +++ b/test/json/renkan.json Tue Sep 04 17:14:53 2012 +0200 @@ -187,6 +187,22 @@ "to": "node-2012-08-22-9da6eef6c6391d05-000b", "created_by": "u-raphv" }, { + "id": "edge-manual-001", + "title": "theme of", + "uri": "", + "description": "", + "from": "node-2012-08-22-9da6eef6c6391d05-000b", + "to": "node-2012-08-22-9da6eef6c6391d05-0001", + "created_by": "u-cybunk" + }, { + "id": "edge-manual-002", + "title": "example of", + "uri": "", + "description": "", + "from": "node-2012-08-22-b778a9fc31296d6b-000a", + "to": "node-2012-08-22-9da6eef6c6391d05-000b", + "created_by": "u-cybunk" + }, { "id": "edge-2012-08-22-b778a9fc31296d6b-0002", "title": "Are related to", "uri": "",