public final class CompositeGeometryHandlesProvider extends Object implements AutoCloseable, IGeometryHandlesProvider
IGeometryHandlesProvider
.
This composite allows you to:
CompositeGeometryHandlesProvider#add
CompositeGeometryHandlesProvider#remove
CompositeGeometryHandlesProvider#getList
The composite implementation uses its delegate instances in a specific order. The order is based on the priority you assign when you add the delegate instance. If the priorities of two instances are equal, the instance that you added first gets priority.
A default implementation is available, see createDefault
.
Constructor and Description |
---|
CompositeGeometryHandlesProvider()
Creates an empty composite instance.
|
Modifier and Type | Method and Description |
---|---|
void |
add(IGeometryHandlesProvider handlesProvider)
Adds the given instance to the list of registered instances with the given priority.
|
void |
add(IGeometryHandlesProvider handlesProvider,
Priority priority)
Adds the given instance to the list of registered instances with the given priority.
|
boolean |
canProvide(Observable<Geometry> geometry,
FeatureEditContext context)
Indicates if this handles provider can create handles for the given geometry.
|
void |
close() |
static CompositeGeometryHandlesProvider |
createDefault()
Creates a a composite instance with a default set of instances that can handle the following geometries:
|
protected void |
finalize() |
List<IGeometryHandlesProvider> |
getList() |
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 |
remove(IGeometryHandlesProvider handlesProvider)
Removes this given instance from the list of registered instances.
|
public CompositeGeometryHandlesProvider()
public void close()
close
in interface AutoCloseable
@NotNull public static CompositeGeometryHandlesProvider createDefault()
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
.public void add(@NotNull IGeometryHandlesProvider handlesProvider, @NotNull Priority priority) throws NullPointerException
If you want to remove an instance again, use CompositeGeometryHandlesProvider#remove
.
handlesProvider
- a new instance to register, cannot be null
priority
- a priority. The default is PriorityDefault.NullPointerException
- when null
is passed.public void add(@NotNull IGeometryHandlesProvider handlesProvider) throws NullPointerException
If you want to remove an instance again, use CompositeGeometryHandlesProvider#remove
.
handlesProvider
- a new instance to register, cannot be null
NullPointerException
- when null
is passed.public void remove(@NotNull IGeometryHandlesProvider handlesProvider) throws NullPointerException
Nothing will happen if the given instance was never added before.
handlesProvider
- the instance to remove from this composite, cannot be null
.NullPointerException
- when null
is passed.@NotNull public List<IGeometryHandlesProvider> getList()