options.d.ts 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. import { Point, Rectangle } from '@antv/x6-geometry';
  2. import { Node, Edge } from '../../../model';
  3. import { EdgeView } from '../../../view';
  4. import { Router } from '../index';
  5. export type Direction = 'top' | 'right' | 'bottom' | 'left';
  6. type Callable<T> = T | ((this: ManhattanRouterOptions) => T);
  7. export interface ResolvedOptions {
  8. /**
  9. * The size of step to find a route (the grid of the manhattan pathfinder).
  10. */
  11. step: number;
  12. /**
  13. * The number of route finding loops that cause the router to abort returns
  14. * fallback route instead.
  15. */
  16. maxLoopCount: number;
  17. /**
  18. * The number of decimal places to round floating point coordinates.
  19. */
  20. precision: number;
  21. /**
  22. * The maximum change of direction.
  23. */
  24. maxDirectionChange: number;
  25. /**
  26. * Should the router use perpendicular edgeView option? Does not connect
  27. * to the anchor of node but rather a point close-by that is orthogonal.
  28. */
  29. perpendicular: boolean;
  30. /**
  31. * Should the source and/or target not be considered as obstacles?
  32. */
  33. excludeTerminals: Edge.TerminalType[];
  34. /**
  35. * Should certain nodes not be considered as obstacles?
  36. */
  37. excludeNodes: (Node | string)[];
  38. /**
  39. * Should certain types of nodes not be considered as obstacles?
  40. */
  41. excludeShapes: string[];
  42. /**
  43. * Possible starting directions from a node.
  44. */
  45. startDirections: Direction[];
  46. /**
  47. * Possible ending directions to a node.
  48. */
  49. endDirections: Direction[];
  50. /**
  51. * Specify the directions used above and what they mean
  52. */
  53. directionMap: {
  54. top: Point.PointLike;
  55. right: Point.PointLike;
  56. bottom: Point.PointLike;
  57. left: Point.PointLike;
  58. };
  59. /**
  60. * Returns the cost of an orthogonal step.
  61. */
  62. cost: number;
  63. /**
  64. * Returns an array of directions to find next points on the route different
  65. * from start/end directions.
  66. */
  67. directions: {
  68. cost: number;
  69. offsetX: number;
  70. offsetY: number;
  71. angle?: number;
  72. gridOffsetX?: number;
  73. gridOffsetY?: number;
  74. }[];
  75. /**
  76. * A penalty received for direction change.
  77. */
  78. penalties: {
  79. [key: number]: number;
  80. };
  81. padding?: {
  82. top: number;
  83. right: number;
  84. bottom: number;
  85. left: number;
  86. };
  87. /**
  88. * The padding applied on the element bounding boxes.
  89. */
  90. paddingBox: Rectangle.RectangleLike;
  91. fallbackRouter: Router.Definition<any>;
  92. draggingRouter?: ((this: EdgeView, dragFrom: Point.PointLike, dragTo: Point.PointLike, options: ResolvedOptions) => Point[]) | null;
  93. fallbackRoute?: (this: EdgeView, from: Point, to: Point, options: ResolvedOptions) => Point[] | null;
  94. previousDirectionAngle?: number | null;
  95. snapToGrid?: boolean;
  96. }
  97. export type ManhattanRouterOptions = {
  98. [Key in keyof ResolvedOptions]: Callable<ResolvedOptions[Key]>;
  99. };
  100. export declare const defaults: ManhattanRouterOptions;
  101. export declare function resolve<T>(input: Callable<T>, options: ManhattanRouterOptions): any;
  102. export declare function resolveOptions(options: ManhattanRouterOptions): ResolvedOptions;
  103. export {};