Class SimpleLineSymbol

  • All Implemented Interfaces:
    JsonSerializable

    public final class SimpleLineSymbol
    extends LineSymbol
    Defines a SimpleLineSymbol which is a LineSymbol based on simple patterns.

    SimpleLineSymbols symbolize Graphics and Features that have Polyline geometries using predefined style patterns. A SimpleLineSymbol is used to draw generic linear Features but renders faster than more advance LineSymbols.

    Example of creating a SimpleLineSymbol:

     // create points for the line
     PointCollection points = new PointCollection(SpatialReferences.getWebMercator());
     points.add(-226913, 6550477);
     points.add(-226643, 6550477);
     Polyline line = new Polyline(points);
    
     // creates a solid red simple line symbol
     SimpleLineSymbol lineSymbol = new SimpleLineSymbol(Style.SOLID, 0xFFFF0000, 3);
    
     // add line with symbol to graphics overlay and add overlay to map view
     GraphicsOverlay graphicsOverlay = new GraphicsOverlay();
     mapView.getGraphicsOverlays().add(graphicsOverlay);
     graphicsOverlay.getGraphics().add(new Graphic(line, lineSymbol));
     
    A SimpleLineSymbol can be displayed using a Graphic and setting it to a GraphicsOverlay or setting symbol as a Renderer.
     GraphicsOverlay.getGraphics().add(new Graphic(Geometry, SimpleLineSymbol));
     
    OR
     GraphicsOverlay.setRender(new SimpleRenderer(SimpleLineSymbol));
     
    Since:
    100.0.0
    See Also:
    Graphic, GraphicsOverlay, SimpleRenderer, LineSymbol
    • Constructor Detail

      • SimpleLineSymbol

        public SimpleLineSymbol()
        Creates a new SimpleLineSymbol with default properties set. Useful if the properties of the Symbol are only known after the application is running.

        Each property can be set on its own but setting the style property by itself will have no effect on making the Symbol visible.

        Default properties:

        Since:
        100.0.0
      • SimpleLineSymbol

        public SimpleLineSymbol​(SimpleLineSymbol.Style style,
                                int color,
                                float width)
        Creates a new SimpleLineSymbol with the given properties:
        • Style, pattern that makes up the area of the symbol
        • Color, interior color of the symbol
        • Width, thickness of the symbol in density-independent pixels (dp)

        If the width of the symbol is 0 or less then the symbol will not be displayed.

        Parameters:
        style - the style of the Symbol, not null
        color - an integer representing the line color as 0xAARRGGBB
        width - the width of the Symbol in dp
        Throws:
        java.lang.IllegalArgumentException - if style is null
        Since:
        100.0.0
      • SimpleLineSymbol

        public SimpleLineSymbol​(SimpleLineSymbol.Style style,
                                int color,
                                float width,
                                SimpleLineSymbol.MarkerStyle markerStyle,
                                SimpleLineSymbol.MarkerPlacement markerPlacement)
        Creates a new SimpleLineSymbol with the given properties:
        • Style, pattern that makes up the area of the symbol
        • Color, interior color of the symbol
        • Width, thickness of the symbol in density-independent pixels (dp)
        • MarkerStyle, style of markers at the ends of the symbol
        • MarkerPlacement, placement of markers at the ends of the symbol

        If the width of the symbol is 0 or less then the symbol will not be displayed.

        Parameters:
        style - the style of the Symbol, not null
        color - an integer representing the line color as 0xAARRGGBB
        width - the width of the Symbol in dp
        markerStyle - the marker style
        markerPlacement - the marker placement
        Throws:
        java.lang.IllegalArgumentException - if style, markerStyle, or markerPlacement are null
        Since:
        100.2.0
    • Method Detail

      • toMultilayerSymbol

        public MultilayerPolylineSymbol toMultilayerSymbol()
        Gets a multilayer polyline symbol generated from this simple line symbol. The multilayer symbol will contain a SolidStrokeSymbolLayer with a collection of DashGeometricEffects defining any dash patterns from the original simple line symbol.
        Returns:
        a converted multilayer polyline symbol
        Since:
        100.5.0
      • getStyle

        public SimpleLineSymbol.Style getStyle()
        Gets the line style that describes how the symbol's pattern is being displayed.

        Default value is SOLID.

        Returns:
        the current line style of this Symbol
        Since:
        100.0.0
        See Also:
        SimpleLineSymbol.Style
      • setStyle

        public void setStyle​(SimpleLineSymbol.Style style)
        Sets the line style that describes how this Symbol's pattern will be displayed.
        Parameters:
        style - the new line style for this symbol, not null
        Throws:
        java.lang.IllegalArgumentException - if style is null
        Since:
        100.0.0
        See Also:
        SimpleLineSymbol.Style
      • setMarkerPlacement

        public void setMarkerPlacement​(SimpleLineSymbol.MarkerPlacement markerPlacement)
        Sets the marker placement type for this symbol.
        Parameters:
        markerPlacement - the marker placement type
        Throws:
        java.lang.IllegalArgumentException - if markerPlacement is null
        Since:
        100.2.0
      • setMarkerStyle

        public void setMarkerStyle​(SimpleLineSymbol.MarkerStyle markerStyle)
        Sets the marker style for this symbol.
        Parameters:
        markerStyle - the marker style value
        Throws:
        java.lang.IllegalArgumentException - if markerStyle is null
        Since:
        100.2.0