forked from cytoscape/cytoscape.js
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathcy-modifications.txt
195 lines (144 loc) · 6.62 KB
/
cy-modifications.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
This file indicate the modifications done in the original Cytoscape.js
Replace any draw(), checkPoint() and intersectLine() calls on node shapes with the ones from
node-fcn-caller.js (see the parameters of the functions from that file).
In one of draw() calls from extensions/renderer/canvas/drawing-images.js an image rendering is followed
by original draw() call. Check if the shape is an sbgn shape (not an original cy shape but it is defined from sbgnviz renderer)
there if so then use the image object for the related parameter. Again if it is an sbgn shape do not make
the image rendering since it will be rendered from the shapes draw function.
The original of the related code segment is the following (by the time this is written):
"if( repeat === 'no-repeat' ){
if( shouldClip ){
context.save();
if( rs.pathCache ){
context.clip( rs.pathCache );
} else {
r.nodeShapes[ r.getNodeShape( node ) ].draw(
context,
nodeX, nodeY,
nodeTW, nodeTH );
context.clip();
}
}
r.safeDrawImage( context, img, 0, 0, imgW, imgH, x, y, w, h );
if( shouldClip ){
context.restore();
}
}"
It is replaced by the following (by the time you are making the change there could
be changes in the original function, look for that)
"if( repeat === 'no-repeat' ){
if( shouldClip ){
context.save();
if( rs.pathCache ){
context.clip( rs.pathCache );
} else {
var isSbgnShape = sbgn.sbgnShapes[r.getNodeShape(node)];
var imgObj = isSbgnShape ? {
img: img,
imgW: imgW,
imgH: imgH,
x: x,
y: y,
w: w,
h: h
} : null;
nodeFcnCaller.draw(
context,
node, imgObj, r );
if ( !isSbgnShape ) {
context.clip();
}
}
}
if(!sbgn.sbgnShapes[r.getNodeShape(node)]){
r.safeDrawImage( context, img, 0, 0, imgW, imgH, x, y, w, h );
}
if( shouldClip ){
context.restore();
}
}"
For other draw() calls of node shapes use null for image object parameter.
In extensions/renderer/base/coord-ele-math/coords.js
In checkNode function inside findNearestElement
"if(
pos.x - hw <= x && x <= pos.x + hw // bb check x
&&
pos.y - hh <= y && y <= pos.y + hh // bb check y
){"
is updated as
"if(
sbgn.isNodeShapeTotallyOverriden( r, node ) ||
( pos.x - hw <= x && x <= pos.x + hw // bb check x
&&
pos.y - hh <= y && y <= pos.y + hh ) // bb check y
){"
"sbgn.isNodeShapeTotallyOverriden( r, node ) ||" is added because if sbgn shape
can have multimer and/or infoboxes then its bounding box is more than the bbox of
plain shape.
In BRp.getNodeShape function
"if( node.isParent() ){
if( shape === 'rectangle' || shape === 'roundrectangle' ){
return shape;
} else {
return 'rectangle';
}
}" is commented out.
This is done not to restrict the shapes of the parent nodes.
In extensions/renderer/base/node-shapes.js
Add "BRp.nodeShapes = {};" immediately after "var BRp = {};"
In BRp.registerNodeShapes function
"var nodeShapes = this.nodeShapes = {}" => "var nodeShapes = this.nodeShapes = BRp.nodeShapes;"
Add "sbgn.registerSbgnNodeShapes();" statement to BRp.registerNodeShapes function.
In extensions\renderer\canvas\index.js
CRp.usePaths return false.
In index.js
Expose more things for sbgnviz
In extensions\renderer\canvas\arrow-shapes.js
In 'triangle-tee' and 'triangle-cross' functions remove internal 'context.beginPath()' and 'context.endPath()' calls.
When they are not commented out only the tee part of shapes are not rendered properly (It is happening in our fork not sure
about the exact reason yet).
In collection/dimensions/bounds.js
consider state-infos, multimers on bounding box calculation
Find '// handle node dimensions' comment in the file (it is inside 'if( isNode && options.includeNodes )'
right after variable declarations). Update the code segment inside that code segment as
how it is done in current version. Changes are very similar to the older commit
https://github.com/iVis-at-Bilkent/sbgnviz.js/commit/12d400fef6cec4784c33abc10f680b7efe4ca34b
but not exactly the same.
Add sbgn.js and node-fcn-caller.js under src folder and require them whenever it is used.
See the current version for the content of the files.
%-------------------------------------------------------------%
% SVG SUPPORT %
%-------------------------------------------------------------%
See: https://github.com/iVis-at-Bilkent/cytoscape.js/commit/5d7654e82edfe3f9c78f9be2537d86fc3915272a
Related issue: https://github.com/iVis-at-Bilkent/newt/issues/147
Note that changes happened in Cytoscape.js after this commit.
In src/extensions/renderer/canvas/drawing-nodes.js
make setupBorderColor() and drawBorder() calls right after drawShape() call
(looks like this change is done for fixing a bug in exporting the graph as svg).
Also use 'ahmetcandiroglu/canvas2svg' instead of 'kinimesi/canvas2svg#master'.
Note: In sbgnviz renderer drawBorder() function of extensions/renderer/canvas/drawing-nodes.js
is copied and updated because of the reasons explained there. If the function here is updated
update the one in sbgnviz renderer as well.
%-------------------------------------------------------------%
% Line Dash Pattern SUPPORT %
%-------------------------------------------------------------%
See: https://github.com/iVis-at-Bilkent/cytoscape.js/commit/f69f8198558a13ee69465c56c70692c01b433eab
Changes made:
In src/style/properties.js the following lines were added:
{ name: 'line-fill', type: t.fill },
{ name: 'line-cap', type: t.lineCap },
{ name: 'line-dash-pattern', type: t.numbers },
{ name: 'line-dash-offset', type: t.number },
'line-dash-pattern': [6, 3],
'line-dash-offset': 0,
In src/extensions/renderer/canvas/drawing-edges.js the following lines were added:
let lineDashPattern = edge.pstyle('line-dash-pattern').pfValue;
let lineDashOffset = edge.pstyle('line-dash-offset').pfValue;
canvasCxt.setLineDash( lineDashPattern );
canvasCxt.lineDashOffset = lineDashOffset;
The following line was deleted:
canvasCxt.setLineDash( [ 6, 3 ] );
dist/cytoscape.cjs.js, dist/cytoscape.js, and dist/cytoscape.min.js files were changed accourdingly
by running "gulp dist" command
src/version.js was also modified accourdingly
For more details see: https://github.com/cytoscape/cytoscape.js/pull/2163