all files / lib/layout/ ConnectionDocking.js

28.57% Statements 2/7
0% Branches 0/2
0% Functions 0/3
28.57% Lines 2/7
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                                                                                                                                     
/**
 * @memberOf djs.layout
 */
 
/**
 * @class DockingPointDescriptor
 */
 
/**
 * @name DockingPointDescriptor#point
 * @type djs.Point
 */
 
/**
 * @name DockingPointDescriptor#actual
 * @type djs.Point
 */
 
/**
 * @name DockingPointDescriptor#idx
 * @type Number
 */
 
/**
 * A layout component for connections that retrieves waypoint information.
 *
 * @class
 * @constructor
 */
export default function ConnectionDocking() {}
 
 
/**
 * Return the actual waypoints of the connection (visually).
 *
 * @param {djs.model.Connection} connection
 * @param {djs.model.Base} [source]
 * @param {djs.model.Base} [target]
 *
 * @return {Array<Point>}
 */
ConnectionDocking.prototype.getCroppedWaypoints = function(connection, source, target) {
  return connection.waypoints;
};
 
/**
 * Return the connection docking point on the specified shape
 *
 * @param {djs.model.Connection} connection
 * @param {djs.model.Shape} shape
 * @param {Boolean} [dockStart=false]
 *
 * @return {DockingPointDescriptor}
 */
ConnectionDocking.prototype.getDockingPoint = function(connection, shape, dockStart) {
 
  var waypoints = connection.waypoints,
      dockingIdx,
      dockingPoint;
 
  dockingIdx = dockStart ? 0 : waypoints.length - 1;
  dockingPoint = waypoints[dockingIdx];
 
  return {
    point: dockingPoint,
    actual: dockingPoint,
    idx: dockingIdx
  };
};