Class DataVectorSource<E>
- Type Parameters:
E
- item type
- All Implemented Interfaces:
GeoObjectClickNotifier<E>
,AbstractVectorSource.HasOverlaps
,AbstractVectorSource.HasUseSpatialIndex
,AbstractVectorSource.HasVectorSourceOptions
,Source.HasAttributions
,Source.HasWrapX
,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>
-
Field Summary
Modifier and TypeFieldDescriptionprotected org.springframework.context.ApplicationContext
protected DataVectorSourceBinding<E>
protected DataVectorSourceItems<E>
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, projection, wrapX
Fields inherited from class io.jmix.mapsflowui.kit.component.model.MapObservableObject
children, dirty, eventBus, listener, metaProperties, removedChildren, syncId
-
Constructor Summary
-
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
addGeoObjectSingleClickListener
(Consumer<GeoObjectClickNotifier.GeoObjectSingleClickEvent<E>> listener) Adds geo-object single click listener.protected void
getItems()
protected String
getType()
getWrapX()
void
setApplicationContext
(org.springframework.context.ApplicationContext applicationContext) void
setAttributions
(List<String> attributions) void
setItems
(DataVectorSourceItems<E> items) Sets the data provider to the source.void
setOverlaps
(Boolean overlaps) Sets whether source may have overlapping geometries.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.void
protected void
withAttributions
(List<String> attributions) withItems
(DataVectorSourceItems<E> items) withOverlaps
(Boolean overlaps) SeesetOverlaps(Boolean)
.withStyleProvider
(Function<? super E, Style> styleProvider) withUseSpatialIndex
(Boolean useSpatialIndex) SeesetWrapX(Boolean)
.Methods inherited from class io.jmix.mapsflowui.kit.component.model.source.Source
getAttributionsCollapsible, getProjection, setAttributionsCollapsible, setProjection
Methods inherited from class io.jmix.mapsflowui.kit.component.model.MapObservableObject
addChild, addListener, clearRemovedChildren, clearRemovedChildrenInDepth, equals, fireChangeEvent, getChildren, getEventBus, getMetaProperties, getRemovedChildren, getSyncId, hashCode, isDirty, isDirtyInDepth, markAsDirty, markAsDirtyInDepth, removeChild, setMapObjectChangeListener, setMetaProperty, unmarkDirtyInDepth
-
Field Details
-
applicationContext
protected org.springframework.context.ApplicationContext applicationContext -
items
-
binder
-
styleProvider
-
-
Constructor Details
-
DataVectorSource
public DataVectorSource()
-
-
Method Details
-
getType
- Specified by:
getType
in classMapObservableObject
-
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
-
getItems
- Returns:
- source's items or
null
if not set
-
setItems
Sets the data provider to the source.- Parameters:
items
- items to set
-
withItems
- Parameters:
items
- items to set- Returns:
- current instance
-
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:StreamResource streamResource = new StreamResource("marker.png", () -> MarkerFeature.class .getResourceAsStream("/META-INF/frontend/jmix-openlayers-map/icon/marker.png")); source.setStyleProvider(shop -> new Style() .withImage(new IconStyle() .withResource(streamResource) .withScale(0.5) .withAnchorOrigin(IconOrigin.BOTTOM_LEFT) .withAnchor(new Anchor(0.49, 0.12))) .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
-
withStyleProvider
- Parameters:
styleProvider
- function that takes an entity as an argument and produces aStyle
for the entity's geometry- Returns:
- current instance
-
getAttributions
- Specified by:
getAttributions
in interfaceSource.HasAttributions
- Overrides:
getAttributions
in classSource
- Returns:
- the attributions of the source or
null
if not set
-
setAttributions
- Specified by:
setAttributions
in interfaceSource.HasAttributions
- Overrides:
setAttributions
in classSource
- Parameters:
attributions
- info about copyrights and licences
-
withAttributions
- Parameters:
attributions
- info about copyrights and licences- Returns:
- current instance
-
getWrapX
- Specified by:
getWrapX
in interfaceSource.HasWrapX
- Overrides:
getWrapX
in classSource
- Returns:
- whether the source should be looped along the X coordinate or
null
if not set
-
setWrapX
- Specified by:
setWrapX
in interfaceSource.HasWrapX
- Overrides:
setWrapX
in classSource
- Parameters:
wrapX
- whether the source should be looped along the X coordinate
-
withWrapX
SeesetWrapX(Boolean)
.- Parameters:
wrapX
- whether the source should be looped along the X coordinate- Returns:
- current instance
-
getOverlaps
- Specified by:
getOverlaps
in interfaceAbstractVectorSource.HasOverlaps
- Overrides:
getOverlaps
in classAbstractVectorSource
- Returns:
- overlaps value or
null
if not set
-
setOverlaps
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
-
withOverlaps
SeesetOverlaps(Boolean)
.- Parameters:
overlaps
- overlaps option- Returns:
- current instance
-
getUseSpatialIndex
- Specified by:
getUseSpatialIndex
in interfaceAbstractVectorSource.HasUseSpatialIndex
- Overrides:
getUseSpatialIndex
in classAbstractVectorSource
- Returns:
- useSpatialIndex value or
null
if not set
-
setUseSpatialIndex
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
-
withUseSpatialIndex
- Parameters:
useSpatialIndex
- whether to use spatial index- Returns:
- current instance
-
addGeoObjectClickListener
public com.vaadin.flow.shared.Registration addGeoObjectClickListener(Consumer<GeoObjectClickNotifier.GeoObjectClickEvent<E>> listener) 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) 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) 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
-
unbindItems
protected void unbindItems() -
bindItems
protected void bindItems()
-