BaseLayouter.js 877 B

1234567891011121314151617181920212223242526272829303132333435
  1. import {
  2. getMid
  3. } from './LayoutUtil';
  4. /**
  5. * A base connection layouter implementation
  6. * that layouts the connection by directly connecting
  7. * mid(source) + mid(target).
  8. */
  9. export default function BaseLayouter() {}
  10. /**
  11. * Return the new layouted waypoints for the given connection.
  12. *
  13. * The connection passed is still unchanged; you may figure out about
  14. * the new connection start / end via the layout hints provided.
  15. *
  16. * @param {djs.model.Connection} connection
  17. * @param {Object} [hints]
  18. * @param {Point} [hints.connectionStart]
  19. * @param {Point} [hints.connectionEnd]
  20. *
  21. * @return {Array<Point>} the layouted connection waypoints
  22. */
  23. BaseLayouter.prototype.layoutConnection = function(connection, hints) {
  24. hints = hints || {};
  25. return [
  26. hints.connectionStart || getMid(connection.source),
  27. hints.connectionEnd || getMid(connection.target)
  28. ];
  29. };