An Editor describes how features or shapes should be edited and created.

It creates handles that are used by the EditController to edit features and the CreateController to create new features.

Edit handles generally correspond to the shape of the feature being edited. For example, to edit a four-sided polygon, an Editor might create five handles: four to move each of the individual vertices of the polygon (see getEditHandles), and a fifth one to move the polygon as a whole (see createTranslateHandle).

For more information, check out the Customizing creation and editing guide.

Hierarchy (view full)

Constructors

  • Creates a new Editor instance

    Returns Editor

Methods

  • Indicates which features/shapes this editor can edit.

    The default implementation always returns false.

    Parameters

    Returns boolean

  • Creates the shape translation handle.

    This is a handle that allows translation (moving) of an entire shape / feature.

    Parameters

    • context: EditContext

      The context to retrieve the shape translate handle for

    Returns null | EditHandle

  • Returns a handle that is used to create the given object.

    Parameters

    Returns null | EditHandle

    an editing handle that is used to initialize the state of the object being created.

  • This method is called by EditController to retrieve the handles for editing.

    For example, point list translation/insertion/deletion handles, handles to modify a circles center and radius,... By default, all editors include a shape translation handle.

    This is also used for creation, when the "create-by-template" approach is used to create new shapes.

    Parameters

    • context: EditContext

      The context to retrieve the handles for.

    Returns EditHandle[]

  • Restores the feature of the given context to a previously saved state.

    This applies the saved state that was created by saveState to the context's EditContext.feature. It is used to revert back to the initial state when editing is cancelled (ie. the controller deactivates without finishing) or restarted. When editing is cancelled, restoreState is called to revert the edited feature back to its initial state.

    The default implementation updates the feature's shape to the shape that was returned by the saveState method If your editor / handles change other feature properties, you can override saveState and restoreState to save and restore these additional properties as well.

    Parameters

    • savedState: any

      The state that was saved, as returned by saveState.

    • context: EditContext

      The editing context.

    Returns void

    Since

    2024.0

  • Returns a save state of the feature in the given context being edited.

    This save state is used to revert back to the initial state when editing is cancelled (ie. the controller deactivates without finishing) or restarted. When editing is cancelled, restoreState is called to revert the edited feature back to its initial state.

    The default implementation saves a copy of the feature's shape. If your editor / handles change other feature properties, you can override saveState and restoreState to save and restore these additional properties as well.

    Parameters

    Returns any

    The save state. By default, this is a copy of the feature's shape.

    Since

    2024.0