changeset 805:bb7afd783321

Removed trailing whitespace. Added more javadoc. gnv-artifacts/trunk@887 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Thu, 08 Apr 2010 11:31:44 +0000
parents 9058c08eac3a
children 2cea76f1112e
files gnv-artifacts/ChangeLog gnv-artifacts/src/main/java/de/intevation/gnv/math/ConstantXYDepth.java gnv-artifacts/src/main/java/de/intevation/gnv/math/Interpolator.java gnv-artifacts/src/main/java/de/intevation/gnv/math/L1Comparator.java gnv-artifacts/src/main/java/de/intevation/gnv/math/LinearFunction.java gnv-artifacts/src/main/java/de/intevation/gnv/math/LinearMetrics.java gnv-artifacts/src/main/java/de/intevation/gnv/math/LinearToMap.java gnv-artifacts/src/main/java/de/intevation/gnv/math/Metrics.java gnv-artifacts/src/main/java/de/intevation/gnv/math/QueriedXYDepth.java gnv-artifacts/src/main/java/de/intevation/gnv/state/profile/horizontalcrosssection/HorizontalCrossSectionMeshOutputState.java gnv-artifacts/src/main/java/de/intevation/gnv/state/timeseries/TimeSeriesOutputState.java
diffstat 11 files changed, 236 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/gnv-artifacts/ChangeLog	Thu Apr 08 10:10:04 2010 +0000
+++ b/gnv-artifacts/ChangeLog	Thu Apr 08 11:31:44 2010 +0000
@@ -1,3 +1,19 @@
+2010-04-08	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
+
+	* src/main/java/de/intevation/gnv/state/profile/horizontalcrosssection/HorizontalCrossSectionMeshOutputState.java,
+	  src/main/java/de/intevation/gnv/state/timeseries/TimeSeriesOutputState.java:
+	  Removed trailing whitespace.
+
+	* src/main/java/de/intevation/gnv/math/ConstantXYDepth.java,
+	  src/main/java/de/intevation/gnv/math/LinearMetrics.java,
+	  src/main/java/de/intevation/gnv/math/QueriedXYDepth.java,
+	  src/main/java/de/intevation/gnv/math/L1Comparator.java,
+	  src/main/java/de/intevation/gnv/math/Metrics.java,
+	  src/main/java/de/intevation/gnv/math/LinearToMap.java,
+	  src/main/java/de/intevation/gnv/math/LinearFunction.java,
+	  src/main/java/de/intevation/gnv/math/Interpolator.java:
+	  Added more javadoc.
+
 2010-04-08  Ingo Weinzierl <ingo.weinzierl@intevation.de>
 
 	* src/main/java/de/intevation/gnv/state/profile/horizontalcrosssection/HorizontalCrossSectionMeshOutputState.java,
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/math/ConstantXYDepth.java	Thu Apr 08 10:10:04 2010 +0000
+++ b/gnv-artifacts/src/main/java/de/intevation/gnv/math/ConstantXYDepth.java	Thu Apr 08 11:31:44 2010 +0000
@@ -3,16 +3,28 @@
 import com.vividsolutions.jts.geom.Coordinate;
 
 /**
+ * Instances of the implementation return a constant value.
+ *
  * @author <a href="mailto:sascha.teichmann@intevation.de">Sascha L. Teichmann</a>
  */
 public class ConstantXYDepth
 implements   XYDepth
 {
+    /**
+     * The constant depth.
+     */
     protected double depth;
 
+    /**
+     * Default constructor. The constant depth = 0.
+     */
     public ConstantXYDepth() {
     }
 
+    /**
+     * Construtor to create a ConstantXYDepth with a given depth.
+     * @param depth The constant depth.
+     */
     public ConstantXYDepth(double depth) {
         this.depth = depth;
     }
@@ -21,4 +33,4 @@
         return depth;
     }
 }
-// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
\ No newline at end of file
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/math/Interpolator.java	Thu Apr 08 10:10:04 2010 +0000
+++ b/gnv-artifacts/src/main/java/de/intevation/gnv/math/Interpolator.java	Thu Apr 08 11:31:44 2010 +0000
@@ -3,10 +3,19 @@
 import com.vividsolutions.jts.geom.Coordinate;
 
 /**
+ * Implementations of this interface interpolate coordinates
+ * a line at a given point determined by a factor t (0 &lt;= t &lt;= 1).<br>
+ * If t = 0 the start point of the line is used.<br>
+ * If t = 1 the start point of the line is used.
  * @author <a href="mailto:sascha.teichmann@intevation.de">Sascha L. Teichmann</a>
  */
 public interface Interpolator
 {
+    /**
+     * Interpolates a point along a line with a given factor between 0 and 1.
+     * @param t The factor.
+     * @param v The result of the interpolation is stored in this coordinate.
+     */
     void interpolate(double t, Coordinate v);
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/math/L1Comparator.java	Thu Apr 08 10:10:04 2010 +0000
+++ b/gnv-artifacts/src/main/java/de/intevation/gnv/math/L1Comparator.java	Thu Apr 08 11:31:44 2010 +0000
@@ -5,6 +5,11 @@
 import java.util.Comparator;
 
 /**
+ * Compares two coordinates a and b by their L1(Matnhattan) distance
+ * relative to a reference point r.
+ * da = L1(a, r)<br>
+ * db = L1(b, r)<br>
+ * -1 if da &lt; db, +1 if da &gt; db, 0 else.
  * @author <a href="mailto:sascha.teichmann@intevation.de">Sascha L. Teichmann</a>
  */
 public  class L1Comparator
@@ -12,17 +17,35 @@
 {
     private Coordinate ref;
 
+    /**
+     * Default constructor.
+     */
     public L1Comparator() {
     }
 
+    /**
+     * Constructor to create a L1Comparator with a given reference point.
+     * @param ref The reference point.
+     */
     public L1Comparator(Coordinate ref) {
         this.ref = ref;
     }
 
+    /**
+     * Explicitly sets the reference point.
+     * @param ref The reference point.
+     */
     public void setReference(Coordinate ref) {
         this.ref = ref;
     }
 
+    /**
+     * Compares to coordinate by their L1 distance to the reference point.
+     * @param a The first coordinate.
+     * @param b The second coordinate.
+     * @return -1 if L1(a, ref) &lt; L1(b, ref),
+     * +1 if L1(a, ref) &gt; L1(b, ref), 0 else.
+     */
     public int compare(Object a, Object b) {
         Coordinate pa = (Coordinate)a;
         Coordinate pb = (Coordinate)b;
@@ -33,9 +56,15 @@
         return 0;
     }
 
+    /**
+     * Computes the L1 distance between two points a and b:<br>
+     * L1(a, b) = abs(a.x - b.x) + abs(a.y - b.y)
+     * @param a The first point.
+     * @param b The second point.
+     * @return The L1 distance.
+     */
     public static double L1(Coordinate a, Coordinate b) {
         return Math.abs(a.x - b.x) + Math.abs(a.y - b.y);
     }
-
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/math/LinearFunction.java	Thu Apr 08 10:10:04 2010 +0000
+++ b/gnv-artifacts/src/main/java/de/intevation/gnv/math/LinearFunction.java	Thu Apr 08 11:31:44 2010 +0000
@@ -7,22 +7,49 @@
 import org.apache.commons.math.optimization.fitting.ParametricRealFunction;
 
 /**
+ * Models a linear function to be usable in the fitting frame of
+ * the Apache Commons Mathematics Library.
+ *
  *  @author <a href="mailto:sascha.teichmann@intevation.de">Sascha L. Teichmann</a>
  */
 public class LinearFunction
 implements   ParametricRealFunction
 {
+    /**
+     * Instance to prevent needless creations of instances.
+     */
     public static final LinearFunction INSTANCE = new LinearFunction();
 
+    /**
+     * Specialized class to be useful in function evaluating
+     * in the Apache Commons Mathematics Library.
+     */
     public static class Univariate
     implements          UnivariateRealFunction
     {
+        /**
+         * The linear scaling factor.
+         */
         protected double m;
+        /**
+         * The linear offset.
+         */
         protected double b;
 
+        /**
+         * Default constructor.
+         */
         public Univariate() {
         }
 
+        /**
+         * Constructor to create a Univariate with the linear parameters
+         * of the line between (x1, y1) and (x2, y2).
+         * @param x1 The x coordinate of the first point.
+         * @param y1 The y coordinate of the first point.
+         * @param x2 The x coordinate of the second point.
+         * @param y2 The y coordinate of the second point.
+         */
         public Univariate(double x1, double y1, double x2, double y2) {
             if (y1 == y2) {
                 m = 0d;
@@ -39,6 +66,9 @@
         }
     } // class Univariate
 
+    /**
+     * Default constructor.
+     */
     public LinearFunction() {
     }
 
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/math/LinearMetrics.java	Thu Apr 08 10:10:04 2010 +0000
+++ b/gnv-artifacts/src/main/java/de/intevation/gnv/math/LinearMetrics.java	Thu Apr 08 11:31:44 2010 +0000
@@ -3,14 +3,22 @@
 import com.vividsolutions.jts.geom.Coordinate;
 
 /**
+ * Implements {@link de.intevation.gnv.math.Metrics}
+ * for linear interpolations and distance measurements.
  * @author <a href="mailto:sascha.teichmann@intevation.de">Sascha L. Teichmann</a>
  */
 public final class LinearMetrics
 implements         Metrics
 {
+    /**
+     * Instance to prevent needless creations of instances.
+     */
     public static final Metrics INSTANCE =
         new LinearMetrics();
 
+    /**
+     * Implements the corresponding linear interpolator.
+     */
     public static final class LinearInterpolator
     implements                Interpolator
     {
@@ -19,6 +27,12 @@
         private double my;
         private double by;
 
+        /**
+         * Constructor to create a linear interpolator between two
+         * given points.
+         * @param p1 The first point.
+         * @param p2 The second point.
+         */
         public LinearInterpolator(Coordinate p1, Coordinate p2) {
 
             /*
@@ -56,4 +70,4 @@
         return new LinearInterpolator(p1, p2);
     }
 }
-// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
\ No newline at end of file
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/math/LinearToMap.java	Thu Apr 08 10:10:04 2010 +0000
+++ b/gnv-artifacts/src/main/java/de/intevation/gnv/math/LinearToMap.java	Thu Apr 08 11:31:44 2010 +0000
@@ -7,10 +7,18 @@
 import java.util.NoSuchElementException;
 
 /**
+ * Given a list of line segments instances of this class are able
+ * to span a metric system between a start and an end point
+ * represented as scalar values to 2D coordinate on the
+ * course of the segments.
+ *
  * @author <a href="mailto:sascha.teichmann@intevation.de">Sascha L. Teichmann</a>
  */
 public class LinearToMap
 {
+    /**
+     * Represents a segment of the line string.
+     */
     public static final class Range {
         private Range next;
 
@@ -23,9 +31,23 @@
 
         private Interpolator interpolator;
 
+        /**
+         * Default constructor.
+         */
         public Range() {
         }
 
+        /**
+         * Constructor to create a segment that maps
+         * a coordinate pair to two scalar values.
+         * Interpolations inside this segment are done with
+         * a given interpolator.
+         * @param from Start point of the segment.
+         * @param to End point of the segment.
+         * @param interpolator The interpolator.
+         * @param p1 The scalar value mapped to the start point.
+         * @param p2 The scalar value mappend to the end point.
+         */
         public Range(
             double       from,
             double       to,
@@ -44,29 +66,70 @@
                 : 1.0d/(to - from);
         }
 
+        /**
+         * Interpolated a coordinate on the segment given a scalar value
+         * between the start and end point of the range.
+         * @param x The scalar value.
+         * @param v The interpolated value is stored here.
+         */
         public void eval(double x, Coordinate v) {
             interpolator.interpolate((x - from)*b, v);
         }
 
+        /**
+         * Checks if a given value is inside this segment.
+         * @param x The value to test
+         * @return true if inside, else false.
+         */
         public boolean inside(double x) {
             return x >= from && x <= to;
         }
 
+        /**
+         * Returns the start point of this segment.
+         * @return The start point.
+         */
         public Coordinate startPoint() {
             return p1;
         }
 
+        /**
+         * Return the end point of this segment.
+         * @return The end point.
+         */
         public Coordinate endPoint() {
             return p2;
         }
     } // class Range
 
+    /**
+     * The head of the internal range list.
+     */
     protected Range head;
+
+    /**
+     * The last accessed segment. Used to accelerate
+     * the access of the right segment.
+     */
     protected Range last;
 
+    /**
+     * Default constructor.
+     */
     public LinearToMap() {
     }
 
+    /**
+     * Constructor to create a LinearToMap that maps
+     * given scalar values to coordinates of a given
+     * list of line segments.
+     * @param path The list of line segments.
+     * @param from The start value mapped to the start point
+     * of the first line segment.
+     * @param to The end value mapped to the end point of
+     * the last line segment.
+     * @param metrics The metric used to span the 2D space.
+     */
     public LinearToMap(
         List<? extends Coordinate> path,
         double                     from,
@@ -108,6 +171,11 @@
         }
     }
 
+    /**
+     * Returns a segment on which a given value is found.
+     * @param diagramX The value.
+     * @return The segment or null if no matching segment was found.
+     */
     protected Range locateRange(double diagramX) {
 
         if (last != null && last.inside(diagramX)) {
@@ -125,6 +193,13 @@
         return null;
     }
 
+    /**
+     * Interpolates a coordinate at a given scalar position.
+     * @param diagramX The scalar position.
+     * @param v The interpolated coordinate is stored here.
+     * @return true if the scalar position is inside the
+     * spanned range of the line string, else false.
+     */
     public boolean locate(double diagramX, Coordinate v) {
         Range range = locateRange(diagramX);
         if (range == null) {
@@ -134,6 +209,13 @@
         return true;
     }
 
+    /**
+     * Returns the length of a given line string using
+     * a given metric.
+     * @param path The line string.
+     * @param metrics The used metric.
+     * @return The length of the line string.
+     */
     public static double length(
         List<? extends Coordinate> path,
         Metrics                    metrics
@@ -147,6 +229,10 @@
         return sum;
     }
 
+    /**
+     * Return the number of segments in this map.
+     * @return the number of segments.
+     */
     public int numRanges() {
         int count = 0;
         Range current = head;
@@ -157,6 +243,10 @@
         return count;
     }
 
+    /**
+     * Returns an iterator over all segments of this map.
+     * @return The iterator.
+     */
     public Iterator ranges() {
         return new Iterator() {
 
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/math/Metrics.java	Thu Apr 08 10:10:04 2010 +0000
+++ b/gnv-artifacts/src/main/java/de/intevation/gnv/math/Metrics.java	Thu Apr 08 11:31:44 2010 +0000
@@ -3,12 +3,28 @@
 import com.vividsolutions.jts.geom.Coordinate;
 
 /**
+ * Implementations provides the ability to calculate the distance between
+ * two points ans support for interpolating points between two points.
+ *
  * @author <a href="mailto:sascha.teichmann@intevation.de">Sascha L. Teichmann</a>
  */
 public interface Metrics
 {
+    /**
+     * Calculates the distance between two given points.
+     * @param p1 The first point.
+     * @param p2 The second point.
+     * @return The distance.
+     */
     double distance(Coordinate p1, Coordinate p2);
 
+    /**
+     * Return an interpolator which allows interpolations between
+     * two given points.
+     * @param p1 The first point.
+     * @param p2 The second point.
+     * @return The interpolator.
+     */
     Interpolator getInterpolator(Coordinate p1, Coordinate p2);
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/math/QueriedXYDepth.java	Thu Apr 08 10:10:04 2010 +0000
+++ b/gnv-artifacts/src/main/java/de/intevation/gnv/math/QueriedXYDepth.java	Thu Apr 08 11:31:44 2010 +0000
@@ -21,14 +21,15 @@
 import org.apache.log4j.Logger;
 
 /**
+ * This implementation uses the geo backend to query a depth via
+ * a raster layer stored in the database.
+ *
  * @author <a href="mailto:tim.englich@intevation.de">Tim Englich</a>
  * @author <a href="mailto:sascha.teichmann@intevation.de">Sascha L. Teichmann</a>
  */
-public class QueriedXYDepth implements XYDepth {
-
-    /**
-     * the logger, used to log exceptions and additonaly information
-     */
+public class QueriedXYDepth
+implements   XYDepth
+{
     private static Logger log = Logger.getLogger(QueriedXYDepth.class);
 
     private static final String queryID = "rasterQuery";
@@ -41,19 +42,24 @@
 
     private int interpolation;
 
+    /**
+     * Default construtor. Interpolation method is bilinear.
+     */
     public QueriedXYDepth() {
         this(RasterObject.BILINEAR);
     }
 
+    /**
+     * Constructor to create a QueriedXYDepth with a given interpolation
+     * method.
+     * @param interpolation The interpolation method.
+     */
     public QueriedXYDepth(int interpolation) {
         this.interpolation = interpolation;
         rasterData    = new ArrayList<SoftReference<RasterObject>>();
         queryExecutor = QueryExecutorFactory.getInstance().getQueryExecutor();
     }
 
-    /**
-     * @see de.intevation.gnv.math.XYDepth#depth(com.vividsolutions.jts.geom.Coordinate)
-     */
     public double depth(Coordinate coordinate) {
         double resultValue = Double.NaN;
 
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/state/profile/horizontalcrosssection/HorizontalCrossSectionMeshOutputState.java	Thu Apr 08 10:10:04 2010 +0000
+++ b/gnv-artifacts/src/main/java/de/intevation/gnv/state/profile/horizontalcrosssection/HorizontalCrossSectionMeshOutputState.java	Thu Apr 08 11:31:44 2010 +0000
@@ -386,7 +386,7 @@
     /**
      * Find the parameter name which is used during mapfile creation in
      * MapfileGenerator.
-     * 
+     *
      * @param callContext The CallContext object.
      * @return the parameter name of the current parameterization.
      */
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/state/timeseries/TimeSeriesOutputState.java	Thu Apr 08 10:10:04 2010 +0000
+++ b/gnv-artifacts/src/main/java/de/intevation/gnv/state/timeseries/TimeSeriesOutputState.java	Thu Apr 08 11:31:44 2010 +0000
@@ -203,7 +203,7 @@
         "QF"
     };
 
-    
+
     /**
      * Profile for exporting data to odv
      */
@@ -620,7 +620,7 @@
     /**
      * Create an odv file representing the data corresponding to the current
      * parameterization.
-     * 
+     *
      * @param outputStream The output stream used to export the odv file.
      * @param result The data used for odv file creation.
      * @param uuid The UUID of the current artifact.

http://dive4elements.wald.intevation.org