Package com.luciad.models.features
Class DefaultFeatureGeometryProvider
java.lang.Object
com.luciad.models.features.DefaultFeatureGeometryProvider
- All Implemented Interfaces:
IFeatureGeometryProvider
,AutoCloseable
public final class DefaultFeatureGeometryProvider
extends Object
implements AutoCloseable, IFeatureGeometryProvider
Default geometry provider that works for Features with a
DataType
using a GeometryDataAnnotation
.
It is implemented as follows:
- getGeometry: Calls
Feature#findGeometry
- applyGeometry: Uses
Feature#asBuilder
to copy-and-edit a feature, and replaces theGeometry
value of the property in theGeometryDataAnnotation
by a newGeometry
This class should not be used when:
- The geometry of the feature is not exposed using
Feature#findGeometry
. The geometry isn't an explicit part of the feature, for example, but you can derive it from other properties on the feature. - The returned geometry is not the same as the geometry exposed by
Feature#findGeometry
. It can be useful to display a distinct geometry when a user edits a feature. For example, when users edit the location and orientation of a vessel, you can show anEllipse
, which also has a location and an orientation. - The feature has properties that are derived from the geometry. A simple example is a feature that has a
Geometry
property, and a property with the length of that geometry. When theGeometry
property changes, the length property needs to change as well. You can do so by providing a custom implementation ofIFeatureGeometryProvider#applyGeometry
that changes the geometry, but also changes the length property.
In these cases, a custom IFeatureGeometryProvider
implementation needs to be used.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionapplyGeometry
(Feature originalFeature, Geometry newGeometry) void
close()
protected void
finalize()
getGeometry
(Feature feature)
-
Constructor Details
-
DefaultFeatureGeometryProvider
public DefaultFeatureGeometryProvider()
-
-
Method Details
-
finalize
protected void finalize() -
close
public void close()- Specified by:
close
in interfaceAutoCloseable
-
getGeometry
Return the geometry for aFeature
(for example aGeometry
using which aGeometry
can be edited or created).This
Geometry
is not necessarily the same geometry as the one used for painting.See
IFeatureGeometryProvider
for more information.- Specified by:
getGeometry
in interfaceIFeatureGeometryProvider
- Parameters:
feature
- theFeature
to edit- Returns:
- the
Geometry
using which aFeature
can be edited, ornull
if theFeature
can not be edited using aGeometry
-
applyGeometry
@Nullable public Feature applyGeometry(@NotNull Feature originalFeature, @NotNull Geometry newGeometry) Updates the originalFeature
using the modifiedGeometry
, and returns it.This
Geometry
is not necessarily the same geometry as the one used for painting. SeeIFeatureGeometryProvider
for an example.- Specified by:
applyGeometry
in interfaceIFeatureGeometryProvider
- Parameters:
originalFeature
- the originalFeature
newGeometry
- a newGeometry
to apply on theFeature
- Returns:
- a new
Feature
, based on a modifiedGeometry
-