com.vividsolutions.jump.geom.precision
Class NumberPrecisionReducer

java.lang.Object
  extended by com.vividsolutions.jump.geom.precision.NumberPrecisionReducer

public class NumberPrecisionReducer
extends java.lang.Object

Reduces the precision of a number by rounding it off after scaling by a given scale factor.


Constructor Summary
NumberPrecisionReducer()
           
NumberPrecisionReducer(double scaleFactor)
          A negative value for scaleFactor indicates that the precision reduction will eliminate significant digits to the left of the decimal point.
 
Method Summary
 double reducePrecision(double d)
           
static double scaleFactorForDecimalPlaces(int decimalPlaces)
          Computes the scale factor for a given number of decimal places.
 void setScaleFactor(double scaleFactor)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NumberPrecisionReducer

public NumberPrecisionReducer()

NumberPrecisionReducer

public NumberPrecisionReducer(double scaleFactor)
A negative value for scaleFactor indicates that the precision reduction will eliminate significant digits to the left of the decimal point. (I.e. the scale factor will be divided rather than multiplied). A zero value for scaleFactor will result in no precision reduction being performed. A scale factor is normally an integer value.

Parameters:
scaleFactor -
Method Detail

scaleFactorForDecimalPlaces

public static double scaleFactorForDecimalPlaces(int decimalPlaces)
Computes the scale factor for a given number of decimal places. A negative value for decimalPlaces indicates the scale factor should be divided rather than multiplied. The negative sign is carried through to the computed scale factor.

Parameters:
decimalPlaces -
Returns:

setScaleFactor

public void setScaleFactor(double scaleFactor)

reducePrecision

public double reducePrecision(double d)