Class SldUtilities


  • public class SldUtilities
    extends Object
    Utilities to handle style.
    Since:
    0.7.0
    Author:
    Andrea Antonello (www.hydrologis.com)
    • Field Detail

      • sf

        public static org.geotools.styling.StyleFactory sf
        The default StyleFactory to use.
      • ff

        public static org.opengis.filter.FilterFactory ff
        The default FilterFactory to use.
      • sb

        public static org.geotools.styling.StyleBuilder sb
        The default StyleBuilder to use.
      • GENERIC_FEATURE_TYPENAME

        public static final String GENERIC_FEATURE_TYPENAME
        The type name that can be used in an SLD in the featuretypestyle that matches all feature types.
        See Also:
        Constant Field Values
    • Constructor Detail

      • SldUtilities

        public SldUtilities()
    • Method Detail

      • getStyleFromFile

        public static org.geotools.styling.Style getStyleFromFile​(File file)
        Get the style from an sld file.
        Parameters:
        file - the SLD file or a companion file.
        Returns:
        the Style object.
        Throws:
        IOException
      • getStyleFile

        public static File getStyleFile​(File dataFile)
        Get the style file related to a given datafile.
        Parameters:
        dataFile - the file that should have the style file as sidecar file.
        Returns:
        the style file, if available.
      • getStyleFromSldString

        public static org.geotools.styling.Style getStyleFromSldString​(String sldString)
                                                                throws IOException
        Throws:
        IOException
      • getStyleFromRasterFile

        public static org.geotools.styling.Style getStyleFromRasterFile​(File file)
                                                                 throws Exception
        Throws:
        Exception
      • getGrassStyle

        public static org.geotools.styling.Style getGrassStyle​(String path)
                                                        throws Exception
        Throws:
        Exception
      • styleToString

        public static String styleToString​(org.geotools.styling.Style style)
                                    throws Exception
        Converts a style to its string representation to be written to file.
        Parameters:
        style - the style to convert.
        Returns:
        the style string.
        Throws:
        Exception
      • getDefaultStyle

        public static org.geotools.styling.Style getDefaultStyle​(org.geotools.styling.StyledLayerDescriptor sld)
      • colorWithoutAlpha

        public static Color colorWithoutAlpha​(Color color)
        REmoves the alpha channel from a color.
        Parameters:
        color - the color.
        Returns:
        the color without alpha.
      • colorWithAlpha

        public static Color colorWithAlpha​(Color color,
                                           int alpha)
        Creates a color with the given alpha.
        Parameters:
        color - the color to use.
        alpha - an alpha value between 0 and 255.
        Returns:
        the color with alpha.