Closed dotasek closed 5 years ago
A good discussion of edge bend mechanics can be found here: https://stackoverflow.com/questions/41638266/how-to-use-bezier-curves-in-cytoscape-js
A quick synopsis follows:
The set of control points for an edge is defined by N weights (w1, w2, ... wN) and N respective distances (d1, d2, ... dN).
The above diagram also appears to apply to segmented edges:
http://js.cytoscape.org/#style/segments-edges
In Cytoscape desktop, whenever an edge has an EDGE_BEND property, and the EDGE_CURVED property is true, the edge is treated as a series of bezier curves. Conversely if EDGE_CURVED is false, any EDGE_BEND contents are treated as segments.
The above fix covers most cases, with the exception of an edge case included in the examples resources directory: https://github.com/cytoscape/cx2js/blob/e35328008124030ae8ee849bf6543f3c5473e11a/examples/resources/default_edge_bends.cx
When Cytoscape Desktop defines an edge bend, it defines it via a set of sin and cos values related to an angle theta.
This means that the bend point will scale with the resulting edge. In Cytoscape JS, the equivalent behaviour would be a d value that shifts with the length of the edge.
In our code, only edges with bypass values can be correctly recreated, and this is done by calculating the d value from the observed edge length. If there are default edge bend points in Cytoscape Desktop, it would be expensive to replicate: selectors would have to be made for all edges that don't currently have bypass values in order to accurately calculate and add d values. This would deviate significantly from what the Cytoscape Desktop author originally intended. So, for now, any default bend points are passed through, and the resultant renderings may be inaccurate and throw warnings.
EDGE_BEND defines bend points within the line; EDGE_CURVED decides whether or not those are rendered as curves, or as hard corners. The format EDGE_BEND must be extracted from Cytoscape code. EDGE_CURVED will likely map to the js curve-style properties “bezier” and “segments”.