sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1521776 - in /sis/branches/JDK7/core: sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/ sis-utility/src/main/java/org/apache/sis/util/resources/
Date Wed, 11 Sep 2013 10:04:37 GMT
Author: desruisseaux
Date: Wed Sep 11 10:04:36 2013
New Revision: 1521776

URL: http://svn.apache.org/r1521776
Log:
Javadoc and better error message in case of indices out of bounds.

Modified:
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/Matrices.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/Matrix1.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/Matrix2.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/Matrix3.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/MatrixSIS.java
    sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java
    sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties
    sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/Matrices.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/Matrices.java?rev=1521776&r1=1521775&r2=1521776&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/Matrices.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/Matrices.java
[UTF-8] Wed Sep 11 10:04:36 2013
@@ -145,13 +145,14 @@ public final class Matrices extends Stat
      * on the {@code mode} argument:
      *
      * <ul>
-     *   <li>{@link ComparisonMode#STRICT STRICT}: the two matrices must be of the
same class,
-     *       have the same size and the same element values.</li>
-     *   <li>{@link ComparisonMode#BY_CONTRACT BY_CONTRACT}/{@link ComparisonMode#IGNORE_METADATA
-     *       IGNORE_METADATA}: the two matrices must have the same size and the same element
values,
+     *   <li>{@link ComparisonMode#STRICT STRICT}:
+     *       the two matrices must be of the same class, have the same size and the same
element values.</li>
+     *   <li>{@link ComparisonMode#BY_CONTRACT BY_CONTRACT}:
+     *       the two matrices must have the same size and the same element values,
      *       but are not required to be the same implementation class (any {@link Matrix}
is okay).</li>
-     *   <li>{@link ComparisonMode#APPROXIMATIVE APPROXIMATIVE}: the two matrixes must
have the same size,
-     *       but the element values can differ up to some threshold.
+     *   <li>{@link ComparisonMode#IGNORE_METADATA IGNORE_METADATA}: same as {@code
BY_CONTRACT}.
+     *   <li>{@link ComparisonMode#APPROXIMATIVE APPROXIMATIVE}:
+     *       the two matrices must have the same size, but the element values can differ
up to some threshold.
      *       The threshold value is determined empirically and may change in any future SIS
versions.</li>
      * </ul>
      *

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/Matrix1.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/Matrix1.java?rev=1521776&r1=1521775&r2=1521776&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/Matrix1.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/Matrix1.java
[UTF-8] Wed Sep 11 10:04:36 2013
@@ -21,13 +21,24 @@ import org.apache.sis.internal.util.Nume
 
 
 /**
- * A matrix of fixed {@value #SIZE}×{@value #SIZE} size. This trivial matrix is returned
as a result
- * of {@linkplain org.opengis.referencing.operation.MathTransform1D} derivative computation.
+ * A matrix of fixed {@value #SIZE}×{@value #SIZE} size.
+ * The matrix member is:
+ *
+ * <blockquote><pre>┌     ┐
+ * │ {@link #m00} │
+ * └     ┘</pre></blockquote>
+ *
+ * This trivial matrix can be returned as a result of
+ * {@linkplain org.opengis.referencing.operation.MathTransform1D} derivative computation.
  *
  * @author  Martin Desruisseaux (IRD, Geomatys)
  * @since   0.4 (derived from geotk-2.2)
  * @version 0.4
  * @module
+ *
+ * @see Matrix2
+ * @see Matrix3
+ * @see Matrix4
  */
 public final class Matrix1 extends MatrixSIS {
     /**
@@ -75,7 +86,7 @@ public final class Matrix1 extends Matri
     /**
      * Returns the number of rows in this matrix, which is always {@value #SIZE} in this
implementation.
      *
-     * @return {@value SIZE}.
+     * @return Always {@value SIZE}.
      */
     @Override
     public final int getNumRow() {
@@ -85,7 +96,7 @@ public final class Matrix1 extends Matri
     /**
      * Returns the number of columns in this matrix, which is always {@value #SIZE} in this
implementation.
      *
-     * @return {@value SIZE}.
+     * @return Always {@value SIZE}.
      */
     @Override
     public final int getNumCol() {
@@ -107,7 +118,7 @@ public final class Matrix1 extends Matri
         if (row == 0 && column == 0) {
             return m00;
         } else {
-            throw new IndexOutOfBoundsException();
+            throw indexOutOfBounds(row, column);
         }
     }
 
@@ -126,7 +137,7 @@ public final class Matrix1 extends Matri
         if (row == 0 && column == 0) {
             m00 = value;
         } else {
-            throw new IndexOutOfBoundsException();
+            throw indexOutOfBounds(row, column);
         }
     }
 

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/Matrix2.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/Matrix2.java?rev=1521776&r1=1521775&r2=1521776&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/Matrix2.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/Matrix2.java
[UTF-8] Wed Sep 11 10:04:36 2013
@@ -22,6 +22,13 @@ import org.apache.sis.internal.util.Nume
 
 /**
  * A matrix of fixed {@value #SIZE}×{@value #SIZE} size.
+ * The matrix members are:
+ *
+ * <blockquote><pre>┌         ┐
+ * │ {@link #m00} {@link #m01} │
+ * │ {@link #m10} {@link #m11} │
+ * └         ┘</pre></blockquote>
+ *
  * This simple matrix is returned as a result of {@linkplain org.opengis.referencing.operation.MathTransform2D}
  * derivative computation.
  *
@@ -29,6 +36,10 @@ import org.apache.sis.internal.util.Nume
  * @since   0.4 (derived from geotk-2.2)
  * @version 0.4
  * @module
+ *
+ * @see Matrix1
+ * @see Matrix3
+ * @see Matrix4
  */
 public final class Matrix2 extends MatrixSIS {
     /**
@@ -75,8 +86,9 @@ public final class Matrix2 extends Matri
      * The length of the given array must be 4 and the values in the same order than the
above constructor.
      *
      * @param elements Elements of the matrix. Column indices vary fastest.
+     * @throws IllegalArgumentException If the given array does not have the expected length.
      */
-    public Matrix2(final double[] elements) {
+    public Matrix2(final double[] elements) throws IllegalArgumentException {
         ensureLengthMatch(SIZE*SIZE, elements);
         m00 = elements[0];
         m01 = elements[1];
@@ -101,7 +113,7 @@ public final class Matrix2 extends Matri
     /**
      * Returns the number of rows in this matrix, which is always {@value #SIZE} in this
implementation.
      *
-     * @return {@value SIZE}.
+     * @return Always {@value SIZE}.
      */
     @Override
     public final int getNumRow() {
@@ -111,7 +123,7 @@ public final class Matrix2 extends Matri
     /**
      * Returns the number of columns in this matrix, which is always {@value #SIZE} in this
implementation.
      *
-     * @return {@value SIZE}.
+     * @return Always {@value SIZE}.
      */
     @Override
     public final int getNumCol() {
@@ -135,7 +147,7 @@ public final class Matrix2 extends Matri
             case 1:  return m01;
             case 2:  return m10;
             case 3:  return m11;
-            default: throw new IndexOutOfBoundsException();
+            default: throw indexOutOfBounds(row, column);
         }
     }
 
@@ -156,7 +168,7 @@ public final class Matrix2 extends Matri
             case 1:  m01 = value; break;
             case 2:  m10 = value; break;
             case 3:  m11 = value; break;
-            default: throw new IndexOutOfBoundsException();
+            default: throw indexOutOfBounds(row, column);
         }
     }
 

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/Matrix3.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/Matrix3.java?rev=1521776&r1=1521775&r2=1521776&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/Matrix3.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/Matrix3.java
[UTF-8] Wed Sep 11 10:04:36 2013
@@ -23,13 +23,26 @@ import org.apache.sis.math.MathFunctions
 
 
 /**
- * A matrix of fixed {@value #SIZE}×{@value #SIZE} size. This specialized matrix provides
- * better accuracy than {@link GeneralMatrix} for matrix inversion and multiplication.
+ * A matrix of fixed {@value #SIZE}×{@value #SIZE} size.
+ * The matrix members are:
+ *
+ * <blockquote><pre>┌             ┐
+ * │ {@link #m00} {@link #m01} {@link #m02} │
+ * │ {@link #m10} {@link #m11} {@link #m12} │
+ * │ {@link #m20} {@link #m21} {@link #m22} │
+ * └             ┘</pre></blockquote>
+ *
+ * This specialized matrix implementation provides better accuracy than generic implementation
+ * for some operations.
  *
  * @author  Martin Desruisseaux (IRD, Geomatys)
  * @since   0.4 (derived from geotk-2.2)
  * @version 0.4
  * @module
+ *
+ * @see Matrix1
+ * @see Matrix2
+ * @see Matrix4
  */
 public final class Matrix3 extends MatrixSIS {
 // Note: if the above 'final' keyword is removed, revisit the methods in this class
@@ -96,8 +109,9 @@ public final class Matrix3 extends Matri
      * The length of the given array must be 9 and the values in the same order than the
above constructor.
      *
      * @param elements Elements of the matrix. Column indices vary fastest.
+     * @throws IllegalArgumentException If the given array does not have the expected length.
      */
-    public Matrix3(final double[] elements) {
+    public Matrix3(final double[] elements) throws IllegalArgumentException {
         ensureLengthMatch(SIZE*SIZE, elements);
         m00 = elements[0];
         m01 = elements[1];
@@ -128,7 +142,7 @@ public final class Matrix3 extends Matri
     /**
      * Returns the number of rows in this matrix, which is always {@value #SIZE} in this
implementation.
      *
-     * @return {@value SIZE}.
+     * @return Always {@value SIZE}.
      */
     @Override
     public final int getNumRow() {
@@ -138,7 +152,7 @@ public final class Matrix3 extends Matri
     /**
      * Returns the number of columns in this matrix, which is always {@value #SIZE} in this
implementation.
      *
-     * @return {@value SIZE}.
+     * @return Always {@value SIZE}.
      */
     @Override
     public final int getNumCol() {
@@ -178,7 +192,7 @@ public final class Matrix3 extends Matri
             case 6:  return m20;
             case 7:  return m21;
             case 8:  return m22;
-            default: throw new IndexOutOfBoundsException();
+            default: throw indexOutOfBounds(row, column);
         }
     }
 
@@ -204,7 +218,7 @@ public final class Matrix3 extends Matri
             case 6:  m20 = value; break;
             case 7:  m21 = value; break;
             case 8:  m22 = value; break;
-            default: throw new IndexOutOfBoundsException();
+            default: throw indexOutOfBounds(row, column);
         }
     }
 

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/MatrixSIS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/MatrixSIS.java?rev=1521776&r1=1521775&r2=1521776&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/MatrixSIS.java
(original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/MatrixSIS.java
Wed Sep 11 10:04:36 2013
@@ -57,8 +57,10 @@ public abstract class MatrixSIS implemen
     /**
      * Ensures that the given array is non-null and has the expected length.
      * This is a convenience method for subclasses constructors.
+     *
+     * @throws IllegalArgumentException If the given array does not have the expected length.
      */
-    static void ensureLengthMatch(final int expected, final double[] elements) {
+    static void ensureLengthMatch(final int expected, final double[] elements) throws IllegalArgumentException
{
         ArgumentChecks.ensureNonNull("elements", elements);
         if (elements.length != expected) {
             throw new IllegalArgumentException(Errors.format(
@@ -81,6 +83,13 @@ public abstract class MatrixSIS implemen
     }
 
     /**
+     * Returns an exception for the given indices.
+     */
+    static IndexOutOfBoundsException indexOutOfBounds(final int row, final int column) {
+        return new IndexOutOfBoundsException(Errors.format(Errors.Keys.IndicesOutOfBounds_2,
row, column));
+    }
+
+    /**
      * Returns {@code true} if this matrix represents an affine transform.
      * A transform is affine if the matrix is square and its last row contains
      * only zeros, except in the last column which contains 1.
@@ -126,7 +135,7 @@ public abstract class MatrixSIS implemen
      * This method is often used together with {@link #isIdentity(double)} in order to workaround
rounding errors,
      * like below:
      *
-     * {@preformat
+     * {@preformat java
      *     if (matrix.isIdentity(1E-10)) {
      *         matrix.setToIdentity();
      *     }
@@ -170,9 +179,10 @@ public abstract class MatrixSIS implemen
      * Returns a new matrix which is the result of multiplying this matrix with the specified
one.
      * In other words, returns {@code this} × {@code matrix}.
      *
-     * <p>In the context of coordinate transformations, this is equivalent to
-     * {@link java.awt.geom.AffineTransform#concatenate AffineTransform.concatenate(…)}:
-     * first transforms by the supplied transform and then transform the result by the original
transform.</p>
+     * {@section Relationship with coordinate operations}
+     * In the context of coordinate operations, {@code Matrix.multiply(other)} is equivalent
to
+     * <code>{@linkplain java.awt.geom.AffineTransform#concatenate AffineTransform.concatenate}(other)</code>:
+     * first transforms by the supplied transform and then transform the result by the original
transform.
      *
      * @param  matrix The matrix to multiply to this matrix.
      * @return The result of {@code this} × {@code matrix}.
@@ -218,13 +228,14 @@ public abstract class MatrixSIS implemen
      * objects must meet the following conditions, which depend on the {@code mode} argument:
      *
      * <ul>
-     *   <li>{@link ComparisonMode#STRICT STRICT}: the two matrices must be of the
same class,
-     *       have the same size and the same element values.</li>
-     *   <li>{@link ComparisonMode#BY_CONTRACT BY_CONTRACT} or {@link ComparisonMode#IGNORE_METADATA
-     *       IGNORE_METADATA}: the two matrices must have the same size and the same element
values,
+     *   <li>{@link ComparisonMode#STRICT STRICT}:
+     *       the two matrices must be of the same class, have the same size and the same
element values.</li>
+     *   <li>{@link ComparisonMode#BY_CONTRACT BY_CONTRACT}:
+     *       the two matrices must have the same size and the same element values,
      *       but are not required to be the same implementation class (any {@link Matrix}
is okay).</li>
-     *   <li>{@link ComparisonMode#APPROXIMATIVE APPROXIMATIVE}: the two matrices must
have the same size,
-     *       but the element values can differ up to some threshold.
+     *   <li>{@link ComparisonMode#IGNORE_METADATA IGNORE_METADATA}: same as {@code
BY_CONTRACT}.
+     *   <li>{@link ComparisonMode#APPROXIMATIVE APPROXIMATIVE}:
+     *       the two matrices must have the same size, but the element values can differ
up to some threshold.
      *       The threshold value is determined empirically and may change in any future SIS
versions.</li>
      * </ul>
      *

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java?rev=1521776&r1=1521775&r2=1521776&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java
[UTF-8] Wed Sep 11 10:04:36 2013
@@ -291,6 +291,11 @@ public final class Errors extends Indexe
         public static final int IndexOutOfBounds_1 = 4;
 
         /**
+         * Indices ({0}, {1}) are out of bounds.
+         */
+        public static final int IndicesOutOfBounds_2 = 120;
+
+        /**
          * Argument ‘{0}’ can not take an infinite value.
          */
         public static final int InfiniteArgumentValue_1 = 45;

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties?rev=1521776&r1=1521775&r2=1521776&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties
[ISO-8859-1] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties
[ISO-8859-1] Wed Sep 11 10:04:36 2013
@@ -69,6 +69,7 @@ InconsistentAttribute_2         = Value 
 InconsistentTableColumns        = Inconsistent table columns.
 IdentifierAlreadyBound_1        = Identifier \u201c{0}\u201d is already associated to another
object.
 IndexOutOfBounds_1              = Index {0} is out of bounds.
+IndicesOutOfBounds_2            = Indices ({0}, {1}) are out of bounds.
 InfiniteArgumentValue_1         = Argument \u2018{0}\u2019 can not take an infinite value.
 InfiniteRecursivity             = Infinite recursivity.
 InsufficientArgumentSize_3      = Argument \u2018{0}\u2019 shall contain at least {1} elements.
A number of {2} is insufficient.

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties?rev=1521776&r1=1521775&r2=1521776&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties
[ISO-8859-1] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties
[ISO-8859-1] Wed Sep 11 10:04:36 2013
@@ -59,6 +59,7 @@ InconsistentAttribute_2         = La val
 InconsistentTableColumns        = Les colonnes des tables ne sont pas coh\u00e9rentes.
 IdentifierAlreadyBound_1        = L\u2019identifiant \u201c{0}\u201d est d\u00e9j\u00e0 associ\u00e9
\u00e0 un autre objet.
 IndexOutOfBounds_1              = L\u2019index {0} est en dehors des limites permises.
+IndicesOutOfBounds_2            = Les index ({0}, {1}) sont en dehors des limites permises.
 InfiniteArgumentValue_1         = L\u2019argument \u2018{0}\u2019 ne peut pas prendre une
valeur infinie.
 InfiniteRecursivity             = R\u00e9cursivit\u00e9 infinie.
 InsufficientArgumentSize_3      = L\u2019argument \u2018{0}\u2019 doit contenir au moins
{1} \u00e9l\u00e9ments. Un nombre de {2} est insuffisant.



Mime
View raw message