Commit 16a00384 authored by techird's avatar techird

添加鱼骨图布局 - Kick Off

parent d8823e40
...@@ -60,6 +60,7 @@ ...@@ -60,6 +60,7 @@
{ path: 'src/layout/mind.js', pack: 'edit|share|m-share' }, { path: 'src/layout/mind.js', pack: 'edit|share|m-share' },
{ path: 'src/layout/filetree.js', pack: 'edit|share|m-share' }, { path: 'src/layout/filetree.js', pack: 'edit|share|m-share' },
{ path: 'src/layout/btree.js', pack: 'edit|share|m-share' }, { path: 'src/layout/btree.js', pack: 'edit|share|m-share' },
{ path: 'src/layout/fish-bone-master.js', pack: 'edit|share|m-share' },
/* 连线 */ /* 连线 */
{ path: 'src/connect/bezier.js', pack: 'edit|share|m-share' }, { path: 'src/connect/bezier.js', pack: 'edit|share|m-share' },
...@@ -78,6 +79,7 @@ ...@@ -78,6 +79,7 @@
{ path: 'src/template/structure.js', pack: 'edit|share|m-share' }, { path: 'src/template/structure.js', pack: 'edit|share|m-share' },
{ path: 'src/template/filetree.js', pack: 'edit|share|m-share' }, { path: 'src/template/filetree.js', pack: 'edit|share|m-share' },
{ path: 'src/template/right.js', pack: 'edit|share|m-share' }, { path: 'src/template/right.js', pack: 'edit|share|m-share' },
{ path: 'src/template/fish-bone.js', pack: 'edit|share|m-share' },
/* 模块 */ /* 模块 */
{ path: 'src/module/node.js', pack: 'edit|share|m-share' }, { path: 'src/module/node.js', pack: 'edit|share|m-share' },
......
/**
* @fileOverview
*
* 鱼骨头主干连线
*
* @author: techird
* @copyright: Baidu FEX, 2014
*/
KityMinder.registerConnectProvider('fish-bone-master', function(node, parent, connection) {
});
\ No newline at end of file
/**
* @fileOverview
*
* 鱼骨图主骨架布局
*
* @author: techird
* @copyright: Baidu FEX, 2014
*/
/* global Layout:true */
KityMinder.registerLayout('fish-bone-master', kity.createClass('FishBoneMasterLayout', {
base: Layout,
doLayout: function(parent, children) {
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 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(cMarginLeft, cMarginTop));
}
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');
this.move(upPart, pMarginRight + cMarginLeft, -cMarginBottom);
this.move(downPart, pMarginRight + cMarginLeft + cMarginLeft, +cMarginTop);
}
}));
\ No newline at end of file
/**
* @fileOverview
*
* 默认模板 - 鱼骨头模板
*
* @author: techird
* @copyright: Baidu FEX, 2014
*/
KityMinder.registerTemplate('fish-bone', {
getLayout: function(node) {
if (node.getData('layout')) return node.getData('layout');
var level = node.getLevel();
// 根节点
if (level === 0) {
return 'fish-bone-master';
}
// 一级节点
if (level === 1) {
return 'right';
}
return node.parent.getLayout();
},
// getConnect: function(node) {
// if (node.getLevel() == 1) return 'arc';
// return 'under';
// }
});
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment