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.HasVectorSourceOptionsNested classes/interfaces inherited from class io.jmix.mapsflowui.kit.component.model.source.Source
Source.HasAttributions, Source.HasAttributionsCollapsible, Source.HasProjection, Source.HasSourceOptions, Source.HasWrapXNested classes/interfaces inherited from class io.jmix.mapsflowui.kit.component.model.MapObservableObject
MapObservableObject.ObjectChangeEventNested 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.ApplicationContextprotected AbstractDataVectorSourceBinding<E>Fields inherited from class io.jmix.mapsflowui.component.model.source.AbstractDataVectorSource
itemsFields inherited from class io.jmix.mapsflowui.kit.component.model.source.AbstractEditableVectorSource
featureDragEnabled, featureModifyEnabled, featureSelectEnabled, jmixSourceFeatureDeleteRegistration, jmixSourceFeatureDragEndRegistration, jmixSourceFeatureDragStartRegistration, jmixSourceFeatureModifyEndRegistration, jmixSourceFeatureModifyStartRegistration, jmixSourceFeatureSelectionRegistrationFields inherited from class io.jmix.mapsflowui.kit.component.model.source.AbstractVectorSource
overlaps, useSpatialIndexFields inherited from class io.jmix.mapsflowui.kit.component.model.source.Source
attributions, attributionsCollapsible, id, projection, wrapXFields 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.RegistrationAdds geo-object click listener.com.vaadin.flow.shared.RegistrationaddGeoObjectDoubleClickListener(Consumer<GeoObjectClickNotifier.GeoObjectDoubleClickEvent<E>> listener) Adds geo-object double click listener.com.vaadin.flow.shared.RegistrationAdds geo-object drag end listener.com.vaadin.flow.shared.RegistrationAdds geo-object drag start listener.com.vaadin.flow.shared.RegistrationaddGeoObjectSingleClickListener(Consumer<GeoObjectClickNotifier.GeoObjectSingleClickEvent<E>> listener) Adds geo-object single click listener.com.vaadin.flow.shared.RegistrationaddSourceGeoObjectModifyEndListener(Consumer<HasGeoObjectModify.SourceGeoObjectModifyEndEvent<E>> listener) Adds geo-object modify end listener.com.vaadin.flow.shared.RegistrationaddSourceGeoObjectModifyStartListener(Consumer<HasGeoObjectModify.SourceGeoObjectModifyStartEvent<E>> listener) Adds geo-object modify start listener.com.vaadin.flow.shared.RegistrationaddSourceGeoObjectSelectListener(Consumer<HasGeoObjectSelect.SourceGeoObjectSelectEvent<E>> listener) Adds geo-object select listener.protected voidapplyDeletion(Collection<E> itemsTuUpdate) protected voidapplyModifyChanges(Map<Feature, SimpleGeometry<?>> features) protected voidprotected Collection<E>convertFeaturesToItems(Collection<Feature> features) voidDeselects all items in the source.voiddeselectGeoObject(E item) Deselects the provided item.voiddeselectGeoObjects(Collection<E> items) Deselects the collection of items.booleanisGeoObjetSelected(E item) Checks whether an item is selected.protected voidonGeoObjectRemove(E item) protected voidprotected voidprotected voidprotected voidprotected voidprotected voidprotected voidonJmixSourceGeoObjectSelection(List<E> selected, List<E> deselected) voidSelects all items in the source.voidselectGeoObject(E item) Selects the provided item.voidselectGeoObjects(Collection<E> items) Selects the collection of items.voidsetApplicationContext(org.springframework.context.ApplicationContext applicationContext) voidsetFeatureDragEnabled(Boolean enabled) Enables / disables feature drag mode.voidsetFeatureModifyEnabled(Boolean enabled) Enables / disables feature modify mode.voidsetFeatureSelectEnabled(Boolean enabled) Enables / disables feature select mode.voidsetModifyStyleProvider(Function<? super E, List<Style>> modifyStyleProvider) Sets modify style provider for a layer's geo-objects.voidsetOverlaps(Boolean overlaps) Sets whether source may have overlapping geometries.voidsetSelectStyleProvider(Function<? super E, List<Style>> selectStyleProvider) Sets select style provider for a layer's geo-objects.voidsetStyleProvider(Function<? super E, Style> styleProvider) Sets the style provider for a layer's geo-objects, i.e.voidsetUseSpatialIndex(Boolean useSpatialIndex) Sets whether to use spatial index.protected voidprotected voidupdateSelectedGeoObjects(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, setWrapXMethods inherited from class io.jmix.mapsflowui.kit.component.model.source.AbstractEditableVectorSource
attachJmixSourceFeatureDeleteListener, attachJmixSourceFeatureDragEndListener, attachJmixSourceFeatureDragStartListener, attachJmixSourceFeatureModifyEndListener, attachJmixSourceFeatureModifyStartListener, attachJmixSourceFeatureSelectionListenerMethods inherited from class io.jmix.mapsflowui.kit.component.model.source.Source
getAttributionsCollapsible, getId, getProjection, setAttributionsCollapsible, setId, setProjectionMethods 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:
setApplicationContextin interfaceorg.springframework.context.ApplicationContextAware- Throws:
org.springframework.beans.BeansException
-
getStyleProvider
- Returns:
- style provider for a layer's geo-objects or
nullif 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
MarkerFeaturethat 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 aStylefor the entity's geometry
-
getSelectStyleProvider
- Returns:
- select style provider for a layer's geo-objects or
nullif 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
Polygongeometry 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 aStylefor the entity's geometry
-
getModifyStyleProvider
- Returns:
- modify style provider for a layer's geo-objects or
nullif 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
Polygongeometry 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 aStylefor the entity's geometry
-
getOverlaps
- Specified by:
getOverlapsin interfaceAbstractVectorSource.HasOverlaps- Overrides:
getOverlapsin classAbstractVectorSource- Returns:
- overlaps value or
nullif not set
-
setOverlaps
Description copied from interface:AbstractVectorSource.HasOverlapsSets 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:
setOverlapsin interfaceAbstractVectorSource.HasOverlaps- Overrides:
setOverlapsin classAbstractVectorSource- Parameters:
overlaps- overlaps option
-
getUseSpatialIndex
- Specified by:
getUseSpatialIndexin interfaceAbstractVectorSource.HasUseSpatialIndex- Overrides:
getUseSpatialIndexin classAbstractVectorSource- Returns:
- useSpatialIndex value or
nullif not set
-
setUseSpatialIndex
Description copied from interface:AbstractVectorSource.HasUseSpatialIndexSets whether to use spatial index. When features are removed and added frequently, and the total number of features is low, setting this tofalsemay improve performance. The default value istrue.- Specified by:
setUseSpatialIndexin interfaceAbstractVectorSource.HasUseSpatialIndex- Overrides:
setUseSpatialIndexin 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:GeoObjectClickNotifierAdds geo-object click listener. Note, if the user makes double click, theGeoObjectClickNotifier.GeoObjectClickEventwill be fired twice.- Specified by:
addGeoObjectClickListenerin 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:GeoObjectClickNotifierAdds geo-object single click listener. Single click means that an event won't be fired if the user makes double click.- Specified by:
addGeoObjectSingleClickListenerin 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:GeoObjectClickNotifierAdds geo-object double click listener.- Specified by:
addGeoObjectDoubleClickListenerin 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:HasGeoObjectSelectAdds geo-object select listener.- Specified by:
addSourceGeoObjectSelectListenerin 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:HasGeoObjectDragAdds geo-object drag start listener.- Specified by:
addGeoObjectDragStartListenerin 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:HasGeoObjectDragAdds geo-object drag end listener.- Specified by:
addGeoObjectDragEndListenerin 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:HasGeoObjectModifyAdds geo-object modify start listener.- Specified by:
addSourceGeoObjectModifyStartListenerin 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:HasGeoObjectModifyAdds geo-object modify end listener.- Specified by:
addSourceGeoObjectModifyEndListenerin interfaceHasGeoObjectModify<E>- Parameters:
listener- listener to add- Returns:
- a registration object for removing an event listener
-
isGeoObjetSelected
Description copied from interface:HasGeoObjectSelectChecks whether an item is selected.- Specified by:
isGeoObjetSelectedin interfaceHasGeoObjectSelect<E>- Parameters:
item- item to check- Returns:
trueif feature is selected
-
getSelectedGeoObjects
- Specified by:
getSelectedGeoObjectsin interfaceHasGeoObjectSelect<E>- Returns:
- unmodifiable collection of selected items
-
selectGeoObject
Description copied from interface:HasGeoObjectSelectSelects the provided item.Note that selection works only when
SupportsFeatureSelect.getFeatureSelectEnabled()is enabled.- Specified by:
selectGeoObjectin interfaceHasGeoObjectSelect<E>- Parameters:
item- item to select
-
deselectGeoObject
Description copied from interface:HasGeoObjectSelectDeselects the provided item.Note that selection works only when
SupportsFeatureSelect.getFeatureSelectEnabled()is enabled.- Specified by:
deselectGeoObjectin interfaceHasGeoObjectSelect<E>- Parameters:
item- item to deselect
-
selectGeoObjects
Description copied from interface:HasGeoObjectSelectSelects the collection of items.Note that selection works only when
SupportsFeatureSelect.getFeatureSelectEnabled()is enabled.- Specified by:
selectGeoObjectsin interfaceHasGeoObjectSelect<E>- Parameters:
items- items to select
-
deselectGeoObjects
Description copied from interface:HasGeoObjectSelectDeselects the collection of items.Note that selection works only when
SupportsFeatureSelect.getFeatureSelectEnabled()is enabled.- Specified by:
deselectGeoObjectsin interfaceHasGeoObjectSelect<E>- Parameters:
items- items to deselect
-
selectAllGeoObjects
public void selectAllGeoObjects()Description copied from interface:HasGeoObjectSelectSelects all items in the source.Note that selection works only when
SupportsFeatureSelect.getFeatureSelectEnabled()is enabled.- Specified by:
selectAllGeoObjectsin interfaceHasGeoObjectSelect<E>
-
deselectAllGeoObjects
public void deselectAllGeoObjects()Description copied from interface:HasGeoObjectSelectDeselects all items in the source.Note that selection works only when
SupportsFeatureSelect.getFeatureSelectEnabled()is enabled.- Specified by:
deselectAllGeoObjectsin interfaceHasGeoObjectSelect<E>
-
getFeatureSelectEnabled
- Specified by:
getFeatureSelectEnabledin interfaceSupportsFeatureSelect- Overrides:
getFeatureSelectEnabledin classAbstractEditableVectorSource- Returns:
- whether select mode is enabled or not
-
setFeatureSelectEnabled
Description copied from interface:SupportsFeatureSelectEnables / disables feature select mode.The default value is
false.- Specified by:
setFeatureSelectEnabledin interfaceSupportsFeatureSelect- Overrides:
setFeatureSelectEnabledin classAbstractEditableVectorSource- Parameters:
enabled- whether to enable select mode
-
getFeatureDragEnabled
- Specified by:
getFeatureDragEnabledin interfaceSupportsFeatureDrag- Overrides:
getFeatureDragEnabledin classAbstractEditableVectorSource- Returns:
- whether drag mode is enabled or not
-
setFeatureDragEnabled
Description copied from interface:SupportsFeatureDragEnables / disables feature drag mode.The default value is
false.- Specified by:
setFeatureDragEnabledin interfaceSupportsFeatureDrag- Overrides:
setFeatureDragEnabledin classAbstractEditableVectorSource- Parameters:
enabled- whether to enable drag mode
-
getFeatureModifyEnabled
- Specified by:
getFeatureModifyEnabledin interfaceSupportsFeatureModify- Overrides:
getFeatureModifyEnabledin classAbstractEditableVectorSource- Returns:
- whether modify mode is enabled or not
-
setFeatureModifyEnabled
Description copied from interface:SupportsFeatureModifyEnables / disables feature modify mode.The default value is
false.- Specified by:
setFeatureModifyEnabledin interfaceSupportsFeatureModify- Overrides:
setFeatureModifyEnabledin 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 aStylefor 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:
unbindItemsin classAbstractDataVectorSource<E>
-
bindItems
protected void bindItems()- Specified by:
bindItemsin classAbstractDataVectorSource<E>
-
onJmixSourceGeoObjectSelection
-
onJmixSourceFeatureSelection
- Overrides:
onJmixSourceFeatureSelectionin classAbstractEditableVectorSource
-
onJmixSourceFeatureDragStart
- Overrides:
onJmixSourceFeatureDragStartin classAbstractEditableVectorSource
-
onJmixSourceFeatureDragEnd
- Overrides:
onJmixSourceFeatureDragEndin classAbstractEditableVectorSource
-
onJmixSourceFeatureModifyStart
- Overrides:
onJmixSourceFeatureModifyStartin classAbstractEditableVectorSource
-
onJmixSourceFeatureModifyEnd
- Overrides:
onJmixSourceFeatureModifyEndin classAbstractEditableVectorSource
-
onJmixSourceFeatureDelete
- Overrides:
onJmixSourceFeatureDeletein classAbstractEditableVectorSource
-
onGeoObjectRemove
-
applyDeletion
-
applyModifyChanges
-
convertFeaturesToItems
-
updateSelectedGeoObjects
-