Package org.hortonmachine.gears.utils
Class SldUtilities
- java.lang.Object
-
- org.hortonmachine.gears.utils.SldUtilities
-
public class SldUtilities extends Object
Utilities to handle style.- Since:
- 0.7.0
- Author:
- Andrea Antonello (www.hydrologis.com)
-
-
Field Summary
Fields Modifier and Type Field Description static org.opengis.filter.FilterFactoryffThe defaultFilterFactoryto use.static StringGENERIC_FEATURE_TYPENAMEThe type name that can be used in an SLD in the featuretypestyle that matches all feature types.static org.geotools.styling.StyleBuildersbThe defaultStyleBuilderto use.static org.geotools.styling.StyleFactorysfThe defaultStyleFactoryto use.static StringSLD_EXTENSION
-
Constructor Summary
Constructors Constructor Description SldUtilities()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ColorcolorWithAlpha(Color color, int alpha)Creates a color with the given alpha.static ColorcolorWithoutAlpha(Color color)REmoves the alpha channel from a color.static org.geotools.styling.StylegetDefaultStyle(org.geotools.styling.StyledLayerDescriptor sld)static org.geotools.styling.StylegetGrassStyle(String path)static FilegetStyleFile(File dataFile)Get the style file related to a given datafile.static org.geotools.styling.StylegetStyleFromFile(File file)Get the style from an sld file.static org.geotools.styling.StylegetStyleFromRasterFile(File file)static org.geotools.styling.StylegetStyleFromSldString(String sldString)static StringstyleToString(org.geotools.styling.Style style)Converts a style to its string representation to be written to file.
-
-
-
Field Detail
-
SLD_EXTENSION
public static final String SLD_EXTENSION
- See Also:
- Constant Field Values
-
sf
public static org.geotools.styling.StyleFactory sf
The defaultStyleFactoryto use.
-
ff
public static org.opengis.filter.FilterFactory ff
The defaultFilterFactoryto use.
-
sb
public static org.geotools.styling.StyleBuilder sb
The defaultStyleBuilderto 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
-
-
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
Styleobject. - 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.
-
-