Class CompositeGeometryHandlesProvider
- All Implemented Interfaces:
IGeometryHandlesProvider,AutoCloseable
IGeometryHandlesProvider.
This composite allows you to:
- add instances:
CompositeGeometryHandlesProvider#add - remove instances:
CompositeGeometryHandlesProvider#remove - retrieve instances:
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(IGeometryHandlesProvider handlesProvider) Adds the given instance to the list of registered instances with the given priority.voidadd(IGeometryHandlesProvider handlesProvider, Priority priority) Adds the given instance to the list of registered instances with the given priority.booleancanProvide(Observable<@Nullable Geometry> geometry, FeatureEditContext context) Indicates if this handles provider can create handles for the given geometry.voidclose()Creates a a composite instance with a default set of instances that can handle the following geometries:booleanprotected voidfinalize()List<@NotNull IGeometryHandlesProvider> getList()Returns the list containing all registered instances, ordered by priority (highest priority first).inthashCode()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.voidremove(IGeometryHandlesProvider handlesProvider) Removes this given instance from the list of registered instances.
-
Constructor Details
-
CompositeGeometryHandlesProvider
public CompositeGeometryHandlesProvider()Creates an empty composite instance.
-
-
Method Details
-
finalize
protected void finalize() -
close
public void close()- Specified by:
closein interfaceAutoCloseable
-
createDefault
Creates a a composite instance with a default set of instances that can handle the following geometries:- Returns:
- a composite instance with a default set of instances. These instances are registered using CompositeGeometryHandlesProvider::PriorityDefault.
-
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:
canProvidein interfaceIGeometryHandlesProvider- Parameters:
geometry- an observable geometry, cannot benullcontext- 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:
translationof features is handled byIFeatureHandlesProvider. So geometry handles providers should not provide handles to translate a geometry.- Specified by:
providein 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 theFeaturehas 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, for example theFeatureHandlesProviderimplementation. It calls this method to retrieve a translate action, and uses it to create aTranslateEditHandle.When
ITranslateEditAction#translateis called, the returned implementation must:- apply a translation to the geometry
- apply this
IGeometryHandlesProvider's constraint (if configured) to the translated geometry - call
IGeometryEditCallbackwith the resulting geometry
- Specified by:
provideTranslateActionin interfaceIGeometryHandlesProvider- Parameters:
geometry- the observable geometry for which to provide a translate action, cannot benullcontext- the context, cannot benullgeometryEditCallback- a callback that notifies the caller of this method when a translation has occurred, cannot benull- Returns:
- a translate action. Never
null.
-
add
public void add(@NotNull IGeometryHandlesProvider handlesProvider, @NotNull Priority priority) throws NullPointerException Adds the given instance to the list of registered instances with the given priority.If you want to remove an instance again, use
CompositeGeometryHandlesProvider#remove.- Parameters:
handlesProvider- a new instance to register, cannot benullpriority- a priority. The default is PriorityDefault.- Throws:
NullPointerException- whennullis passed.
-
add
Adds the given instance to the list of registered instances with the given priority.If you want to remove an instance again, use
CompositeGeometryHandlesProvider#remove.- Parameters:
handlesProvider- a new instance to register, cannot benull- Throws:
NullPointerException- whennullis passed.
-
remove
Removes this given instance from the list of registered instances.Nothing will happen if the given instance was never added before.
- Parameters:
handlesProvider- the instance to remove from this composite, cannot benull.- Throws:
NullPointerException- whennullis passed.
-
getList
Returns the list containing all registered instances, ordered by priority (highest priority first).- Returns:
- the list containing all registered instances, ordered by priority (highest priority first).
-
hashCode
public int hashCode() -
equals
-