Commit 322eb8ec authored by 张博's avatar 张博

add tianpan template

parent 832cb0c6
/**
*
* 圆弧连线
*
* @author: along
* @copyright: bpd729@163.com , 2015
*/
define(function(require, exports, module) {
var kity = require('../core/kity');
var connect = require('../core/connect');
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');
});
connect.register('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);
});
});
\ No newline at end of file
......@@ -76,6 +76,7 @@ define(function(require, exports, module) {
require('./layout/filetree');
require('./layout/fish-bone-master');
require('./layout/fish-bone-slave');
require('./layout/tianpan');
require('./theme/default');
require('./theme/snow');
......@@ -83,8 +84,10 @@ define(function(require, exports, module) {
require('./theme/fish');
require('./theme/snow');
require('./theme/wire');
require('./theme/tianpan');
require('./connect/arc');
require('./connect/arc_tp');
require('./connect/bezier');
require('./connect/fish-bone-master');
require('./connect/l');
......@@ -96,6 +99,7 @@ define(function(require, exports, module) {
require('./template/filetree');
require('./template/right');
require('./template/fish-bone');
require('./template/tianpan');
module.exports = kityminder;
});
\ No newline at end of file
/**
* @fileOverview
*
* 天盘模板
*
* @author: along
* @copyright: bpd729@163.com, 2015
*/
define(function(require, exports, module) {
var kity = require('../core/kity');
var Layout = require('../core/layout');
var Minder = require('../core/minder');
Layout.register('tianpan', kity.createClass({
base: Layout,
doLayout: function (parent, children) {
if (children.length == 0) return;
var layout = this;
var pbox = parent.getContentBox();
var x, y,box;
var _theta = 5;
var _r = Math.max(pbox.width, 50);
children.forEach(function (child, index) {
child.setLayoutTransform(new kity.Matrix());
box = layout.getTreeBox(child);
_r = Math.max(Math.max(box.width, box.height), _r);
})
_r = _r / 1.5 / Math.PI;
children.forEach(function (child, index) {
x = _r * (Math.cos(_theta) + Math.sin(_theta) * _theta);
y = _r * (Math.sin(_theta) - Math.cos(_theta) * _theta);
_theta += (0.9 - index * 0.02);
child.setLayoutVectorIn(new kity.Vector(1, 0));
child.setVertexIn(new kity.Point(pbox.cx, pbox.cy));
child.setLayoutTransform(new kity.Matrix());
layout.move([child], x, y);
});
},
getOrderHint: function (node) {
var hint = [];
var box = node.getLayoutBox();
var offset = 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;
}
}));
});
\ No newline at end of file
/**
* @fileOverview
*
* 天盘模板
*
* @author: along
* @copyright: bpd729@163.com, 2015
*/
define(function(require, exports, module) {
var template = require('../core/template');
template.register('tianpan', {
getLayout: function (node) {
if (node.getData('layout')) return node.getData('layout');
var level = node.getLevel();
// 根节点
if (level === 0) {
return 'tianpan';
}
return node.parent.getLayout();
},
getConnect: function (node) {
return 'arc_tp';
}
});
});
\ No newline at end of file
define(function(require, exports, module) {
var theme = require('../core/theme');
['tianpan', 'tianpan-compact'].forEach(function (name) {
var compact = name == 'tianpan-compact';
theme.register(name, {
'background': '#3A4144 url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAIAAAACDbGyAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyRpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2LjE0NTY2MSwgMjAxMi8wMi8wNi0xNDo1NjoyNyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNiAoTWFjaW50b3NoKSIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDowQzg5QTQ0NDhENzgxMUUzOENGREE4QTg0RDgzRTZDNyIgeG1wTU06RG9jdW1lbnRJRD0ieG1wLmRpZDowQzg5QTQ0NThENzgxMUUzOENGREE4QTg0RDgzRTZDNyI+IDx4bXBNTTpEZXJpdmVkRnJvbSBzdFJlZjppbnN0YW5jZUlEPSJ4bXAuaWlkOkMwOEQ1NDRGOEQ3NzExRTM4Q0ZEQThBODREODNFNkM3IiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOkMwOEQ1NDUwOEQ3NzExRTM4Q0ZEQThBODREODNFNkM3Ii8+IDwvcmRmOkRlc2NyaXB0aW9uPiA8L3JkZjpSREY+IDwveDp4bXBtZXRhPiA8P3hwYWNrZXQgZW5kPSJyIj8+e9P33AAAACVJREFUeNpisXJ0YUACTAyoAMr/+eM7EGGRZ4FQ7BycEAZAgAEAHbEGtkoQm/wAAAAASUVORK5CYII=") repeat',
'root-color': '#430',
'root-background': '#e9df98',
'root-stroke': '#e9df98',
'root-font-size': 25,
'root-padding': compact ? 15 : 20,
'root-margin': compact ? [15, 25] : 100,
'root-radius': 30,
'root-space': 10,
'root-shadow': 'rgba(0, 0, 0, .25)',
'root-shape': 'circle',
'main-color': '#333',
'main-background': '#a4c5c0',
'main-stroke': '#a4c5c0',
'main-font-size': 15,
'main-padding': compact ? 10 : 12,
'main-margin': compact ? 10 : 12,
'main-radius': 10,
'main-space': 5,
'main-shadow': 'rgba(0, 0, 0, .25)',
'main-shape': 'circle',
'sub-color': '#333',
'sub-background': '#99ca6a',
'sub-stroke': '#a4c5c0',
'sub-font-size': 13,
'sub-padding': 5,
'sub-margin': compact ? 6 : 10,
'sub-tree-margin': 30,
'sub-radius': 5,
'sub-space': 5,
'sub-shadow': 'rgba(0, 0, 0, .25)',
'sub-shape': 'circle',
'connect-color': 'white',
'connect-width': 2,
'main-connect-width': 3,
'connect-radius': 5,
'selected-background': 'rgb(254, 219, 0)',
'selected-stroke': 'rgb(254, 219, 0)',
'selected-color': 'black',
'marquee-background': 'rgba(255,255,255,.3)',
'marquee-stroke': 'white',
'drop-hint-color': 'yellow',
'sub-drop-hint-width': 2,
'main-drop-hint-width': 4,
'root-drop-hint-width': 4,
'order-hint-area-color': 'rgba(0, 255, 0, .5)',
'order-hint-path-color': '#0f0',
'order-hint-path-width': 1,
'text-selection-color': 'rgb(27,171,255)',
'line-height': 1.4
});
});
});
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