org.geotools.styling.visitor
Class UomRescaleStyleVisitor

java.lang.Object
  extended by org.geotools.styling.visitor.DuplicatingStyleVisitor
      extended by org.geotools.styling.visitor.UomRescaleStyleVisitor
All Implemented Interfaces:
StyleVisitor

public class UomRescaleStyleVisitor
extends DuplicatingStyleVisitor

Visitor used for rescaling a Style given a map scale (e.g., meters per pixel) and taking into consideration the Unit of Measure (UOM, e.g., SI.METER, NonSI.FOOT) of each symbolizer. The resulting Style's Symbolizer sizes will all be given in PIXELS, so that they can be directly used by a renderer that is unaware of units of measure or the current map scale. For example, points with size == 100 meters could be rescaled to 10 pixels for higher levels of zoom and 2 pixels for a lower level of zoom.

This visitor extends DuplicatingStyleVisitor and as such yields a copy of the original Style. Usage is simply to call the desired visit() method and then call getCopy() to retrieve the result.

Author:
milton

Field Summary
 
Fields inherited from class org.geotools.styling.visitor.DuplicatingStyleVisitor
copyFilter, ff, pages, sf, STRICT
 
Constructor Summary
UomRescaleStyleVisitor(double mapScale)
          Constructor: requires the current mapScale to inform the window to viewport (world to screen) relation in order to correctly rescale sizes according to units of measure given in world units (e.g., SI.METER, NonSI.FOOT, etc).
 
Method Summary
protected  double computeRescaleMultiplier(double mapScale, javax.measure.unit.Unit<javax.measure.quantity.Length> uom)
          Computes a rescaling multiplier to be applied to an unscaled value.
protected  double rescale(double unscaled, double mapScale, javax.measure.unit.Unit<javax.measure.quantity.Length> uom)
          Used to rescale the provided unscaled value.
protected  org.opengis.filter.expression.Expression rescale(org.opengis.filter.expression.Expression unscaled, double mapScale, javax.measure.unit.Unit<javax.measure.quantity.Length> uom)
          Used to rescale the provided unscaled value.
protected  float[] rescale(float[] dashArray, double mapScale, javax.measure.unit.Unit<javax.measure.quantity.Length> unitOfMeasure)
          Used to rescale the provided dash array.
protected  void rescaleStroke(Stroke stroke, double mapScale, javax.measure.unit.Unit<javax.measure.quantity.Length> uom)
          Used to rescale the provided stroke.
 void visit(LineSymbolizer line)
          Called when accept is called on a linesymbolizer
 void visit(PointSymbolizer ps)
          Called when accept is called on a pointsymbolizer
 void visit(PolygonSymbolizer poly)
          Called when accept is called on a polygon symbolizer
 void visit(TextSymbolizer text)
          Called when accept is called on a textsymbolizer
 
Methods inherited from class org.geotools.styling.visitor.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, copy, 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, visit, visit, visit, visit
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UomRescaleStyleVisitor

public UomRescaleStyleVisitor(double mapScale)
Constructor: requires the current mapScale to inform the window to viewport (world to screen) relation in order to correctly rescale sizes according to units of measure given in world units (e.g., SI.METER, NonSI.FOOT, etc).

Parameters:
mapScale - The specified map scale, given in pixels per meter.
Method Detail

computeRescaleMultiplier

protected double computeRescaleMultiplier(double mapScale,
                                          javax.measure.unit.Unit<javax.measure.quantity.Length> uom)
Computes a rescaling multiplier to be applied to an unscaled value.

Parameters:
mapScale - the mapScale in pixels per meter.
uom - the unit of measure that will be used to scale.
Returns:
the rescaling multiplier for the provided parameters.

rescale

protected org.opengis.filter.expression.Expression rescale(org.opengis.filter.expression.Expression unscaled,
                                                           double mapScale,
                                                           javax.measure.unit.Unit<javax.measure.quantity.Length> uom)
Used to rescale the provided unscaled value.

Parameters:
unscaled - the unscaled value.
mapScale - the mapScale in pixels per meter.
uom - the unit of measure that will be used to scale.
Returns:
the expression multiplied by the provided scale.

rescale

protected double rescale(double unscaled,
                         double mapScale,
                         javax.measure.unit.Unit<javax.measure.quantity.Length> uom)
Used to rescale the provided unscaled value.

Parameters:
unscaled - the unscaled value.
mapScale - the mapScale in pixels per meter.
uom - the unit of measure that will be used to scale.
Returns:
a scaled value.

rescale

protected float[] rescale(float[] dashArray,
                          double mapScale,
                          javax.measure.unit.Unit<javax.measure.quantity.Length> unitOfMeasure)
Used to rescale the provided dash array.

Parameters:
dashArray - the unscaled dash array. If null, the method returns null.
mapScale - the mapScale in pixels per meter.
uom - the unit of measure that will be used to scale.
Returns:
the rescaled dash array

rescaleStroke

protected void rescaleStroke(Stroke stroke,
                             double mapScale,
                             javax.measure.unit.Unit<javax.measure.quantity.Length> uom)
Used to rescale the provided stroke.

Parameters:
stroke - the unscaled stroke, which will be modified in-place.
mapScale - the mapScale in pixels per meter.
uom - the unit of measure that will be used to scale.

visit

public void visit(PointSymbolizer ps)
Description copied from interface: StyleVisitor
Called when accept is called on a pointsymbolizer

Specified by:
visit in interface StyleVisitor
Overrides:
visit in class DuplicatingStyleVisitor
Parameters:
ps - the point symbolizer to visit

visit

public void visit(LineSymbolizer line)
Description copied from interface: StyleVisitor
Called when accept is called on a linesymbolizer

Specified by:
visit in interface StyleVisitor
Overrides:
visit in class DuplicatingStyleVisitor
Parameters:
line - the line symbolizer to visit

visit

public void visit(PolygonSymbolizer poly)
Description copied from interface: StyleVisitor
Called when accept is called on a polygon symbolizer

Specified by:
visit in interface StyleVisitor
Overrides:
visit in class DuplicatingStyleVisitor
Parameters:
poly - the polygon symbolizer to visit

visit

public void visit(TextSymbolizer text)
Description copied from interface: StyleVisitor
Called when accept is called on a textsymbolizer

Specified by:
visit in interface StyleVisitor
Overrides:
visit in class DuplicatingStyleVisitor
Parameters:
text - the text symbolizer to visit


Copyright © 1996-2010 Geotools. All Rights Reserved.