Commit 86daaa49 authored by Akikonata's avatar Akikonata

added files

parent 4a5ccc85
Subproject commit 022e5cb489e65df8a38eedf8508478ee1d29c29c
Subproject commit 437d9c160a7961a3843cce3d9e2b01f64090f0df
/* global Layout:true */
window.layoutSwitch = true;
KityMinder.registerLayout('filetree', kity.createClass({
base: Layout,
doLayout: function(node) {
var layout = this;
if (node.isLayoutRoot()) {
this.doLayoutRoot(node);
} else {
this.arrange(node);
}
},
doLayoutRoot: function(root) {
this.arrange(root);
},
arrange: function(node) {
var children = node.getChildren();
var _this = this;
if (!children.length) {
return false;
} else {
var totalTreeWidth = 0;
// 计算每个 child 的树所占的矩形区域
var childTreeBoxes = children.map(function(node, index, children) {
var box = _this.getTreeBox([node]);
return box;
});
var nodeContentBox = node.getContentBox();
var i, x, y, child, childTreeBox, childContentBox;
var transform = new kity.Matrix();
y = nodeContentBox.bottom + node.getStyle('margin-bottom');
for (var i = 0; i < children.length; i++) {
child = children[i];
childTreeBox = childTreeBoxes[i];
childContentBox = child.getContentBox();
if (!childContentBox.width) continue;
x = 10;
y += child.getStyle('margin-top');
child.setLayoutTransform(new kity.Matrix().translate(x, y));
y += childTreeBox.height + children[i].getStyle('margin-bottom');
child.setLayoutVector(new kity.Vector(childContentBox.left + 5, childContentBox.cy));
}
}
}
}));
KityMinder.registerConnectProvider('filetree', function(node, parent) {
var box = node.getLayoutBox(),
pBox = parent.getLayoutBox();
var abs = Math.abs;
var pathData = [];
var side = box.cx > pBox.cx ? 'right' : 'left';
var left = pBox.left + 5;
pathData.push('M', new kity.Point(left, pBox.bottom));
pathData.push('L', new kity.Point(left, box.cy));
pathData.push('L', new kity.Point(box.left, box.cy));
return pathData;
});
\ No newline at end of file
KityMinder.registerTheme('filetree', {
'root-color': '#430',
'root-background': '#e9df98',
'root-stroke': 'none',
'root-font-size': 24,
'root-padding': [15, 25],
'root-margin': 100,
'root-radius': 30,
'root-space': 10,
'main-color': '#333',
'main-background': '#a4c5c0',
'main-stroke': 'none',
'main-font-size': 16,
'main-padding': [6, 20],
'main-margin': [30, 0, 10, 0],
'main-radius': 10,
'main-space': 5,
'sub-color': 'black',
'sub-background': 'white',
'sub-stroke': 'none',
'sub-font-size': 12,
'sub-padding': [5, 10],
'sub-margin': [5, 15, 10, 5],
'sub-radius': 5,
'sub-space': 5,
'connect-color': 'white',
'connect-width': 2,
'connect-radius': 5,
'selected-background': 'rgb(254, 219, 0)'
});
\ 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