Class MultiPolygonFeature
- All Implemented Interfaces:
FeatureClickNotifier<MultiPolygonFeature>,HasFeatureModifyStyles,HasFeatureSelectStyles,Serializable
MultiPolygonGeometry.
Usage example:
private void addMultiPolygon(VectorSource vectorSource) {
GeometryFactory factory = GeometryUtils.getGeometryFactory();
Polygon polygon1 = factory.createPolygon(
factory.createLinearRing(new Coordinate[]{
new Coordinate(25.095057034220535, 31.6734818426374),
new Coordinate(25.095057034220535, 21.916591864189783),
new Coordinate(36.273764258555126, 21.916591864189783),
new Coordinate(31.711026615969566, 30.893621948904325),
new Coordinate(25.095057034220535, 31.6734818426374)}));
Polygon polygon2 = factory.createPolygon(
factory.createLinearRing(new Coordinate[]{
new Coordinate(26.836428848759905, 40.89954566030514),
new Coordinate(26.836428848759905, 35.71188725771292),
new Coordinate(45.08737941910209, 36.265661479563505),
new Coordinate(43.49042124419716, 41.4148387201449),
new Coordinate(26.836428848759905, 40.89954566030514)}));
MultiPolygon multiPolygon = factory.createMultiPolygon(new Polygon[]{polygon1, polygon2});
vectorSource.addFeature(new MultiPolygonFeature(multiPolygon));
}
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class io.jmix.mapsflowui.kit.component.model.MapObservableObject
MapObservableObject.ObjectChangeEventNested classes/interfaces inherited from interface io.jmix.mapsflowui.component.model.feature.FeatureClickNotifier
FeatureClickNotifier.AbstractFeatureClickEvent<F>, FeatureClickNotifier.FeatureClickEvent<F extends Feature>, FeatureClickNotifier.FeatureDoubleClickEvent<F extends Feature>, FeatureClickNotifier.FeatureSingleClickEvent<F extends Feature> -
Field Summary
Fields inherited from class io.jmix.mapsflowui.kit.component.model.feature.Feature
geometry, modifyStyles, properties, selectStyles, stylesFields 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 feature click listener.com.vaadin.flow.shared.RegistrationaddDoubleClickListener(Consumer<FeatureClickNotifier.FeatureDoubleClickEvent<MultiPolygonFeature>> listener) Adds feature double click listener.voidaddModifyStyles(Style... styles) Adds modify styles to a feature.voidaddSelectStyles(Style... styles) Adds select styles to a feature.com.vaadin.flow.shared.RegistrationaddSingleClickListener(Consumer<FeatureClickNotifier.FeatureSingleClickEvent<MultiPolygonFeature>> listener) Adds feature single click listener.voidAdds style to the feature.org.locationtech.jts.geom.MultiPolygonvoidsetMultiPolygon(org.locationtech.jts.geom.MultiPolygon multiPolygon) Sets multipolygon to the feature's geometry.withModifyStyles(Style... styles) withProperties(Map<String, Object> properties) Sets the properties that will be associated with the feature.withProperty(String name, Object value) Sets the property that will be associated with the feature.withSelectStyles(Style... styles) withStyles(Style... styles) SeeaddStyles(Style...).Methods inherited from class io.jmix.mapsflowui.kit.component.model.feature.Feature
addAllModifyStyles, addAllSelectStyles, getModifyStyles, getProperties, getSelectStyles, getStyles, getType, removeAllModifyStyles, removeAllProperties, removeAllSelectStyles, removeAllStyles, removeModifyStyles, removeProperty, removeSelectStyles, removeStyles, updateModifyStyleIds, updateSelectStyleIdsMethods 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
-
Constructor Details
-
MultiPolygonFeature
public MultiPolygonFeature(org.locationtech.jts.geom.MultiPolygon multiPolygon)
-
-
Method Details
-
getGeometry
- Overrides:
getGeometryin classFeature- Returns:
- feature's geometry
-
getMultiPolygon
public org.locationtech.jts.geom.MultiPolygon getMultiPolygon()- Returns:
- multipolygon from feature's geometry
getGeometry()
-
setMultiPolygon
public void setMultiPolygon(org.locationtech.jts.geom.MultiPolygon multiPolygon) Sets multipolygon to the feature's geometry.- Parameters:
multiPolygon- multipolygon to set
-
addStyles
Adds style to the feature. Note, if the feature contains custom styles, the default styles or added ones to the layer won't be applied to this feature. And you have to provide fully described style to the specific feature.For instance, custom polygon style:
new MultiPolygonFeature(multiPolygon) .withStyles(new PolygonStyle() .withFill(new Fill("rgba(1, 147, 154, 0.2)")) .withStroke(new Stroke() .withWidth(3.) .withColor("#123EAB")) .build()); -
withStyles
SeeaddStyles(Style...).- Overrides:
withStylesin classFeature- Parameters:
styles- styles to add- Returns:
- current instance
-
addSelectStyles
Adds select styles to a feature. The styles will be applied for a feature's geometry when the user selects it.To enable select mode set
SupportsFeatureSelect.setFeatureSelectEnabled(Boolean)totrue.For instance, custom select style for multipolygon:
new MultiPolygonFeature(multiPolygon) .withSelectStyles(new PolygonStyle() .withFill(new Fill("hsla(244, 57%, 65%, 0.4)")) .withStroke(new Stroke() .withColor("#2219B2") .withWidth(3d)) .build());- Specified by:
addSelectStylesin interfaceHasFeatureSelectStyles- Overrides:
addSelectStylesin classFeature- Parameters:
styles- styles to add
-
withSelectStyles
- Overrides:
withSelectStylesin classFeature- Parameters:
styles- styles to add- Returns:
- current instance
-
addModifyStyles
Adds modify styles to a feature.Note, modify styles will be applied not to the feature's geometry, but to the generated vertex point of the feature's geometry. This is because the map generates a point for geometry's vertices to enable modification: adding new vertex, change vertex position. So the provided styles should be valid for the Point Feature.
To enable modify mode set
SupportsFeatureModify.setFeatureModifyEnabled(Boolean)totrue.For instance, custom modify style for multipolygon:
new MultiPolygonFeature(multiPolygon) .withModifyStyles( new PointStyle() .withImage(new CircleStyle() .withRadius(6) .withFill(new Fill("#00B945")) .withStroke(new Stroke() .withLineDash(List.of(4d, 6d)) .withWidth(3d) .withColor("#0776A0"))) .build());- Specified by:
addModifyStylesin interfaceHasFeatureModifyStyles- Overrides:
addModifyStylesin classFeature- Parameters:
styles- styles to add
-
withModifyStyles
- Overrides:
withModifyStylesin classFeature- Parameters:
styles- styles to add- Returns:
- current instance
-
withProperties
Description copied from class:FeatureSets the properties that will be associated with the feature.For instance, if cluster specified weight property it will try to get it from the feature's properties. The same with heatmap when it is specified its weight property.
Another example of using feature's properties is listening click events in source. For instance:
vectorSource.addSourceFeatureClickListener(event -> { Feature feature = event.getFeature(); String description = (String) feature.getProperties().get("description"); notifications.show(description); });- Overrides:
withPropertiesin classFeature- Parameters:
properties- properties to set- Returns:
- current instance
-
withProperty
Description copied from class:FeatureSets the property that will be associated with the feature.For instance, if cluster specified weight property it will try to get it from the feature's properties. The same with heatmap when it is specified its weight property.
Another example of using feature's properties is listening click events in source. For instance:
vectorSource.addSourceFeatureClickListener(event -> { Feature feature = event.getFeature(); String description = (String) feature.getProperties().get("description"); notifications.show(description); });- Overrides:
withPropertyin classFeature- Parameters:
name- property namevalue- value- Returns:
- current instance
-
addClickListener
public com.vaadin.flow.shared.Registration addClickListener(Consumer<FeatureClickNotifier.FeatureClickEvent<MultiPolygonFeature>> listener) Description copied from interface:FeatureClickNotifierAdds feature click listener. Note, if the user makes double click on a feature, theFeatureClickNotifier.FeatureClickEventwill be fired twice.- Specified by:
addClickListenerin interfaceFeatureClickNotifier<MultiPolygonFeature>- Parameters:
listener- listener to add- Returns:
- a registration object for removing an event listener
-
addSingleClickListener
public com.vaadin.flow.shared.Registration addSingleClickListener(Consumer<FeatureClickNotifier.FeatureSingleClickEvent<MultiPolygonFeature>> listener) Description copied from interface:FeatureClickNotifierAdds feature single click listener. Single click means that an event won't be fired if the user makes double click.- Specified by:
addSingleClickListenerin interfaceFeatureClickNotifier<MultiPolygonFeature>- Parameters:
listener- listener to add- Returns:
- a registration object for removing an event listener
-
addDoubleClickListener
public com.vaadin.flow.shared.Registration addDoubleClickListener(Consumer<FeatureClickNotifier.FeatureDoubleClickEvent<MultiPolygonFeature>> listener) Description copied from interface:FeatureClickNotifierAdds feature double click listener.- Specified by:
addDoubleClickListenerin interfaceFeatureClickNotifier<MultiPolygonFeature>- Parameters:
listener- listener to add- Returns:
- a registration object for removing an event listener
-