Class SLD

Object
SLD

public class SLD extends Object
Utility class that provides static helper methods for common operations on GeoTools styling objects (e.g. StyledLayerDescriptor, Style, FeatureTypeStyle, Rule, Symbolizer, Stroke and Fill).
Author:
Jody Garnett
  • Field Details

  • Constructor Details

    • SLD

      public SLD()
  • Method Details

    • lineColor

      public static Color lineColor(LineSymbolizer symbolizer)
      Retrieve linestring color from linesymbolizer if available.
      Parameters:
      symbolizer - Line symbolizer information.
      Returns:
      Color of linestring, or null if unavailable.
    • color

      public static Color color(Stroke stroke)
      Retrieve the color of a stroke object
      Parameters:
      stroke - a Stroke object
      Returns:
      color or null if stroke was null
    • color

      public static Color color(Fill fill)
      Retrieve the color of a fill object
      Parameters:
      fill - a Fill object
      Returns:
      color or null if fill was null
    • setLineColour

      public static void setLineColour(Style style, Color colour)
      Updates the color for line symbolizers in the current style.

      This method will update the Style in place; some of the symbolizers will be replaced with modified copies.

      Parameters:
      style - the Style object to be updated
      colour - Color to to use
    • setLineColour

      public static void setLineColour(LineSymbolizer symbolizer, Color colour)
      Sets the Colour for the given Line symbolizer
    • color

      public static Color color(LineSymbolizer symbolizer)
      Retrieve color from linesymbolizer if available.
      Parameters:
      symbolizer - Line symbolizer information.
      Returns:
      Color of linestring, or null if unavailable.
    • lineWidth

      public static int lineWidth(LineSymbolizer symbolizer)
      Retrieve linestring width from symbolizer if available.
      Parameters:
      symbolizer - Line symbolizer information.
      Returns:
      width of linestring, or NOTFOUND
    • width

      public static int width(Stroke stroke)
      Retrieve the width of a Stroke object.
      Parameters:
      stroke - the Stroke object.
      Returns:
      width or NOTFOUND if not available.
    • size

      public static int size(Mark mark)
      Retrieve the size of a Mark object
      Parameters:
      mark - the Mark object
      Returns:
      size or NOTFOUND if not available
    • width

      public static int width(LineSymbolizer symbolizer)
      Retrieve linestring width from symbolizer if available.
      Parameters:
      symbolizer - Line symbolizer information.
      Returns:
      width or NOTFOUND if not available
    • lineOpacity

      public static double lineOpacity(LineSymbolizer symbolizer)
      Retrieve the opacity from a LineSymbolizer object.
      Parameters:
      symbolizer - Line symbolizer information.
      Returns:
      double of the line symbolizer's opacity, or NaN if unavailable.
    • opacity

      public static double opacity(Stroke stroke)
      Retrieve the opacity from a Stroke object.
      Parameters:
      stroke - the Stroke object.
      Returns:
      double of the line stroke's opacity, or NaN if unavailable.
    • opacity

      public static double opacity(RasterSymbolizer rasterSymbolizer)
      Retrieve the opacity from a RasterSymbolizer object.
      Parameters:
      rasterSymbolizer - raster symbolizer information.
      Returns:
      double of the raster symbolizer's opacity, or 1.0 if unavailable.
    • lineLinejoin

      public static String lineLinejoin(LineSymbolizer symbolizer)
      Retrieves the linejoin from a LineSymbolizer.
      Parameters:
      symbolizer - Line symbolizer information.
      Returns:
      String of the linejoin, or null if unavailable.
    • lineLinecap

      public static String lineLinecap(LineSymbolizer symbolizer)
      Retrieves the line cap from a LineSymbolizer.
      Parameters:
      symbolizer - Line symbolizer information.
      Returns:
      String of the line stroke's line cap, or null if unavailable.
    • lineDash

      public static float[] lineDash(LineSymbolizer symbolizer)
      Retrieves the dashes array from a LineSymbolizer.
      Parameters:
      symbolizer - Line symbolizer information.
      Returns:
      float[] of the line dashes array, or null if unavailable.
    • pointGraphic

      public static URL pointGraphic(Style style)
      Retrieves the location of the first external graphic in a Style object.
      Parameters:
      style - SLD style information.
      Returns:
      Location of the first external graphic, or null if unavailabe.
    • pointMark

      public static Mark pointMark(Style style)
      Retrieves the first Mark used in a Style object.
      Parameters:
      style - the Style
      Returns:
      the first Mark object or null if unavailable.
    • mark

      public static Mark mark(PointSymbolizer sym)
      Retrieves the first Mark used in a PointSymbolizer object.
      Parameters:
      sym - the PointSymbolizer
      Returns:
      the first Mark object or null if unavailable.
    • mark

      public static Mark mark(Graphic graphic)
      Retrieves the first Mark object from the given Graphic object.
      Parameters:
      graphic - the Graphic object.
      Returns:
      a Mark object or null if unavailable.
    • graphic

      public static Graphic graphic(PointSymbolizer sym)
    • pointSize

      public static int pointSize(PointSymbolizer symbolizer)
      Retrieves the size of the point's graphic, if found.

      If you are using something fun like symbols you will need to do your own thing.

      Parameters:
      symbolizer - Point symbolizer information.
      Returns:
      size of the graphic or NOTFOUND
    • pointWellKnownName

      public static String pointWellKnownName(PointSymbolizer symbolizer)
      Retrieves the well known name of the first Mark that has one in a PointSymbolizer object

      If you are using something fun like symbols you will need to do your own thing.

      Parameters:
      symbolizer - Point symbolizer information.
      Returns:
      well known name of the first Mark or null if unavailable.
    • wellKnownName

      public static String wellKnownName(Mark mark)
      Retrieves the "well known name" of a Mark object.
      Parameters:
      mark - the Mark object
      Returns:
      well known name or null if unavailable.
    • pointColor

      public static Color pointColor(PointSymbolizer symbolizer)
      Retrieves the color of the first Mark in a PointSymbolizer object. This method is identical to color(PointSymbolizer).

      If you are using something fun like symbols you will need to do your own thing.

      Parameters:
      symbolizer - Point symbolizer information.
      Returns:
      Color of the point's mark, or null if unavailable.
    • setPointColour

      public static void setPointColour(Style style, Color colour)
      Sets the Colour for the point symbolizer
    • setPointColour

      public static void setPointColour(PointSymbolizer symbolizer, Color colour)
      Sets the Colour for the given point symbolizer
      Parameters:
      symbolizer - the point symbolizer
      colour - the new colour
    • color

      public static Color color(PointSymbolizer symbolizer)
      Retrieves the color from the first Mark in a PointSymbolizer object.

      If you are using something fun like symbols you will need to do your own thing.

      Parameters:
      symbolizer - Point symbolizer information.
      Returns:
      Color of the point's mark, or null if unavailable.
    • pointWidth

      public static int pointWidth(PointSymbolizer symbolizer)
      Retrieves the width of the first Mark with a Stroke that has a non-null width.

      If you are using something fun like symbols you will need to do your own thing.

      Parameters:
      symbolizer - Point symbolizer information.
      Returns:
      width of the points border or NOTFOUND if unavailable.
    • pointBorderOpacity

      public static double pointBorderOpacity(PointSymbolizer symbolizer)
      Retrieves the point border opacity from a PointSymbolizer.

      If you are using something fun like rules you will need to do your own thing.

      Parameters:
      symbolizer - Point symbolizer information.
      Returns:
      double of the point's border opacity, or NaN if unavailable.
    • pointOpacity

      public static double pointOpacity(PointSymbolizer symbolizer)
      Retrieves the point opacity from a PointSymbolizer.

      If you are using something fun like rules you will need to do your own thing.

      Parameters:
      symbolizer - Point symbolizer information.
      Returns:
      double of the point's opacity, or NaN if unavailable.
    • pointFill

      public static Color pointFill(PointSymbolizer symbolizer)
      Retrieves the fill from the first Mark defined in a PointSymbolizer.

      If you are using something fun like symbols you will need to do your own thing.

      Parameters:
      symbolizer - Point symbolizer information.
      Returns:
      Color of the point's fill, or null if unavailable.
    • polyWidth

      public static int polyWidth(PolygonSymbolizer symbolizer)
      Retrieves the outline width from a PolygonSymbolizer

      If you are using something fun like rules you will need to do your own thing.

      Parameters:
      symbolizer - Polygon symbolizer information.
      Returns:
      outline width or NOTFOUND if unavailable.
    • polyColor

      public static Color polyColor(PolygonSymbolizer symbolizer)
      Retrieves the outline (stroke) color from a PolygonSymbolizer.

      If you are using something fun like rules you will need to do your own thing.

      Parameters:
      symbolizer - Polygon symbolizer information.
      Returns:
      Color of the polygon's stroke, or null if unavailable.
    • setRasterOpacity

      public static void setRasterOpacity(Style style, double opacity)
      Updates the raster opacity in the current style

      Note: This method will update the Style in place; some of the rules and symbolizers will be replaced with modified copies. All symbolizers associated with all rules are modified.

      Parameters:
      style - the Style object to be updated
      opacity - - a new opacity value between 0 and 1
    • setChannelSelection

      public static void setChannelSelection(Style style, SelectedChannelType[] rgb, SelectedChannelType gray)
      Updates the raster channel selection in a Style object

      This method will update the Style in place; some of the rules & symbolizers will be replace with modified copies. All symbolizes associated with all rules are updated.

      Parameters:
      style - the Style object to be updated
      rgb - - an array of the new red, green, blue channels or null if setting the gray channel
      gray - - the new gray channel; ignored if rgb is not null
    • setPolyColour

      public static void setPolyColour(Style style, Color colour)
      Sets the colour for the first polygon symbolizer defined in the provided style
      Parameters:
      style - the Style object
      colour - the colour for polygon outlines and fill
    • setPolyColour

      public static void setPolyColour(PolygonSymbolizer symbolizer, Color colour)
      Sets the colour to use for outline (stroke) and fill in a polygon symbolizer
      Parameters:
      symbolizer - the polygon symbolizer
      colour - the colour for polygon outlines and fill
    • polyFill

      public static Color polyFill(PolygonSymbolizer symbolizer)
      Retrieves the fill colour from a PolygonSymbolizer.

      If you are using something fun like rules you will need to do your own thing.

      Parameters:
      symbolizer - Polygon symbolizer information.
      Returns:
      Color of the polygon's fill, or null if unavailable.
    • polyBorderOpacity

      public static double polyBorderOpacity(PolygonSymbolizer symbolizer)
      Retrieves the border (stroke) opacity from a PolygonSymbolizer.

      If you are using something fun like rules you will need to do your own thing.

      Parameters:
      symbolizer - Polygon symbolizer information.
      Returns:
      double of the polygon's border opacity, or NaN if unavailable.
    • polyFillOpacity

      public static double polyFillOpacity(PolygonSymbolizer symbolizer)
      Retrieves the fill opacity from the first PolygonSymbolizer.

      If you are using something fun like rules you will need to do your own thing.

      Parameters:
      symbolizer - Polygon symbolizer information.
      Returns:
      double of the polygon's fill opacity, or NaN if unavailable.
    • opacity

      public static double opacity(Fill fill)
      Retrieve the opacity from the provided fill; or return the default.
      Returns:
      opacity from the above fill; or return the Fill.DEFAULT value
    • rasterOpacity

      public static double rasterOpacity(RasterSymbolizer symbolizer)
      Retrieves the opacity from a RasterSymbolizer.

      If you are using something fun like rules you will need to do your own thing.

      Parameters:
      symbolizer - Raster symbolizer information.
      Returns:
      opacity of the first RasterSymbolizer or NaN if unavailable.
    • rasterOpacity

      public static double rasterOpacity(Style style)
      Retrieves the opacity from the first RasterSymbolizer defined in a style.
      Parameters:
      style - the Style object
      Returns:
      opacity of the raster symbolizer or NaN if unavailable.
    • textSymbolizer

      public static TextSymbolizer textSymbolizer(FeatureTypeStyle fts)
      Retrieve the first TextSymbolizer from the provided FeatureTypeStyle.
      Parameters:
      fts - FeatureTypeStyle information.
      Returns:
      TextSymbolizer, or null if not found.
    • textSymbolizer

      public static TextSymbolizer textSymbolizer(Style style)
      Retrieve the first TextSymbolizer from the provided Style.
      Parameters:
      style - the Style object
      Returns:
      TextSymbolizer, or null if not found.
    • font

      public static Font font(TextSymbolizer symbolizer)
      Retrieves the font from a TextSymbolizer. Equivalent to symbolizer.getFont().
      Parameters:
      symbolizer - the symbolizer
      Returns:
      the first font defined in the symbolizer or null if unavailable.
    • textLabel

      public static Expression textLabel(TextSymbolizer symbolizer)
      Retrieves the label from a TextSymbolizer.
      Parameters:
      symbolizer - Text symbolizer information.
      Returns:
      Expression of the label's text, or null if unavailable.
    • textLabelString

      public static String textLabelString(TextSymbolizer symbolizer)
      Retrieves the label from a TextSymbolizer.
      Parameters:
      symbolizer - Text symbolizer information.
      Returns:
      the label's text, or null if unavailable.
    • textFontFill

      public static Color textFontFill(TextSymbolizer symbolizer)
      Retrieves the colour of the font fill from a TextSymbolizer.
      Parameters:
      symbolizer - Text symbolizer information.
      Returns:
      Color of the font's fill, or null if unavailable.
    • textHaloFill

      public static Color textHaloFill(TextSymbolizer symbolizer)
      Retrieves the colour of the halo fill a TextSymbolizer.
      Parameters:
      symbolizer - Text symbolizer information.
      Returns:
      Color of the halo's fill, or null if unavailable.
    • textHaloWidth

      public static int textHaloWidth(TextSymbolizer symbolizer)
      Retrieves the halo width from a TextSymbolizer.
      Parameters:
      symbolizer - Text symbolizer information.
      Returns:
      the halo's width, or 0 if unavailable.
    • textHaloOpacity

      public static double textHaloOpacity(TextSymbolizer symbolizer)
      Retrieves the halo opacity from the first TextSymbolizer.
      Parameters:
      symbolizer - Text symbolizer information.
      Returns:
      double of the halo's opacity, or NaN if unavailable.
    • color

      public static Color color(Expression expr)
      Navigate through the expression finding the first mentioned Color.

      If you have a specific Feature in mind please use:

      
       Object value = expr.getValue( feature );
       return value instanceof Color ? (Color) value : null;
       
      Parameters:
      expr - the Expression object
      Returns:
      First available color, or null.
    • rasterSymbolizer

      public static RasterSymbolizer rasterSymbolizer(FeatureTypeStyle fts)
      Retrieve the first RasterSymbolizer from the provided FeatureTypeStyle.
      Parameters:
      fts - the FeatureTypeStyle information.
      Returns:
      RasterSymbolizer, or null if not found.
    • rasterSymbolizer

      public static RasterSymbolizer rasterSymbolizer(Style style)
      Retrieve the first RasterSymbolizer from the provided Style.
      Parameters:
      style - the Style object
      Returns:
      RasterSymbolizer, or null if not found.
    • lineSymbolizer

      public static LineSymbolizer lineSymbolizer(FeatureTypeStyle fts)
      Retrieve the first LineSymbolizer from the provided FeatureTypeStyle.
      Parameters:
      fts - the FeatureTypeStyle object
      Returns:
      LineSymbolizer, or null if not found.
    • lineSymbolizer

      public static LineSymbolizer lineSymbolizer(Style style)
      Retrieve the first LineSymbolizer from the provided Style.
      Parameters:
      style - the Style object
      Returns:
      LineSymbolizer, or null if not found.
    • stroke

      public static Stroke stroke(LineSymbolizer sym)
      Retrieves the Stroke from a LineSymbolizer.
      Parameters:
      sym - the symbolizer
      Returns:
      the Stroke or null if not found.
    • stroke

      public static Stroke stroke(PolygonSymbolizer sym)
      Retrieves the Stroke from a PolygonSymbolizer.
      Parameters:
      sym - the symbolizer
      Returns:
      the Stroke or null if not found.
    • stroke

      public static Stroke stroke(PointSymbolizer sym)
      Retrieves the Stroke from a PointSymbolizer.
      Parameters:
      sym - the symbolizer
      Returns:
      the Stroke or null if not found.
    • fill

      public static Fill fill(PolygonSymbolizer sym)
      Retrieves the Fill from a PolygonSymbolizer.
      Parameters:
      sym - the symbolizer
      Returns:
      the Fill or null if not found.
    • fill

      public static Fill fill(PointSymbolizer sym)
      Retrieves the Fill from a PointSymbolizer.
      Parameters:
      sym - the symbolizer
      Returns:
      the Fill or null if not found.
    • pointSymbolizer

      public static PointSymbolizer pointSymbolizer(FeatureTypeStyle fts)
      Retrieve the first PointSymbolizer from the provided FeatureTypeStyle.
      Parameters:
      fts - the FeatureTypeStyle object
      Returns:
      PointSymbolizer, or null if not found.
    • pointSymbolizer

      public static PointSymbolizer pointSymbolizer(Style style)
      Retrieve the first PointSymbolizer from the provided Style.
      Parameters:
      style - the Style object
      Returns:
      PointSymbolizer, or null if not found.
    • polySymbolizer

      public static PolygonSymbolizer polySymbolizer(FeatureTypeStyle fts)
      Retrieve the first PolygonSymbolizer from the provided FeatureTypeStyle.
      Parameters:
      fts - FeatureTypeStyle object.
      Returns:
      PolygonSymbolizer, or null if not found.
    • polySymbolizer

      public static PolygonSymbolizer polySymbolizer(Style style)
      Retrieve the first PolygonSymbolizer from the provided Style.
      Parameters:
      style - the Style object
      Returns:
      PolygonSymbolizer, or null if not found.
    • featureTypeStyle

      public static FeatureTypeStyle featureTypeStyle(Style style, SimpleFeatureType type)
      Returns the feature type style in the style which matched a particular name.
      Parameters:
      style - the Style object
      type - the feature type (must be non-null)
      Returns:
      The FeatureTypeStyle object if it exists, otherwise false.
    • matchingStyle

      public static Style matchingStyle(Style[] styles, SimpleFeatureType schema)
      Returns the first style object which matches a given schema.
      Parameters:
      styles - Array of style objects.
      schema - Feature schema.
      Returns:
      The first object to match the feature type, otherwise null if no match.
    • symbolizer

      protected static Symbolizer symbolizer(Style style, Class SYMBOLIZER)
      Retrieve the first Symbolizer from the provided Style.
      Parameters:
      style - SLD style information.
      SYMBOLIZER - LineSymbolizer.class, PointSymbolizer.class, PolygonSymbolizer.class, RasterSymbolizer.class, or TextSymbolizer.class
      Returns:
      symbolizer instance from style, or null if not found.
    • symbolizer

      protected static Symbolizer symbolizer(FeatureTypeStyle fts, Class SYMBOLIZER)
      Retrieve the first Symbolizer from the provided FeatureTypeStyle.
      Parameters:
      fts - the FeatureTypeStyle SLD style information.
      SYMBOLIZER - LineSymbolizer.class, PointSymbolizer.class, PolygonSymbolizer.class, RasterSymbolizer.class, or TextSymbolizer.class
      Returns:
      symbolizer instance from fts, or null if not found.
    • colorToHex

      public static String colorToHex(Color c)
      Convert a Color object to hex representation
      Parameters:
      c - the Color object
      Returns:
      a hex String
    • styles

      public static Style[] styles(StyledLayerDescriptor sld)
      Get the Styles defined in the given StyledLayerDescriptor
      Parameters:
      sld - the StyledLayerDescriptor object
      Returns:
      an array of Styles
    • featureTypeStyles

      public static FeatureTypeStyle[] featureTypeStyles(StyledLayerDescriptor sld)
      Get the FeatureTypeStyles defined in the given StyledLayerDescriptor
      Parameters:
      sld - the StyledLayerDescriptor object
      Returns:
      an array of FeatureTypeStyles
    • featureTypeStyle

      public static FeatureTypeStyle featureTypeStyle(StyledLayerDescriptor sld, SimpleFeatureType type)
      Retrieve the first FeatureTypeStyle defined in the given StyledLayerDescriptor object that matches the specified feature type
      Parameters:
      sld - a StyledLayerDescriptor object
      type - the feature type to match
      Returns:
      a FeatureTypeStyle or null if there was no match
    • defaultStyle

      public static Style defaultStyle(StyledLayerDescriptor sld)
      Retrieve the default style from the given StyledLayerDescriptor.
      Parameters:
      sld - the StyledLayerDescriptor object
      Returns:
      the default style; or the first style if no default is defined; or null if there are no styles
    • filters

      public static Filter[] filters(Rule... rule)
      Retrieves all filters defined in a rule
      Parameters:
      rule - the rule
      Returns:
      array of filters
    • filters

      public static Filter[] filters(Style style)
      Retrieves all filters defined in a style
      Parameters:
      style - the style
      Returns:
      array of filters
    • rules

      public static Rule[] rules(Style style)
      Retrieves all rules defined in a style
      Parameters:
      style - the style
      Returns:
      an array of unique rules
    • symbolizers

      public static Symbolizer[] symbolizers(Style style)
      Retrieves all symbolizers defined in a style
      Parameters:
      style - the style
      Returns:
      an array of unique symbolizers
    • symbolizers

      public static Symbolizer[] symbolizers(Rule rule)
      Retrieves all symbolizers defined in a rule
      Parameters:
      rule - the rule
      Returns:
      an array of unique symbolizers
    • colors

      public static String[] colors(Style style)
      Retrieves all colour names defined in a style
      Parameters:
      style - the style
      Returns:
      an array of unique colour names
    • colors

      public static String[] colors(Rule rule)
      Retrieves all colour names defined in a rule
      Parameters:
      rule - the rule
      Returns:
      an array of unique colour names
    • toHTMLColor

      public static String toHTMLColor(Color color)
      Converts a java.awt.Color into an HTML Colour
      Parameters:
      color - color to convert
      Returns:
      HTML Color (fill) in hex #RRGGBB
    • toColor

      public static Color toColor(String htmlColor)
      Convert an HTML colour string to a java.awt.Color object
      Parameters:
      htmlColor - the colour string
      Returns:
      a new Color object
    • isSemanticTypeMatch

      public static boolean isSemanticTypeMatch(FeatureTypeStyle fts, String regex)
      Test if the given FeatureTypeStyle object matches a regular expression
      Parameters:
      fts - the feature type style
      regex - regular expression to match
      Returns:
      true if a match is found; false otherwise
    • minScale

      public static double minScale(FeatureTypeStyle fts)
      Returns the min scale of the default (first) rule
      Parameters:
      fts - the feature type style
      Returns:
      min scale or 0 if no min scale is set
    • maxScale

      public static double maxScale(FeatureTypeStyle fts)
      Returns the max scale of the default (first) rule
      Parameters:
      fts - the feature type style
      Returns:
      min scale or NaN if no max scale is set
    • getPlacement

      public static PointPlacement getPlacement(double horizAlign, double vertAlign, double rotation)
      Create a PointPlacement object.
      Parameters:
      horizAlign - horizontal alignment (0 to 1)
      vertAlign - vertical alignment (0 to 1)
      rotation - rotation angle in degrees
      Returns:
      a new PointPlacement object
    • createSimpleStyle

      public static Style createSimpleStyle(DataStore store, String typeName, Color color) throws IOException
      Create a minimal style to render features of type typeName read from the given data store
      Parameters:
      store - the data store containing the features
      typeName - the feature type to create the style for
      color - single color to use for all components of the Style
      Returns:
      a new Style instance
      Throws:
      IOException - if the data store cannot be accessed
    • createSimpleStyle

      public static Style createSimpleStyle(FeatureType type)
      Create a minimal style to render features of type type.
      Parameters:
      type - the feature type
      Returns:
      a new Style instance
    • createSimpleStyle

      public static Style createSimpleStyle(FeatureType type, Color color)
      Create a minimal style to render features of type type
      Parameters:
      type - the feature type to create the style for
      color - single color to use for all components of the Style
      Returns:
      a new Style instance
      Throws:
      IOException - if the data store cannot be accessed
    • createPolygonStyle

      public static Style createPolygonStyle(Color outlineColor, Color fillColor, float opacity)
      Create a polygon style with the given colors and opacity.
      Parameters:
      outlineColor - color of polygon outlines
      fillColor - color for the fill
      opacity - proportional opacity (0 to 1)
      Returns:
      a new Style instance
    • createPolygonStyle

      public static Style createPolygonStyle(Color outlineColor, Color fillColor, float opacity, String labelField, Font labelFont)
      Create a polygon style with the given colors, opacity and optional labels.
      Parameters:
      outlineColor - color of polygon outlines
      fillColor - color for the fill
      opacity - proportional opacity (0 to 1)
      labelField - name of the feature field (attribute) to use for labelling; mauy be null for no labels
      labelFont - GeoTools Font object to use for labelling; if null and labelField is not null the default font will be used
      Returns:
      a new Style instance
    • createLineStyle

      public static Style createLineStyle(Color lineColor, float width)
      Create a line style with given color and line width
      Parameters:
      lineColor - color of lines
      width - width of lines
      Returns:
      a new Style instance
    • createLineStyle

      public static Style createLineStyle(Color lineColor, float width, String labelField, Font labelFont)
      Create a line style with given color, line width and optional labels
      Parameters:
      lineColor - color of lines
      width - width of lines
      labelField - name of the feature field (attribute) to use for labelling; mauy be null for no labels
      labelFont - GeoTools Font object to use for labelling; if null and labelField is not null the default font will be used
      Returns:
      a new Style instance
    • createPointStyle

      public static Style createPointStyle(String wellKnownName, Color lineColor, Color fillColor, float opacity, float size)
      Create a point style without labels
      Parameters:
      wellKnownName - one of: Circle, Square, Cross, X, Triangle or Star
      lineColor - color for the point symbol outline
      fillColor - color for the point symbol fill
      opacity - a value between 0 and 1 for the opacity of the fill
      size - size of the point symbol
      Returns:
      a new Style instance
    • createPointStyle

      public static Style createPointStyle(String wellKnownName, Color lineColor, Color fillColor, float opacity, float size, String labelField, Font labelFont)
      Create a point style, optionally with text labels
      Parameters:
      wellKnownName - one of: Circle, Square, Cross, X, Triangle or Star
      lineColor - color for the point symbol outline
      fillColor - color for the point symbol fill
      opacity - a value between 0 and 1 for the opacity of the fill
      size - size of the point symbol
      labelField - name of the feature field (attribute) to use for labelling; mauy be null for no labels
      labelFont - GeoTools Font object to use for labelling; if null and labelField is not null the default font will be used
      Returns:
      a new Style instance
    • wrapSymbolizers

      public static Style wrapSymbolizers(Symbolizer... symbolizers)
      Wrap one or more symbolizers into a Rule / FeatureTypeStyle / Style
      Parameters:
      symbolizers - one or more symbolizer objects
      Returns:
      a new Style instance or null if no symbolizers are provided