Class StylePreviewFactory


  • public class StylePreviewFactory
    extends Object
    Factory for creating style preview labels that are used in GUI elements to show how style agents will appear. Currently the the factory supports creation of two size: regular and small. Regular sized previews show how the styles will actually appear in the display with respect to size, while the small version is just a scaled down version that can easily fit in GUI elements like buttons or table cells.
    Author:
    Eric Tatara, Nick Collier
    • Field Detail

      • DEFAULT_POINT_ROTATION

        public static final double DEFAULT_POINT_ROTATION
        See Also:
        Constant Field Values
      • DEFAULT_POINT_FILL

        public static final Color DEFAULT_POINT_FILL
      • DEFAULT_POINT_OPACITY

        public static final double DEFAULT_POINT_OPACITY
        See Also:
        Constant Field Values
      • DEFAULT_POINT_STROKE_WIDTH

        public static final double DEFAULT_POINT_STROKE_WIDTH
        See Also:
        Constant Field Values
      • DEFAULT_POINT_STROKE_COLOR

        public static final Color DEFAULT_POINT_STROKE_COLOR
      • DEFAULT_POINT_STROKE_OPACITY

        public static final double DEFAULT_POINT_STROKE_OPACITY
        See Also:
        Constant Field Values
      • DEFAULT_LINE_STROKE_WIDTH

        public static final double DEFAULT_LINE_STROKE_WIDTH
        See Also:
        Constant Field Values
      • DEFAULT_LINE_STROKE_COLOR

        public static final Color DEFAULT_LINE_STROKE_COLOR
      • DEFAULT_LINE_STROKE_OPACITY

        public static final double DEFAULT_LINE_STROKE_OPACITY
        See Also:
        Constant Field Values
      • DEFAULT_POLY_FILL

        public static final Color DEFAULT_POLY_FILL
      • DEFAULT_POLY_STROKE_WIDTH

        public static final double DEFAULT_POLY_STROKE_WIDTH
        See Also:
        Constant Field Values
      • DEFAULT_POLY_STROKE_COLOR

        public static final Color DEFAULT_POLY_STROKE_COLOR
      • DEFAULT_POLY_STROKE_OPACITY

        public static final double DEFAULT_POLY_STROKE_OPACITY
        See Also:
        Constant Field Values
    • Constructor Detail

      • StylePreviewFactory

        public StylePreviewFactory()
    • Method Detail

      • createPreviewLabel

        public static PreviewLabel createPreviewLabel​(org.geotools.styling.Rule rule)
        Creates an instance of a PreviewLabel using the Rule properties.
        Parameters:
        rule - the Rule used to create the PreviewLabel
        Returns:
        the new PrviewLabel
      • createIcon

        public static Icon createIcon​(org.geotools.styling.Style style)
        Create an Icon instance from a Style. Useful for creating JLabel Icons for GUI components.
        Parameters:
        style - the Style used to create the Icon
        Returns:
        the Icon
      • createIcon

        public static Icon createIcon​(org.geotools.styling.Rule rule)
        Create an Icon instance from a Rule. Useful for creating JLabel Icons for GUI components.
        Parameters:
        rule - the Rule used to create the Icon
        Returns:
        the Icon
      • createSmallIcon

        public static Icon createSmallIcon​(org.geotools.styling.Rule rule)
        Create an small Icon instance from a Rule. Useful for creating JLabel Icons for GUI components that require small icons.
        Parameters:
        rule - the Rule used to create the Icon
        Returns:
        the Icon
      • getDefaultStyle

        public static org.geotools.styling.Style getDefaultStyle​(GeometryUtil.GeometryType geomType)
        Provide a default style for the style editors.
        Parameters:
        geomType - the geometry type for the selected agent class.
        Returns:
        the default style for the geometry type.
      • evaluateExpression

        public static <T> T evaluateExpression​(org.opengis.filter.expression.Expression expr,
                                               T defaultValue,
                                               Class<T> type)
        Returns either the evaluated expression if the expression is a Literal, or the default value for other types of expression, such as property expressions (which are the property name to be evaluated at run time).
        Parameters:
        expr - the Expression to evaluate
        defaultValue - the default value to use when the expression is not a Literal
        type - the class of the Expression literal
        Returns:
        the evaluated expression