Class PolylineHandlesProvider
- All Implemented Interfaces:
IGeometryHandlesProvider
,AutoCloseable
Polyline
geometries.
It offer the following handles:
move point
handlesinsert point
handles- a
prepend point
handle - an
append point
handle remove point
handleselevation point
handles. Note that the default implementation ofPointHandlesProvider.IHandleFactory
automatically omits these handles on a 2D map, or on a 3D map for polylines without elevation.
Note: the handle to translate the entire feature is typically created by the IFeatureHandlesProvider
. FeatureHandlesProvider
does this by default.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
Allows you to specify which handles are used by this handles provider. -
Constructor Summary
ConstructorDescriptionCreates a new handles provider that can create handles to modifyPolyline
geometries. -
Method Summary
Modifier and TypeMethodDescriptionboolean
canProvide
(Observable<@Nullable Geometry> geometry, FeatureEditContext context) Indicates if this handles provider can create handles for the given geometry.void
close()
protected void
finalize()
Returns the constraint that is applied to the handles' edit actions.Returns the handle factory used by the handles provider.long
Returns the maximum number of points a polyline can have.long
Returns the minimum number of points a polyline can have.provide
(Observable<@Nullable Geometry> geometry, FeatureEditContext context, IGeometryEditCallback geometryEditCallback) Returns the handles for the given feature.provideTranslateAction
(Observable<@Nullable Geometry> geometry, FeatureEditContext context, IGeometryEditCallback geometryEditCallback) Provides a translate action that can be used by the caller to add translation behavior.void
setConstraint
(IPolylineConstraint constraint) Sets the constraint that is applied to the handles' edit actions.void
setHandleFactory
(PolylineHandlesProvider.IHandleFactory handleFactory) Sets the handle factory used by the handles provider.void
setMaxPointCount
(long maxPointCount) Sets the maximum number of points a polyline can have.void
setMinPointCount
(long minPointCount) Sets the minimum number of points a polyline can have.
-
Constructor Details
-
PolylineHandlesProvider
public PolylineHandlesProvider()Creates a new handles provider that can create handles to modifyPolyline
geometries.
-
-
Method Details
-
finalize
protected void finalize() -
close
public void close()- Specified by:
close
in interfaceAutoCloseable
-
canProvide
public boolean canProvide(@NotNull Observable<@Nullable Geometry> geometry, @NotNull FeatureEditContext context) Indicates if this handles provider can create handles for the given geometry.- Specified by:
canProvide
in interfaceIGeometryHandlesProvider
- Parameters:
geometry
- an observable geometry, cannot benull
context
- the context. Contains additional information about the edited feature, cannot benull
.- Returns:
- if this handles provider can provide handles and a translate action for the given
Feature
-
provide
@NotNull public IEditHandles provide(@NotNull Observable<@Nullable Geometry> geometry, @NotNull FeatureEditContext context, @NotNull IGeometryEditCallback geometryEditCallback) Returns the handles for the given feature.Note:
translation
of features is handled byIFeatureHandlesProvider
. So geometry handles providers should not provide handles to translate a geometry.- Specified by:
provide
in interfaceIGeometryHandlesProvider
- Parameters:
geometry
- the observable geometry for which to provide handles, cannot benull
.context
- the context. Contains additional information about the edited feature, cannot benull
.geometryEditCallback
- a callback that notifies the caller when theFeature
has changed, cannot benull
.- Returns:
- handles for the given feature. Never
null
.
-
provideTranslateAction
@NotNull public ITranslateEditAction provideTranslateAction(@NotNull Observable<@Nullable Geometry> geometry, @NotNull FeatureEditContext context, @NotNull IGeometryEditCallback geometryEditCallback) Provides a translate action that can be used by the caller to add translation behavior.A translation handle is typically added by an
IFeatureHandlesProvider
, like for example theFeatureHandlesProvider
implementation. It calls this method to retrieve a translate action, and uses it to create aTranslateEditHandle
.When
ITranslateEditAction#translate
is called, the returned implementation must:- apply a translation on the geometry
- apply this
IGeometryHandlesProvider
's constraint (if configured) on the translated geometry - call
IGeometryEditCallback
with the resulting geometry
- Specified by:
provideTranslateAction
in interfaceIGeometryHandlesProvider
- Parameters:
geometry
- the observable geometry for which to provide a translate action, cannot benull
context
- the context, cannot benull
geometryEditCallback
- a callback that notifies the caller of this method when a translation has occurred, cannot benull
- Returns:
- a translate action. Never
null
.
-
getHandleFactory
Returns the handle factory used by the handles provider.- Returns:
- the handle factory used by the handles provider.
-
setHandleFactory
public void setHandleFactory(@NotNull PolylineHandlesProvider.IHandleFactory handleFactory) throws NullPointerException Sets the handle factory used by the handles provider.If this method is not called, a default handle factory is used. You can change the behavior of this default handle factory by:
- wrapping it with your own
IHandleFactory
implementation, by delegating to the default factory - omitting/replacing one or more handles that are returned
- Parameters:
handleFactory
- a handle factory- Throws:
NullPointerException
- whennull
is passed.
- wrapping it with your own
-
setMinPointCount
Sets the minimum number of points a polyline can have.If a polyline's point count is lower than or equal to this value, this handles provider will not provide handles to remove points from that polyline. By default, this value is 2.
- Parameters:
minPointCount
- the minimum number of points allowed.- Throws:
IllegalArgumentException
- ifminPointCount
is lower than 2, or higher than the currentmaximum point count
.
-
getMinPointCount
public long getMinPointCount()Returns the minimum number of points a polyline can have.- Returns:
- the minimum number of points a polyline can have.
- See Also:
-
setMaxPointCount
Sets the maximum number of points a polyline can have.If a polyline's point count is higher than or equal to this value, this handles provider will not provide handles to insert, prepend or append new points for that polyline. By default, this value is the maximum value of
size_t
, which realistically corresponds to "no maximum".- Parameters:
maxPointCount
- the maximum number of points allowed.- Throws:
IllegalArgumentException
- ifmaxPointCount
is lower than the currentmin point count
.
-
getMaxPointCount
public long getMaxPointCount()Returns the maximum number of points a polyline can have.- Returns:
- the maximum number of points a polyline can have.
- See Also:
-
setConstraint
Sets the constraint that is applied to the handles' edit actions.They always call this constraint with a
PolylineChange
, describing a single change. More specifically:Move point handles
andelevation point handles
provide aPolylineChange
containing onemoved point index
.Insert point handles
and theprepend
orappend
point handle provide aPolylineChange
containing oneinserted point index
.Remove point handles
provide aPolylineChange
containing oneremoved point index
.
- Parameters:
constraint
- the constraint that is applied to the handles' edit actions, ornull
if no constraint should be applied.
-
getConstraint
Returns the constraint that is applied to the handles' edit actions.Can be
null
if no constraint is set.- Returns:
- the constraint that is applied to the handles' edit actions, or
null
if no constraint is set.
-