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
Showing
19 changed files
with
437 additions
and
80 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
Submodule kity
updated
4 files
+2 −2 | dist/kity.js | |
+2 −2 | dist/kity.min.js | |
+1 −0 | src/graphic/paper.js | |
+1 −1 | src/graphic/rect.js |
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,28 @@ | ||
/** | ||
* @fileOverview | ||
* | ||
* 鱼骨头主干连线 | ||
* | ||
* @author: techird | ||
* @copyright: Baidu FEX, 2014 | ||
*/ | ||
|
||
KityMinder.registerConnectProvider('fish-bone-master', function(node, parent, connection) { | ||
|
||
var pout = parent.getLayoutVertexOut(), | ||
pin = node.getLayoutVertexIn(); | ||
|
||
var abs = Math.abs; | ||
|
||
var dy = abs(pout.y - pin.y), | ||
dx = abs(pout.x - pin.x); | ||
|
||
var pathData = []; | ||
|
||
pathData.push('M', pout.x, pout.y); | ||
pathData.push('h', dx - dy); | ||
pathData.push('L', pin.x, pin.y); | ||
|
||
connection.setMarker(null); | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,68 +1,83 @@ | ||
/* global Layout:true */ | ||
KityMinder.registerLayout('filetree', kity.createClass({ | ||
base: Layout, | ||
|
||
doLayout: function(parent, children) { | ||
var pBox = parent.getContentBox(); | ||
var indent = 20; | ||
|
||
parent.setVertexOut(new kity.Point(pBox.left + indent, pBox.bottom)); | ||
parent.setLayoutVectorOut(new kity.Vector(0, 1)); | ||
|
||
if (!children.length) return; | ||
|
||
children.forEach(function(child) { | ||
var cbox = child.getContentBox(); | ||
child.setLayoutTransform(new kity.Matrix()); | ||
|
||
child.setVertexIn(new kity.Point(cbox.left, cbox.cy)); | ||
child.setLayoutVectorIn(new kity.Vector(1, 0)); | ||
}); | ||
|
||
this.align(children, 'left'); | ||
this.stack(children, 'y'); | ||
|
||
var xAdjust = 0; | ||
xAdjust += pBox.left; | ||
xAdjust += indent; | ||
xAdjust += children[0].getStyle('margin-left'); | ||
var yAdjust = 0; | ||
yAdjust += pBox.bottom; | ||
yAdjust += parent.getStyle('margin-bottom'); | ||
yAdjust += children[0].getStyle('margin-top'); | ||
|
||
this.move(children, xAdjust, yAdjust); | ||
|
||
}, | ||
|
||
getOrderHint: function(node) { | ||
var hint = []; | ||
var box = node.getLayoutBox(); | ||
var offset = node.getLevel() > 1 ? 3 : 5; | ||
|
||
hint.push({ | ||
type: 'up', | ||
node: node, | ||
area: { | ||
x: box.x, | ||
y: box.top - node.getStyle('margin-top') - offset, | ||
width: box.width, | ||
height: node.getStyle('margin-top') | ||
}, | ||
path: ['M', box.x, box.top - offset, 'L', box.right, box.top - offset] | ||
}); | ||
|
||
hint.push({ | ||
type: 'down', | ||
node: node, | ||
area: { | ||
x: box.x, | ||
y: box.bottom + offset, | ||
width: box.width, | ||
height: node.getStyle('margin-bottom') | ||
}, | ||
path: ['M', box.x, box.bottom + offset, 'L', box.right, box.bottom + offset] | ||
}); | ||
return hint; | ||
} | ||
})); | ||
|
||
[-1, 1].forEach(function (dir) { | ||
var name = 'filetree-' + (dir > 0 ? 'down' : 'up'); | ||
|
||
KityMinder.registerLayout(name, kity.createClass({ | ||
base: Layout, | ||
|
||
doLayout: function(parent, children, round) { | ||
var pBox = parent.getContentBox(); | ||
var indent = 20; | ||
|
||
parent.setVertexOut(new kity.Point(pBox.left + indent, dir > 0 ? pBox.bottom : pBox.top)); | ||
parent.setLayoutVectorOut(new kity.Vector(0, dir)); | ||
|
||
if (!children.length) return; | ||
|
||
children.forEach(function(child) { | ||
var cbox = child.getContentBox(); | ||
child.setLayoutTransform(new kity.Matrix()); | ||
|
||
child.setVertexIn(new kity.Point(cbox.left, cbox.cy)); | ||
child.setLayoutVectorIn(new kity.Vector(1, 0)); | ||
}); | ||
|
||
this.align(children, 'left'); | ||
this.stack(children, 'y'); | ||
|
||
var xAdjust = 0; | ||
xAdjust += pBox.left; | ||
xAdjust += indent; | ||
xAdjust += children[0].getStyle('margin-left'); | ||
|
||
var yAdjust = 0; | ||
|
||
if (dir > 0) { | ||
yAdjust += pBox.bottom; | ||
yAdjust += parent.getStyle('margin-bottom'); | ||
yAdjust += children[0].getStyle('margin-top'); | ||
} else { | ||
yAdjust -= this.getTreeBox(children).bottom; | ||
yAdjust += pBox.top; | ||
yAdjust -= parent.getStyle('margin-top'); | ||
yAdjust -= children[0].getStyle('margin-bottom'); | ||
} | ||
|
||
this.move(children, xAdjust, yAdjust); | ||
|
||
}, | ||
|
||
getOrderHint: function(node) { | ||
var hint = []; | ||
var box = node.getLayoutBox(); | ||
var offset = node.getLevel() > 1 ? 3 : 5; | ||
|
||
hint.push({ | ||
type: 'up', | ||
node: node, | ||
area: { | ||
x: box.x, | ||
y: box.top - node.getStyle('margin-top') - offset, | ||
width: box.width, | ||
height: node.getStyle('margin-top') | ||
}, | ||
path: ['M', box.x, box.top - offset, 'L', box.right, box.top - offset] | ||
}); | ||
|
||
hint.push({ | ||
type: 'down', | ||
node: node, | ||
area: { | ||
x: box.x, | ||
y: box.bottom + offset, | ||
width: box.width, | ||
height: node.getStyle('margin-bottom') | ||
}, | ||
path: ['M', box.x, box.bottom + offset, 'L', box.right, box.bottom + offset] | ||
}); | ||
return hint; | ||
} | ||
})); | ||
|
||
}); |
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,73 @@ | ||
/** | ||
* @fileOverview | ||
* | ||
* 鱼骨图主骨架布局 | ||
* | ||
* @author: techird | ||
* @copyright: Baidu FEX, 2014 | ||
*/ | ||
/* global Layout:true */ | ||
KityMinder.registerLayout('fish-bone-master', kity.createClass('FishBoneMasterLayout', { | ||
base: Layout, | ||
|
||
doLayout: function(parent, children, round) { | ||
|
||
var upPart = [], | ||
downPart = []; | ||
|
||
var child = children[0]; | ||
var pBox = parent.getContentBox(); | ||
|
||
parent.setVertexOut(new kity.Point(pBox.right, pBox.cy)); | ||
parent.setLayoutVectorOut(new kity.Vector(1, 0)); | ||
|
||
if (!child) return; | ||
|
||
var cBox = child.getContentBox(); | ||
var pMarginRight = parent.getStyle('margin-right'); | ||
var cMarginLeft = child.getStyle('margin-left'); | ||
var cMarginTop = child.getStyle('margin-top'); | ||
var cMarginBottom = child.getStyle('margin-bottom'); | ||
|
||
children.forEach(function(child, index) { | ||
child.setLayoutTransform(new kity.Matrix()); | ||
var cBox = child.getContentBox(); | ||
|
||
if (index % 2) { | ||
downPart.push(child); | ||
child.setVertexIn(new kity.Point(cBox.left, cBox.top)); | ||
child.setLayoutVectorIn(new kity.Vector(1, 1)); | ||
} | ||
else { | ||
upPart.push(child); | ||
child.setVertexIn(new kity.Point(cBox.left, cBox.bottom)); | ||
child.setLayoutVectorIn(new kity.Vector(1, -1)); | ||
} | ||
|
||
}); | ||
|
||
this.stack(upPart, 'x'); | ||
this.stack(downPart, 'x'); | ||
|
||
this.align(upPart, 'bottom'); | ||
this.align(downPart, 'top'); | ||
|
||
var xAdjust = pBox.right + pMarginRight + cMarginLeft; | ||
var yAdjustUp = pBox.cy - cMarginBottom - parent.getStyle('margin-top'); | ||
var yAdjustDown = pBox.cy + cMarginTop + parent.getStyle('margin-bottom'); | ||
|
||
this.move(upPart, xAdjust, yAdjustUp); | ||
this.move(downPart, xAdjust + cMarginLeft, yAdjustDown); | ||
|
||
// children.forEach(function(child, index) { | ||
// var matrix = child.getLayoutTransform(); | ||
// var dx, dy; | ||
// dx = matrix.getMatrix().e; | ||
// dy = matrix.getMatrix().f; | ||
// matrix.translate(-dx, -dy); | ||
// matrix.rotate(index % 2 ? 45 : -45); | ||
// matrix.translate(dx, dy); | ||
// }); | ||
|
||
} | ||
})); |
Oops, something went wrong.