forked from fex-team/kityminder
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e4e1487
commit 4c16313
Showing
7 changed files
with
113 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/** | ||
* @fileOverview | ||
* | ||
* 圆弧连线 | ||
* | ||
* @author: techird | ||
* @copyright: Baidu FEX, 2014 | ||
*/ | ||
|
||
var connectMarker = new kity.Marker().pipe(function() { | ||
var r = 7; | ||
var dot = new kity.Circle(r - 1); | ||
this.addShape(dot); | ||
this.setRef(r - 1, 0).setViewBox(-r, -r, r + r, r + r).setWidth(r).setHeight(r); | ||
this.dot = dot; | ||
this.node.setAttribute('markerUnits', 'userSpaceOnUse'); | ||
}); | ||
|
||
KityMinder.registerConnectProvider('arc_tp', function(node, parent, connection, width, color) { | ||
var end_box = node.getLayoutBox(), | ||
start_box = parent.getLayoutBox(); | ||
|
||
|
||
if(node.getIndex()>0){ | ||
var index = node.getIndex(); | ||
start_box = parent.getChildren()[index-1].getLayoutBox(); | ||
} | ||
|
||
|
||
var start, end, vector; | ||
var abs = Math.abs; | ||
var pathData = []; | ||
var side = end_box.x > start_box.x ? 'right' : 'left'; | ||
|
||
node.getMinder().getPaper().addResource(connectMarker); | ||
|
||
start = new kity.Point(start_box.cx, start_box.cy); | ||
end = new kity.Point(end_box.cx, end_box.cy); | ||
|
||
var jl = Math.sqrt(Math.abs(start.x -end.x) * Math.abs(start.x - end.x) + Math.abs(start.y -end.y) * Math.abs(start.y -end.y)); //两圆中心点距离 | ||
|
||
jl = node.getIndex()==0 ? jl *0.4 : jl; | ||
|
||
vector = kity.Vector.fromPoints(start, end); | ||
pathData.push('M', start); | ||
pathData.push('A', jl, jl, 0, 0 , 1, end); | ||
|
||
connection.setMarker(connectMarker); | ||
connectMarker.dot.fill(color); | ||
|
||
connection.setPathData(pathData); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters