Class StyleGenerator


  • public class StyleGenerator
    extends Object
    Generates a style/featureTypeStyle using ColorBrewer.
    WARNING: this is unstable and subject to radical change.
    Author:
    Cory Horner, Refractions Research Inc.
    • Constructor Detail

      • StyleGenerator

        protected StyleGenerator()
    • Method Detail

      • createFeatureTypeStyle

        public static FeatureTypeStyle createFeatureTypeStyle​(Classifier classifier,
                                                              Expression expression,
                                                              Color[] colors,
                                                              String typeId,
                                                              GeometryDescriptor geometryAttrType,
                                                              int elseMode,
                                                              double opacity,
                                                              Stroke defaultStroke)
                                                       throws IllegalFilterException
        Merges a classifier, array of colors and other data into a FeatureTypeStyle object. Yes, this constructor is insane and likely to change very soon.
        Parameters:
        typeId - semantic type identifier, which will be prefixed with "colorbrewer:"
        Throws:
        IllegalFilterException
      • toStyleExpression

        public static String toStyleExpression​(Filter filter)
      • toStyleExpression

        public static String[] toStyleExpression​(Filter[] filter)
      • toFilter

        public static Filter[] toFilter​(String[] styleExpression,
                                        SimpleFeatureType[] featureType,
                                        String[] attributeTypeName)
                                 throws IllegalFilterException
        Converts an array of styleExpressions and attributes into Filters

        styleExpression[0] = "1..5";
        styleExpression[1] = "5..10";
        styleExpression[2] = "11, -13";
        --->
        filter[0] = [[1 <= attr] AND [attr < 5]]
        filter[1] = [[6 <= attr] AND [attr <= 10]]
        filter[2] = [[attr = 11] OR [attr = -13]]

        Parameters:
        styleExpression - strings of ranged expressions "lowValue..highValue" or explicit values "value1, value2"
        Returns:
        an array with all the filters
        Throws:
        IllegalFilterException
      • toRangedFilter

        public static Filter toRangedFilter​(String styleExpression,
                                            SimpleFeatureType featureType,
                                            String attributeTypeName,
                                            boolean upperBoundClosed)
                                     throws IllegalFilterException
        Creates a filter for a range of values.

        Examples:
        "1..5", closed=true --> [[1 <= attr] AND [attr <= 5]]
        "1..10", closed=false --> [[1 <= attr] AND [attr < 10]] "..10, closed=true --> [attr <= 10]

        Parameters:
        styleExpression - the ranged style expression (minValue..maxValue)
        featureType - the featureType
        attributeTypeName - the attributeTypeName whose values correspond to
        upperBoundClosed - does the upper bound include the max value? (true: <=, false: <)
        Returns:
        a filter
        Throws:
        IllegalFilterException
      • isRanged

        public static boolean isRanged​(String styleExpression)
        Determines if a string is an instance of a ranged expression or unique values.
      • toExplicitFilter

        public static Filter toExplicitFilter​(String styleExpression,
                                              SimpleFeatureType featureType,
                                              String attributeTypeName)
                                       throws IllegalFilterException
        Creates a filter with each value explicitly defined.

        Examples:
        "LIB" --> [PARTY = LIB]
        "LIB, NDP" --> [[PARTY = LIB] OR [PARTY = NDP]]

        Parameters:
        styleExpression - the list of attribute values, separated by commas (and optional spaces)
        attributeTypeName - A Sting with the attributeTypeName whose values correspond to
        Returns:
        a filter
        Throws:
        IllegalFilterException
      • toExplicitFilter

        public static Filter toExplicitFilter​(String styleExpression,
                                              Expression attribExpr)
                                       throws IllegalFilterException
        Creates a filter with each value explicitly defined.

        Examples:
        "LIB" --> [PARTY = LIB]
        "LIB, NDP" --> [[PARTY = LIB] OR [PARTY = NDP]]

        Parameters:
        styleExpression - the list of attribute values, separated by commas (and optional spaces)
        attribExpr - an Expression to compare each value with (simple case = attributeExpression)
        Returns:
        a filter
        Throws:
        IllegalFilterException