forked from fex-team/kityminder
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
301 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
|
||
|
||
/* global Layout:true */ | ||
|
||
[-1, 1].forEach(function (dir) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
})); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'; | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
}); | ||
}); |
Oops, something went wrong.