Author: erans Date: Fri Oct 1 12:56:07 2010 New Revision: 1003521 URL: http://svn.apache.org/viewvc?rev=1003521&view=rev Log: MATH-422 Made "MicrosphereInterpolator" immutable.
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/MicrosphereInterpolatingFunction.java commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/MicrosphereInterpolator.java Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/MicrosphereInterpolatingFunction.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/MicrosphereInterpolatingFunction.java?rev=1003521&r1=1003520&r2=1003521&view=diff ============================================================================== --- commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/MicrosphereInterpolatingFunction.java (original) +++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/MicrosphereInterpolatingFunction.java Fri Oct 1 12:56:07 2010 @@ -240,5 +240,4 @@ public class MicrosphereInterpolatingFun private double cosAngle(final RealVector v, final RealVector w) { return v.dotProduct(w) / (v.getNorm() * w.getNorm()); } - } Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/MicrosphereInterpolator.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/MicrosphereInterpolator.java?rev=1003521&r1=1003520&r2=1003521&view=diff ============================================================================== --- commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/MicrosphereInterpolator.java (original) +++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/MicrosphereInterpolator.java Fri Oct 1 12:56:07 2010 @@ -32,49 +32,53 @@ import org.apache.commons.math.random.Un */ public class MicrosphereInterpolator implements MultivariateRealInterpolator { - /** * Default number of surface elements that composes the microsphere. */ public static final int DEFAULT_MICROSPHERE_ELEMENTS = 2000; - /** * Default exponent used the weights calculation. */ public static final int DEFAULT_BRIGHTNESS_EXPONENT = 2; - /** * Number of surface elements of the microsphere. */ - private int microsphereElements; - + private final int microsphereElements; /** * Exponent used in the power law that computes the weights of the * sample data. */ - private int brightnessExponent; + private final int brightnessExponent; - /** Create a microsphere interpolator with default settings. - * <p>Calling this constructor is equivalent to call {...@link + /** + * Create a microsphere interpolator with default settings. + * Calling this constructor is equivalent to call {...@link * #MicrosphereInterpolator(int, int) * MicrosphereInterpolator(MicrosphereInterpolator.DEFAULT_MICROSPHERE_ELEMENTS, - * MicrosphereInterpolator.DEFAULT_BRIGHTNESS_EXPONENT)}.</p> + * MicrosphereInterpolator.DEFAULT_BRIGHTNESS_EXPONENT)}. */ public MicrosphereInterpolator() { this(DEFAULT_MICROSPHERE_ELEMENTS, DEFAULT_BRIGHTNESS_EXPONENT); } /** Create a microsphere interpolator. - * @param microsphereElements number of surface elements of the microsphere. - * @param brightnessExponent exponent used in the power law that computes the - * weights of the sample data. - * @throws NotPositiveException if {...@code microsphereElements <= 0} - * or {...@code brightnessExponent < 0}. - */ - public MicrosphereInterpolator(final int microsphereElements, - final int brightnessExponent) { - setMicropshereElements(microsphereElements); - setBrightnessExponent(brightnessExponent); + * @param elements Number of surface elements of the microsphere. + * @param exponent Exponent used in the power law that computes the + * weights (distance dimming factor) of the sample data. + * @throws NotPositiveException if {...@code exponent < 0}. + * @throws NotStrictlyPositiveException if {...@code elements <= 0}. + */ + public MicrosphereInterpolator(final int elements, + final int exponent) { + if (exponent < 0) { + throw new NotPositiveException(exponent); + } + if (elements <= 0) { + throw new NotStrictlyPositiveException(elements); + } + + microsphereElements = elements; + brightnessExponent = exponent; } /** @@ -90,29 +94,4 @@ public class MicrosphereInterpolator microsphereElements, rand); } - - /** - * Set the brightness exponent. - * @param exponent Exponent for computing the distance dimming - * factor. - * @throws NotPositiveException if {...@code exponent < 0}. - */ - public void setBrightnessExponent(final int exponent) { - if (exponent < 0) { - throw new NotPositiveException(exponent); - } - brightnessExponent = exponent; - } - - /** - * Set the number of microsphere elements. - * @param elements Number of surface elements of the microsphere. - * @throws NotStrictlyPositiveException if {...@code elements <= 0}. - */ - public void setMicropshereElements(final int elements) { - if (elements <= 0) { - throw new NotStrictlyPositiveException(elements); - } - microsphereElements = elements; - } }