Skip to content
D
Documentation

SetLinkPointsCommand

reference
1 min readUpdated

Import it from @grafloria/engine.

Also has every member of Command, listed on its own entry.

Replace a link's points (its routed polyline, including any user waypoints), undoable. Each bend gesture on the canvas (insert, move, remove) commits one of these when the pointer is released.

The hasManualWaypoints metadata flag is part of the state being changed: the renderer keeps a link's interior points only while that flag is set, so execute sets it when the new path has bends and undo restores the value it had before. Without the old value, undoing a bend drag would clear the flag and the next re-route would drop the bend itself.

ts
class SetLinkPointsCommand extends Command

Parameters

  • linkId: The link to edit.
  • newPoints: The path to apply.
  • oldPoints: The path to restore on undo. Pass it when the link has already been changed live (during a drag); omitted, the link's points at the first execute are used.
  • oldManual: The hasManualWaypoints flag to restore on undo. Pass it with oldPoints when the flag has also been changed live; omitted, the link's flag at the first execute is used.

Methods

  • constructor( private linkId: string, newPoints: Point[], oldPoints?: Point[], oldManual?: boolean )
  • override execute(context: CommandContext): void — Execute the command
  • override undo(context: CommandContext): void — Undo the command
  • override canExecute(context: CommandContext): boolean — Check if command can be executed
  • override canUndo(context: CommandContext): boolean — Check if command can be undone
  • override canMergeWith(): boolean — One vertex gesture = one undo step; never merge two of them.
  • override serialize(): SerializedCommand — Serialize command
  • override getDescription(): string — Get description for UI

Was this page helpful?

SetLinkPointsCommand — Grafloria