Skip to content

Commit

Permalink
Merge branch 'dev' of https://github.com/baipgydx729/kityminder into …
Browse files Browse the repository at this point in the history
…pr-233
  • Loading branch information
techird committed Apr 3, 2015
2 parents 66cda09 + 0d2dd94 commit 98472c9
Show file tree
Hide file tree
Showing 32 changed files with 433 additions and 48 deletions.
7 changes: 6 additions & 1 deletion import.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@

/* 布局 */
{ path: 'src/layout/mind.js', pack: 'edit|share|m-share' },
{ path: 'src/layout/tianpan.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/fish-bone-master.js', pack: 'edit|share|m-share' },
Expand All @@ -76,19 +77,22 @@
{ path: 'src/connect/bezier.js', pack: 'edit|share|m-share' },
{ path: 'src/connect/poly.js', pack: 'edit|share|m-share' },
{ path: 'src/connect/arc.js', pack: 'edit|share|m-share' },
{ path: 'src/connect/arc_tp.js', pack: 'edit|share|m-share' },
{ 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/theme/default.js', pack: 'edit|share|m-share' },
{ path: 'src/theme/tianpan.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/template/default.js', pack: 'edit|share|m-share' },
{ path: 'src/template/tianpan.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' },
Expand Down Expand Up @@ -161,7 +165,7 @@
{ path: 'ui/nav.js', pack: 'edit|share' },

/* UI Top Bar */
{ path: 'ui/topbar/moreservice.js', pack: 'edit|share'},
{ path: 'ui/topbar/moreservice.js', pack: 'edit|share'},

/* UI 菜单 */
{ path: 'ui/menu/menu.js', pack: 'edit|share' },
Expand Down Expand Up @@ -196,6 +200,7 @@
{ path: 'ui/topbar/quickvisit.js', pack: 'edit|share' },
{ path: 'ui/topbar/history.js', pack: 'edit' },
{ path: 'ui/topbar/user.js', pack: 'edit' },
{ path: 'ui/topbar/share.js', pack: 'edit|share' },
{ path: 'ui/topbar/feedback.js', pack: 'edit|share' },
{ path: 'ui/topbar/search.js', pack: 'edit|share' },
{ path: 'ui/topbar/switch-view.js', pack: 'm-share' },
Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

/* 初始化网盘使用的 APP 身份 */
fio.user.init({
apiKey: 'wiE55BGOG8BkGnpPs6UNtPbb'
apiKey: 'IF1PQMDsNy2iy0GKCx084qdx' //微行平台Key
});

var $a = $('p.login a').hide();
Expand Down
2 changes: 1 addition & 1 deletion kityminder.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@
maxImageHeight: 200,

// 修改后自动保存时间间隔(单位:秒);设置为 false 不自动保存
autoSave: 2
autoSave: 1000
};
})();
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
2 changes: 1 addition & 1 deletion src/connect/arc.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ KityMinder.registerConnectProvider('arc', function(node, parent, connection, wid

vector = kity.Vector.fromPoints(start, end);
pathData.push('M', start);
pathData.push('A', abs(vector.x), abs(vector.y), 0, 0, (vector.x * vector.y > 0 ? 0 : 1), end);
pathData.push('A', abs(vector.x), abs(vector.y), 0, 0 , (vector.x * vector.y > 0 ? 0 : 1), end);

connection.setMarker(connectMarker);
connectMarker.dot.fill(color);
Expand Down
53 changes: 53 additions & 0 deletions src/connect/arc_tp.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/**
* @fileOverview
*
* 圆弧连线
*
* @author: techird
* @copyright: Baidu FEX, 2014
*/

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);
});
1 change: 0 additions & 1 deletion src/connect/fish-bone-master.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
*/

KityMinder.registerConnectProvider('fish-bone-master', function(node, parent, connection) {

var pout = parent.getLayoutVertexOut(),
pin = node.getLayoutVertexIn();

Expand Down
5 changes: 2 additions & 3 deletions src/core/layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -507,12 +507,10 @@ var Layout = kity.createClass('Layout', {
matrix = node.getLayoutTransform();

treeBox = node.getContentBox();

if (node.isExpanded() && node.children.length) {
treeBox = g.mergeBox(treeBox, this.getTreeBox(node.children));
}

box = g.mergeBox(box, matrix.transformBox(treeBox));
box = g.mergeBox(box,matrix.transformBox(treeBox));
}

return box;
Expand All @@ -529,6 +527,7 @@ var LayoutCommand = kity.createClass('LayoutCommand', {
execute: function(minder, name) {
var nodes = minder.getSelectedNodes();
nodes.forEach(function(node) {

node.layout(name);
});
},
Expand Down
5 changes: 4 additions & 1 deletion src/core/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,10 @@ kity.extendClass(Minder, (function() {
// 更新渲染图形
latestBox = renderer.update(renderer.getRenderShape(), node, node._contentBox);

if (typeof(latestBox) == 'function') latestBox = latestBox();
if (typeof(latestBox) == 'function'){
latestBox = latestBox();
}


// 合并渲染区域
if (latestBox) {
Expand Down
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
11 changes: 8 additions & 3 deletions src/layout/fish-bone-master.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,11 @@ KityMinder.registerLayout('fish-bone-master', kity.createClass('FishBoneMasterLa
var child = children[0];
var pBox = parent.getContentBox();

parent.setVertexOut(new kity.Point(pBox.right, pBox.cy));
parent.setLayoutVectorOut(new kity.Vector(1, 0));
var point = new kity.Point(pBox.right, pBox.cy);
parent.setVertexOut(point);
var vector = new kity.Vector(1, 0);
parent.setLayoutVectorOut(vector);


if (!child) return;

Expand All @@ -29,6 +32,7 @@ KityMinder.registerLayout('fish-bone-master', kity.createClass('FishBoneMasterLa
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();
Expand All @@ -43,9 +47,10 @@ KityMinder.registerLayout('fish-bone-master', kity.createClass('FishBoneMasterLa
child.setVertexIn(new kity.Point(cBox.left, cBox.bottom));
child.setLayoutVectorIn(new kity.Vector(1, -1));
}

});



this.stack(upPart, 'x');
this.stack(downPart, 'x');

Expand Down
3 changes: 2 additions & 1 deletion src/layout/fish-bone-slave.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ KityMinder.registerLayout('fish-bone-slave', kity.createClass('FishBoneSlaveLayo

doLayout: function (parent, children, round) {

//debugger
var layout = this;
var abs = Math.abs;
var GOLD_CUT = 1 - 0.618;
Expand Down Expand Up @@ -50,7 +51,7 @@ KityMinder.registerLayout('fish-bone-slave', kity.createClass('FishBoneSlaveLayo
yAdjust -= child.getStyle('margin-bottom');
} else {
yAdjust += parent.getContentBox().bottom;
yAdjust += parent.getStyle('margin-bottom');
yAdjust += parent.getStyle('margin-botttom');
yAdjust += child.getStyle('margin-top');
}

Expand Down
1 change: 1 addition & 0 deletions src/layout/mind.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ KityMinder.registerLayout('mind', kity.createClass({
base: Layout,

doLayout: function(node, children) {

var layout = this;
var half = Math.ceil(node.children.length / 2);
var right = [];
Expand Down
125 changes: 125 additions & 0 deletions src/layout/tianpan.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
/**
* Created with JetBrains WebStorm.
* User: chenbaolong
* Date: 15-3-20
* Time: 上午11:04
* To change this template use File | Settings | File Templates.
*/
/* global Layout:true */

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;
var _theta = 5;
var _r = Math.max(pbox.width,50);
children.forEach(function(child, index) {
child.setLayoutTransform(new kity.Matrix());
var box = layout.getTreeBox(child);
var w = Math.max(box.width,box.height);
_r = Math.max(w,_r);
})
_r = _r / 1.5 / Math.PI;

children.forEach(function(child, index) {
// x = _r * (Math.cos(alpha) + Math.sin(alpha)* alpha * Math.PI/180);
// y = _r * (Math.sin(alpha) - Math.cos(alpha)* alpha * Math.PI/180);
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.left+15, pbox.cy+25));
child.setLayoutTransform(new kity.Matrix());
layout.move([child],x,y);

//
// child.getContentBox().translate(x, y);
// console.log(child.getContentBox());
// debugger


// _tmp_rects.forEach(function (tmpRect) {
// debugger
// if (g.getIntersectBox(tmpRect,_cut_rect)) {
// _cover = true;
// }
// })
//
// if (_cover) {
// _r += 2;
// console.log('true')
// } else {
// _do = false;
// _tempchilds.push({child: child, r: _r, theta: _theta, area: _cut_rect})
// _theta += 0.9;
// _tmp_rects.push(_cut_rect);
// }
// }
});



return;

//debugger
var layout = this;
var half = Math.ceil(node.children.length / 2);
var right = [];
var left = [];

children.forEach(function(child) {
if (child.getIndex() < half) right.push(child);
else left.push(child);
});

var leftLayout = KityMinder.getLayoutInstance('left');
var rightLayout = KityMinder.getLayoutInstance('right');

leftLayout.doLayout(node, left);
rightLayout.doLayout(node, right);

var box = node.getContentBox();
node.setVertexOut(new kity.Point(box.cx, box.cy));
node.setLayoutVectorOut(new kity.Vector(0, 0));
},

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
Loading

0 comments on commit 98472c9

Please sign in to comment.