BaseLayouter.js 975 B

12345678910111213141516171819202122232425262728293031323334353637
  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. * @param {Point} [hints.source]
  21. * @param {Point} [hints.target]
  22. *
  23. * @return {Array<Point>} the layouted connection waypoints
  24. */
  25. BaseLayouter.prototype.layoutConnection = function(connection, hints) {
  26. hints = hints || {};
  27. return [
  28. hints.connectionStart || getMid(hints.source || connection.source),
  29. hints.connectionEnd || getMid(hints.target || connection.target)
  30. ];
  31. };