Skip to content

Commit

Permalink
Merge branch 'pr-233' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
techird committed Apr 8, 2015
2 parents 9f6f8c5 + 9f8018b commit 53206fa
Show file tree
Hide file tree
Showing 17 changed files with 301 additions and 6 deletions.
4 changes: 4 additions & 0 deletions import.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
{ path: 'src/layout/btree.js', pack: 'edit|share|m-share' },
{ path: 'src/layout/fish-bone-master.js', pack: 'edit|share|m-share' },
{ path: 'src/layout/fish-bone-slave.js', pack: 'edit|share|m-share' },
{ path: 'src/layout/tianpan.js', pack: 'edit|share|m-share' },

/* 连线 */
{ path: 'src/connect/bezier.js', pack: 'edit|share|m-share' },
Expand All @@ -79,20 +80,23 @@
{ path: 'src/connect/under.js', pack: 'edit|share|m-share' },
{ path: 'src/connect/l.js', pack: 'edit|share|m-share' },
{ path: 'src/connect/fish-bone-master.js', pack: 'edit|share|m-share' },
{ path: 'src/connect/arc_tp.js', pack: 'edit|share|m-share' },

/* 皮肤 */
{ path: 'src/theme/default.js', pack: 'edit|share|m-share' },
{ path: 'src/theme/snow.js', pack: 'edit|share|m-share' },
{ path: 'src/theme/fresh.js', pack: 'edit|share|m-share' },
{ path: 'src/theme/fish.js', pack: 'edit|share|m-share' },
{ path: 'src/theme/wire.js', pack: 'edit|share|m-share' },
{ path: 'src/theme/tianpan.js', pack: 'edit|share|m-share' },

/* 模板 */
{ path: 'src/template/default.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/right.js', pack: 'edit|share|m-share' },
{ path: 'src/template/fish-bone.js', pack: 'edit|share|m-share' },
{ path: 'src/template/tianpan.js', pack: 'edit|share|m-share' },

/* 模块 */
{ path: 'src/module/node.js', pack: 'edit|share|m-share' },
Expand Down
6 changes: 5 additions & 1 deletion lang/zh-cn/zh-cn.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@

KityMinder.LANG['zh-cn'] = {
'template': {
'default': '思维导图',
'tianpan': '天盘图',
'structure': '组织结构图',
'filetree': '目录组织图',
'right': '逻辑结构图',
Expand All @@ -24,7 +26,9 @@ KityMinder.LANG['zh-cn'] = {
'fresh-green-compat': '紧凑绿',
'fresh-blue-compat': '紧凑蓝',
'fresh-purple-compat': '紧凑紫',
'fresh-pink-compat': '紧凑粉'
'fresh-pink-compat': '紧凑粉',
'tianpan':'经典天盘',
'tianpan-compact': '紧凑天盘'
},
'maintopic': '中心主题',
'topic': '分支主题',
Expand Down
52 changes: 52 additions & 0 deletions src/connect/arc_tp.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/**
*
* 圆弧连线
*
* @author: along
* @copyright: [email protected] , 2015
*/

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);
});
2 changes: 2 additions & 0 deletions src/layout/filetree.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@


/* global Layout:true */

[-1, 1].forEach(function (dir) {
Expand Down
70 changes: 70 additions & 0 deletions src/layout/tianpan.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/**
* @fileOverview
*
* 天盘模板
*
* @author: along
* @copyright: [email protected], 2015
*/
KityMinder.registerLayout('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;
}
}));
1 change: 1 addition & 0 deletions src/module/dragtree.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ var TreeDragger = kity.createClass('TreeDragger', {
} else {
this._minder.fire('savescene');
}

this._minder.layout(300);
this._leaveDragMode();
this._minder.fire('contentchange');
Expand Down
56 changes: 53 additions & 3 deletions src/module/outline.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ var OutlineRenderer = kity.createClass('OutlineRenderer', {

update: function(outline, node, box) {

//增加圆形update、待更好解决方案
var shape = node.getStyle('shape');
if(shape){
if(shape=='circle'){
return updateCircle(outline, node, box);
}
}
var paddingLeft = node.getStyle('padding-left'),
paddingRight = node.getStyle('padding-right'),
paddingTop = node.getStyle('padding-top'),
Expand All @@ -42,6 +49,39 @@ var OutlineRenderer = kity.createClass('OutlineRenderer', {
}
});


//圆
function updateCircle(outline, node, box){

var paddingLeft = node.getStyle('padding-left'),
paddingRight = node.getStyle('padding-right'),
paddingTop = node.getStyle('padding-top'),
paddingBottom = node.getStyle('padding-bottom');

var width= Math.max(box.width,box.height);

var outlineBox = {
x: box.x - paddingLeft,
y: box.y - paddingTop,
width: width + paddingLeft + paddingRight,
height: width + paddingTop + paddingBottom
};

var prefix = node.isSelected() ? 'selected-' : '';

width= Math.max(outlineBox.width,outlineBox.height);

outline
.setPosition(outlineBox.x, outlineBox.y)
.setSize(width, width)
.setRadius(width/2)
.fill(node.getData('background') || node.getStyle(prefix + 'background') || node.getStyle('background'))
.stroke(node.getStyle(prefix + 'stroke' || node.getStyle('stroke')),
node.getStyle(prefix + 'stroke-width'));
return new kity.Box(outlineBox);
}


var ShadowRenderer = kity.createClass('ShadowRenderer', {
base: Renderer,

Expand All @@ -56,12 +96,22 @@ var ShadowRenderer = kity.createClass('ShadowRenderer', {

update: function(shadow, node, box) {
shadow.setPosition(box.x + 4, box.y + 5)
.setSize(box.width, box.height)
.fill(node.getStyle('shadow'))
.setRadius(node.getStyle('radius'));
.fill(node.getStyle('shadow'));

var shape = node.getStyle('shape');
if(!shape){
shadow.setSize(box.width, box.height)
shadow.setRadius(node.getStyle('radius'));

}else if(shape=='circle'){
var width= Math.max(box.width,box.height);
shadow.setSize(width, width)
shadow.setRadius(width/2);
}
}
});


var marker = new kity.Marker();

marker.setWidth(10);
Expand Down
8 changes: 7 additions & 1 deletion src/module/text.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,13 @@ var TextRenderer = KityMinder.TextRenderer = kity.createClass('TextRenderer', {
rBox = rBox.merge(new kity.Box(0, y, textShape.getBoundaryBox().width || 1, fontSize));
});

var nBox = new kity.Box(r(rBox.x), r(rBox.y), r(rBox.width), r(rBox.height));
//为了让文字在圆中垂直居中
var w = 0;
var shape = node.getStyle('shape');
if(shape && shape=='circle'){
w = Math.max(rBox.width,rBox.height)/2-rBox.height/2;
}
var nBox = new kity.Box(r(rBox.x), r(rBox.y-w), r(rBox.width), r(rBox.height));

node._currentTextGroupBox = nBox;
return nBox;
Expand Down
26 changes: 26 additions & 0 deletions src/template/tianpan.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
* @fileOverview
*
* 天盘模板
*
* @author: along
* @copyright: [email protected], 2015
*/

KityMinder.registerTemplate('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';
}
});
65 changes: 65 additions & 0 deletions src/theme/tianpan.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
['tianpan', 'tianpan-compact'].forEach(function (name) {
var compact = name == 'tianpan-compact';

KityMinder.registerTheme(name, {
'background': '#3A4144 url(ui/theme/default/images/grid.png) 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
});
});
Loading

0 comments on commit 53206fa

Please sign in to comment.