| author | ymh <ymh.work@gmail.com> |
| Tue, 25 Dec 2012 21:29:11 +0100 | |
| changeset 47 | 267d67791e05 |
| child 48 | 01fb9167ad75 |
| permissions | -rw-r--r-- |
|
47
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1 |
Rkns.Renderer = { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
2 |
_MARGIN_X: 80, |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
3 |
_MARGIN_Y: 50, |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
4 |
_MIN_DRAG_DISTANCE: 2, |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
5 |
_NODE_RADIUS: 25, |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
6 |
_NODE_BUTTON_INNER: 26, |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
7 |
_NODE_BUTTON_OUTER: 60, |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
8 |
_EDGE_BUTTON_INNER: 1, |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
9 |
_EDGE_BUTTON_OUTER: 40, |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
10 |
_NODE_FONT_SIZE: 10, |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
11 |
_EDGE_FONT_SIZE: 9, |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
12 |
_NODE_MAX_CHAR: 50, |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
13 |
_EDGE_MAX_CHAR: 40, |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
14 |
_ARROW_LENGTH: 16, |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
15 |
_ARROW_WIDTH: 8, |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
16 |
_EDITOR_ARROW_LENGTH : 20, |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
17 |
_EDITOR_ARROW_WIDTH : 40, |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
18 |
_EDITOR_MARGIN : 15, |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
19 |
_EDITOR_PADDING : 10, |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
20 |
_EDITOR_GRADIENT : new paper.Gradient(['#f0f0f0', '#d0d0d0']), |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
21 |
_CLICKMODE_ADDNODE : 1, |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
22 |
_CLICKMODE_STARTEDGE : 2, |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
23 |
_CLICKMODE_ENDEDGE : 3 |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
24 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
25 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
26 |
Rkns.Renderer.Utils = { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
27 |
drawEditBox : function(_coords, _path, _width, _xmargin, _selector) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
28 |
_selector.css({ |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
29 |
width: (_width - 2* Rkns.Renderer._EDITOR_PADDING), |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
30 |
}) |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
31 |
var _height = _selector.outerHeight() + 2* Rkns.Renderer._EDITOR_PADDING, |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
32 |
_isLeft = (_coords.x < paper.view.center.x ? 1 : -1), |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
33 |
_left = _coords.x + _isLeft * ( _xmargin + Rkns.Renderer._EDITOR_ARROW_LENGTH ), |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
34 |
_right = _coords.x + _isLeft * ( _xmargin + Rkns.Renderer._EDITOR_ARROW_LENGTH + _width ), |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
35 |
_top = _coords.y - _height / 2; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
36 |
if (_top < Rkns.Renderer._EDITOR_MARGIN) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
37 |
_top = Math.min( Rkns.Renderer._EDITOR_MARGIN, _coords.y - Rkns.Renderer._EDITOR_ARROW_WIDTH / 2 ); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
38 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
39 |
var _bottom = _top + _height; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
40 |
if (_bottom > (paper.view.size.height - Rkns.Renderer._EDITOR_MARGIN)) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
41 |
_bottom = Math.max( paper.view.size.height - Rkns.Renderer._EDITOR_MARGIN, _coords.y + Rkns.Renderer._EDITOR_ARROW_WIDTH / 2 ); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
42 |
_top = _bottom - _height; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
43 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
44 |
_path.segments[0].point |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
45 |
= _path.segments[7].point |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
46 |
= _coords.add([_isLeft * _xmargin, 0]); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
47 |
_path.segments[1].point.x |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
48 |
= _path.segments[2].point.x |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
49 |
= _path.segments[5].point.x |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
50 |
= _path.segments[6].point.x |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
51 |
= _left; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
52 |
_path.segments[3].point.x |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
53 |
= _path.segments[4].point.x |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
54 |
= _right; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
55 |
_path.segments[2].point.y |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
56 |
= _path.segments[3].point.y |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
57 |
= _top; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
58 |
_path.segments[4].point.y |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
59 |
= _path.segments[5].point.y |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
60 |
= _bottom; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
61 |
_path.segments[1].point.y = _coords.y - Rkns.Renderer._EDITOR_ARROW_WIDTH / 2; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
62 |
_path.segments[6].point.y = _coords.y + Rkns.Renderer._EDITOR_ARROW_WIDTH / 2; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
63 |
_path.closed = true; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
64 |
_path.fillColor = new paper.GradientColor(Rkns.Renderer._EDITOR_GRADIENT, [0,_top], [0, _bottom]); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
65 |
_selector.css({ |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
66 |
left: (Rkns.Renderer._EDITOR_PADDING + Math.min(_left, _right)), |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
67 |
top: (Rkns.Renderer._EDITOR_PADDING + _top) |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
68 |
}); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
69 |
}, |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
70 |
sector : function(_repr, _inR, _outR, _startAngle, _endAngle, _padding, _imgsrc, _caption) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
71 |
var _startRads = _startAngle * Math.PI / 180, |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
72 |
_endRads = _endAngle * Math.PI / 180, |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
73 |
_img = new Image(), |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
74 |
_span = _endRads - _startRads, |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
75 |
_k = .0879 * _span, |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
76 |
_kin = _k * _inR, |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
77 |
_kout = _k * _outR, |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
78 |
_startdx = - Math.sin(_startRads), |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
79 |
_startdy = Math.cos(_startRads), |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
80 |
_startXIn = Math.cos(_startRads) * _inR + _padding * _startdx, |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
81 |
_startYIn = Math.sin(_startRads) * _inR + _padding * _startdy, |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
82 |
_startXOut = Math.cos(_startRads) * _outR + _padding * _startdx, |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
83 |
_startYOut = Math.sin(_startRads) * _outR + _padding * _startdy, |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
84 |
_enddx = - Math.sin(_endRads), |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
85 |
_enddy = Math.cos(_endRads), |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
86 |
_endXIn = Math.cos(_endRads) * _inR - _padding * _enddx, |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
87 |
_endYIn = Math.sin(_endRads) * _inR - _padding * _enddy, |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
88 |
_endXOut = Math.cos(_endRads) * _outR - _padding * _enddx, |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
89 |
_endYOut = Math.sin(_endRads) * _outR - _padding * _enddy, |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
90 |
_centerR = (_inR + _outR)/2, |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
91 |
_centerRads = (_startRads + _endRads) / 2, |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
92 |
_centerX = Math.cos(_centerRads) * _centerR, |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
93 |
_centerY = Math.sin(_centerRads) * _centerR, |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
94 |
_textX = Math.cos(_centerRads) * (_outR + 3), |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
95 |
_textY = Math.sin(_centerRads) * (_outR + 3), |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
96 |
_segments = []; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
97 |
_segments.push([[_startXIn, _startYIn], [0, 0], [ _kin * _startdx, _kin * _startdy ]]); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
98 |
for (var i = 1; i < 4; i++) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
99 |
var _rads = i * _span / 4 + _startRads, |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
100 |
_dx = - Math.sin(_rads), |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
101 |
_dy = Math.cos(_rads), |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
102 |
_x = Math.cos(_rads) * _inR, |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
103 |
_y = Math.sin(_rads) * _inR; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
104 |
_segments.push([[_x, _y], [ - _kin * _dx, - _kin * _dy], [ _kin * _dx, _kin * _dy ]]); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
105 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
106 |
_segments.push([[_endXIn, _endYIn], [ - _kin * _enddx, - _kin * _enddy ], [0,0]]); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
107 |
_segments.push([[_endXOut, _endYOut], [ 0,0 ], [ - _kout * _enddx, - _kout * _enddy ]]); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
108 |
for (var i = 3; i > 0; i--) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
109 |
var _rads = i * _span / 4 + _startRads, |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
110 |
_dx = - Math.sin(_rads), |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
111 |
_dy = Math.cos(_rads), |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
112 |
_x = Math.cos(_rads) * _outR, |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
113 |
_y = Math.sin(_rads) * _outR; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
114 |
_segments.push([[_x, _y], [ _kout * _dx, _kout * _dy], [ - _kout * _dx, - _kout * _dy ]]); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
115 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
116 |
_segments.push([[_startXOut, _startYOut], [ _kout * _startdx, _kout * _startdy ], [0, 0]]); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
117 |
var _path = new paper.Path(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
118 |
_path.add.apply(_path, _segments); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
119 |
_path.fillColor = "#333333"; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
120 |
_path.opacity = .5; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
121 |
_path.closed = true; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
122 |
_path.__representation = _repr; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
123 |
if (_textX >= -2 && _textX <= 2) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
124 |
if (_textY > 0) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
125 |
_textY += 6; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
126 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
127 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
128 |
var _text = new paper.PointText(_textX,_textY); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
129 |
_text.characterStyle = { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
130 |
fontSize: 9, |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
131 |
fillColor: '#c000c0' |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
132 |
}; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
133 |
if (_textX > 2) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
134 |
_text.paragraphStyle.justification = 'left'; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
135 |
} else if (_textX < -2) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
136 |
_text.paragraphStyle.justification = 'right'; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
137 |
} else { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
138 |
_text.paragraphStyle.justification = 'center'; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
139 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
140 |
_text.visible = false; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
141 |
var _visible = false, |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
142 |
_restPos = new paper.Point(-200, -200), |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
143 |
_grp = new paper.Group([_path, _text]), |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
144 |
_delta = _grp.position, |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
145 |
_imgdelta = new paper.Point([_centerX, _centerY]), |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
146 |
_currentPos = new paper.Point(0,0); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
147 |
_text.content = _caption; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
148 |
_grp.visible = false; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
149 |
_grp.position = _restPos; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
150 |
var _res = { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
151 |
show: function() { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
152 |
_visible = true; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
153 |
_grp.position = _currentPos.add(_delta); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
154 |
_grp.visible = true; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
155 |
}, |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
156 |
moveTo: function(_point) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
157 |
_currentPos = _point; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
158 |
if (_visible) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
159 |
_grp.position = _point.add(_delta); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
160 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
161 |
}, |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
162 |
hide: function() { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
163 |
_visible = false; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
164 |
_grp.visible = false; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
165 |
_grp.position = _restPos; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
166 |
}, |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
167 |
select: function() { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
168 |
_path.opacity = .8; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
169 |
_text.visible = true; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
170 |
}, |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
171 |
unselect: function() { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
172 |
_path.opacity = .5; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
173 |
_text.visible = false; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
174 |
}, |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
175 |
destroy: function() { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
176 |
_grp.remove(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
177 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
178 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
179 |
_img.onload = function() { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
180 |
var _h = _img.height; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
181 |
var _raster = new paper.Raster(_img); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
182 |
_raster.position = _imgdelta.add(_grp.position).subtract(_delta); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
183 |
_grp.addChild(_raster); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
184 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
185 |
_img.src = _imgsrc; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
186 |
return _res |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
187 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
188 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
189 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
190 |
Rkns.Renderer._BaseRepresentation = function(_renderer, _model) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
191 |
if (typeof _renderer !== "undefined") { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
192 |
this.renderer = _renderer; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
193 |
this.project = _renderer.renkan.project; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
194 |
this.model = _model; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
195 |
if (this.model) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
196 |
var _this = this; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
197 |
this._changeBinding = function() { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
198 |
_this.redraw(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
199 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
200 |
this._removeBinding = function() { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
201 |
_renderer.removeRepresentation(_this); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
202 |
_renderer.redraw(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
203 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
204 |
this.model.on("change", this._changeBinding ); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
205 |
this.model.on("remove", this._removeBinding ); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
206 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
207 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
208 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
209 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
210 |
Rkns.Renderer._BaseRepresentation.prototype.super = function(_func) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
211 |
Rkns.Renderer._BaseRepresentation.prototype[_func].apply(this, Array.prototype.slice.call(arguments, 1)); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
212 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
213 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
214 |
Rkns.Renderer._BaseRepresentation.prototype.select = function() {} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
215 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
216 |
Rkns.Renderer._BaseRepresentation.prototype.unselect = function() {} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
217 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
218 |
Rkns.Renderer._BaseRepresentation.prototype.highlight = function() {} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
219 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
220 |
Rkns.Renderer._BaseRepresentation.prototype.unhighlight = function() {} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
221 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
222 |
Rkns.Renderer._BaseRepresentation.prototype.mouseup = function() {} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
223 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
224 |
Rkns.Renderer._BaseRepresentation.prototype.destroy = function() { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
225 |
if (this.model) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
226 |
this.model.off("change", this._changeBinding ); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
227 |
this.model.off("remove", this._removeBinding ); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
228 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
229 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
230 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
231 |
Rkns.Renderer.Node = Rkns.Utils.inherit(Rkns.Renderer._BaseRepresentation); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
232 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
233 |
Rkns.Renderer.Node.prototype._init = function() { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
234 |
this.renderer.node_layer.activate(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
235 |
this.type = "Node"; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
236 |
this.circle = new paper.Path.Circle([0, 0], Rkns.Renderer._NODE_RADIUS); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
237 |
this.circle.fillColor = '#ffffff'; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
238 |
this.circle.__representation = this; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
239 |
this.title = new paper.PointText([0,0]); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
240 |
this.title.characterStyle = { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
241 |
fontSize: Rkns.Renderer._NODE_FONT_SIZE, |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
242 |
fillColor: 'black' |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
243 |
}; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
244 |
this.edit_button = new Rkns.Renderer.NodeEditButton(this.renderer, null); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
245 |
this.edit_button.node_representation = this; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
246 |
this.remove_button = new Rkns.Renderer.NodeRemoveButton(this.renderer, null); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
247 |
this.remove_button.node_representation = this; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
248 |
this.link_button = new Rkns.Renderer.NodeLinkButton(this.renderer, null); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
249 |
this.link_button.node_representation = this; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
250 |
this.title.paragraphStyle.justification = 'center'; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
251 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
252 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
253 |
Rkns.Renderer.Node.prototype.redraw = function() { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
254 |
var _model_coords = new paper.Point(this.model.get("position")); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
255 |
this.paper_coords = this.renderer.toPaperCoords(_model_coords); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
256 |
this.circle.position = this.paper_coords; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
257 |
this.title.content = this.model.get("title"); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
258 |
this.title.position = this.paper_coords.add([0, Rkns.Renderer._NODE_RADIUS + 1.5 *Rkns.Renderer._NODE_FONT_SIZE]); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
259 |
this.circle.strokeColor = this.model.get("created_by").get("color"); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
260 |
this.edit_button.moveTo(this.paper_coords); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
261 |
this.remove_button.moveTo(this.paper_coords); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
262 |
this.link_button.moveTo(this.paper_coords); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
263 |
var _img = this.model.get("image"); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
264 |
if (_img && _img !== this.img) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
265 |
var _image = new Image(), |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
266 |
_this = this; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
267 |
_image.onload = function() { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
268 |
if (_this.node_image) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
269 |
_this.node_image.remove(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
270 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
271 |
_this.renderer.node_layer.activate(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
272 |
var _ratio = Math.min(1, 2 * Rkns.Renderer._NODE_RADIUS / _image.width, 2 * Rkns.Renderer._NODE_RADIUS / _image.height ); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
273 |
var _raster = new paper.Raster(_image); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
274 |
var _clip = new paper.Path.Circle([0, 0], Rkns.Renderer._NODE_RADIUS); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
275 |
_raster.scale(_ratio); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
276 |
_this.node_image = new paper.Group(_clip, _raster); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
277 |
_this.node_image.opacity = .9; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
278 |
/* This is a workaround to allow clipping at group level |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
279 |
* If opacity was set to 1, paper.js would merge all clipping groups in one (known bug). |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
280 |
*/ |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
281 |
_this.node_image.clipped = true; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
282 |
_this.node_image.position = _this.paper_coords; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
283 |
_this.node_image.__representation = _this; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
284 |
_clip.__representation = _this; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
285 |
paper.view.draw(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
286 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
287 |
_image.src = _img; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
288 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
289 |
this.img = _img; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
290 |
if (this.node_image) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
291 |
if (!this.img) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
292 |
this.node_image.remove(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
293 |
delete this.node_image; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
294 |
} else { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
295 |
this.node_image.position = this.paper_coords; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
296 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
297 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
298 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
299 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
300 |
Rkns.Renderer.Node.prototype.paperShift = function(_delta) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
301 |
var _coords = this.renderer.toModelCoords(this.paper_coords.add(_delta)), |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
302 |
_data = { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
303 |
position: { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
304 |
x: _coords.x, |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
305 |
y: _coords.y |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
306 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
307 |
}; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
308 |
this.model.set(_data); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
309 |
this.renderer.redraw(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
310 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
311 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
312 |
Rkns.Renderer.Node.prototype.openEditor = function() { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
313 |
this.renderer.removeRepresentationsOfType("editor"); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
314 |
var _editor = this.renderer.addRepresentation("NodeEditor",null); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
315 |
_editor.node_representation = this; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
316 |
_editor.draw(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
317 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
318 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
319 |
Rkns.Renderer.Node.prototype.select = function() { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
320 |
this.circle.strokeWidth = 3; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
321 |
this.edit_button.show(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
322 |
this.remove_button.show(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
323 |
this.link_button.show(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
324 |
var _uri = this.model.get("uri"); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
325 |
Rkns.$('.Rk-Bin-Item').each(function() { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
326 |
var _el = Rkns.$(this); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
327 |
if (_el.attr("data-uri") == _uri) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
328 |
_el.addClass("selected"); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
329 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
330 |
}); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
331 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
332 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
333 |
Rkns.Renderer.Node.prototype.unselect = function(_newTarget) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
334 |
if (!_newTarget || _newTarget.node_representation !== this) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
335 |
this.edit_button.hide(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
336 |
this.remove_button.hide(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
337 |
this.link_button.hide(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
338 |
this.circle.strokeWidth = 1; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
339 |
Rkns.$('.Rk-Bin-Item').removeClass("selected"); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
340 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
341 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
342 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
343 |
Rkns.Renderer.Node.prototype.highlight = function() { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
344 |
this.circle.fillColor = "#ffff80"; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
345 |
if (this.node_image) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
346 |
this.node_image.opacity = .5; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
347 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
348 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
349 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
350 |
Rkns.Renderer.Node.prototype.unhighlight = function(_newTarget) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
351 |
this.circle.fillColor = "#ffffff"; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
352 |
if (this.node_image) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
353 |
this.node_image.opacity = .9; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
354 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
355 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
356 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
357 |
Rkns.Renderer.Node.prototype.mouseup = function(_event) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
358 |
if (!this.renderer.is_dragging) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
359 |
this.openEditor(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
360 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
361 |
this.renderer.click_target = null; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
362 |
this.renderer.is_dragging = false; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
363 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
364 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
365 |
Rkns.Renderer.Node.prototype.destroy = function(_event) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
366 |
this.super("destroy"); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
367 |
this.edit_button.destroy(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
368 |
this.remove_button.destroy(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
369 |
this.link_button.destroy(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
370 |
this.circle.remove(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
371 |
this.title.remove(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
372 |
if (this.node_image) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
373 |
this.node_image.remove(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
374 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
375 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
376 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
377 |
/* */ |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
378 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
379 |
Rkns.Renderer.Edge = Rkns.Utils.inherit(Rkns.Renderer._BaseRepresentation); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
380 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
381 |
Rkns.Renderer.Edge.prototype._init = function() { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
382 |
this.renderer.edge_layer.activate(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
383 |
this.type = "Edge"; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
384 |
this.from_representation = this.renderer.getRepresentationByModel(this.model.get("from")); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
385 |
this.to_representation = this.renderer.getRepresentationByModel(this.model.get("to")); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
386 |
this.bundle = this.renderer.addToBundles(this); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
387 |
this.line = new paper.Path(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
388 |
this.line.add([0,0],[0,0],[0,0]); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
389 |
this.line.__representation = this; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
390 |
this.arrow = new paper.Path(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
391 |
this.arrow.add([0,0],[Rkns.Renderer._ARROW_LENGTH,Rkns.Renderer._ARROW_WIDTH / 2],[0,Rkns.Renderer._ARROW_WIDTH]); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
392 |
this.arrow.__representation = this; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
393 |
this.text = new paper.PointText(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
394 |
this.text.characterStyle = { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
395 |
fontSize: Rkns.Renderer._EDGE_FONT_SIZE, |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
396 |
fillColor: 'black' |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
397 |
}; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
398 |
this.text.paragraphStyle.justification = 'center'; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
399 |
this.text_angle = 0; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
400 |
this.arrow_angle = 0; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
401 |
this.edit_button = new Rkns.Renderer.EdgeEditButton(this.renderer, null); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
402 |
this.edit_button.edge_representation = this; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
403 |
this.remove_button = new Rkns.Renderer.EdgeRemoveButton(this.renderer, null); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
404 |
this.remove_button.edge_representation = this; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
405 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
406 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
407 |
Rkns.Renderer.Edge.prototype.redraw = function() { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
408 |
var _p0a = this.from_representation.paper_coords, |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
409 |
_p1a = this.to_representation.paper_coords, |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
410 |
_v = _p1a.subtract(_p0a), |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
411 |
_r = _v.length, |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
412 |
_u = _v.divide(_r), |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
413 |
_group_pos = this.bundle.getPosition(this), |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
414 |
_delta = new paper.Point([- _u.y, _u.x]).multiply( 12 * _group_pos ), |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
415 |
_p0b = _p0a.add(_delta), /* Adding a 4 px difference */ |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
416 |
_p1b = _p1a.add(_delta), /* to differentiate inbound and outbound links */ |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
417 |
_a = _v.angle, |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
418 |
_handle = _v.divide(3), |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
419 |
_color = this.model.get("created_by").get("color"); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
420 |
this.paper_coords = _p0b.add(_p1b).divide(2); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
421 |
this.line.strokeColor = _color; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
422 |
this.line.segments[0].point = _p0a; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
423 |
this.line.segments[1].point = this.paper_coords; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
424 |
this.line.segments[1].handleIn = _handle.multiply(-1); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
425 |
this.line.segments[1].handleOut = _handle; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
426 |
this.line.segments[2].point = _p1a; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
427 |
this.arrow.rotate(_a - this.arrow_angle); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
428 |
this.arrow.fillColor = _color; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
429 |
this.arrow.position = this.paper_coords.subtract(_u.multiply(4)); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
430 |
this.arrow_angle = _a; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
431 |
if (_a > 90) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
432 |
_a -= 180; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
433 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
434 |
if (_a < -90) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
435 |
_a += 180; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
436 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
437 |
this.text.rotate(_a - this.text_angle); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
438 |
this.text.content = this.model.get("title"); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
439 |
this.text.position = this.paper_coords; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
440 |
this.text_angle = _a; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
441 |
this.edit_button.moveTo(this.paper_coords); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
442 |
this.remove_button.moveTo(this.paper_coords); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
443 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
444 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
445 |
Rkns.Renderer.Edge.prototype.openEditor = function() { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
446 |
this.renderer.removeRepresentationsOfType("editor"); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
447 |
var _editor = this.renderer.addRepresentation("EdgeEditor",null); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
448 |
_editor.edge_representation = this; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
449 |
_editor.draw(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
450 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
451 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
452 |
Rkns.Renderer.Edge.prototype.select = function() { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
453 |
this.line.strokeWidth = 3; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
454 |
this.edit_button.show(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
455 |
this.remove_button.show(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
456 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
457 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
458 |
Rkns.Renderer.Edge.prototype.unselect = function(_newTarget) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
459 |
if (!_newTarget || _newTarget.edge_representation !== this) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
460 |
this.edit_button.hide(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
461 |
this.remove_button.hide(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
462 |
this.line.strokeWidth = 1; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
463 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
464 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
465 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
466 |
Rkns.Renderer.Edge.prototype.mouseup = function(_event) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
467 |
if (!this.renderer.is_dragging) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
468 |
this.openEditor(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
469 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
470 |
this.renderer.click_target = null; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
471 |
this.renderer.is_dragging = false; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
472 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
473 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
474 |
Rkns.Renderer.Edge.prototype.paperShift = function(_delta) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
475 |
this.from_representation.paperShift(_delta); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
476 |
this.to_representation.paperShift(_delta); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
477 |
this.renderer.redraw(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
478 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
479 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
480 |
Rkns.Renderer.Edge.prototype.destroy = function() { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
481 |
this.super("destroy"); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
482 |
this.line.remove(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
483 |
this.arrow.remove(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
484 |
this.text.remove(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
485 |
this.edit_button.destroy(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
486 |
this.remove_button.destroy(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
487 |
var _this = this; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
488 |
this.bundle.edges = Rkns._(this.bundle.edges).reject(function(_edge) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
489 |
return _edge === _this; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
490 |
}); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
491 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
492 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
493 |
/* */ |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
494 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
495 |
Rkns.Renderer.TempEdge = Rkns.Utils.inherit(Rkns.Renderer._BaseRepresentation); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
496 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
497 |
Rkns.Renderer.TempEdge.prototype._init = function() { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
498 |
this.renderer.edge_layer.activate(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
499 |
this.type = "temp-edge"; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
500 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
501 |
var _color = this.project.get("users").get(this.renderer.renkan.current_user).get("color"); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
502 |
this.line = new paper.Path(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
503 |
this.line.strokeColor = _color; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
504 |
this.line.add([0,0],[0,0]); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
505 |
this.line.__representation = this; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
506 |
this.arrow = new paper.Path(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
507 |
this.arrow.fillColor = _color; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
508 |
this.arrow.add([0,0],[Rkns.Renderer._ARROW_LENGTH,Rkns.Renderer._ARROW_WIDTH / 2],[0,Rkns.Renderer._ARROW_WIDTH]); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
509 |
this.arrow.__representation = this; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
510 |
this.arrow_angle = 0; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
511 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
512 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
513 |
Rkns.Renderer.TempEdge.prototype.redraw = function() { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
514 |
var _p0 = this.from_representation.paper_coords, |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
515 |
_p1 = this.end_pos, |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
516 |
_a = _p1.subtract(_p0).angle, |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
517 |
_c = _p0.add(_p1).divide(2); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
518 |
this.line.segments[0].point = _p0; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
519 |
this.line.segments[1].point = _p1; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
520 |
this.arrow.rotate(_a - this.arrow_angle); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
521 |
this.arrow.position = _c; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
522 |
this.arrow_angle = _a; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
523 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
524 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
525 |
Rkns.Renderer.TempEdge.prototype.paperShift = function(_delta) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
526 |
this.end_pos = this.end_pos.add(_delta); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
527 |
var _hitResult = paper.project.hitTest(this.end_pos); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
528 |
this.renderer.findTarget(_hitResult); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
529 |
this.redraw(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
530 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
531 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
532 |
Rkns.Renderer.TempEdge.prototype.mouseup = function(_event) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
533 |
var _hitResult = paper.project.hitTest(_event.point), |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
534 |
_model = this.from_representation.model, |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
535 |
_endDrag = true; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
536 |
if (_hitResult && typeof _hitResult.item.__representation !== "undefined") { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
537 |
var _target = _hitResult.item.__representation; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
538 |
if (_target.type === "Node" && _model !== _target.model) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
539 |
var _data = { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
540 |
id: Rkns.Utils.getUID('edge'), |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
541 |
created_by: this.renderer.renkan.current_user, |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
542 |
from: _model.get("_id"), |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
543 |
to: _target.model.get("_id") |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
544 |
}; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
545 |
this.project.addEdge(_data); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
546 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
547 |
if (_model === _target.model || (_target.node_representation && _target.node_representation.model === _model)) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
548 |
_endDrag = false; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
549 |
this.renderer.is_dragging = true; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
550 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
551 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
552 |
if (_endDrag) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
553 |
this.renderer.click_target = null; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
554 |
this.renderer.is_dragging = false; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
555 |
this.renderer.removeRepresentation(this); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
556 |
paper.view.draw(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
557 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
558 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
559 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
560 |
Rkns.Renderer.TempEdge.prototype.destroy = function() { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
561 |
this.arrow.remove(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
562 |
this.line.remove(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
563 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
564 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
565 |
/* */ |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
566 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
567 |
Rkns.Renderer.NodeEditor = Rkns.Utils.inherit(Rkns.Renderer._BaseRepresentation); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
568 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
569 |
Rkns.Renderer.NodeEditor.prototype._init = function() { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
570 |
this.renderer.overlay_layer.activate(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
571 |
this.type = "editor"; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
572 |
this.editor_block = new paper.Path(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
573 |
var _pts = Rkns._(Rkns._.range(8)).map(function() {return [0,0]}); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
574 |
this.editor_block.add.apply(this.editor_block, _pts); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
575 |
this.editor_block.strokeWidth = 2; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
576 |
this.editor_block.strokeColor = "#999999"; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
577 |
this.editor_block.fillColor = "#e0e0e0"; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
578 |
this.editor_block.opacity = .8; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
579 |
this.editor_$ = Rkns.$('<div>') |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
580 |
.appendTo(this.renderer.editor_$) |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
581 |
.css({ |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
582 |
position: "absolute", |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
583 |
opacity: .8 |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
584 |
}) |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
585 |
.hide(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
586 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
587 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
588 |
Rkns.Renderer.NodeEditor.prototype.template = Rkns._.template( |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
589 |
'<h2><span class="Rk-CloseX">×</span><%=l10n.edit_node%></span></h2>' |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
590 |
+ '<p><label><%=l10n.edit_title%></label><input class="Rk-Edit-Title" type="text" value="<%=node.title%>"/></p>' |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
591 |
+ '<p><label><%=l10n.edit_uri%></label><input class="Rk-Edit-URI" type="text" value="<%=node.uri%>"/><a class="Rk-Edit-Goto" href="<%=node.uri%>" target="_blank"></a></p>' |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
592 |
+ '<p><label><%=l10n.edit_description%></label><textarea class="Rk-Edit-Description"><%=node.description%></textarea></p>' |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
593 |
+ '<p><label><%=l10n.edit_image%></label><input class="Rk-Edit-Image" type="text" value="<%=node.image%>"/><img class="Rk-Edit-ImgPreview" src="<%=node.image%>" /></p>' |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
594 |
+ '<p><label><%=l10n.created_by%></label> <span class="Rk-UserColor" style="background:<%=node.created_by_color%>;"></span><%=node.created_by_title%></p>' |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
595 |
); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
596 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
597 |
Rkns.Renderer.NodeEditor.prototype.draw = function() { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
598 |
var _model = this.node_representation.model; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
599 |
this.editor_$ |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
600 |
.html(this.template({ |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
601 |
node: { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
602 |
title: _model.get("title"), |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
603 |
uri: _model.get("uri"), |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
604 |
description: _model.get("description"), |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
605 |
image: _model.get("image") || "", |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
606 |
created_by_color: _model.get("created_by").get("color"), |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
607 |
created_by_title: _model.get("created_by").get("title") |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
608 |
}, |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
609 |
l10n: this.renderer.renkan.l10n |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
610 |
})); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
611 |
this.redraw(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
612 |
var _this = this; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
613 |
this.editor_$.find(".Rk-CloseX").click(function() { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
614 |
_this.renderer.removeRepresentation(_this); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
615 |
paper.view.draw(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
616 |
}); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
617 |
this.editor_$.find("input, textarea").bind("keyup change", function() { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
618 |
var _uri = _this.editor_$.find(".Rk-Edit-URI").val(), |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
619 |
_image = _this.editor_$.find(".Rk-Edit-Image").val(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
620 |
_this.editor_$.find(".Rk-Edit-ImgPreview").attr("src", _image); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
621 |
_this.editor_$.find(".Rk-Edit-Goto").attr("href",_uri); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
622 |
var _data = { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
623 |
title: _this.editor_$.find(".Rk-Edit-Title").val(), |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
624 |
description: _this.editor_$.find(".Rk-Edit-Description").val(), |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
625 |
uri: _uri, |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
626 |
image: _image |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
627 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
628 |
_model.set(_data); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
629 |
_this.redraw(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
630 |
}); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
631 |
this.editor_$.find("img").load(function() { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
632 |
_this.redraw(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
633 |
}) |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
634 |
this.editor_$.find(".Rk-Edit-Title")[0].focus(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
635 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
636 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
637 |
Rkns.Renderer.NodeEditor.prototype.redraw = function() { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
638 |
var _coords = this.node_representation.paper_coords; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
639 |
Rkns.Renderer.Utils.drawEditBox(_coords, this.editor_block, 250, 20, this.editor_$); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
640 |
this.editor_$.show(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
641 |
paper.view.draw(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
642 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
643 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
644 |
Rkns.Renderer.NodeEditor.prototype.destroy = function() { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
645 |
this.editor_block.remove(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
646 |
this.editor_$.detach(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
647 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
648 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
649 |
/* */ |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
650 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
651 |
Rkns.Renderer.EdgeEditor = Rkns.Utils.inherit(Rkns.Renderer._BaseRepresentation); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
652 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
653 |
Rkns.Renderer.EdgeEditor.prototype._init = function() { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
654 |
this.renderer.overlay_layer.activate(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
655 |
this.type = "editor"; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
656 |
this.editor_block = new paper.Path(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
657 |
var _pts = Rkns._(Rkns._.range(8)).map(function() {return [0,0]}); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
658 |
this.editor_block.add.apply(this.editor_block, _pts); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
659 |
this.editor_block.strokeWidth = 2; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
660 |
this.editor_block.strokeColor = "#999999"; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
661 |
this.editor_block.fillColor = "#e0e0e0"; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
662 |
this.editor_block.opacity = .8; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
663 |
this.editor_$ = Rkns.$('<div>') |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
664 |
.appendTo(this.renderer.editor_$) |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
665 |
.css({ |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
666 |
position: "absolute", |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
667 |
opacity: .8 |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
668 |
}) |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
669 |
.hide(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
670 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
671 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
672 |
Rkns.Renderer.EdgeEditor.prototype.template = Rkns._.template( |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
673 |
'<h2><span class="Rk-CloseX">×</span><%=l10n.edit_edge%></span></h2>' |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
674 |
+ '<p><label><%=l10n.edit_title%></label><input class="Rk-Edit-Title" type="text" value="<%=edge.title%>"/></p>' |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
675 |
+ '<p><label><%=l10n.edit_uri%></label><input class="Rk-Edit-URI" type="text" value="<%=edge.uri%>"/><a class="Rk-Edit-Goto" href="<%=edge.uri%>" target="_blank"></a></p>' |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
676 |
+ '<p><label><%=l10n.edit_from%></label><span class="Rk-UserColor" style="background:<%=edge.from_created_by_color%>;"></span><%=edge.from_title%></p>' |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
677 |
+ '<p><label><%=l10n.edit_to%></label><span class="Rk-UserColor" style="background:<%=edge.to_created_by_color%>;"></span><%=edge.to_title%></p>' |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
678 |
+ '<p><label><%=l10n.created_by%> </label><span class="Rk-UserColor" style="background:<%=edge.created_by_color%>;"></span><%=edge.created_by_title%></p>' |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
679 |
); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
680 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
681 |
Rkns.Renderer.EdgeEditor.prototype.draw = function() { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
682 |
var _model = this.edge_representation.model; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
683 |
this.editor_$ |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
684 |
.html(this.template({ |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
685 |
edge: { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
686 |
title: _model.get("title"), |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
687 |
uri: _model.get("uri"), |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
688 |
description: _model.get("description"), |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
689 |
from_title: _model.get("from").get("title"), |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
690 |
to_title: _model.get("to").get("title"), |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
691 |
from_created_by_color: _model.get("from").get("created_by").get("color"), |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
692 |
to_created_by_color: _model.get("to").get("created_by").get("color"), |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
693 |
created_by_color: _model.get("created_by").get("color"), |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
694 |
created_by_title: _model.get("created_by").get("title") |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
695 |
}, |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
696 |
l10n: this.renderer.renkan.l10n |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
697 |
})); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
698 |
this.redraw(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
699 |
var _this = this; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
700 |
this.editor_$.find(".Rk-CloseX").click(function() { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
701 |
_this.renderer.removeRepresentation(_this); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
702 |
paper.view.draw(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
703 |
}); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
704 |
this.editor_$.find("input, textarea").bind("keyup change", function() { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
705 |
_this.editor_$.find(".Rk-Edit-Goto").attr("href",_this.editor_$.find(".Rk-Edit-URI").val()); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
706 |
var _data = { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
707 |
title: _this.editor_$.find(".Rk-Edit-Title").val(), |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
708 |
uri: _this.editor_$.find(".Rk-Edit-URI").val() |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
709 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
710 |
_model.set(_data); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
711 |
_this.redraw(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
712 |
}); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
713 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
714 |
Rkns.Renderer.EdgeEditor.prototype.redraw = function() { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
715 |
var _coords = this.edge_representation.paper_coords; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
716 |
Rkns.Renderer.Utils.drawEditBox(_coords, this.editor_block, 250, 5, this.editor_$); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
717 |
this.editor_$.show(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
718 |
paper.view.draw(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
719 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
720 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
721 |
Rkns.Renderer.EdgeEditor.prototype.destroy = function() { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
722 |
this.editor_block.remove(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
723 |
this.editor_$.detach(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
724 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
725 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
726 |
/* */ |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
727 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
728 |
Rkns.Renderer.NodeEditButton = Rkns.Utils.inherit(Rkns.Renderer._BaseRepresentation); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
729 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
730 |
Rkns.Renderer.NodeEditButton.prototype._init = function() { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
731 |
this.renderer.overlay_layer.activate(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
732 |
this.type = "Node-edit-button"; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
733 |
this.sector = Rkns.Renderer.Utils.sector(this, Rkns.Renderer._NODE_BUTTON_INNER, Rkns.Renderer._NODE_BUTTON_OUTER, - 90, 30, 1, this.renderer.renkan.static_url+'img/edit.png', this.renderer.renkan.l10n.caption_edit); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
734 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
735 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
736 |
Rkns.Renderer.NodeEditButton.prototype.moveTo = function(_pos) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
737 |
this.sector.moveTo(_pos); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
738 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
739 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
740 |
Rkns.Renderer.NodeEditButton.prototype.show = function() { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
741 |
this.sector.show(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
742 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
743 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
744 |
Rkns.Renderer.NodeEditButton.prototype.hide = function() { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
745 |
this.sector.hide(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
746 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
747 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
748 |
Rkns.Renderer.NodeEditButton.prototype.select = function() { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
749 |
this.sector.select(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
750 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
751 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
752 |
Rkns.Renderer.NodeEditButton.prototype.unselect = function(_newTarget) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
753 |
this.sector.unselect(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
754 |
if (!_newTarget || (_newTarget !== this.node_representation && _newTarget.node_representation !== this.node_representation)) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
755 |
this.node_representation.unselect(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
756 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
757 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
758 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
759 |
Rkns.Renderer.NodeEditButton.prototype.mouseup = function() { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
760 |
if (!this.renderer.is_dragging) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
761 |
this.node_representation.openEditor(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
762 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
763 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
764 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
765 |
Rkns.Renderer.NodeEditButton.prototype.destroy = function() { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
766 |
this.sector.destroy(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
767 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
768 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
769 |
/* */ |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
770 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
771 |
Rkns.Renderer.NodeRemoveButton = Rkns.Utils.inherit(Rkns.Renderer._BaseRepresentation); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
772 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
773 |
Rkns.Renderer.NodeRemoveButton.prototype._init = function() { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
774 |
this.renderer.overlay_layer.activate(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
775 |
this.type = "Node-remove-button"; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
776 |
this.sector = Rkns.Renderer.Utils.sector(this, Rkns.Renderer._NODE_BUTTON_INNER, Rkns.Renderer._NODE_BUTTON_OUTER, -210, -90, 1, this.renderer.renkan.static_url+'img/remove.png', this.renderer.renkan.l10n.caption_remove); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
777 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
778 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
779 |
Rkns.Renderer.NodeRemoveButton.prototype.moveTo = function(_pos) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
780 |
this.sector.moveTo(_pos); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
781 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
782 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
783 |
Rkns.Renderer.NodeRemoveButton.prototype.show = function() { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
784 |
this.sector.show(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
785 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
786 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
787 |
Rkns.Renderer.NodeRemoveButton.prototype.hide = function() { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
788 |
this.sector.hide(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
789 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
790 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
791 |
Rkns.Renderer.NodeRemoveButton.prototype.select = function() { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
792 |
this.sector.select(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
793 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
794 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
795 |
Rkns.Renderer.NodeRemoveButton.prototype.unselect = function(_newTarget) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
796 |
this.sector.unselect(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
797 |
if (!_newTarget || (_newTarget !== this.node_representation && _newTarget.node_representation !== this.node_representation)) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
798 |
this.node_representation.unselect(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
799 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
800 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
801 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
802 |
Rkns.Renderer.NodeRemoveButton.prototype.mouseup = function() { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
803 |
this.renderer.removeRepresentationsOfType("editor"); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
804 |
if (confirm('Do you really wish to remove node "' + this.node_representation.model.get("title") + '"?')) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
805 |
this.project.removeNode(this.node_representation.model); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
806 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
807 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
808 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
809 |
Rkns.Renderer.NodeRemoveButton.prototype.destroy = function() { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
810 |
this.sector.destroy(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
811 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
812 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
813 |
/* */ |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
814 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
815 |
Rkns.Renderer.NodeLinkButton = Rkns.Utils.inherit(Rkns.Renderer._BaseRepresentation); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
816 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
817 |
Rkns.Renderer.NodeLinkButton.prototype._init = function() { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
818 |
this.renderer.overlay_layer.activate(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
819 |
this.type = "Node-link-button"; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
820 |
this.sector = Rkns.Renderer.Utils.sector(this, Rkns.Renderer._NODE_BUTTON_INNER, Rkns.Renderer._NODE_BUTTON_OUTER, 30, 150, 1, this.renderer.renkan.static_url+'img/link.png', this.renderer.renkan.l10n.caption_link); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
821 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
822 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
823 |
Rkns.Renderer.NodeLinkButton.prototype.moveTo = function(_pos) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
824 |
this.sector.moveTo(_pos); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
825 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
826 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
827 |
Rkns.Renderer.NodeLinkButton.prototype.show = function() { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
828 |
this.sector.show(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
829 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
830 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
831 |
Rkns.Renderer.NodeLinkButton.prototype.hide = function() { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
832 |
this.sector.hide(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
833 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
834 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
835 |
Rkns.Renderer.NodeLinkButton.prototype.select = function() { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
836 |
this.sector.select(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
837 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
838 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
839 |
Rkns.Renderer.NodeLinkButton.prototype.unselect = function(_newTarget) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
840 |
this.sector.unselect(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
841 |
if (!_newTarget || (_newTarget !== this.node_representation && _newTarget.node_representation !== this.node_representation)) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
842 |
this.node_representation.unselect(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
843 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
844 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
845 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
846 |
Rkns.Renderer.NodeLinkButton.prototype.destroy = function() { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
847 |
this.sector.destroy(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
848 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
849 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
850 |
/* */ |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
851 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
852 |
Rkns.Renderer.EdgeEditButton = Rkns.Utils.inherit(Rkns.Renderer._BaseRepresentation); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
853 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
854 |
Rkns.Renderer.EdgeEditButton.prototype._init = function() { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
855 |
this.renderer.overlay_layer.activate(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
856 |
this.type = "Edge-edit-button"; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
857 |
this.sector = Rkns.Renderer.Utils.sector(this, Rkns.Renderer._EDGE_BUTTON_INNER, Rkns.Renderer._EDGE_BUTTON_OUTER, - 90, 90, 1, this.renderer.renkan.static_url+'img/edit.png', this.renderer.renkan.l10n.caption_edit); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
858 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
859 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
860 |
Rkns.Renderer.EdgeEditButton.prototype.moveTo = function(_pos) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
861 |
this.sector.moveTo(_pos); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
862 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
863 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
864 |
Rkns.Renderer.EdgeEditButton.prototype.show = function() { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
865 |
this.sector.show(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
866 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
867 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
868 |
Rkns.Renderer.EdgeEditButton.prototype.hide = function() { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
869 |
this.sector.hide(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
870 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
871 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
872 |
Rkns.Renderer.EdgeEditButton.prototype.select = function() { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
873 |
this.sector.select(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
874 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
875 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
876 |
Rkns.Renderer.EdgeEditButton.prototype.unselect = function(_newTarget) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
877 |
this.sector.unselect(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
878 |
if (!_newTarget || (_newTarget !== this.edge_representation && _newTarget.edge_representation !== this.edge_representation)) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
879 |
this.edge_representation.unselect(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
880 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
881 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
882 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
883 |
Rkns.Renderer.EdgeEditButton.prototype.mouseup = function() { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
884 |
if (!this.renderer.is_dragging) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
885 |
this.edge_representation.openEditor(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
886 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
887 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
888 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
889 |
Rkns.Renderer.EdgeEditButton.prototype.destroy = function() { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
890 |
this.sector.destroy(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
891 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
892 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
893 |
/* */ |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
894 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
895 |
Rkns.Renderer.EdgeRemoveButton = Rkns.Utils.inherit(Rkns.Renderer._BaseRepresentation); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
896 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
897 |
Rkns.Renderer.EdgeRemoveButton.prototype._init = function() { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
898 |
this.renderer.overlay_layer.activate(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
899 |
this.type = "Edge-remove-button"; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
900 |
this.sector = Rkns.Renderer.Utils.sector(this, Rkns.Renderer._EDGE_BUTTON_INNER, Rkns.Renderer._EDGE_BUTTON_OUTER, - 270, -90, 1, this.renderer.renkan.static_url+'img/remove.png', this.renderer.renkan.l10n.caption_remove); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
901 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
902 |
Rkns.Renderer.EdgeRemoveButton.prototype.moveTo = function(_pos) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
903 |
this.sector.moveTo(_pos); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
904 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
905 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
906 |
Rkns.Renderer.EdgeRemoveButton.prototype.show = function() { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
907 |
this.sector.show(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
908 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
909 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
910 |
Rkns.Renderer.EdgeRemoveButton.prototype.hide = function() { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
911 |
this.sector.hide(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
912 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
913 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
914 |
Rkns.Renderer.EdgeRemoveButton.prototype.select = function() { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
915 |
this.sector.select(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
916 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
917 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
918 |
Rkns.Renderer.EdgeRemoveButton.prototype.unselect = function(_newTarget) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
919 |
this.sector.unselect(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
920 |
if (!_newTarget || (_newTarget !== this.edge_representation && _newTarget.edge_representation !== this.edge_representation)) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
921 |
this.edge_representation.unselect(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
922 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
923 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
924 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
925 |
Rkns.Renderer.EdgeRemoveButton.prototype.mouseup = function() { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
926 |
this.renderer.removeRepresentationsOfType("editor"); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
927 |
if (confirm('Do you really wish to remove edge "' + this.edge_representation.model.get("title") + '"?')) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
928 |
this.project.removeEdge(this.edge_representation.model); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
929 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
930 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
931 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
932 |
Rkns.Renderer.EdgeRemoveButton.prototype.destroy = function() { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
933 |
this.sector.destroy(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
934 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
935 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
936 |
/* */ |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
937 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
938 |
Rkns.Renderer.Scene = function(_renkan) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
939 |
this.renkan = _renkan; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
940 |
this.$ = Rkns.$(".Rk-Render"); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
941 |
this.representations = []; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
942 |
this.$.html(this.template({ |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
943 |
l10n: _renkan.l10n |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
944 |
})) |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
945 |
this.canvas_$ = this.$.find(".Rk-Canvas"); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
946 |
this.editor_$ = this.$.find(".Rk-Editor"); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
947 |
this.notif_$ = this.$.find(".Rk-Notifications"); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
948 |
paper.setup(this.canvas_$[0]); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
949 |
this.scale = 1; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
950 |
this.offset = paper.view.center; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
951 |
this.totalScroll = 0; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
952 |
this.click_target = null; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
953 |
this.selected_target = null; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
954 |
this.edge_layer = new paper.Layer(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
955 |
this.node_layer = new paper.Layer(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
956 |
this.overlay_layer = new paper.Layer(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
957 |
this.bundles = []; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
958 |
this.click_mode = false; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
959 |
var _tool = new paper.Tool(), |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
960 |
_this = this; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
961 |
_tool.minDistance = Rkns.Renderer._MIN_DRAG_DISTANCE; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
962 |
_tool.onMouseMove = function(_event) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
963 |
_this.onMouseMove(_event); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
964 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
965 |
_tool.onMouseDown = function(_event) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
966 |
_this.onMouseDown(_event); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
967 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
968 |
_tool.onMouseDrag = function(_event) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
969 |
_this.onMouseDrag(_event); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
970 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
971 |
this.canvas_$.mouseup(function(_event) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
972 |
_this.onMouseUp(_event); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
973 |
}); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
974 |
this.canvas_$.mousewheel(function(_event, _delta) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
975 |
_this.onScroll(_event, _delta); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
976 |
}); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
977 |
this.canvas_$.dblclick(function(_event) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
978 |
_this.onDoubleClick(_event); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
979 |
}); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
980 |
this.canvas_$.mouseenter(function(_event) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
981 |
_this.onMouseEnter(_event); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
982 |
}); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
983 |
this.editor_$.find(".Rk-ZoomOut").click(function() { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
984 |
_this.offset = new paper.Point([ |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
985 |
_this.canvas_$.width(), |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
986 |
_this.canvas_$.height() |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
987 |
]).multiply( .5 * ( 1 - Math.SQRT1_2 ) ).add(_this.offset.multiply( Math.SQRT1_2 )); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
988 |
_this.setScale( _this.scale * Math.SQRT1_2 ); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
989 |
_this.redraw(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
990 |
}); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
991 |
this.editor_$.find(".Rk-ZoomIn").click(function() { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
992 |
_this.offset = new paper.Point([ |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
993 |
_this.canvas_$.width(), |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
994 |
_this.canvas_$.height() |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
995 |
]).multiply( .5 * ( 1 - Math.SQRT2 ) ).add(_this.offset.multiply( Math.SQRT2 )); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
996 |
_this.setScale( _this.scale * Math.SQRT2 ); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
997 |
_this.redraw(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
998 |
}); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
999 |
this.$.find(".Rk-CurrentUser").mouseenter( |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1000 |
function() { _this.$.find(".Rk-UserList").slideDown() } |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1001 |
); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1002 |
this.$.find(".Rk-Users").mouseleave( |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1003 |
function() { _this.$.find(".Rk-UserList").slideUp(); } |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1004 |
); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1005 |
this.$.find(".Rk-FullScreen-Button").click(function() { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1006 |
var _isFull = document.fullScreen || document.mozFullScreen || document.webkitIsFullScreen, |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1007 |
_el = _this.renkan.$[0], |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1008 |
_requestMethods = ["requestFullScreen","mozRequestFullScreen","webkitRequestFullScreen"], |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1009 |
_cancelMethods = ["cancelFullScreen","mozCancelFullScreen","webkitCancelFullScreen"]; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1010 |
if (_isFull) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1011 |
for (var i = 0; i < _cancelMethods.length; i++) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1012 |
if (typeof document[_cancelMethods[i]] === "function") { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1013 |
document[_cancelMethods[i]](); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1014 |
break; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1015 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1016 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1017 |
} else { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1018 |
for (var i = 0; i < _requestMethods.length; i++) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1019 |
if (typeof _el[_requestMethods[i]] === "function") { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1020 |
_el[_requestMethods[i]](); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1021 |
break; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1022 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1023 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1024 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1025 |
}); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1026 |
this.$.find(".Rk-AddNode-Button").click(function() { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1027 |
if (_this.click_mode === Rkns.Renderer._CLICKMODE_ADDNODE) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1028 |
_this.click_mode = false; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1029 |
_this.notif_$.hide(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1030 |
} else { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1031 |
_this.click_mode = Rkns.Renderer._CLICKMODE_ADDNODE; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1032 |
_this.notif_$.html(_renkan.l10n.notif_add_node).fadeIn(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1033 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1034 |
}); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1035 |
this.$.find(".Rk-AddEdge-Button").click(function() { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1036 |
if (_this.click_mode === Rkns.Renderer._CLICKMODE_STARTEDGE || _this.click_mode === Rkns.Renderer._CLICKMODE_ENDEDGE) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1037 |
_this.click_mode = false; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1038 |
_this.notif_$.hide(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1039 |
} else { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1040 |
_this.click_mode = Rkns.Renderer._CLICKMODE_STARTEDGE; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1041 |
_this.notif_$.html(_renkan.l10n.notif_start_edge).fadeIn(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1042 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1043 |
}); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1044 |
this.$.find(".Rk-TopBar-Button").mouseover(function() { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1045 |
Rkns.$(this).find(".Rk-TopBar-Tooltip").show(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1046 |
}).mouseout(function() { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1047 |
Rkns.$(this).find(".Rk-TopBar-Tooltip").hide(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1048 |
}); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1049 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1050 |
paper.view.onResize = function(_event) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1051 |
_this.offset = _this.offset.add(_event.delta.divide(2)); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1052 |
_this.redraw(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1053 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1054 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1055 |
var _thRedraw = Rkns._.throttle(function() { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1056 |
_this.redraw(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1057 |
},50); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1058 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1059 |
this.addRepresentations("Node", this.renkan.project.get("nodes")); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1060 |
this.addRepresentations("Edge", this.renkan.project.get("edges")); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1061 |
this.renkan.project.get("users").each(function(_user) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1062 |
_this.addUser(_user); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1063 |
}) |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1064 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1065 |
this.renkan.project.on("add:users", function(_user) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1066 |
_this.addUser(_user); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1067 |
}); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1068 |
this.renkan.project.on("add:nodes", function(_node) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1069 |
_this.addRepresentation("Node", _node); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1070 |
_thRedraw(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1071 |
}); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1072 |
this.renkan.project.on("add:edges", function(_edge) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1073 |
_this.addRepresentation("Edge", _edge); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1074 |
_thRedraw(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1075 |
}); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1076 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1077 |
this.redraw(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1078 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1079 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1080 |
Rkns.Renderer.Scene.prototype.template = Rkns._.template( |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1081 |
'<div class="Rk-TopBar"><h3 class="Rk-PadTitle"><%=l10n.untitled_project%></h3>' |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1082 |
+ '<div class="Rk-Users"><div class="Rk-CurrentUser"><span class="Rk-CurrentUser-Color"></span><span class="Rk-CurrentUser-Name"><unknown user></span></div><ul class="Rk-UserList"></ul></div>' |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1083 |
+ '<div class="Rk-TopBar-Separator"></div><div class="Rk-TopBar-Button Rk-FullScreen-Button"><div class="Rk-TopBar-Tooltip"><div class="Rk-TopBar-Tooltip-Tip"></div><div class="Rk-TopBar-Tooltip-Contents"><%=l10n.full_screen%></div></div></div>' |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1084 |
+ '<div class="Rk-TopBar-Separator"></div><div class="Rk-TopBar-Button Rk-AddNode-Button"><div class="Rk-TopBar-Tooltip"><div class="Rk-TopBar-Tooltip-Tip"></div><div class="Rk-TopBar-Tooltip-Contents"><%=l10n.add_node%></div></div></div>' |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1085 |
+ '<div class="Rk-TopBar-Separator"></div><div class="Rk-TopBar-Button Rk-AddEdge-Button"><div class="Rk-TopBar-Tooltip"><div class="Rk-TopBar-Tooltip-Tip"></div><div class="Rk-TopBar-Tooltip-Contents"><%=l10n.add_edge%></div></div></div>' |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1086 |
+ '<div class="Rk-TopBar-Separator"></div></div>' |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1087 |
+ '<canvas class="Rk-Canvas" resize></canvas><div class="Rk-Editor"><div class="Rk-Notifications"></div>' |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1088 |
+ '<div class="Rk-ZoomButtons"><div class="Rk-ZoomIn" title="<%=l10n.zoom_in%>"></div><div class="Rk-ZoomOut" title="<%=l10n.zoom_out%>"></div></div>' |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1089 |
+ '</div>' |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1090 |
); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1091 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1092 |
Rkns.Renderer.Scene.prototype.addToBundles = function(_edgeRepr) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1093 |
var _bundle = Rkns._(this.bundles).find(function(_bundle) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1094 |
return ( |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1095 |
( _bundle.from === _edgeRepr.from_representation && _bundle.to === _edgeRepr.to_representation ) |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1096 |
|| ( _bundle.from === _edgeRepr.to_representation && _bundle.to === _edgeRepr.from_representation ) |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1097 |
); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1098 |
}); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1099 |
if (typeof _bundle !== "undefined") { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1100 |
_bundle.edges.push(_edgeRepr) |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1101 |
} else { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1102 |
_bundle = { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1103 |
from: _edgeRepr.from_representation, |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1104 |
to: _edgeRepr.to_representation, |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1105 |
edges: [ _edgeRepr ], |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1106 |
getPosition: function(_er) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1107 |
var _dir = (_er.from_representation === this.from) ? 1 : -1; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1108 |
return _dir * ( Rkns._(this.edges).indexOf(_er) - (this.edges.length - 1) / 2 ); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1109 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1110 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1111 |
this.bundles.push(_bundle); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1112 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1113 |
return _bundle; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1114 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1115 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1116 |
Rkns.Renderer.Scene.prototype.setScale = function(_newScale) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1117 |
this.scale = _newScale; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1118 |
this.redraw(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1119 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1120 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1121 |
Rkns.Renderer.Scene.prototype.autoScale = function() { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1122 |
var nodes = this.renkan.project.get("nodes") |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1123 |
if (nodes.length > 1) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1124 |
var _xx = nodes.map(function(_node) { return _node.get("position").x }), |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1125 |
_yy = nodes.map(function(_node) { return _node.get("position").y }), |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1126 |
_minx = Math.min.apply(Math, _xx), |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1127 |
_miny = Math.min.apply(Math, _yy), |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1128 |
_maxx = Math.max.apply(Math, _xx), |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1129 |
_maxy = Math.max.apply(Math, _yy); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1130 |
var _scale = Math.min((paper.view.size.width - 2 * Rkns.Renderer._MARGIN_X) / (_maxx - _minx), (paper.view.size.height - 2 * Rkns.Renderer._MARGIN_Y) / (_maxy - _miny)); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1131 |
this.offset = paper.view.center.subtract(new paper.Point([(_maxx + _minx) / 2, (_maxy + _miny) / 2]).multiply(_scale)); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1132 |
this.setScale(_scale); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1133 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1134 |
if (nodes.length === 1) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1135 |
this.offset = paper.view.center.subtract(new paper.Point([nodes.at(0).get("position").x, nodes.at(0).get("position").y])); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1136 |
this.setScale(1); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1137 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1138 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1139 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1140 |
Rkns.Renderer.Scene.prototype.toPaperCoords = function(_point) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1141 |
return _point.multiply(this.scale).add(this.offset); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1142 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1143 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1144 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1145 |
Rkns.Renderer.Scene.prototype.toModelCoords = function(_point) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1146 |
return _point.subtract(this.offset).divide(this.scale); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1147 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1148 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1149 |
Rkns.Renderer.Scene.prototype.addRepresentation = function(_type, _model) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1150 |
var _repr = new Rkns.Renderer[_type](this, _model); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1151 |
this.representations.push(_repr); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1152 |
return _repr; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1153 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1154 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1155 |
Rkns.Renderer.Scene.prototype.addRepresentations = function(_type, _collection) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1156 |
var _this = this; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1157 |
_collection.forEach(function(_model) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1158 |
_this.addRepresentation(_type, _model); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1159 |
}); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1160 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1161 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1162 |
Rkns.Renderer.Scene.prototype.userTemplate = Rkns._.template( |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1163 |
'<li class="Rk-User"><span class="Rk-UserColor" style="background:<%=background%>;"></span><%=name%></li>' |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1164 |
); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1165 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1166 |
Rkns.Renderer.Scene.prototype.addUser = function(_user) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1167 |
if (_user.get("_id") === this.renkan.current_user) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1168 |
this.$.find(".Rk-CurrentUser-Name").text(_user.get("title")); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1169 |
this.$.find(".Rk-CurrentUser-Color").css("background", _user.get("color")); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1170 |
} else { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1171 |
this.$.find(".Rk-UserList").append( |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1172 |
Rkns.$( |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1173 |
this.userTemplate({ |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1174 |
name: _user.get("title"), |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1175 |
background: _user.get("color") |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1176 |
}) |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1177 |
) |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1178 |
); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1179 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1180 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1181 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1182 |
Rkns.Renderer.Scene.prototype.removeRepresentation = function(_representation) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1183 |
_representation.destroy(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1184 |
this.representations = Rkns._(this.representations).reject( |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1185 |
function(_repr) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1186 |
return _repr == _representation |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1187 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1188 |
); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1189 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1190 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1191 |
Rkns.Renderer.Scene.prototype.getRepresentationByModel = function(_model) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1192 |
return Rkns._(this.representations).find(function(_repr) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1193 |
return _repr.model === _model; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1194 |
}); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1195 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1196 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1197 |
Rkns.Renderer.Scene.prototype.removeRepresentationsOfType = function(_type) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1198 |
var _representations = Rkns._(this.representations).filter(function(_repr) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1199 |
return _repr.type == _type; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1200 |
}), |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1201 |
_this = this; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1202 |
Rkns._(_representations).each(function(_repr) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1203 |
_this.removeRepresentation(_repr); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1204 |
}); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1205 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1206 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1207 |
Rkns.Renderer.Scene.prototype.highlightModel = function(_model) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1208 |
var _repr = this.getRepresentationByModel(_model); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1209 |
if (_repr) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1210 |
_repr.highlight(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1211 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1212 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1213 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1214 |
Rkns.Renderer.Scene.prototype.unhighlightAll = function(_model) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1215 |
Rkns._(this.representations).each(function(_repr) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1216 |
_repr.unhighlight(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1217 |
}); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1218 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1219 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1220 |
Rkns.Renderer.Scene.prototype.redraw = function() { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1221 |
Rkns._(this.representations).each(function(_representation) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1222 |
_representation.redraw(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1223 |
}); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1224 |
paper.view.draw(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1225 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1226 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1227 |
Rkns.Renderer.Scene.prototype.addTempEdge = function(_from, _point) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1228 |
var _tmpEdge = this.addRepresentation("TempEdge",null); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1229 |
_tmpEdge.end_pos = _point; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1230 |
_tmpEdge.from_representation = _from; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1231 |
_tmpEdge.redraw(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1232 |
this.click_target = _tmpEdge; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1233 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1234 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1235 |
Rkns.Renderer.Scene.prototype.findTarget = function(_hitResult) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1236 |
if (_hitResult && typeof _hitResult.item.__representation !== "undefined") { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1237 |
var _newTarget = _hitResult.item.__representation; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1238 |
if (this.selected_target !== _hitResult.item.__representation) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1239 |
if (this.selected_target) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1240 |
this.selected_target.unselect(_newTarget); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1241 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1242 |
_newTarget.select(this.selected_target); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1243 |
this.selected_target = _newTarget; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1244 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1245 |
} else { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1246 |
if (this.selected_target) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1247 |
this.selected_target.unselect(null); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1248 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1249 |
this.selected_target = null; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1250 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1251 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1252 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1253 |
Rkns.Renderer.Scene.prototype.onMouseMove = function(_event) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1254 |
var _hitResult = paper.project.hitTest(_event.point); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1255 |
if (this.is_dragging) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1256 |
if (this.click_target && typeof this.click_target.paperShift === "function") { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1257 |
this.click_target.paperShift(_event.delta); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1258 |
} else { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1259 |
this.offset = this.offset.add(_event.delta); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1260 |
this.redraw(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1261 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1262 |
} else { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1263 |
this.findTarget(_hitResult); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1264 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1265 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1266 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1267 |
Rkns.Renderer.Scene.prototype.onMouseDown = function(_event) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1268 |
if (!this.click_target || this.click_target.type !== "temp-edge") { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1269 |
this.is_dragging = false; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1270 |
var _hitResult = paper.project.hitTest(_event.point); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1271 |
if (_hitResult && typeof _hitResult.item.__representation !== "undefined") { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1272 |
this.click_target = _hitResult.item.__representation; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1273 |
if (this.click_target.type === "Node-link-button") { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1274 |
this.removeRepresentationsOfType("editor"); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1275 |
this.addTempEdge(this.click_target.node_representation, _event.point); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1276 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1277 |
} else { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1278 |
this.click_target = null; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1279 |
if (this.click_mode === Rkns.Renderer._CLICKMODE_ADDNODE) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1280 |
var _coords = this.toModelCoords(_event.point), |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1281 |
_data = { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1282 |
id: Rkns.Utils.getUID('node'), |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1283 |
created_by: this.renkan.current_user, |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1284 |
position: { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1285 |
x: _coords.x, |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1286 |
y: _coords.y |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1287 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1288 |
}; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1289 |
_node = this.renkan.project.addNode(_data); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1290 |
this.getRepresentationByModel(_node).openEditor(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1291 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1292 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1293 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1294 |
if (this.click_mode) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1295 |
if (this.click_mode === Rkns.Renderer._CLICKMODE_STARTEDGE && this.click_target && this.click_target.type === "Node") { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1296 |
this.removeRepresentationsOfType("editor"); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1297 |
this.addTempEdge(this.click_target, _event.point); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1298 |
this.click_mode = Rkns.Renderer._CLICKMODE_ENDEDGE; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1299 |
this.notif_$.fadeOut(function() { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1300 |
Rkns.$(this).html(_renkan.l10n.notif_end_edge).fadeIn(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1301 |
}); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1302 |
} else { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1303 |
this.notif_$.hide(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1304 |
this.click_mode = false; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1305 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1306 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1307 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1308 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1309 |
Rkns.Renderer.Scene.prototype.onMouseDrag = function(_event) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1310 |
this.is_dragging = true; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1311 |
this.onMouseMove(_event); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1312 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1313 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1314 |
Rkns.Renderer.Scene.prototype.onMouseUp = function(_event) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1315 |
if (this.click_target) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1316 |
var _off = this.canvas_$.offset(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1317 |
this.click_target.mouseup( |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1318 |
{ |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1319 |
point: new paper.Point([ |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1320 |
_event.pageX - _off.left, |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1321 |
_event.pageY - _off.top |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1322 |
]) |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1323 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1324 |
); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1325 |
} else { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1326 |
this.click_target = null; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1327 |
this.is_dragging = false; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1328 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1329 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1330 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1331 |
Rkns.Renderer.Scene.prototype.onScroll = function(_event, _scrolldelta) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1332 |
this.totalScroll += _scrolldelta; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1333 |
if (Math.abs(this.totalScroll) >= 1) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1334 |
var _off = this.canvas_$.offset(), |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1335 |
_delta = new paper.Point([ |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1336 |
_event.pageX - _off.left, |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1337 |
_event.pageY - _off.top |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1338 |
]).subtract(this.offset).multiply( Math.SQRT2 - 1 ); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1339 |
if (this.totalScroll > 0) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1340 |
this.offset = this.offset.subtract(_delta); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1341 |
this.setScale( this.scale * Math.SQRT2 ); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1342 |
} else { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1343 |
this.offset = this.offset.add(_delta.divide( Math.SQRT2 )); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1344 |
this.setScale( this.scale * Math.SQRT1_2); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1345 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1346 |
this.totalScroll = 0; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1347 |
this.redraw(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1348 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1349 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1350 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1351 |
Rkns.Renderer.Scene.prototype.onDoubleClick = function(_event) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1352 |
var _off = this.canvas_$.offset(), |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1353 |
_point = new paper.Point([ |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1354 |
_event.pageX - _off.left, |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1355 |
_event.pageY - _off.top |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1356 |
]); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1357 |
var _hitResult = paper.project.hitTest(_point); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1358 |
if (!_hitResult || typeof _hitResult.item.__representation === "undefined") { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1359 |
var _coords = this.toModelCoords(_point), |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1360 |
_data = { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1361 |
id: Rkns.Utils.getUID('node'), |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1362 |
created_by: this.renkan.current_user, |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1363 |
position: { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1364 |
x: _coords.x, |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1365 |
y: _coords.y |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1366 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1367 |
}; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1368 |
_node = this.renkan.project.addNode(_data); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1369 |
this.getRepresentationByModel(_node).openEditor(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1370 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1371 |
paper.view.draw(); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1372 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1373 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1374 |
Rkns.Renderer.Scene.prototype.onMouseEnter = function(_event) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1375 |
var _newEl = this.renkan.selected_bin_item; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1376 |
if (_newEl) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1377 |
var _off = this.canvas_$.offset(), |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1378 |
_point = new paper.Point([ |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1379 |
_event.pageX - _off.left, |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1380 |
_event.pageY - _off.top |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1381 |
]), |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1382 |
_coords = this.toModelCoords(_point), |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1383 |
_data = { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1384 |
id: Rkns.Utils.getUID('node'), |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1385 |
created_by: this.renkan.current_user, |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1386 |
uri: _newEl.uri, |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1387 |
title: _newEl.title, |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1388 |
description: _newEl.description, |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1389 |
image: _newEl.image, |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1390 |
position: { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1391 |
x: _coords.x, |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1392 |
y: _coords.y |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1393 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1394 |
}; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1395 |
var _node = this.renkan.project.addNode(_data); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1396 |
this.renkan.selected_bin_item = null; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1397 |
this.is_dragging = true; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1398 |
this.click_target = this.getRepresentationByModel(_node); |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1399 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1400 |
} |