2016-07-06 2 views
0

私は独自のカスタムコネクタ実装を使用しています。ソースとターゲット点をより正確に計算するために、同じ要素に他のコネクタを使用できるようにしたいと考えています。JointJS要素に複数のカスタムコネクタを描画する

これまでのところ私は、関数コンテキストの下でもVElement下の役に立つ何かを見つけることができませんでした
joint.connectors.custom = function (sourcePoint, targetPoint, vertices) { 

    // I want to calculate the "middle" point while considering other links that might interrupt 
    var sourceMiddleX = this.sourceBBox.x + this.sourceBBox.width/2; 

    var d = ['M', sourcePoint.x, sourcePoint.y, targetPoint.x, targetPoint.y]; 

    return d.join(' '); 
}; 

..

誰もがより良いアイデアを持っていない限り、私は、各モデルの要素あたりの総リンクを通過します右の気分ではありません。

ありがとうございます!

答えて

0

JointJSのコネクタ関数が呼び出され、thisの値がjoint.dia.LinkViewになります。各linkViewは、それがでレンダリングの論文へのアクセス権を持っている。

var paper = this.paper; // an instance of `joint.dia.Paper` 
var graph = this.paper.model; // an instance of `joint.dia.Graph` 
var link = this.model; // an instance of `joint.dia.Link` 

// an instance of `joint.dia.Element` or `null` 
var sourceElement = link.getSourceElement(); 
var sourceElementLinks = sourceElement 
    // an array of `joint.dia.Link` including the link 
    // these are connecting the same source element as the link 
    ? graph.getConnectedLinks(sourceElement, { outbound: true }) 
    // the link is not connected to a source element 
    : []; 

// an instance of `joint.dia.Element` or `null` 
var targetElement = link.getTargetElement(); 
var targetElementLinks = targetElement 
    // an array of `joint.dia.Link` including the link 
    // these are connecting the same target element as the link 
    ? graph.getConnectedLinks(targetElement, { inbound: true }) 
    // the link is not connected to a target element 
    : []; 

また、同様のロジックを実装する、jumpOverconnectorを確認することができます。

関連する問題