Class DataVectorSource<E>
- Type Parameters:
E
- item type
- All Implemented Interfaces:
GeoObjectClickNotifier<E>
,HasGeoObjectDrag<E>
,HasGeoObjectModify<E>
,HasGeoObjectSelect<E>
,AbstractVectorSource.HasOverlaps
,AbstractVectorSource.HasUseSpatialIndex
,AbstractVectorSource.HasVectorSourceOptions
,Source.HasAttributions
,Source.HasWrapX
,SupportsFeatureDrag
,SupportsFeatureModify
,SupportsFeatureSelect
,Serializable
,org.springframework.beans.factory.Aware
,org.springframework.context.ApplicationContextAware
Geometry
type).
This source acts as a connector between the data (geo-objects provided by
DataVectorSourceItems
interface implementation) and the map UI component.
It carries the data along with some additional information on how
the geo-objects should be displayed on a map.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class io.jmix.mapsflowui.kit.component.model.source.AbstractVectorSource
AbstractVectorSource.HasOverlaps, AbstractVectorSource.HasUseSpatialIndex, AbstractVectorSource.HasVectorSourceOptions
Nested classes/interfaces inherited from class io.jmix.mapsflowui.kit.component.model.source.Source
Source.HasAttributions, Source.HasAttributionsCollapsible, Source.HasProjection, Source.HasSourceOptions, Source.HasWrapX
Nested classes/interfaces inherited from class io.jmix.mapsflowui.kit.component.model.MapObservableObject
MapObservableObject.ObjectChangeEvent
Nested classes/interfaces inherited from interface io.jmix.mapsflowui.component.model.source.GeoObjectClickNotifier
GeoObjectClickNotifier.AbstractGeoObjectClickEvent<E>, GeoObjectClickNotifier.GeoObjectClickEvent<E>, GeoObjectClickNotifier.GeoObjectDoubleClickEvent<E>, GeoObjectClickNotifier.GeoObjectSingleClickEvent<E>
Nested classes/interfaces inherited from interface io.jmix.mapsflowui.component.model.source.HasGeoObjectDrag
HasGeoObjectDrag.AbstractSourceGeoObjectDragEvent<E>, HasGeoObjectDrag.SourceGeoObjectDragEndEvent<E>, HasGeoObjectDrag.SourceGeoObjectDragStartEvent<E>
Nested classes/interfaces inherited from interface io.jmix.mapsflowui.component.model.source.HasGeoObjectModify
HasGeoObjectModify.AbstractGeoObjectModifyEndEvent<E>, HasGeoObjectModify.SourceGeoObjectModifyEndEvent<E>, HasGeoObjectModify.SourceGeoObjectModifyStartEvent<E>
Nested classes/interfaces inherited from interface io.jmix.mapsflowui.component.model.source.HasGeoObjectSelect
HasGeoObjectSelect.SourceGeoObjectSelectEvent<E>
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected org.springframework.context.ApplicationContext
protected AbstractDataVectorSourceBinding<E>
Fields inherited from class io.jmix.mapsflowui.component.model.source.AbstractDataVectorSource
items
Fields inherited from class io.jmix.mapsflowui.kit.component.model.source.AbstractEditableVectorSource
featureDragEnabled, featureModifyEnabled, featureSelectEnabled, jmixSourceFeatureDeleteRegistration, jmixSourceFeatureDragEndRegistration, jmixSourceFeatureDragStartRegistration, jmixSourceFeatureModifyEndRegistration, jmixSourceFeatureModifyStartRegistration, jmixSourceFeatureSelectionRegistration
Fields inherited from class io.jmix.mapsflowui.kit.component.model.source.AbstractVectorSource
overlaps, useSpatialIndex
Fields inherited from class io.jmix.mapsflowui.kit.component.model.source.Source
attributions, attributionsCollapsible, id, projection, wrapX
Fields inherited from class io.jmix.mapsflowui.kit.component.model.MapObservableObject
children, dirty, eventBus, metaProperties, parent, removedChildren, syncId
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncom.vaadin.flow.shared.Registration
Adds geo-object click listener.com.vaadin.flow.shared.Registration
addGeoObjectDoubleClickListener
(Consumer<GeoObjectClickNotifier.GeoObjectDoubleClickEvent<E>> listener) Adds geo-object double click listener.com.vaadin.flow.shared.Registration
Adds geo-object drag end listener.com.vaadin.flow.shared.Registration
Adds geo-object drag start listener.com.vaadin.flow.shared.Registration
addGeoObjectSingleClickListener
(Consumer<GeoObjectClickNotifier.GeoObjectSingleClickEvent<E>> listener) Adds geo-object single click listener.com.vaadin.flow.shared.Registration
addSourceGeoObjectModifyEndListener
(Consumer<HasGeoObjectModify.SourceGeoObjectModifyEndEvent<E>> listener) Adds geo-object modify end listener.com.vaadin.flow.shared.Registration
addSourceGeoObjectModifyStartListener
(Consumer<HasGeoObjectModify.SourceGeoObjectModifyStartEvent<E>> listener) Adds geo-object modify start listener.com.vaadin.flow.shared.Registration
addSourceGeoObjectSelectListener
(Consumer<HasGeoObjectSelect.SourceGeoObjectSelectEvent<E>> listener) Adds geo-object select listener.protected void
applyDeletion
(Collection<E> itemsTuUpdate) protected void
applyModifyChanges
(Map<Feature, SimpleGeometry<?>> features) protected void
protected Collection<E>
convertFeaturesToItems
(Collection<Feature> features) void
Deselects all items in the source.void
deselectGeoObject
(E item) Deselects the provided item.void
deselectGeoObjects
(Collection<E> items) Deselects the collection of items.boolean
isGeoObjetSelected
(E item) Checks whether an item is selected.protected void
onGeoObjectRemove
(E item) protected void
protected void
protected void
protected void
protected void
protected void
protected void
onJmixSourceGeoObjectSelection
(List<E> selected, List<E> deselected) void
Selects all items in the source.void
selectGeoObject
(E item) Selects the provided item.void
selectGeoObjects
(Collection<E> items) Selects the collection of items.void
setApplicationContext
(org.springframework.context.ApplicationContext applicationContext) void
setFeatureDragEnabled
(Boolean enabled) Enables / disables feature drag mode.void
setFeatureModifyEnabled
(Boolean enabled) Enables / disables feature modify mode.void
setFeatureSelectEnabled
(Boolean enabled) Enables / disables feature select mode.void
setModifyStyleProvider
(Function<? super E, List<Style>> modifyStyleProvider) Sets modify style provider for a layer's geo-objects.void
setOverlaps
(Boolean overlaps) Sets whether source may have overlapping geometries.void
setSelectStyleProvider
(Function<? super E, List<Style>> selectStyleProvider) Sets select style provider for a layer's geo-objects.void
setStyleProvider
(Function<? super E, Style> styleProvider) Sets the style provider for a layer's geo-objects, i.e.void
setUseSpatialIndex
(Boolean useSpatialIndex) Sets whether to use spatial index.protected void
protected void
updateSelectedGeoObjects
(Collection<E> selected, Collection<E> deselected) withAttributions
(List<String> attributions) withItems
(DataVectorSourceItems<E> items) withOverlaps
(Boolean overlaps) SeesetOverlaps(Boolean)
.withStyleProvider
(Function<? super E, Style> styleProvider) withUseSpatialIndex
(Boolean useSpatialIndex) Methods inherited from class io.jmix.mapsflowui.component.model.source.AbstractDataVectorSource
getAttributions, getItems, getType, getWrapX, setAttributions, setItems, setWrapX
Methods inherited from class io.jmix.mapsflowui.kit.component.model.source.AbstractEditableVectorSource
attachJmixSourceFeatureDeleteListener, attachJmixSourceFeatureDragEndListener, attachJmixSourceFeatureDragStartListener, attachJmixSourceFeatureModifyEndListener, attachJmixSourceFeatureModifyStartListener, attachJmixSourceFeatureSelectionListener
Methods inherited from class io.jmix.mapsflowui.kit.component.model.source.Source
getAttributionsCollapsible, getId, getProjection, setAttributionsCollapsible, setId, setProjection
Methods inherited from class io.jmix.mapsflowui.kit.component.model.MapObservableObject
addChild, addListener, clearRemovedChildren, clearRemovedChildrenInDepth, equals, fireChangeEvent, getChildren, getEventBus, getMetaProperties, getRemovedChildren, getSuperParent, getSyncId, hashCode, isAttachedToMap, isDirty, isDirtyInDepth, markAsDirty, markAsDirtyInDepth, removeChild, setMetaProperty, setParent, unmarkDirtyInDepth
-
Field Details
-
applicationContext
protected org.springframework.context.ApplicationContext applicationContext -
binder
-
styleProvider
-
selectStyleProvider
-
modifyStyleProvider
-
selectedGeoObjects
-
-
Constructor Details
-
DataVectorSource
public DataVectorSource()
-
-
Method Details
-
setApplicationContext
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) throws org.springframework.beans.BeansException - Specified by:
setApplicationContext
in interfaceorg.springframework.context.ApplicationContextAware
- Throws:
org.springframework.beans.BeansException
-
getStyleProvider
- Returns:
- style provider for a layer's geo-objects or
null
if not set
-
setStyleProvider
Sets the style provider for a layer's geo-objects, i.e. function that determines style for a corresponding entity's geometry that is displayed on a map.Function should return fully described style for geo-object, otherwise, it may be not displayed. The provided style replaces existing styles in a feature.
For instance, source contains geo-objects for entity with Point datatype. For this datatype map renders
MarkerFeature
that has default style with icon. So to add, let's say, text under the icon, new style should contain the icon definition too. To achieve this we can create default marker style usingMarkerStyle.createDefaultStyle()
and edit it:source.setStyleProvider(shop -> MarkerStyle.createDefaultStyle() .withText(new TextStyle() .withText(shop.getName()) .withFont("15px sans-serif") .withOffsetY(10)));
- Parameters:
styleProvider
- function that takes an entity as an argument and produces aStyle
for the entity's geometry
-
getSelectStyleProvider
- Returns:
- select style provider for a layer's geo-objects or
null
if not set
-
setSelectStyleProvider
Sets select style provider for a layer's geo-objects. This function determines styles for a corresponding entity's geometry that is displayed on a map and selected by user. Pay attention that the function should return a list of styles that can be layered.Note that select styles will be applied if
getFeatureSelectEnabled()
is enabled.For instance, for
Polygon
geometry a function can return a style with slightly changed fill color with transparency and stroke with bright color:source.setSelectStyleProvider(entity -> List.of(new Style() .withFill(new Fill("hsla(190, 61%, 51%, 0.4)")) .withStroke(new Stroke() .withWidth(6d) .withColor("#24913C"))));
- Parameters:
selectStyleProvider
- function that takes an entity as an argument and produces aStyle
for the entity's geometry
-
getModifyStyleProvider
- Returns:
- modify style provider for a layer's geo-objects or
null
if not set
-
setModifyStyleProvider
Sets modify style provider for a layer's geo-objects. This function determines styles for generated vertex's point of a corresponding entity's geometry that is displayed on a map. The map generates a point for geometry's vertices to enable modification: adding new vertex, change vertex position.Thus, the styles generated by the provider will be applied not to the entity's geometry, but to the generated vertex point of the entity's geometry.
Note that modify styles will be applied if
getFeatureModifyEnabled()
is enabled.For instance, for
Polygon
geometry a function can return a style that colors a generated vertex to red:source.setModifyStyleProvider(entity -> List.of(new Style() .withImage(new CircleStyle() .withFill(new Fill("#FF1E00")) .withRadius(6) .withStroke(new Stroke() .withWidth(2d) .withColor("#04819E")))));
- Parameters:
modifyStyleProvider
- function that takes an entity as an argument and produces aStyle
for the entity's geometry
-
getOverlaps
- Specified by:
getOverlaps
in interfaceAbstractVectorSource.HasOverlaps
- Overrides:
getOverlaps
in classAbstractVectorSource
- Returns:
- overlaps value or
null
if not set
-
setOverlaps
Description copied from interface:AbstractVectorSource.HasOverlaps
Sets whether source may have overlapping geometries. The default value istrue
.Setting this to
false
(e.g. for sources with polygons that represent administrative boundaries) allows the renderer to optimise fill and stroke operations.Note, overlaps attribute is set only at creation time and cannot be changed at runtime.
- Specified by:
setOverlaps
in interfaceAbstractVectorSource.HasOverlaps
- Overrides:
setOverlaps
in classAbstractVectorSource
- Parameters:
overlaps
- overlaps option
-
getUseSpatialIndex
- Specified by:
getUseSpatialIndex
in interfaceAbstractVectorSource.HasUseSpatialIndex
- Overrides:
getUseSpatialIndex
in classAbstractVectorSource
- Returns:
- useSpatialIndex value or
null
if not set
-
setUseSpatialIndex
Description copied from interface:AbstractVectorSource.HasUseSpatialIndex
Sets whether to use spatial index. When features are removed and added frequently, and the total number of features is low, setting this tofalse
may improve performance. The default value istrue
.- Specified by:
setUseSpatialIndex
in interfaceAbstractVectorSource.HasUseSpatialIndex
- Overrides:
setUseSpatialIndex
in classAbstractVectorSource
- Parameters:
useSpatialIndex
- whether to use spatial index
-
addGeoObjectClickListener
public com.vaadin.flow.shared.Registration addGeoObjectClickListener(Consumer<GeoObjectClickNotifier.GeoObjectClickEvent<E>> listener) Description copied from interface:GeoObjectClickNotifier
Adds geo-object click listener. Note, if the user makes double click, theGeoObjectClickNotifier.GeoObjectClickEvent
will be fired twice.- Specified by:
addGeoObjectClickListener
in interfaceGeoObjectClickNotifier<E>
- Parameters:
listener
- listener to add- Returns:
- a registration object for removing an event listener
-
addGeoObjectSingleClickListener
public com.vaadin.flow.shared.Registration addGeoObjectSingleClickListener(Consumer<GeoObjectClickNotifier.GeoObjectSingleClickEvent<E>> listener) Description copied from interface:GeoObjectClickNotifier
Adds geo-object single click listener. Single click means that an event won't be fired if the user makes double click.- Specified by:
addGeoObjectSingleClickListener
in interfaceGeoObjectClickNotifier<E>
- Parameters:
listener
- listener to add- Returns:
- a registration object for removing an event listener
-
addGeoObjectDoubleClickListener
public com.vaadin.flow.shared.Registration addGeoObjectDoubleClickListener(Consumer<GeoObjectClickNotifier.GeoObjectDoubleClickEvent<E>> listener) Description copied from interface:GeoObjectClickNotifier
Adds geo-object double click listener.- Specified by:
addGeoObjectDoubleClickListener
in interfaceGeoObjectClickNotifier<E>
- Parameters:
listener
- listener to add- Returns:
- a registration object for removing an event listener
-
addSourceGeoObjectSelectListener
public com.vaadin.flow.shared.Registration addSourceGeoObjectSelectListener(Consumer<HasGeoObjectSelect.SourceGeoObjectSelectEvent<E>> listener) Description copied from interface:HasGeoObjectSelect
Adds geo-object select listener.- Specified by:
addSourceGeoObjectSelectListener
in interfaceHasGeoObjectSelect<E>
- Parameters:
listener
- listener to add- Returns:
- a registration object for removing an event listener
-
addGeoObjectDragStartListener
public com.vaadin.flow.shared.Registration addGeoObjectDragStartListener(Consumer<HasGeoObjectDrag.SourceGeoObjectDragStartEvent<E>> listener) Description copied from interface:HasGeoObjectDrag
Adds geo-object drag start listener.- Specified by:
addGeoObjectDragStartListener
in interfaceHasGeoObjectDrag<E>
- Parameters:
listener
- listener to add- Returns:
- a registration object for removing an event listener
-
addGeoObjectDragEndListener
public com.vaadin.flow.shared.Registration addGeoObjectDragEndListener(Consumer<HasGeoObjectDrag.SourceGeoObjectDragEndEvent<E>> listener) Description copied from interface:HasGeoObjectDrag
Adds geo-object drag end listener.- Specified by:
addGeoObjectDragEndListener
in interfaceHasGeoObjectDrag<E>
- Parameters:
listener
- listener to add- Returns:
- a registration object for removing an event listener
-
addSourceGeoObjectModifyStartListener
public com.vaadin.flow.shared.Registration addSourceGeoObjectModifyStartListener(Consumer<HasGeoObjectModify.SourceGeoObjectModifyStartEvent<E>> listener) Description copied from interface:HasGeoObjectModify
Adds geo-object modify start listener.- Specified by:
addSourceGeoObjectModifyStartListener
in interfaceHasGeoObjectModify<E>
- Parameters:
listener
- listener to add- Returns:
- a registration object for removing an event listener
-
addSourceGeoObjectModifyEndListener
public com.vaadin.flow.shared.Registration addSourceGeoObjectModifyEndListener(Consumer<HasGeoObjectModify.SourceGeoObjectModifyEndEvent<E>> listener) Description copied from interface:HasGeoObjectModify
Adds geo-object modify end listener.- Specified by:
addSourceGeoObjectModifyEndListener
in interfaceHasGeoObjectModify<E>
- Parameters:
listener
- listener to add- Returns:
- a registration object for removing an event listener
-
isGeoObjetSelected
Description copied from interface:HasGeoObjectSelect
Checks whether an item is selected.- Specified by:
isGeoObjetSelected
in interfaceHasGeoObjectSelect<E>
- Parameters:
item
- item to check- Returns:
true
if feature is selected
-
getSelectedGeoObjects
- Specified by:
getSelectedGeoObjects
in interfaceHasGeoObjectSelect<E>
- Returns:
- unmodifiable collection of selected items
-
selectGeoObject
Description copied from interface:HasGeoObjectSelect
Selects the provided item.Note that selection works only when
SupportsFeatureSelect.getFeatureSelectEnabled()
is enabled.- Specified by:
selectGeoObject
in interfaceHasGeoObjectSelect<E>
- Parameters:
item
- item to select
-
deselectGeoObject
Description copied from interface:HasGeoObjectSelect
Deselects the provided item.Note that selection works only when
SupportsFeatureSelect.getFeatureSelectEnabled()
is enabled.- Specified by:
deselectGeoObject
in interfaceHasGeoObjectSelect<E>
- Parameters:
item
- item to deselect
-
selectGeoObjects
Description copied from interface:HasGeoObjectSelect
Selects the collection of items.Note that selection works only when
SupportsFeatureSelect.getFeatureSelectEnabled()
is enabled.- Specified by:
selectGeoObjects
in interfaceHasGeoObjectSelect<E>
- Parameters:
items
- items to select
-
deselectGeoObjects
Description copied from interface:HasGeoObjectSelect
Deselects the collection of items.Note that selection works only when
SupportsFeatureSelect.getFeatureSelectEnabled()
is enabled.- Specified by:
deselectGeoObjects
in interfaceHasGeoObjectSelect<E>
- Parameters:
items
- items to deselect
-
selectAllGeoObjects
public void selectAllGeoObjects()Description copied from interface:HasGeoObjectSelect
Selects all items in the source.Note that selection works only when
SupportsFeatureSelect.getFeatureSelectEnabled()
is enabled.- Specified by:
selectAllGeoObjects
in interfaceHasGeoObjectSelect<E>
-
deselectAllGeoObjects
public void deselectAllGeoObjects()Description copied from interface:HasGeoObjectSelect
Deselects all items in the source.Note that selection works only when
SupportsFeatureSelect.getFeatureSelectEnabled()
is enabled.- Specified by:
deselectAllGeoObjects
in interfaceHasGeoObjectSelect<E>
-
getFeatureSelectEnabled
- Specified by:
getFeatureSelectEnabled
in interfaceSupportsFeatureSelect
- Overrides:
getFeatureSelectEnabled
in classAbstractEditableVectorSource
- Returns:
- whether select mode is enabled or not
-
setFeatureSelectEnabled
Description copied from interface:SupportsFeatureSelect
Enables / disables feature select mode.The default value is
false
.- Specified by:
setFeatureSelectEnabled
in interfaceSupportsFeatureSelect
- Overrides:
setFeatureSelectEnabled
in classAbstractEditableVectorSource
- Parameters:
enabled
- whether to enable select mode
-
getFeatureDragEnabled
- Specified by:
getFeatureDragEnabled
in interfaceSupportsFeatureDrag
- Overrides:
getFeatureDragEnabled
in classAbstractEditableVectorSource
- Returns:
- whether drag mode is enabled or not
-
setFeatureDragEnabled
Description copied from interface:SupportsFeatureDrag
Enables / disables feature drag mode.The default value is
false
.- Specified by:
setFeatureDragEnabled
in interfaceSupportsFeatureDrag
- Overrides:
setFeatureDragEnabled
in classAbstractEditableVectorSource
- Parameters:
enabled
- whether to enable drag mode
-
getFeatureModifyEnabled
- Specified by:
getFeatureModifyEnabled
in interfaceSupportsFeatureModify
- Overrides:
getFeatureModifyEnabled
in classAbstractEditableVectorSource
- Returns:
- whether modify mode is enabled or not
-
setFeatureModifyEnabled
Description copied from interface:SupportsFeatureModify
Enables / disables feature modify mode.The default value is
false
.- Specified by:
setFeatureModifyEnabled
in interfaceSupportsFeatureModify
- Overrides:
setFeatureModifyEnabled
in classAbstractEditableVectorSource
- Parameters:
enabled
- whether to enable modify mode
-
withOverlaps
SeesetOverlaps(Boolean)
.- Parameters:
overlaps
- overlaps option- Returns:
- current instance
-
withUseSpatialIndex
- Parameters:
useSpatialIndex
- whether to use spatial index- Returns:
- current instance
-
withStyleProvider
- Parameters:
styleProvider
- function that takes an entity as an argument and produces aStyle
for the entity's geometry- Returns:
- current instance
-
withAttributions
- Parameters:
attributions
- info about copyrights and licences- Returns:
- current instance
-
withWrapX
- Parameters:
wrapX
- whether the source should be looped along the X coordinate- Returns:
- current instance
-
withItems
- Parameters:
items
- items to set- Returns:
- current instance
-
unbindItems
protected void unbindItems()- Specified by:
unbindItems
in classAbstractDataVectorSource<E>
-
bindItems
protected void bindItems()- Specified by:
bindItems
in classAbstractDataVectorSource<E>
-
onJmixSourceGeoObjectSelection
-
onJmixSourceFeatureSelection
- Overrides:
onJmixSourceFeatureSelection
in classAbstractEditableVectorSource
-
onJmixSourceFeatureDragStart
- Overrides:
onJmixSourceFeatureDragStart
in classAbstractEditableVectorSource
-
onJmixSourceFeatureDragEnd
- Overrides:
onJmixSourceFeatureDragEnd
in classAbstractEditableVectorSource
-
onJmixSourceFeatureModifyStart
- Overrides:
onJmixSourceFeatureModifyStart
in classAbstractEditableVectorSource
-
onJmixSourceFeatureModifyEnd
- Overrides:
onJmixSourceFeatureModifyEnd
in classAbstractEditableVectorSource
-
onJmixSourceFeatureDelete
- Overrides:
onJmixSourceFeatureDelete
in classAbstractEditableVectorSource
-
onGeoObjectRemove
-
applyDeletion
-
applyModifyChanges
-
convertFeaturesToItems
-
updateSelectedGeoObjects
-