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 TypeMethodDescriptionvoid
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<@Nullable Geometry> geometry, FeatureEditContext context) Indicates if this handles provider can create handles for the given geometry.void
close()
Creates a a composite instance with a default set of instances that can handle the following geometries:boolean
protected void
finalize()
List
<@NotNull IGeometryHandlesProvider> getList()
Returns the list containing all registered instances, ordered by priority (highest priority first).int
hashCode()
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
remove
(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:
close
in 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:
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
.
-
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 benull
priority
- a priority. The default is PriorityDefault.- Throws:
NullPointerException
- whennull
is 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
- whennull
is 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
- whennull
is 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
-