Class RescaleStyleVisitor

  • All Implemented Interfaces:
    StyleVisitor
    Direct Known Subclasses:
    DpiRescaleStyleVisitor

    public class RescaleStyleVisitor
    extends DuplicatingStyleVisitor
    This is a style visitor that will produce a copy of the provided style rescaled by a provided factor.

    The provided scale will be use to modify all line widths, font sizes and so forth. We may need to go the extra distance and play with the min/max scale on rules, and if there is any DPI specific madness going on we are going to cry.

    According to the specification we are supposed to use environmental variables to make our styles render in a resolution independent manner. The current GeoTools environment variable visitor only does processing for mapscale but does not have a dpi substitution. On the plus side this visitor accepts a general Expression and you are free to use an environmental variable expression in order to make sure a normal base style is tweaked in all the right spots.

    Author:
    Jody Garnett (Refractions Research)
    • Field Detail

      • scale

        protected Expression scale
        This is the scale used as a multiplication factory for everything that has a size.
      • defaultUnit

        protected Unit<Length> defaultUnit
    • Constructor Detail

      • RescaleStyleVisitor

        public RescaleStyleVisitor​(double scale)
      • RescaleStyleVisitor

        public RescaleStyleVisitor​(Expression scale)
      • RescaleStyleVisitor

        public RescaleStyleVisitor​(FilterFactory filterFactory,
                                   double scale)
    • Method Detail

      • rescale

        protected Expression rescale​(Expression expr)
        Used to rescale the provided expr.

        We do optimize the case where the provided expression is a literal; no sense doing a calculation each time if we don't have to.

        Returns:
        expr multiplied by the provided scale
      • rescale

        protected List<Expression> rescale​(List<Expression> expressions)
        Rescale a list of expressions, can handle null.
      • rescaleDashArray

        protected List<Expression> rescaleDashArray​(List<Expression> expressions)
        Rescale using listMultiply, if there is only one entry.
      • visit

        public void visit​(Stroke stroke)
        Increase stroke width.

        Based on feedback we may need to change the dash array as well.

        Specified by:
        visit in interface StyleVisitor
        Overrides:
        visit in class DuplicatingStyleVisitor
        Parameters:
        stroke - the stroke to visit
      • visit

        public void visit​(Symbolizer sym)
        Description copied from interface: StyleVisitor
        since it is impossible to create a Symbolizer this method should generate an exception or warning.
        Specified by:
        visit in interface StyleVisitor
        Overrides:
        visit in class DuplicatingStyleVisitor
        Parameters:
        sym - the symbolizer to visit
      • rescaleOption

        protected void rescaleOption​(Map<String,​String> options,
                                     String key,
                                     double defaultValue)
        Rescales the specified vendor option
      • rescaleOption

        protected void rescaleOption​(Map<String,​String> options,
                                     String key,
                                     int defaultValue)
        Rescales the specified vendor option
      • rescaleArrayOption

        protected void rescaleArrayOption​(Map<String,​String> options,
                                          String key,
                                          int defaultValue)
        Rescales the specified vendor option