Class SketchEditor

java.lang.Object
com.esri.arcgisruntime.mapping.view.SketchEditor

@Deprecated(since="200.2.0", forRemoval=true) public final class SketchEditor extends Object
Deprecated, for removal: This API element is subject to removal in a future version.
As of 200.2.0, a new GeometryEditor class provides a successor to this class, supporting a wider array of use cases and providing a foundation for additional future geometry editing capabilities. If starting new development, use GeometryEditor in preference to SketchEditor.
Represents a sketch editor that allows users to interactively sketch geometries on the map view. Different geometry types can be sketched from scratch such as point, multipoint, polyline, or polygon by starting the SketchEditor with the corresponding SketchCreationMode, see start(SketchCreationMode). An existing geometry can be modified using start(Geometry), start(Geometry, SketchCreationMode) or replaceGeometry(Geometry).

During a sketch session, a geometry can be modified by moving or deleting the vertices or parts interactively. A sketch editor must be set on the map view MapView.setSketchEditor(SketchEditor) before calling the start methods, otherwise a runtime exception IllegalStateException will be thrown. The stop() method needs to be called to finish the current sketch editing session.

Interactions:

  • Using Mouse:
    • Left-click - on a vertex to select it; on geometry's outline to select geometry; otherwise, to draw.
    • Left-press and drag - on a vertex to move a vertex; on geometry's outline to move geometry; otherwise to draw in freehand mode.
    • Right-click - to show a context menu with option to clear the vertex or geometry.
  • Using Touch:
    • Touch and release - on a vertex to select it; on geometry's outline to select geometry; otherwise, to add a vertex.
    • Touch and move - on a vertex to move a vertex; on geometry's outline to move geometry; otherwise to draw in freehand mode.
    • Touch and hold briefly - on a vertex or outline to show a context menu with option to clear the vertex or geometry.
Since:
100.1.0
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    Deprecated, for removal: This API element is subject to removal in a future version.
    Constructs a default SketchEditor.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Deprecated, for removal: This API element is subject to removal in a future version.
    Adds a geometry changed listener.
    void
    Deprecated, for removal: This API element is subject to removal in a future version.
    Adds a selected vertex changed listener to the SketchEditor.
    boolean
    Deprecated, for removal: This API element is subject to removal in a future version.
    Gets whether there are actions to redo.
    boolean
    Deprecated, for removal: This API element is subject to removal in a future version.
    Gets whether there are actions to undo.
    void
    Deprecated, for removal: This API element is subject to removal in a future version.
    Clears the current sketch geometry.
    Deprecated, for removal: This API element is subject to removal in a future version.
    Gets the current sketch geometry.
    float
    Deprecated, for removal: This API element is subject to removal in a future version.
    Gets the opacity of sketch components.
    Deprecated, for removal: This API element is subject to removal in a future version.
    Gets the selected sketch vertex.
    Deprecated, for removal: This API element is subject to removal in a future version.
    Gets the sketch creation mode.
    Deprecated, for removal: This API element is subject to removal in a future version.
    Gets the sketch edit configuration.
    Deprecated, for removal: This API element is subject to removal in a future version.
    Gets the current sketch style.
    boolean
    Deprecated, for removal: This API element is subject to removal in a future version.
    Inserts a new vertex after the selected vertex.
    boolean
    Deprecated, for removal: This API element is subject to removal in a future version.
    A lightweight check to see if the current Geometry of this SketchEditor can produce a valid geometry.
    boolean
    Deprecated, for removal: This API element is subject to removal in a future version.
    Gets the visibility of sketch components.
    boolean
    Deprecated, for removal: This API element is subject to removal in a future version.
    Moves the selected vertex to a new position.
    void
    Deprecated, for removal: This API element is subject to removal in a future version.
    Redoes the last action to the sketch geometry.
    boolean
    Deprecated, for removal: This API element is subject to removal in a future version.
    Removes a geometry changed listener.
    boolean
    Deprecated, for removal: This API element is subject to removal in a future version.
    Removes the selected vertex.
    boolean
    Deprecated, for removal: This API element is subject to removal in a future version.
    Removes the specified selected vertex changed listener from the SketchEditor
    void
    Deprecated, for removal: This API element is subject to removal in a future version.
    Replaces the current sketch geometry with the given geometry if the sketch editor has started.
    void
    setOpacity(float opacity)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Sets the opacity of sketch components.
    boolean
    Deprecated, for removal: This API element is subject to removal in a future version.
    Sets the SketchVertex to be selected.
    void
    Deprecated, for removal: This API element is subject to removal in a future version.
    Sets the sketch style.
    void
    setVisible(boolean visible)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Sets the visibility of sketch components.
    void
    start(Geometry geometry)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Starts a sketch editing session based on the provided geometry.
    void
    start(Geometry geometry, SketchCreationMode creationMode)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Starts a sketch editing session based on the provided geometry and creation mode.
    void
    start(Geometry geometry, SketchCreationMode creationMode, SketchEditConfiguration editConfiguration)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Starts a sketch editing session based on the provided geometry, creation mode and edit configuration.
    void
    start(SketchCreationMode creationMode)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Starts a new editing session for given sketch creation mode.
    void
    start(SketchCreationMode creationMode, SketchEditConfiguration editConfiguration)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Starts a new editing session for given sketch creation mode and edit configuration.
    void
    Deprecated, for removal: This API element is subject to removal in a future version.
    Stops sketching.
    void
    Deprecated, for removal: This API element is subject to removal in a future version.
    Undoes the last action to the sketch geometry.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • SketchEditor

      public SketchEditor()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Constructs a default SketchEditor.
      Since:
      100.1.0
  • Method Details

    • start

      public void start(Geometry geometry, SketchCreationMode creationMode)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Starts a sketch editing session based on the provided geometry and creation mode.
      Parameters:
      geometry - geometry to start the sketch with
      creationMode - represents the type of sketch. A default creation mode is used if null
      Throws:
      IllegalArgumentException - if the geometry is null
      IllegalArgumentException - if the geometry type is incompatible with the sketch creation mode
      IllegalStateException - if the method is called before the SketchEditor is set on a map view
      IllegalStateException - if the map is null or not loaded
      Since:
      100.1.0
    • start

      public void start(Geometry geometry)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Starts a sketch editing session based on the provided geometry. A non-freehand sketch creation mode and a default edit configuration is created and used based on the geometry type.

      To set a freehand editing mode, use start(Geometry, SketchCreationMode), with either SketchCreationMode.FREEHAND_LINE or SketchCreationMode.FREEHAND_POLYGON.

      Parameters:
      geometry - the geometry to start the sketch with
      Throws:
      IllegalArgumentException - if the geometry is null
      IllegalStateException - if the method is called before the SketchEditor is set on a map view
      IllegalStateException - if the map is null or not loaded
      Since:
      100.1.0
    • start

      public void start(SketchCreationMode creationMode)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Starts a new editing session for given sketch creation mode.
      Parameters:
      creationMode - represents the type of sketch
      Throws:
      IllegalArgumentException - if the creationMode is null
      IllegalStateException - if the method is called before the SketchEditor is set on a map view
      IllegalStateException - if the map is null or not loaded
      Since:
      100.1.0
    • start

      public void start(SketchCreationMode creationMode, SketchEditConfiguration editConfiguration)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Starts a new editing session for given sketch creation mode and edit configuration.
      Parameters:
      creationMode - representing the type of geometry that users are going to sketch
      editConfiguration - the SketchEditConfiguration
      Throws:
      IllegalArgumentException - if creationMode or editConfiguration is null
      IllegalStateException - if the method is called before the SketchEditor is set on a map view
      IllegalStateException - if the map is null or not loaded
      Since:
      100.3.0
    • start

      public void start(Geometry geometry, SketchCreationMode creationMode, SketchEditConfiguration editConfiguration)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Starts a sketch editing session based on the provided geometry, creation mode and edit configuration. The sketch editor will respond to user interactions with the map view to perform a sketch.
      Parameters:
      geometry - the geometry to start the sketch with
      creationMode - representing the type of geometry that users are going to sketch, the type must be compatible with the geometry being provided. A default creation mode is used if it is null
      editConfiguration - the SketchEditConfiguration
      Throws:
      IllegalArgumentException - if geometry or editConfiguration is null
      IllegalArgumentException - if the geometry type is incompatible with the sketch creation mode
      IllegalStateException - if the method is called before the SketchEditor is set on a map view
      IllegalStateException - if the map is null or not loaded
      Since:
      100.3.0
    • stop

      public void stop()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Stops sketching. The sketch geometry can be obtained using the listener SketchGeometryChangedListener.
      Since:
      100.1.0
    • clearGeometry

      public void clearGeometry()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Clears the current sketch geometry.
      Since:
      100.1.0
    • replaceGeometry

      public void replaceGeometry(Geometry geometry)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Replaces the current sketch geometry with the given geometry if the sketch editor has started. The type of geometries must match.
      Parameters:
      geometry - the new geometry to be used
      Throws:
      IllegalArgumentException - if the geometry is null or if the geometry type is incompatible with current creation mode
      Since:
      100.1.0
    • isSketchValid

      public boolean isSketchValid()
      Deprecated, for removal: This API element is subject to removal in a future version.
      A lightweight check to see if the current Geometry of this SketchEditor can produce a valid geometry. Returns true if:
      • It is a Point and contains non-NaN x and y coordinates.
      • It is a Multipoint and contains at least one valid vertex.
      • It is a Polyline with at least 2 vertices in each part, and at least one part.
      • It is a Polygon with at least 3 vertices in each part, and at least one part.
      • It is an Envelope and contains non-NaN xmin, ymin, xmax, and ymax coordinates.

      Prior to v100.8, only one part of a multipart polygon or polyline was required to have the minimum number (2 for a polyline, 3 for a polygon) of vertices.

      Returns:
      true if the current sketch geometry is valid, false otherwise
      Since:
      100.1.0
    • isVisible

      public boolean isVisible()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Gets the visibility of sketch components.
      Returns:
      true if the sketch components are visible, false otherwise
      Since:
      100.1.0
    • setVisible

      public void setVisible(boolean visible)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Sets the visibility of sketch components.
      Parameters:
      visible - true to set graphics visible on the sketch editor, false to set invisible
      Since:
      100.1.0
    • setOpacity

      public void setOpacity(float opacity)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Sets the opacity of sketch components.
      Parameters:
      opacity - the value to set the opacity of sketch components, it should be a value between 0 (fully transparent) and 1 (fully opaque)
      Throws:
      IllegalArgumentException - if the opacity value is out of range from 0 to 1
      Since:
      100.1.0
    • getOpacity

      public float getOpacity()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Gets the opacity of sketch components.
      Returns:
      the opacity of sketch components, it should be a value between 0 (fully transparent) and 1 (fully opaque)
      Since:
      100.1.0
    • getSketchCreationMode

      public SketchCreationMode getSketchCreationMode()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Gets the sketch creation mode.
      Returns:
      the current sketch creation mode
      Since:
      100.1.0
    • setSketchStyle

      public void setSketchStyle(SketchStyle sketchStyle)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Sets the sketch style.
      Parameters:
      sketchStyle - the sketch style
      Throws:
      IllegalArgumentException - if the sketchStyle is null
      Since:
      100.1.0
    • getSketchStyle

      public SketchStyle getSketchStyle()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Gets the current sketch style. If not set, a default is used. To apply the changes of the sketch style on the sketching geometry, the setSketchStyle(SketchStyle) method needs to be called, e.g.
       SketchStyle style = sketchEditor.getSketchStyle();
         style.getLineSymbol().setColor(0xFF00FF00);
         style.getLineSymbol().setWidth(2.0f);
         style.setVertexSymbol(new SimpleMarkerSymbol(SimpleMarkerSymbol.Style.CIRCLE, 0xFFFF0000, 10));
         sketchEditor.setSketchStyle(style);
       
       
      Returns:
      the current sketch style
      Since:
      100.1.0
    • getSketchEditConfiguration

      public SketchEditConfiguration getSketchEditConfiguration()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Gets the sketch edit configuration.
      Returns:
      the SketchEditConfiguration
      Since:
      100.3.0
    • addGeometryChangedListener

      public void addGeometryChangedListener(SketchGeometryChangedListener listener)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Adds a geometry changed listener.

      This listener will be invoked on the UI thread if it is added from the UI thread, otherwise it is not guaranteed on which thread the listener is invoked.

      Parameters:
      listener - the geometry change listener to add
      Throws:
      IllegalArgumentException - if the listener is null
      Since:
      100.1.0
    • removeGeometryChangedListener

      public boolean removeGeometryChangedListener(SketchGeometryChangedListener listener)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Removes a geometry changed listener.
      Parameters:
      listener - the geometry changed listener to remove
      Returns:
      true if the geometry changes listener was removed, false otherwise
      Since:
      100.1.0
    • addSelectedVertexChangedListener

      public void addSelectedVertexChangedListener(SelectedVertexChangedListener selectedVertexChangedListener)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Adds a selected vertex changed listener to the SketchEditor. A selected vertex changed listener will be called when a new vertex is selected.
      Parameters:
      selectedVertexChangedListener - the listener to add
      Throws:
      IllegalArgumentException - if selectedVertexChangedListener is null
      Since:
      100.3.0
      See Also:
    • removeSelectedVertexChangedListener

      public boolean removeSelectedVertexChangedListener(SelectedVertexChangedListener selectedVertexChangedListener)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Removes the specified selected vertex changed listener from the SketchEditor
      Parameters:
      selectedVertexChangedListener - the listener to remove
      Returns:
      true if selectedVertexChangedListener is removed successfully, false otherwise
      Since:
      100.3.0
    • getGeometry

      public Geometry getGeometry()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Gets the current sketch geometry.

      Use SketchGeometryChangedListener to listen to the changes of the sketch geometry.

      Returns:
      the current geometry, or null if the sketch editor is not started
      Since:
      100.1.0
    • undo

      public void undo()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Undoes the last action to the sketch geometry.
      Since:
      100.2.0
    • canUndo

      public boolean canUndo()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Gets whether there are actions to undo.
      Returns:
      true if there are actions to undo, otherwise false
      Since:
      100.2.0
    • redo

      public void redo()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Redoes the last action to the sketch geometry.
      Since:
      100.2.0
    • canRedo

      public boolean canRedo()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Gets whether there are actions to redo.
      Returns:
      true if there are actions to redo, otherwise false
      Since:
      100.2.0
    • getSelectedVertex

      public SketchVertex getSelectedVertex()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Gets the selected sketch vertex.
      Returns:
      the selected SketchVertex, or null if no sketch vertex is selected.
      Since:
      100.3.0
      See Also:
    • setSelectedVertex

      public boolean setSelectedVertex(SketchVertex sketchVertex)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Sets the SketchVertex to be selected.
      Parameters:
      sketchVertex - the SketchVertex to be selected. If sketchVertex is null, the currently selected vertex will be unselected.
      Returns:
      true if sketchVertex is valid and selected successfully, false otherwise
      Since:
      100.3.0
    • removeSelectedVertex

      public boolean removeSelectedVertex()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Removes the selected vertex.
      Returns:
      true if the selected vertex is removed successfully, false otherwise
      Since:
      100.3.0
    • insertVertexAfterSelectedVertex

      public boolean insertVertexAfterSelectedVertex(Point point)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Inserts a new vertex after the selected vertex. If the sketch geometry is empty, a new vertex is to be added and selected. If the sketch geometry is a point, this method will move the existing selected point to the specified location and selects it.
      Parameters:
      point - the new point to be inserted
      Returns:
      true if point is inserted after the selected vertex successfully, false otherwise
      Throws:
      IllegalArgumentException - if point is null
      Since:
      100.3.0
    • moveSelectedVertex

      public boolean moveSelectedVertex(Point point)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Moves the selected vertex to a new position.
      Parameters:
      point - the new point to which to move the selected vertex
      Returns:
      true if the selected vertex is moved to the new position successfully, false otherwise
      Throws:
      IllegalArgumentException - if point is null
      Since:
      100.3.0