Class MultiLineStringFeature

All Implemented Interfaces:
FeatureClickNotifier<MultiLineStringFeature>, HasFeatureModifyStyles, HasFeatureSelectStyles, Serializable

public class MultiLineStringFeature extends Feature implements FeatureClickNotifier<MultiLineStringFeature>
Multilinestring feature with predefined MultiLineStringFeature.

Usage example:

 private void addMultiLineString(VectorSource vectorSource) {
     GeometryFactory factory = GeometryUtils.getGeometryFactory();

     LineString lineString1 = factory.createLineString(new Coordinate[]{
             new Coordinate(37.59610278959945, 55.75230701125054),
             new Coordinate(24.94409456852425, 60.18627418174103),
             new Coordinate(12.483009200616205, 41.87228189777008)});

     LineString lineString2 = factory.createLineString(new Coordinate[]{
             new Coordinate(30.799901492251276, 36.89489780945887),
             new Coordinate(-3.71329777467964, 40.4106248584977)});

     MultiLineString multiLineString = factory.createMultiLineString(new LineString[]{lineString1, lineString2});
     vectorSource.addFeature(new MultiLineStringFeature(multiLineString));
 }
 
See Also:
  • Constructor Details

    • MultiLineStringFeature

      public MultiLineStringFeature(org.locationtech.jts.geom.MultiLineString multiLineString)
  • Method Details

    • getGeometry

      public MultiLineStringGeometry getGeometry()
      Overrides:
      getGeometry in class Feature
      Returns:
      feature's geometry
    • getMultiLineString

      public org.locationtech.jts.geom.MultiLineString getMultiLineString()
      Returns:
      multilinestring from feature's geometry getGeometry()
    • setMultiLineString

      public void setMultiLineString(org.locationtech.jts.geom.MultiLineString multiLineString)
      Sets multilinestring to the feature's geometry.
      Parameters:
      multiLineString - multiLineString to set
    • addStyles

      public void addStyles(Style... styles)
      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 multilinestring style:

       new MultiLineStringFeature(multiLineString)
               .withStyles(new LineStringStyle()
                       .withStroke(new Stroke()
                               .withWidth(3.0)
                               .withColor("#F60018"))
                       .build());
       
      Overrides:
      addStyles in class Feature
      Parameters:
      styles - styles to add
    • withStyles

      public MultiLineStringFeature withStyles(Style... styles)
      Overrides:
      withStyles in class Feature
      Parameters:
      styles - styles to add
      Returns:
      current instance
    • addSelectStyles

      public void addSelectStyles(Style... styles)
      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) to true.

      For instance, custom select style for multilinestring:

       new MultiLineStringFeature(multiLineString)
               .withSelectStyles(new LineStringStyle()
                       .withStroke(new Stroke()
                               .withColor("#4D54D8")
                               .withWidth(6d))
                       .build());
       
      Specified by:
      addSelectStyles in interface HasFeatureSelectStyles
      Overrides:
      addSelectStyles in class Feature
      Parameters:
      styles - styles to add
    • withSelectStyles

      public MultiLineStringFeature withSelectStyles(Style... styles)
      Overrides:
      withSelectStyles in class Feature
      Parameters:
      styles - styles to add
      Returns:
      current instance
    • addModifyStyles

      public void addModifyStyles(Style... styles)
      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) to true.

      For instance, custom modify style for multilinestring:

       new MultiLineStringFeature(multiLineString)
               .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:
      addModifyStyles in interface HasFeatureModifyStyles
      Overrides:
      addModifyStyles in class Feature
      Parameters:
      styles - styles to add
    • withModifyStyles

      public MultiLineStringFeature withModifyStyles(Style... styles)
      Overrides:
      withModifyStyles in class Feature
      Parameters:
      styles - styles to add
      Returns:
      current instance
    • withProperties

      public MultiLineStringFeature withProperties(Map<String,Object> properties)
      Description copied from class: Feature
      Sets 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:
      withProperties in class Feature
      Parameters:
      properties - properties to set
      Returns:
      current instance
    • withProperty

      public MultiLineStringFeature withProperty(String name, Object value)
      Description copied from class: Feature
      Sets 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:
      withProperty in class Feature
      Parameters:
      name - property name
      value - value
      Returns:
      current instance
    • addClickListener

      public com.vaadin.flow.shared.Registration addClickListener(Consumer<FeatureClickNotifier.FeatureClickEvent<MultiLineStringFeature>> listener)
      Description copied from interface: FeatureClickNotifier
      Adds feature click listener. Note, if the user makes double click on a feature, the FeatureClickNotifier.FeatureClickEvent will be fired twice.
      Specified by:
      addClickListener in interface FeatureClickNotifier<MultiLineStringFeature>
      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<MultiLineStringFeature>> listener)
      Description copied from interface: FeatureClickNotifier
      Adds feature single click listener. Single click means that an event won't be fired if the user makes double click.
      Specified by:
      addSingleClickListener in interface FeatureClickNotifier<MultiLineStringFeature>
      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<MultiLineStringFeature>> listener)
      Description copied from interface: FeatureClickNotifier
      Adds feature double click listener.
      Specified by:
      addDoubleClickListener in interface FeatureClickNotifier<MultiLineStringFeature>
      Parameters:
      listener - listener to add
      Returns:
      a registration object for removing an event listener