Class RescaleStyleVisitor
- Object
-
- DuplicatingStyleVisitor
-
- 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 Summary
Fields Modifier and Type Field Description protected Unit<Length>
defaultUnit
protected Expression
scale
This is the scale used as a multiplication factory for everything that has a size.-
Fields inherited from class DuplicatingStyleVisitor
copyFilter, ff, pages, sf, STRICT
-
-
Constructor Summary
Constructors Constructor Description RescaleStyleVisitor(double scale)
RescaleStyleVisitor(Expression scale)
RescaleStyleVisitor(FilterFactory filterFactory, double scale)
RescaleStyleVisitor(FilterFactory filterFactory, Expression scale)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected List<Expression>
rescale(List<Expression> expressions)
Rescale a list of expressions, can handle null.protected Expression
rescale(Expression expr)
Used to rescale the provided expr.protected void
rescaleArrayOption(Map<String,String> options, String key, int defaultValue)
Rescales the specified vendor optionprotected List<Expression>
rescaleDashArray(List<Expression> expressions)
Rescale using listMultiply, if there is only one entry.protected Expression
rescaleGraphicSize(Graphic gr)
protected void
rescaleOption(Map<String,String> options, String key, double defaultValue)
Rescales the specified vendor optionprotected void
rescaleOption(Map<String,String> options, String key, int defaultValue)
Rescales the specified vendor optionvoid
visit(Graphic gr)
Make graphics (such as used with PointSymbolizer) biggervoid
visit(LineSymbolizer sym)
Called when accept is called on a linesymbolizervoid
visit(PointSymbolizer sym)
Called when accept is called on a pointsymbolizervoid
visit(PolygonSymbolizer sym)
Called when accept is called on a polygon symbolizervoid
visit(RasterSymbolizer sym)
Called when accept is called on a rastersymbolizervoid
visit(Stroke stroke)
Increase stroke width.void
visit(Symbolizer sym)
since it is impossible to create a Symbolizer this method should generate an exception or warning.void
visit(TextSymbolizer text)
Called when accept is called on a textsymbolizer-
Methods inherited from class DuplicatingStyleVisitor
copy, copy, copy, copy, copy, copy, copy, copy, copy, copy, copy, copy, copy, copy, copy, copy, copy, copy, copy, copy, copy, copy, copy, copy, copy, copy, copy, copyExpressions, copyFonts, getCopy, setStrict, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit
-
-
-
-
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)
-
RescaleStyleVisitor
public RescaleStyleVisitor(FilterFactory filterFactory, Expression 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 interfaceStyleVisitor
- Overrides:
visit
in classDuplicatingStyleVisitor
- Parameters:
stroke
- the stroke to visit
-
visit
public void visit(Graphic gr)
Make graphics (such as used with PointSymbolizer) bigger- Specified by:
visit
in interfaceStyleVisitor
- Overrides:
visit
in classDuplicatingStyleVisitor
- Parameters:
gr
- the graphic to visit
-
rescaleGraphicSize
protected Expression rescaleGraphicSize(Graphic gr)
-
visit
public void visit(TextSymbolizer text)
Description copied from interface:StyleVisitor
Called when accept is called on a textsymbolizer- Specified by:
visit
in interfaceStyleVisitor
- Overrides:
visit
in classDuplicatingStyleVisitor
- Parameters:
text
- the text symbolizer 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 interfaceStyleVisitor
- Overrides:
visit
in classDuplicatingStyleVisitor
- Parameters:
sym
- the symbolizer to visit
-
visit
public void visit(PointSymbolizer sym)
Description copied from interface:StyleVisitor
Called when accept is called on a pointsymbolizer- Specified by:
visit
in interfaceStyleVisitor
- Overrides:
visit
in classDuplicatingStyleVisitor
- Parameters:
sym
- the point symbolizer to visit
-
visit
public void visit(LineSymbolizer sym)
Description copied from interface:StyleVisitor
Called when accept is called on a linesymbolizer- Specified by:
visit
in interfaceStyleVisitor
- Overrides:
visit
in classDuplicatingStyleVisitor
- Parameters:
sym
- the line symbolizer to visit
-
visit
public void visit(PolygonSymbolizer sym)
Description copied from interface:StyleVisitor
Called when accept is called on a polygon symbolizer- Specified by:
visit
in interfaceStyleVisitor
- Overrides:
visit
in classDuplicatingStyleVisitor
- Parameters:
sym
- the polygon symbolizer to visit
-
visit
public void visit(RasterSymbolizer sym)
Description copied from interface:StyleVisitor
Called when accept is called on a rastersymbolizer- Specified by:
visit
in interfaceStyleVisitor
- Overrides:
visit
in classDuplicatingStyleVisitor
- Parameters:
sym
- the raster 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
-
-