public final class PolylineHandlesProvider extends Object implements AutoCloseable, IGeometryHandlesProvider
Polyline
geometries.
It offer the following handles:
move point
handles
insert point
handles
prepend point
handle
append point
handle
remove point
handles
elevation point
handles. Note that the default implementation of PointHandlesProvider.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.
Modifier and Type | Class and Description |
---|---|
static interface |
PolylineHandlesProvider.IHandleFactory
Allows you to specify which handles are used by this handles provider.
|
Constructor and Description |
---|
PolylineHandlesProvider()
Creates a new handles provider that can create handles to modify
Polyline geometries. |
Modifier and Type | Method and Description |
---|---|
boolean |
canProvide(Observable<Geometry> geometry,
FeatureEditContext context)
Indicates if this handles provider can create handles for the given geometry.
|
void |
close() |
protected void |
finalize() |
IPolylineConstraint |
getConstraint() |
PolylineHandlesProvider.IHandleFactory |
getHandleFactory() |
long |
getMaxPointCount() |
long |
getMinPointCount() |
IEditHandles |
provide(Observable<Geometry> geometry,
FeatureEditContext context,
IGeometryEditCallback geometryEditCallback)
Returns the handles for the given feature.
|
ITranslateEditAction |
provideTranslateAction(Observable<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 created by this handles provider.
|
void |
setHandleFactory(PolylineHandlesProvider.IHandleFactory handleFactory)
Sets the
IHandleFactory that is used by this handles provider to create new handles. |
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.
|
public PolylineHandlesProvider()
Polyline
geometries.public void close()
close
in interface AutoCloseable
public boolean canProvide(@NotNull Observable<Geometry> geometry, @NotNull FeatureEditContext context)
canProvide
in interface IGeometryHandlesProvider
geometry
- an observable geometry, cannot be null
context
- the context. Contains additional information about the edited feature, cannot be null
.Feature
@NotNull public IEditHandles provide(@NotNull Observable<Geometry> geometry, @NotNull FeatureEditContext context, @NotNull IGeometryEditCallback geometryEditCallback)
Note: translation
of features is handled by IFeatureHandlesProvider
. So geometry handles providers should not provide handles to translate a geometry.
provide
in interface IGeometryHandlesProvider
geometry
- the observable geometry for which to provide handles, cannot be null
.context
- the context. Contains additional information about the edited feature, cannot be null
.geometryEditCallback
- a callback that notifies the caller when the Feature
has changed, cannot be null
.null
.@NotNull public ITranslateEditAction provideTranslateAction(@NotNull Observable<Geometry> geometry, @NotNull FeatureEditContext context, @NotNull IGeometryEditCallback geometryEditCallback)
A translation handle is typically added by an IFeatureHandlesProvider
, like for example the FeatureHandlesProvider
implementation. It calls this method to retrieve a translate action, and uses it to create a TranslateEditHandle
.
When ITranslateEditAction#translate
is called, the returned implementation must:
IGeometryHandlesProvider
's constraint (if configured) on the translated geometry
IGeometryEditCallback
with the resulting geometry
provideTranslateAction
in interface IGeometryHandlesProvider
geometry
- the observable geometry for which to provide a translate action, cannot be null
context
- the context, cannot be null
geometryEditCallback
- a callback that notifies the caller of this method when a translation has occurred, cannot be null
null
.@NotNull public PolylineHandlesProvider.IHandleFactory getHandleFactory()
public void setHandleFactory(@NotNull PolylineHandlesProvider.IHandleFactory handleFactory) throws NullPointerException
IHandleFactory
that is used by this handles provider to create new handles.
If this method is not called, a default handle factory is used. You can change the behavior of this default handle factory by:
retrieving it
IHandleFactory
implementation, by delegating to the default factory
handleFactory
- a handle factoryNullPointerException
- when null
is passed.public void setMinPointCount(long minPointCount) throws IllegalArgumentException
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.
minPointCount
- the minimum number of points allowed.IllegalArgumentException
- if minPointCount
is lower than 2, or higher than the current maximum point count
.public long getMinPointCount()
setMinPointCount
public void setMaxPointCount(long maxPointCount) throws IllegalArgumentException
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 long
, which realistically corresponds to "no maximum".
maxPointCount
- the maximum number of points allowed.IllegalArgumentException
- if maxPointCount
is lower than the current min point count
.public long getMaxPointCount()
setMaxPointCount
public void setConstraint(@Nullable IPolylineConstraint constraint)
They always call this constraint with a PolylineChange
, describing a single change. More specifically:
Move point handles
and elevation point handles
provide a PolylineChange
containing one moved point index
.
Insert point handles
and the prepend
or append
point handle provide a PolylineChange
containing one inserted point index
.
Remove point handles
provide a PolylineChange
containing one removed point index
.
constraint
- the constraint that is applied to the handles' edit actions, or null
if no constraint should be applied.@Nullable public IPolylineConstraint getConstraint()
null
if no constraint is set.