sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1847794 [2/2] - in /sis/ip-review: ./ rev/10796/ rev/10874/ rev/10906/ rev/13332/ rev/20970/ rev/24925/ rev/29037/
Date Fri, 30 Nov 2018 09:52:08 GMT
Added: sis/ip-review/rev/20970/SampleDimension.xhtml
URL: http://svn.apache.org/viewvc/sis/ip-review/rev/20970/SampleDimension.xhtml?rev=1847794&view=auto
==============================================================================
--- sis/ip-review/rev/20970/SampleDimension.xhtml (added)
+++ sis/ip-review/rev/20970/SampleDimension.xhtml Fri Nov 30 09:52:08 2018
@@ -0,0 +1,1125 @@
+<!DOCTYPE html>
+<html xmlns="http://www.w3.org/1999/xhtml">
+  <head>
+    <meta charset="UTF-8"/>
+    <title>SampleDimension changes for revisions 20599:20970</title>
+    <style type="text/css" media="all">
+      @import url("../../reports.css");
+    </style>
+  </head>
+  <body>
+    <div>
+      <h1>SampleDimension changes for revisions 20599:20970</h1>
+      <p>This commit contains either change irrelevant to Apache SIS (LGPL header),
+         lot of code reformatting (do not apply to SIS) or addition of new constructor.
+         Those new constructors are not kept for Apache SIS; we will use a <code>Builder</code> instead.</p>
+
+<p><b>Command line:</b></p>
+<blockquote><code>svn diff --extensions "--unified --ignore-space-change --ignore-all-space --ignore-eol-style" -r20599:20970 http://svn.osgeo.org/geotools/trunk/modules/library/coverage/src/main/java/org/geotools/coverage/GridSampleDimension.java</code></blockquote>
+<table class="changes">
+<tr><th>Revision 20599</th><th>Revision 20970</th></tr>
+<tr><td><pre>/*
+<span class="del"> * Geotools 2 - OpenSource mapping toolkit</span>
+<span class="del"> * (C) 2003, Geotools Project Management Committee (PMC)</span>
+ * (C) 2001, Institut de Recherche pour le Développement
+ *
+ *    This library is free software; you can redistribute it and/or</pre></td>
+<td><pre>/*
+<span class="add"> *    GeoTools - OpenSource mapping toolkit</span>
+<span class="add"> *    http://geotools.org</span>
+<span class="add"> *    (C) 2003-2006, Geotools Project Management Committee (PMC)</span>
+ * (C) 2001, Institut de Recherche pour le Développement
+ *
+ *    This library is free software; you can redistribute it and/or</pre></td></tr>
+<tr><td><pre>*    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+*    Lesser General Public License for more details.
+*
+<span class="del">*    You should have received a copy of the GNU Lesser General Public</span>
+<span class="del">*    License along with this library; if not, write to the Free Software</span>
+<span class="del">*    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA</span>
+<span class="del">*</span>
+<span class="del">*</span>
+*    This package contains documentation from OpenGIS specifications.
+*    OpenGIS consortium's work is fully acknowledged here.
+*/</pre></td>
+<td><pre>*    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+*    Lesser General Public License for more details.
+*
+*    This package contains documentation from OpenGIS specifications.
+*    OpenGIS consortium's work is fully acknowledged here.
+*/</pre></td></tr>
+<tr><td><pre>import java.awt.image.DataBuffer;  // For javadoc
+import java.awt.image.IndexColorModel;
+import java.awt.image.RenderedImage;
+<span class="del">import java.awt.image.SampleModel;</span>
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Arrays;</pre></td>
+<td><pre>import java.awt.image.DataBuffer;  // For javadoc
+import java.awt.image.IndexColorModel;
+import java.awt.image.RenderedImage;
+<span class="add"></span>
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Arrays;</pre></td></tr>
+<tr><td><pre>import javax.media.jai.util.Range;
+
+// OpenGIS dependencies
+import org.opengis.coverage.ColorInterpretation;
+import org.opengis.coverage.MetadataNameNotFoundException;
+import org.opengis.coverage.PaletteInterpretation;</pre></td>
+<td><pre>import javax.media.jai.util.Range;
+
+// OpenGIS dependencies
+<span class="add">import org.geotools.util.SimpleInternationalString;</span>
+import org.opengis.coverage.ColorInterpretation;
+import org.opengis.coverage.MetadataNameNotFoundException;
+import org.opengis.coverage.PaletteInterpretation;</pre></td></tr>
+<tr><td><pre>private final MathTransform1D sampleToGeophysics;
+
+/**
+ * Constructs a sample dimension with no category.
+ */
+public GridSampleDimension() {
+<span class="del">    this((CategoryList) null);</span>
+}
+
+/**</pre></td>
+<td><pre>private final MathTransform1D sampleToGeophysics;
+
+/**
+<span class="add"> *</span>
+<span class="add"> * Decription for this sample dimension, it is particularly important to</span>
+<span class="add"> * have the possiblity to specify a description for a smple dimension in</span>
+<span class="add"> * order to be able to perform a band select by using human comprehensible</span>
+<span class="add"> * descriptions instead of just numbers. As an instance a service like the</span>
+<span class="add"> * WCS would use this feature in order to perform band subsetting as</span>
+<span class="add"> * directed from a user request.</span>
+<span class="add"> *</span>
+<span class="add"> */</span>
+<span class="add">private InternationalString description;</span>
+<span class="add"></span>
+<span class="add">/**</span>
+<span class="add"> * Constructs a sample dimension with no category, using the provided</span>
+<span class="add"> * description</span>
+<span class="add"> *</span>
+<span class="add"> * @param description</span>
+<span class="add"> *            Description for this Sample Dimension.</span>
+<span class="add"> */</span>
+<span class="add">public GridSampleDimension(final CharSequence description) {</span>
+<span class="add">   this(description, (CategoryList) null);</span>
+<span class="add"></span>
+<span class="add">}</span>
+<span class="add"></span>
+<span class="add">/**</span>
+ * Constructs a sample dimension with no category.
+<span class="add"> *</span>
+<span class="add"> * @deprecated</span>
+<span class="add"> * @see GridSampleDimension#GridSampleDimension(CharSequence)</span>
+<span class="add"> *</span>
+ */
+public GridSampleDimension() {
+<span class="add">   this(null, (CategoryList) null);</span>
+<span class="add"></span>
+}
+
+/**</pre></td></tr>
+<tr><td><pre> * This constructor expects only a sequence of category names for the values
+ * contained in a sample dimension. This allows for names to be assigned to
+ * numerical values. The first entry in the sequence relates to a cell value
+<span class="del"> * of zero. For example: [0]="Background", [1]="Water", [2]="Forest", [3]="Urban".</span>
+<span class="del"> * The created sample dimension will have no unit and a default set of colors.</span>
+ *
+<span class="del"> * @param names Sequence of category names for the values contained in a sample dimension,</span>
+<span class="del"> *              as {@link String} or {@link InternationalString} objects.</span>
+ */
+<span class="del">public GridSampleDimension(final CharSequence[] names) {</span>
+    // TODO: 'list(...)' should be inlined there if only Sun was to fix RFE #4093999
+    //       ("Relax constraint on placement of this()/super() call in constructors").
+<span class="del">    this(list(names));</span>
+}
+
+/** Constructs a list of categories. Used by constructors only. */
+private static CategoryList list(final CharSequence[] names) {
+<span class="del">    final Color[] colors = new Color[names.length];</span>
+<span class="del">    final double scale = 255.0/colors.length;</span>
+<span class="del">    for (int i=0; i&lt;colors.length; i++) {</span>
+        final int r = (int)Math.round(scale*i);
+        colors[i] = new Color(r,r,r);
+    }</pre></td>
+<td><pre> * This constructor expects only a sequence of category names for the values
+ * contained in a sample dimension. This allows for names to be assigned to
+ * numerical values. The first entry in the sequence relates to a cell value
+<span class="add"> * of zero. For example: [0]="Background", [1]="Water", [2]="Forest",</span>
+<span class="add"> * [3]="Urban". The created sample dimension will have no unit and a default</span>
+<span class="add"> * set of colors.</span>
+ *
+<span class="add"> * @param names</span>
+<span class="add"> *            Sequence of category names for the values contained in a</span>
+<span class="add"> *            sample dimension, as {@link String} or</span>
+<span class="add"> *            {@link InternationalString} objects.</span>
+<span class="add"> * @param description</span>
+<span class="add"> *            Description for this Sample Dimension.</span>
+<span class="add"> *</span>
+ */
+<span class="add">public GridSampleDimension(final CharSequence description,</span>
+<span class="add">     final CharSequence[] categoriesNames) {</span>
+<span class="add">   // TODO: 'list(...)' should be inlined there if only Sun was to fix RFE</span>
+<span class="add">   // #4093999</span>
+<span class="add">   // ("Relax constraint on placement of this()/super() call in</span>
+<span class="add">   // constructors").</span>
+<span class="add">   this(description, list(categoriesNames));</span>
+<span class="add">}</span>
+<span class="add"></span>
+<span class="add">/**</span>
+<span class="add"> * Constructs a sample dimension with a set of qualitative categories only.</span>
+<span class="add"> * This constructor expects only a sequence of category names for the values</span>
+<span class="add"> * contained in a sample dimension. This allows for names to be assigned to</span>
+<span class="add"> * numerical values. The first entry in the sequence relates to a cell value</span>
+<span class="add"> * of zero. For example: [0]="Background", [1]="Water", [2]="Forest",</span>
+<span class="add"> * [3]="Urban". The created sample dimension will have no unit and a default</span>
+<span class="add"> * set of colors.</span>
+<span class="add"> *</span>
+<span class="add"> * @param names</span>
+<span class="add"> *            Sequence of category names for the values contained in a</span>
+<span class="add"> *            sample dimension, as {@link String} or</span>
+<span class="add"> *            {@link InternationalString} objects.</span>
+<span class="add"> * @deprecated</span>
+<span class="add"> *</span>
+<span class="add"> */</span>
+<span class="add">public GridSampleDimension(final CharSequence[] categoriesNames) {</span>
+    // TODO: 'list(...)' should be inlined there if only Sun was to fix RFE #4093999
+    //       ("Relax constraint on placement of this()/super() call in constructors").
+<span class="add">   this(null, list(categoriesNames));</span>
+}
+
+/** Constructs a list of categories. Used by constructors only. */
+private static CategoryList list(final CharSequence[] names) {
+<span class="add">   final int length = names.length;</span>
+<span class="add">   final Color[] colors = new Color[length];</span>
+<span class="add">   final double scale = 255.0 / length;</span>
+<span class="add">   for (int i = 0; i &lt; length; i++) {</span>
+        final int r = (int)Math.round(scale*i);
+        colors[i] = new Color(r,r,r);
+    }</pre></td></tr>
+<tr><td><pre>}
+
+/**
+<span class="del"> * Constructs a sample dimension with a set of qualitative categories and colors.</span>
+<span class="del"> * This constructor expects a sequence of category names for the values</span>
+<span class="del"> * contained in a sample dimension. This allows for names to be assigned to</span>
+<span class="del"> * numerical values. The first entry in the sequence relates to a cell value</span>
+<span class="del"> * of zero. For example: [0]="Background", [1]="Water", [2]="Forest", [3]="Urban".</span>
+<span class="del"> * The created sample dimension will have no unit and a default set of colors.</span>
+ *
+<span class="del"> * @param names  Sequence of category names for the values contained in a sample dimension,</span>
+<span class="del"> *               as {@link String} or {@link InternationalString} objects.</span>
+<span class="del"> * @param colors Color to assign to each category. This array must have the same</span>
+<span class="del"> *               length than {@code names}.</span>
+ */
+public GridSampleDimension(final CharSequence[] names, final Color[] colors) {
+<span class="del">    // TODO: 'list(...)' should be inlined there if only Sun was to fix RFE #4093999</span>
+<span class="del">    //       ("Relax constraint on placement of this()/super() call in constructors").</span>
+<span class="del">    this(list(names, colors));</span>
+}
+
+/** Constructs a list of categories. Used by constructors only. */
+<span class="del">private static CategoryList list(final CharSequence[] names, final Color[] colors) {</span>
+    if (names.length != colors.length) {
+<span class="del">        throw new IllegalArgumentException(Errors.format(ErrorKeys.MISMATCHED_ARRAY_LENGTH));</span>
+    }
+<span class="del">    final Category[] categories = new Category[names.length];</span>
+<span class="del">    for (int i=0; i&lt;categories.length; i++) {</span>
+        categories[i] = new Category(names[i], colors[i], i);
+    }
+    return list(categories, null);</pre></td>
+<td><pre>}
+
+/**
+<span class="add"> * Constructs a sample dimension with a set of qualitative categories and</span>
+<span class="add"> * colors. This constructor expects a sequence of category names for the</span>
+<span class="add"> * values contained in a sample dimension. This allows for names to be</span>
+<span class="add"> * assigned to numerical values. The first entry in the sequence relates to</span>
+<span class="add"> * a cell value of zero. For example: [0]="Background", [1]="Water",</span>
+<span class="add"> * [2]="Forest", [3]="Urban". The created sample dimension will have no unit</span>
+<span class="add"> * and a default set of colors.</span>
+ *
+<span class="add"> * @param names</span>
+<span class="add"> *            Sequence of category names for the values contained in a</span>
+<span class="add"> *            sample dimension, as {@link String} or</span>
+<span class="add"> *            {@link InternationalString} objects.</span>
+<span class="add"> * @param colors</span>
+<span class="add"> *            Color to assign to each category. This array must have the</span>
+<span class="add"> *            same length than {@code names}.</span>
+<span class="add"> * @param description</span>
+<span class="add"> *            Description for this Sample Dimension.</span>
+ */
+<span class="add">public GridSampleDimension(final CharSequence description,</span>
+<span class="add">     final CharSequence[] names, final Color[] colors) {</span>
+<span class="add">   // TODO: 'list(...)' should be inlined there if only Sun was to fix RFE</span>
+<span class="add">   // #4093999</span>
+<span class="add">   // ("Relax constraint on placement of this()/super() call in</span>
+<span class="add">   // constructors").</span>
+<span class="add">   this(description, list(names, colors));</span>
+<span class="add">}</span>
+<span class="add"></span>
+<span class="add">/**</span>
+<span class="add"> * Constructs a sample dimension with a set of qualitative categories and</span>
+<span class="add"> * colors. This constructor expects a sequence of category names for the</span>
+<span class="add"> * values contained in a sample dimension. This allows for names to be</span>
+<span class="add"> * assigned to numerical values. The first entry in the sequence relates to</span>
+<span class="add"> * a cell value of zero. For example: [0]="Background", [1]="Water",</span>
+<span class="add"> * [2]="Forest", [3]="Urban". The created sample dimension will have no unit</span>
+<span class="add"> * and a default set of colors.</span>
+<span class="add"> *</span>
+<span class="add"> * @param names</span>
+<span class="add"> *            Sequence of category names for the values contained in a</span>
+<span class="add"> *            sample dimension, as {@link String} or</span>
+<span class="add"> *            {@link InternationalString} objects.</span>
+<span class="add"> * @param colors</span>
+<span class="add"> *            Color to assign to each category. This array must have the</span>
+<span class="add"> *            same length than {@code names}.</span>
+<span class="add"> * @deprecated</span>
+<span class="add"> */</span>
+public GridSampleDimension(final CharSequence[] names, final Color[] colors) {
+<span class="add">   // TODO: 'list(...)' should be inlined there if only Sun was to fix RFE</span>
+<span class="add">   // #4093999</span>
+<span class="add">   // ("Relax constraint on placement of this()/super() call in</span>
+<span class="add">   // constructors").</span>
+<span class="add">   this(null, list(names, colors));</span>
+}
+
+/** Constructs a list of categories. Used by constructors only. */
+<span class="add">private static CategoryList list(final CharSequence[] names,</span>
+<span class="add">     final Color[] colors) {</span>
+    if (names.length != colors.length) {
+<span class="add">     throw new IllegalArgumentException(Errors</span>
+<span class="add">          .format(ErrorKeys.MISMATCHED_ARRAY_LENGTH));</span>
+    }
+<span class="add">   final int length = names.length;</span>
+<span class="add">   final Category[] categories = new Category[length];</span>
+<span class="add">   for (int i = 0; i &lt; length; i++) {</span>
+        categories[i] = new Category(names[i], colors[i], i);
+    }
+    return list(categories, null);</pre></td></tr>
+<tr><td><pre>}
+
+/**
+<span class="del"> * Constructs a sample dimension with the specified properties. For convenience, any argument</span>
+<span class="del"> * which is not a {@code double} primitive can be {@code null}, and any {@linkplain CharSequence</span>
+<span class="del"> * char sequence} can be either a {@link String} or {@link InternationalString} object.</span>
+ *
+<span class="del"> * This constructor allows the construction of a {@code GridSampleDimension} without</span>
+<span class="del"> * explicit construction of {@link Category} objects. An heuristic approach is used for</span>
+<span class="del"> * dispatching the informations into a set of {@link Category} objects. However, this</span>
+<span class="del"> * constructor still less general and provides less fine-grain control than the constructor</span>
+<span class="del"> * expecting an array of {@link Category} objects.</span>
+ *
+<span class="del"> * @param  description The sample dimension title or description, or {@code null} if none.</span>
+<span class="del"> *         This is the value to be returned by {@link #getDescription}.</span>
+<span class="del"> * @param  type The grid value data type (which indicate the number of bits for the data type),</span>
+<span class="del"> *         or {@code null} for computing it automatically from the range</span>
+<span class="del"> *         {@code [minimum..maximum]}. This is the value to be returned by</span>
+<span class="del"> *         {@link #getSampleDimensionType}.</span>
+<span class="del"> * @param  color The color interpretation, or {@code null} for a default value (usually</span>
+<span class="del"> *         {@link ColorInterpretation#PALETTE_INDEX PALETTE_INDEX}). This is the value to be</span>
+<span class="del"> *         returned by {@link #getColorInterpretation}.</span>
+<span class="del"> * @param  palette The color palette associated with the sample dimension, or {@code null}</span>
+<span class="del"> *         for a default color palette (usually grayscale). If {@code categories} is</span>
+<span class="del"> *         non-null, then both arrays usually have the same length. However, this constructor</span>
+<span class="del"> *         is tolerant on this array length. This is the value to be returned (indirectly) by</span>
+<span class="del"> *         {@link #getColorModel}.</span>
+<span class="del"> * @param  categories A sequence of category names for the values contained in the sample</span>
+<span class="del"> *         dimension, or {@code null} if none. This is the values to be returned by</span>
+<span class="del"> *         {@link #getCategoryNames}.</span>
+<span class="del"> * @param  nodata the values to indicate "no data", or {@code null} if none. This is the</span>
+<span class="del"> *         values to be returned by {@link #getNoDataValues}.</span>
+<span class="del"> * @param  minimum The lower value, inclusive. The {@code [minimum..maximum]} range may or</span>
+<span class="del"> *         may not includes the {@code nodata} values; the range will be adjusted as</span>
+<span class="del"> *         needed. If {@code categories} was non-null, then {@code minimum} is</span>
+<span class="del"> *         usually 0. This is the value to be returned by {@link #getMinimumValue}.</span>
+<span class="del"> * @param  maximum The upper value, &lt;strong&gt;inclusive&lt;/strong&gt; as well. The</span>
+<span class="del"> *         {@code [minimum..maximum]} range may or may not includes the {@code nodata}</span>
+<span class="del"> *         values; the range will be adjusted as needed. If {@code categories} was non-null,</span>
+<span class="del"> *         then {@code maximum} is usually equals to {@code categories.length-1}. This</span>
+<span class="del"> *         is the value to be returned by {@link #getMaximumValue}.</span>
+<span class="del"> * @param  scale The value which is multiplied to grid values, or 1 if none. This is the value</span>
+<span class="del"> *         to be returned by {@link #getScale}.</span>
+<span class="del"> * @param  offset The value to add to grid values, or 0 if none. This is the value to be</span>
+<span class="del"> *         returned by {@link #getOffset}.</span>
+<span class="del"> * @param  unit The unit information for this sample dimension, or {@code null} if none.</span>
+<span class="del"> *         This is the value to be returned by {@link #getUnits}.</span>
+ *
+<span class="del"> * @throws IllegalArgumentException if the range {@code [minimum..maximum]} is not valid.</span>
+ */
+public GridSampleDimension(final CharSequence  description,
+<span class="del">                           final SampleDimensionType  type,</span>
+<span class="del">                           final ColorInterpretation color,</span>
+<span class="del">                           final Color[]           palette,</span>
+<span class="del">                           final CharSequence[] categories,</span>
+<span class="del">                           final double[]           nodata,</span>
+<span class="del">                           final double            minimum,</span>
+<span class="del">                           final double            maximum,</span>
+<span class="del">                           final double              scale,</span>
+<span class="del">                           final double             offset,</span>
+<span class="del">                           final Unit                 unit)</span>
+<span class="del">{</span>
+<span class="del">    // TODO: 'list(...)' should be inlined there if only Sun was to fix RFE #4093999</span>
+<span class="del">    //       ("Relax constraint on placement of this()/super() call in constructors").</span>
+<span class="del">    this(list(description, type, color, palette, categories, nodata,</span>
+<span class="del">              minimum, maximum, scale, offset, unit));</span>
+}
+
+/** Constructs a list of categories. Used by constructors only. */
+private static CategoryList list(final CharSequence  description,
+<span class="del">                                       SampleDimensionType  type,</span>
+<span class="del">                                       ColorInterpretation color,</span>
+<span class="del">                                 final Color[]           palette,</span>
+<span class="del">                                 final CharSequence[] categories,</span>
+<span class="del">                                 final double[]           nodata,</span>
+<span class="del">                                       double            minimum,</span>
+<span class="del">                                       double            maximum,</span>
+<span class="del">                                 final double              scale,</span>
+<span class="del">                                 final double             offset,</span>
+<span class="del">                                 final Unit                 unit)</span>
+<span class="del">{</span>
+<span class="del">    if (Double.isInfinite(minimum) || Double.isInfinite(maximum) || !(minimum &lt; maximum)) {</span>
+<span class="del">        throw new IllegalArgumentException(Errors.format(ErrorKeys.BAD_RANGE_$2,</span>
+<span class="del">                                           new Double(minimum), new Double(maximum)));</span>
+    }
+    if (Double.isNaN(scale) || Double.isInfinite(scale) || scale==0) {
+<span class="del">        throw new IllegalArgumentException(Errors.format(ErrorKeys.BAD_PARAMETER_$2,</span>
+<span class="del">                                           "scale", new Double(scale)));</span>
+    }
+    if (Double.isNaN(offset) || Double.isInfinite(offset)) {
+<span class="del">        throw new IllegalArgumentException(Errors.format(ErrorKeys.BAD_PARAMETER_$2,</span>
+<span class="del">                                           "offset", new Double(offset)));</span>
+    }
+    if (type == null) {
+        type = TypeMap.getSampleDimensionType(minimum, maximum);</pre></td>
+<td><pre>}
+
+/**
+<span class="add"> * Constructs a sample dimension with the specified properties. For</span>
+<span class="add"> * convenience, any argument which is not a {@code double} primitive can be</span>
+<span class="add"> * {@code null}, and any {@linkplain CharSequence char sequence} can be</span>
+<span class="add"> * either a {@link String} or {@link InternationalString} object.</span>
+ *
+<span class="add"> * This constructor allows the construction of a {@code GridSampleDimension}</span>
+<span class="add"> * without explicit construction of {@link Category} objects. An heuristic</span>
+<span class="add"> * approach is used for dispatching the informations into a set of</span>
+<span class="add"> * {@link Category} objects. However, this constructor still less general</span>
+<span class="add"> * and provides less fine-grain control than the constructor expecting an</span>
+<span class="add"> * array of {@link Category} objects.</span>
+ *
+<span class="add"> * @param description</span>
+<span class="add"> *            The sample dimension title or description, or {@code null} if</span>
+<span class="add"> *            none. This is the value to be returned by</span>
+<span class="add"> *            {@link #getDescription}.</span>
+<span class="add"> * @param type</span>
+<span class="add"> *            The grid value data type (which indicate the number of bits</span>
+<span class="add"> *            for the data type), or {@code null} for computing it</span>
+<span class="add"> *            automatically from the range {@code [minimum..maximum]}. This</span>
+<span class="add"> *            is the value to be returned by {@link #getSampleDimensionType}.</span>
+<span class="add"> * @param color</span>
+<span class="add"> *            The color interpretation, or {@code null} for a default value</span>
+<span class="add"> *            (usually</span>
+<span class="add"> *            {@link ColorInterpretation#PALETTE_INDEX PALETTE_INDEX}).</span>
+<span class="add"> *            This is the value to be returned by</span>
+<span class="add"> *            {@link #getColorInterpretation}.</span>
+<span class="add"> * @param palette</span>
+<span class="add"> *            The color palette associated with the sample dimension, or</span>
+<span class="add"> *            {@code null} for a default color palette (usually grayscale).</span>
+<span class="add"> *            If {@code categories} is non-null, then both arrays usually</span>
+<span class="add"> *            have the same length. However, this constructor is tolerant on</span>
+<span class="add"> *            this array length. This is the value to be returned</span>
+<span class="add"> *            (indirectly) by {@link #getColorModel}.</span>
+<span class="add"> * @param categories</span>
+<span class="add"> *            A sequence of category names for the values contained in the</span>
+<span class="add"> *            sample dimension, or {@code null} if none. This is the values</span>
+<span class="add"> *            to be returned by {@link #getCategoryNames}.</span>
+<span class="add"> * @param nodata</span>
+<span class="add"> *            the values to indicate "no data", or {@code null} if none.</span>
+<span class="add"> *            This is the values to be returned by {@link #getNoDataValues}.</span>
+<span class="add"> * @param minimum</span>
+<span class="add"> *            The lower value, inclusive. The {@code [minimum..maximum]}</span>
+<span class="add"> *            range may or may not includes the {@code nodata} values; the</span>
+<span class="add"> *            range will be adjusted as needed. If {@code categories} was</span>
+<span class="add"> *            non-null, then {@code minimum} is usually 0. This is the value</span>
+<span class="add"> *            to be returned by {@link #getMinimumValue}.</span>
+<span class="add"> * @param maximum</span>
+<span class="add"> *            The upper value, &lt;strong&gt;inclusive&lt;/strong&gt; as well. The</span>
+<span class="add"> *            {@code [minimum..maximum]} range may or may not includes the</span>
+<span class="add"> *            {@code nodata} values; the range will be adjusted as needed.</span>
+<span class="add"> *            If {@code categories} was non-null, then {@code maximum} is</span>
+<span class="add"> *            usually equals to {@code categories.length-1}. This is the</span>
+<span class="add"> *            value to be returned by {@link #getMaximumValue}.</span>
+<span class="add"> * @param scale</span>
+<span class="add"> *            The value which is multiplied to grid values, or 1 if none.</span>
+<span class="add"> *            This is the value to be returned by {@link #getScale}.</span>
+<span class="add"> * @param offset</span>
+<span class="add"> *            The value to add to grid values, or 0 if none. This is the</span>
+<span class="add"> *            value to be returned by {@link #getOffset}.</span>
+<span class="add"> * @param unit</span>
+<span class="add"> *            The unit information for this sample dimension, or</span>
+<span class="add"> *            {@code null} if none. This is the value to be returned by</span>
+<span class="add"> *            {@link #getUnits}.</span>
+<span class="add"> * @param description</span>
+<span class="add"> *            Description for this Sample Dimension.</span>
+ *
+<span class="add"> * @throws IllegalArgumentException</span>
+<span class="add"> *             if the range {@code [minimum..maximum]} is not valid.</span>
+ */
+public GridSampleDimension(final CharSequence  description,
+<span class="add">     final SampleDimensionType type, final ColorInterpretation color,</span>
+<span class="add">     final Color[] palette, final CharSequence[] categories,</span>
+<span class="add">     final double[] nodata, final double minimum, final double maximum,</span>
+<span class="add">     final double scale, final double offset, final Unit unit) {</span>
+<span class="add">   // TODO: 'list(...)' should be inlined there if only Sun was to fix RFE</span>
+<span class="add">   // #4093999</span>
+<span class="add">   // ("Relax constraint on placement of this()/super() call in</span>
+<span class="add">   // constructors").</span>
+<span class="add">   this(description, list(description, type, color, palette, categories,</span>
+<span class="add">      nodata, minimum, maximum, scale, offset, unit));</span>
+}
+
+/** Constructs a list of categories. Used by constructors only. */
+private static CategoryList list(final CharSequence  description,
+<span class="add">     SampleDimensionType type, ColorInterpretation color,</span>
+<span class="add">     final Color[] palette, final CharSequence[] categories,</span>
+<span class="add">     final double[] nodata, double minimum, double maximum,</span>
+<span class="add">     final double scale, final double offset, final Unit unit) {</span>
+<span class="add">   if (Double.isInfinite(minimum) || Double.isInfinite(maximum)</span>
+<span class="add">      || !(minimum &lt; maximum)) {</span>
+<span class="add">     throw new IllegalArgumentException(Errors.format(</span>
+<span class="add">          ErrorKeys.BAD_RANGE_$2, new Double(minimum), new Double(</span>
+<span class="add">               maximum)));</span>
+    }
+    if (Double.isNaN(scale) || Double.isInfinite(scale) || scale==0) {
+<span class="add">     throw new IllegalArgumentException(Errors.format(</span>
+<span class="add">          ErrorKeys.BAD_PARAMETER_$2, "scale", new Double(scale)));</span>
+    }
+    if (Double.isNaN(offset) || Double.isInfinite(offset)) {
+<span class="add">     throw new IllegalArgumentException(Errors.format(</span>
+<span class="add">          ErrorKeys.BAD_PARAMETER_$2, "offset", new Double(offset)));</span>
+    }
+    if (type == null) {
+        type = TypeMap.getSampleDimensionType(minimum, maximum);</pre></td></tr>
+<tr><td><pre>final int   nodataCount = (nodata    !=null) ?     nodata.length : 0;
+final List categoryList = new ArrayList(nameCount + nodataCount + 2);
+/*
+<span class="del"> * STEP 1 - Add a qualitative category for each 'nodata' value.</span>
+<span class="del"> *          NAME:  Fetched from 'categories' if available, otherwise default to the value.</span>
+<span class="del"> *          COLOR: Fetched from 'palette' if available, otherwise use Category default.</span>
+ */
+for (int i=0; i&lt;nodataCount; i++) {
+    CharSequence name = null;</pre></td>
+<td><pre>final int   nodataCount = (nodata    !=null) ?     nodata.length : 0;
+final List categoryList = new ArrayList(nameCount + nodataCount + 2);
+/*
+<span class="add">* STEP 1 - Add a qualitative category for each 'nodata' value. NAME:</span>
+<span class="add">* Fetched from 'categories' if available, otherwise default to the</span>
+<span class="add">* value. COLOR: Fetched from 'palette' if available, otherwise use</span>
+<span class="add">* Category default.</span>
+ */
+for (int i=0; i&lt;nodataCount; i++) {
+    CharSequence name = null;</pre></td></tr>
+<tr><td><pre>    if (name == null) {
+        name = value.toString();
+    }
+<span class="del">    final NumberRange range = new NumberRange(value.getClass(), value, value);</span>
+<span class="del">    final Color[] colors = ColorUtilities.subarray(palette, intValue, intValue+1);</span>
+<span class="del">    categoryList.add(new Category(name, colors, range, (MathTransform1D)null));</span>
+}
+/*
+<span class="del"> * STEP 2 - Add a qualitative category for each category name.</span>
+<span class="del"> *          RANGE: Fetched from the index (position) in the 'categories' array.</span>
+<span class="del"> *          COLOR: Fetched from 'palette' if available, otherwise use Category default.</span>
+ */
+if (nameCount != 0) {
+    int lower = 0;
+<span class="del">    for (int upper=1; upper&lt;=categories.length; upper++) {</span>
+<span class="del">        if (upper!=categories.length &amp;&amp;</span>
+<span class="del">                categories[lower].toString().trim().equalsIgnoreCase(</span>
+<span class="del">                categories[upper].toString().trim()))</span>
+<span class="del">        {</span>
+<span class="del">            // If there is a suite of categories with identical name,  create only one</span>
+<span class="del">            // category with range [lower..upper] instead of one new category for each</span>
+            // sample value.
+            continue;
+        }</pre></td>
+<td><pre>    if (name == null) {
+        name = value.toString();
+    }
+<span class="add"> final NumberRange range = new NumberRange(value.getClass(), value,</span>
+<span class="add">      value);</span>
+<span class="add"> final Color[] colors = ColorUtilities.subarray(palette, intValue,</span>
+<span class="add">      intValue + 1);</span>
+<span class="add"> categoryList.add(new Category(name, colors, range,</span>
+<span class="add">      (MathTransform1D) null));</span>
+}
+/*
+<span class="add">* STEP 2 - Add a qualitative category for each category name. RANGE:</span>
+<span class="add">* Fetched from the index (position) in the 'categories' array. COLOR:</span>
+<span class="add">* Fetched from 'palette' if available, otherwise use Category default.</span>
+ */
+if (nameCount != 0) {
+    int lower = 0;
+<span class="add"> final int length = categories.length;</span>
+<span class="add"> for (int upper = 1; upper &lt;= length; upper++) {</span>
+<span class="add">  if (upper != length</span>
+<span class="add">         &amp;&amp; categories[lower].toString().trim()</span>
+<span class="add">            .equalsIgnoreCase(</span>
+<span class="add">                   categories[upper].toString().trim())) {</span>
+<span class="add">      // If there is a suite of categories with identical name,</span>
+<span class="add">      // create only one</span>
+<span class="add">      // category with range [lower..upper] instead of one new</span>
+<span class="add">      // category for each</span>
+            // sample value.
+            continue;
+        }</pre></td></tr>
+<tr><td><pre>            max = ClassChanger.cast(max, classe);
+        }
+        final NumberRange range = new NumberRange(classe, min, max);
+<span class="del">        final Color[] colors = ColorUtilities.subarray(palette, lower, upper);</span>
+<span class="del">        categoryList.add(new Category(name, colors, range, (MathTransform1D)null));</span>
+        lower = upper;
+    }
+}
+/*
+<span class="del"> * STEP 3 - Changes some qualitative categories into quantitative ones.  The hard questions</span>
+<span class="del"> *          is: do we want to mark a category as "quantitative"?   OpenGIS has no notion of</span>
+<span class="del"> *          "qualitative" versus "quantitative" category. As an heuristic approach, we will</span>
+<span class="del"> *          look for quantitative category if:</span>
+<span class="del"> *</span>
+<span class="del"> *          - 'scale' and 'offset' do not map to an identity transform. Those</span>
+<span class="del"> *            coefficients can be stored in quantitative category only.</span>
+<span class="del"> *</span>
+<span class="del"> *          - 'nodata' were specified. If the user wants to declare "nodata" values,</span>
+<span class="del"> *            then we can reasonably assume that he have real values somewhere else.</span>
+<span class="del"> *</span>
+<span class="del"> *          - Only 1 category were created so far. A classified raster with only one</span>
+<span class="del"> *            category is useless. Consequently, it is probably a numeric raster instead.</span>
+ */
+boolean needQuantitative = false;
+<span class="del">if (scale!=1 || offset!=0 || nodataCount!=0 || categoryList.size()&lt;=1) {</span>
+    needQuantitative = true;
+    for (int i=categoryList.size(); --i&gt;=0;) {
+        Category category = (Category) categoryList.get(i);</pre></td>
+<td><pre>             max = ClassChanger.cast(max, classe);
+         }
+         final NumberRange range = new NumberRange(classe, min, max);
+<span class="add">   final Color[] colors = ColorUtilities.subarray(palette, lower,</span>
+<span class="add">          upper);</span>
+<span class="add">   categoryList.add(new Category(name, colors, range,</span>
+<span class="add">          (MathTransform1D) null));</span>
+         lower = upper;
+     }
+ }
+ /*
+<span class="add"> * STEP 3 - Changes some qualitative categories into quantitative ones.</span>
+<span class="add"> * The hard questions is: do we want to mark a category as</span>
+<span class="add"> * "quantitative"? OpenGIS has no notion of "qualitative" versus</span>
+<span class="add"> * "quantitative" category. As an heuristic approach, we will look for</span>
+<span class="add"> * quantitative category if: - 'scale' and 'offset' do not map to an</span>
+<span class="add"> * identity transform. Those coefficients can be stored in quantitative</span>
+<span class="add"> * category only. - 'nodata' were specified. If the user wants to</span>
+<span class="add"> * declare "nodata" values, then we can reasonably assume that he have</span>
+<span class="add"> * real values somewhere else. - Only 1 category were created so far. A</span>
+<span class="add"> * classified raster with only one category is useless. Consequently, it</span>
+<span class="add"> * is probably a numeric raster instead.</span>
+  */
+ boolean needQuantitative = false;
+<span class="add">if (scale != 1 || offset != 0 || nodataCount != 0</span>
+<span class="add">   || categoryList.size() &lt;= 1) {</span>
+     needQuantitative = true;
+     for (int i=categoryList.size(); --i&gt;=0;) {
+         Category category = (Category) categoryList.get(i);</pre></td></tr>
+<tr><td><pre>if (!rangeContains(xmin, xmax, nodata)) {
+    final InternationalString name = category.getName();
+    final Color[] colors = category.getColors();
+<span class="del">    category = new Category(name, colors, range, scale, offset);</span>
+    categoryList.set(i, category);
+    needQuantitative = false;
+}</pre></td>
+<td><pre>     if (!rangeContains(xmin, xmax, nodata)) {
+         final InternationalString name = category.getName();
+         final Color[] colors = category.getColors();
+<span class="add">category = new Category(name, colors, range, scale,</span>
+<span class="add">     offset);</span>
+         categoryList.set(i, category);
+         needQuantitative = false;
+     }</pre></td></tr>
+<tr><td><pre>    }
+}
+/*
+<span class="del"> * STEP 4 - Create at most one quantitative category for the remaining sample values.</span>
+<span class="del"> *          The new category will range from 'minimum' to 'maximum' inclusive, minus</span>
+<span class="del"> *          all ranges used by previous categories.  If there is no range left, then</span>
+<span class="del"> *          no new category will be created.  This step will be executed only if the</span>
+<span class="del"> *          information provided by the user seem to be incomplete.</span>
+ *
+ *          Note that substractions way break a range into many smaller ranges.
+ *          The naive algorithm used here try to keep the widest range.</pre></td>
+<td><pre>    }
+}
+/*
+<span class="add">* STEP 4 - Create at most one quantitative category for the remaining</span>
+<span class="add">* sample values. The new category will range from 'minimum' to</span>
+<span class="add">* 'maximum' inclusive, minus all ranges used by previous categories. If</span>
+<span class="add">* there is no range left, then no new category will be created. This</span>
+<span class="add">* step will be executed only if the information provided by the user</span>
+<span class="add">* seem to be incomplete.</span>
+ *
+ *          Note that substractions way break a range into many smaller ranges.
+ *          The naive algorithm used here try to keep the widest range.</pre></td></tr>
+<tr><td><pre>boolean minIncluded = true;
+boolean maxIncluded = true;
+for (int i=categoryList.size(); --i&gt;=0;) {
+<span class="del">    final NumberRange range = ((Category) categoryList.get(i)).getRange();</span>
+    final double  min = range.getMinimum();
+    final double  max = range.getMaximum();
+    if (max-minimum &lt; maximum-min) {</pre></td>
+<td><pre>  boolean minIncluded = true;
+  boolean maxIncluded = true;
+  for (int i=categoryList.size(); --i&gt;=0;) {
+<span class="add">final NumberRange range = ((Category) categoryList.get(i))</span>
+<span class="add">       .getRange();</span>
+      final double  min = range.getMinimum();
+      final double  max = range.getMaximum();
+      if (max-minimum &lt; maximum-min) {</pre></td></tr>
+<tr><td><pre>    final Class classe = ClassChanger.getWidestClass(min, max);
+    min = ClassChanger.cast(min, classe);
+    max = ClassChanger.cast(max, classe);
+<span class="del">    final NumberRange range = new NumberRange(classe, min, minIncluded,</span>
+<span class="del">                                                      max, maxIncluded);</span>
+    final Color[] colors = ColorUtilities.subarray(palette,
+<span class="del">                                         (int)Math.ceil (minimum),</span>
+<span class="del">                                         (int)Math.floor(maximum));</span>
+<span class="del">    categoryList.add(new Category((description!=null) ? description : "(automatic)",</span>
+                                  colors, range, scale, offset));
+    needQuantitative = false;
+}</pre></td>
+<td><pre>      final Class classe = ClassChanger.getWidestClass(min, max);
+      min = ClassChanger.cast(min, classe);
+      max = ClassChanger.cast(max, classe);
+<span class="add">final NumberRange range = new NumberRange(classe, min,</span>
+<span class="add">       minIncluded, max, maxIncluded);</span>
+      final Color[] colors = ColorUtilities.subarray(palette,
+<span class="add">       (int) Math.ceil(minimum), (int) Math.floor(maximum));</span>
+<span class="add">categoryList.add(new Category(</span>
+<span class="add">       (description != null) ? description : "(automatic)",</span>
+                                    colors, range, scale, offset));
+      needQuantitative = false;
+  }</pre></td></tr>
+<tr><td><pre> * STEP 5 - Now, the list of categories should be complete. Construct a
+ *          sample dimension appropriate for the type of palette used.
+ */
+<span class="del">final Category[] cl = (Category[]) categoryList.toArray(new Category[categoryList.size()]);</span>
+<span class="del">if (ColorInterpretation.PALETTE_INDEX.equals(color) ||</span>
+<span class="del">    ColorInterpretation.GRAY_INDEX.equals(color))</span>
+<span class="del">{</span>
+    return list(cl, unit);
+}
+throw new UnsupportedOperationException("Not yet implemented");</pre></td>
+<td><pre>  * STEP 5 - Now, the list of categories should be complete. Construct a
+  *          sample dimension appropriate for the type of palette used.
+  */
+<span class="add">final Category[] cl = (Category[]) categoryList</span>
+<span class="add">   .toArray(new Category[categoryList.size()]);</span>
+<span class="add">if (ColorInterpretation.PALETTE_INDEX.equals(color)</span>
+<span class="add">   || ColorInterpretation.GRAY_INDEX.equals(color)) {</span>
+     return list(cl, unit);
+ }
+ throw new UnsupportedOperationException("Not yet implemented");</pre></td></tr>
+<tr><td><pre>}
+
+/**
+<span class="del"> * Constructs a sample dimension with an arbitrary set of categories, which may be both</span>
+<span class="del"> * quantitative and qualitative.   It is possible to specify more than one quantitative</span>
+<span class="del"> * categories, providing that their sample value ranges do not overlap.    Quantitative</span>
+<span class="del"> * categories can map sample values to geophysics values using arbitrary relation (not</span>
+<span class="del"> * necessarly linear).</span>
+ *
+<span class="del"> * @param  categories The list of categories.</span>
+<span class="del"> * @param  units      The unit information for this sample dimension.</span>
+<span class="del"> *                    May be {@code null} if no category has units.</span>
+<span class="del"> *                    This unit apply to values obtained after the</span>
+<span class="del"> *                    {@link #getSampleToGeophysics sampleToGeophysics} transformation.</span>
+<span class="del"> * @throws IllegalArgumentException if {@code categories} contains incompatible</span>
+<span class="del"> *         categories. If may be the case for example if two or more categories have</span>
+ *         overlapping ranges of sample values.
+ */
+<span class="del">public GridSampleDimension(Category[] categories, Unit units) throws IllegalArgumentException {</span>
+<span class="del">    // TODO: 'list(...)' should be inlined there if only Sun was to fix RFE #4093999</span>
+<span class="del">    //       ("Relax constraint on placement of this()/super() call in constructors").</span>
+<span class="del">    this(list(categories, units));</span>
+}
+
+/** Construct a list of categories. Used by constructors only. */
+<span class="del">private static CategoryList list(final Category[] categories, final Unit units) {</span>
+    if (categories == null) {
+        return null;
+    }
+    final CategoryList list = new CategoryList(categories, units);
+<span class="del">    if (CategoryList.isScaled(categories, false)) return list;</span>
+<span class="del">    if (CategoryList.isScaled(categories, true )) return list.inverse;</span>
+<span class="del">    throw new IllegalArgumentException(Errors.format(ErrorKeys.MIXED_CATEGORIES));</span>
+}
+
+/**
+ * Constructs a sample dimension with the specified list of categories.
+ *
+<span class="del"> * @param list The list of categories, or {@code null}.</span>
+ */
+<span class="del">private GridSampleDimension(final CategoryList list) {</span>
+    MathTransform1D main = null;
+    boolean  isMainValid = true;
+    boolean  qualitative = false;
+    if (list != null) {
+        for (int i=list.size(); --i&gt;=0;) {
+<span class="del">            final MathTransform1D candidate = ((Category)list.get(i)).getSampleToGeophysics();</span>
+            if (candidate == null) {
+                qualitative = true;
+                continue;</pre></td>
+<td><pre>}
+
+/**
+<span class="add"> * Constructs a sample dimension with an arbitrary set of categories, which</span>
+<span class="add"> * may be both quantitative and qualitative. It is possible to specify more</span>
+<span class="add"> * than one quantitative categories, providing that their sample value</span>
+<span class="add"> * ranges do not overlap. Quantitative categories can map sample values to</span>
+<span class="add"> * geophysics values using arbitrary relation (not necessarly linear).</span>
+ *
+<span class="add"> * @param categories</span>
+<span class="add"> *            The list of categories.</span>
+<span class="add"> * @param units</span>
+<span class="add"> *            The unit information for this sample dimension. May be</span>
+<span class="add"> *            {@code null} if no category has units. This unit apply to</span>
+<span class="add"> *            values obtained after the</span>
+<span class="add"> *            {@link #getSampleToGeophysics sampleToGeophysics}</span>
+<span class="add"> *            transformation.</span>
+<span class="add"> * @param description</span>
+<span class="add"> *            Description for this Sample Dimension.</span>
+<span class="add"> * @throws IllegalArgumentException</span>
+<span class="add"> *             if {@code categories} contains incompatible categories. If</span>
+<span class="add"> *             may be the case for example if two or more categories have</span>
+ *         overlapping ranges of sample values.
+ */
+<span class="add">public GridSampleDimension(final CharSequence description,</span>
+<span class="add">     Category[] categories, Unit units) throws IllegalArgumentException {</span>
+<span class="add">   // TODO: 'list(...)' should be inlined there if only Sun was to fix RFE</span>
+<span class="add">   // #4093999</span>
+<span class="add">   // ("Relax constraint on placement of this()/super() call in</span>
+<span class="add">   // constructors").</span>
+<span class="add">   this(description, list(categories, units));</span>
+}
+
+<span class="add">/**</span>
+<span class="add"> * Constructs a sample dimension with an arbitrary set of categories, which</span>
+<span class="add"> * may be both quantitative and qualitative. It is possible to specify more</span>
+<span class="add"> * than one quantitative categories, providing that their sample value</span>
+<span class="add"> * ranges do not overlap. Quantitative categories can map sample values to</span>
+<span class="add"> * geophysics values using arbitrary relation (not necessarly linear).</span>
+<span class="add"> *</span>
+<span class="add"> * @param categories</span>
+<span class="add"> *            The list of categories.</span>
+<span class="add"> * @param units</span>
+<span class="add"> *            The unit information for this sample dimension. May be</span>
+<span class="add"> *            {@code null} if no category has units. This unit apply to</span>
+<span class="add"> *            values obtained after the</span>
+<span class="add"> *            {@link #getSampleToGeophysics sampleToGeophysics}</span>
+<span class="add"> *            transformation.</span>
+<span class="add"> * @deprecated</span>
+<span class="add"> * @throws IllegalArgumentException</span>
+<span class="add"> *             if {@code categories} contains incompatible categories. If</span>
+<span class="add"> *             may be the case for example if two or more categories have</span>
+<span class="add"> *             overlapping ranges of sample values.</span>
+<span class="add"> */</span>
+<span class="add">public GridSampleDimension(Category[] categories, Unit units)</span>
+<span class="add">     throws IllegalArgumentException {</span>
+<span class="add">   // TODO: 'list(...)' should be inlined there if only Sun was to fix RFE</span>
+<span class="add">   // #4093999</span>
+<span class="add">   // ("Relax constraint on placement of this()/super() call in</span>
+<span class="add">   // constructors").</span>
+<span class="add">   this(null, list(categories, units));</span>
+<span class="add">}</span>
+<span class="add"></span>
+/** Construct a list of categories. Used by constructors only. */
+<span class="add">private static CategoryList list(final Category[] categories,</span>
+<span class="add">     final Unit units) {</span>
+    if (categories == null) {
+        return null;
+    }
+    final CategoryList list = new CategoryList(categories, units);
+<span class="add">   if (CategoryList.isScaled(categories, false))</span>
+<span class="add">     return list;</span>
+<span class="add">   if (CategoryList.isScaled(categories, true))</span>
+<span class="add">     return list.inverse;</span>
+<span class="add">   throw new IllegalArgumentException(Errors</span>
+<span class="add">      .format(ErrorKeys.MIXED_CATEGORIES));</span>
+}
+
+/**
+ * Constructs a sample dimension with the specified list of categories.
+ *
+<span class="add"> * @param list</span>
+<span class="add"> *            The list of categories, or {@code null}.</span>
+<span class="add"> * @param description</span>
+<span class="add"> *            Description for this Sample Dimension.</span>
+ */
+<span class="add">private GridSampleDimension(final CharSequence description,</span>
+<span class="add">     final CategoryList list) {</span>
+    MathTransform1D main = null;
+<span class="add">   this.description = checkDescription(description, list);</span>
+    boolean  isMainValid = true;
+    boolean  qualitative = false;
+    if (list != null) {
+        for (int i=list.size(); --i&gt;=0;) {
+<span class="add">      final MathTransform1D candidate = ((Category) list.get(i))</span>
+<span class="add">             .getSampleToGeophysics();</span>
+            if (candidate == null) {
+                qualitative = true;
+                continue;</pre></td></tr>
+<tr><td><pre>}
+
+/**
+ * Constructs a new sample dimension with the same categories and
+ * units than the specified sample dimension.
+ *</pre></td>
+<td><pre>}
+
+/**
+<span class="add"> * Checks the supplied description to see if it is null. In such a case it</span>
+<span class="add"> * builds up a new description by using the list of categories supplied.</span>
+<span class="add"> * This secondo description is much less human readable and it is therefore</span>
+<span class="add"> * much better if the user provide a meaningful name for this sample</span>
+<span class="add"> * dimension.</span>
+<span class="add"> *</span>
+<span class="add"> * @param description</span>
+<span class="add"> *            Supplied description.</span>
+<span class="add"> * @param list</span>
+<span class="add"> *            List of categories for this SampleDimension.</span>
+<span class="add"> * @return description for this sample dimension.</span>
+<span class="add"> */</span>
+<span class="add">private InternationalString checkDescription(CharSequence description,</span>
+<span class="add">     CategoryList list) {</span>
+<span class="add"></span>
+<span class="add">   // do we have a description</span>
+<span class="add">   if (description != null)</span>
+<span class="add">     return SimpleInternationalString.wrap(description);</span>
+<span class="add"></span>
+<span class="add">   // we need to build one</span>
+<span class="add">   // let's use the category list in order to build the name of the sample</span>
+<span class="add">   // dimension</span>
+<span class="add">   if (list != null)</span>
+<span class="add">     return list.getName();</span>
+<span class="add">   return new SimpleInternationalString("");</span>
+<span class="add"></span>
+<span class="add">}</span>
+<span class="add">/**</span>
+ * Constructs a new sample dimension with the same categories and
+ * units than the specified sample dimension.
+ *</pre></td></tr>
+<tr><td><pre>    hasQualitative     = other.hasQualitative;
+    hasQuantitative    = other.hasQuantitative;
+    sampleToGeophysics = other.sampleToGeophysics;
+} else {
+    // 'inverse' will be set when needed.
+    categories         = null;</pre></td>
+<td><pre>    hasQualitative     = other.hasQualitative;
+    hasQuantitative    = other.hasQuantitative;
+    sampleToGeophysics = other.sampleToGeophysics;
+<span class="add"> description = other.description;</span>
+} else {
+    // 'inverse' will be set when needed.
+    categories         = null;</pre></td></tr>
+<tr><td><pre>}
+
+/**
+<span class="del"> * Wrap the specified OpenGIS's sample dimension into a Geotools's implementation</span>
+<span class="del"> * of {@code GridSampleDimension}.</span>
+ *
+<span class="del"> * @param sd The sample dimension to wrap into a Geotools implementation.</span>
+ */
+public static GridSampleDimension wrap(final SampleDimension sd) {
+    if (sd instanceof GridSampleDimension) {</pre></td>
+<td><pre>}
+
+/**
+<span class="add"> * Wrap the specified OpenGIS's sample dimension into a Geotools's</span>
+<span class="add"> * implementation of {@code GridSampleDimension}.</span>
+ *
+<span class="add"> * @param sd</span>
+<span class="add"> *            The sample dimension to wrap into a Geotools implementation.</span>
+ */
+public static GridSampleDimension wrap(final SampleDimension sd) {
+    if (sd instanceof GridSampleDimension) {</pre></td></tr>
+<tr><td><pre>final int[][] palette = sd.getPalette();
+final Color[] colors;
+if (palette != null) {
+<span class="del">    colors = new Color[palette.length];</span>
+<span class="del">    for (int i=0; i&lt;colors.length; i++) {</span>
+        // Assuming RGB. It will be checked in the constructor.
+        final int[] color = palette[i];
+        colors[i] = new Color(color[0], color[1], color[2]);</pre></td>
+<td><pre>final int[][] palette = sd.getPalette();
+final Color[] colors;
+if (palette != null) {
+<span class="add"> final int length = palette.length;</span>
+<span class="add"> colors = new Color[length];</span>
+<span class="add"> for (int i = 0; i &lt; length; i++) {</span>
+        // Assuming RGB. It will be checked in the constructor.
+        final int[] color = palette[i];
+        colors[i] = new Color(color[0], color[1], color[2]);</pre></td></tr>
+<tr><td><pre>    } else {
+        colors = null;
+    }
+<span class="del">    return new GridSampleDimension(sd.getDescription(),</span>
+<span class="del">                                   sd.getSampleDimensionType(),</span>
+<span class="del">                                   sd.getColorInterpretation(),</span>
+<span class="del">                                   colors,</span>
+<span class="del">                                   sd.getCategoryNames(),</span>
+<span class="del">                                   sd.getNoDataValues(),</span>
+<span class="del">                                   sd.getMinimumValue(),</span>
+<span class="del">                                   sd.getMaximumValue(),</span>
+<span class="del">                                   sd.getScale(),</span>
+<span class="del">                                   sd.getOffset(),</span>
+<span class="del">                                   sd.getUnits());</span>
+}
+
+/**</pre></td>
+<td><pre>    } else {
+        colors = null;
+    }
+<span class="add">   return new GridSampleDimension(sd.getDescription(), sd</span>
+<span class="add">      .getSampleDimensionType(), sd.getColorInterpretation(), colors,</span>
+<span class="add">      sd.getCategoryNames(), sd.getNoDataValues(), sd</span>
+<span class="add">             .getMinimumValue(), sd.getMaximumValue(),</span>
+<span class="add">      sd.getScale(), sd.getOffset(), sd.getUnits());</span>
+}
+
+/**</pre></td></tr>
+<tr><td><pre> * This string may be {@code null} if no description is present.
+ */
+public InternationalString getDescription() {
+<span class="del">    return (categories!=null) ? categories.getName() : null;</span>
+}
+
+/**</pre></td>
+<td><pre> * This string may be {@code null} if no description is present.
+ */
+public InternationalString getDescription() {
+<span class="add">   return description;</span>
+}
+
+/**</pre></td></tr>
+<tr><td><pre> * @deprecated Use {@link #getDescription()} instead.
+ */
+public String getDescription(final Locale locale) {
+<span class="del">    return (categories!=null) ? categories.getName().toString(locale) : null;</span>
+}
+
+/**</pre></td>
+<td><pre> * @deprecated Use {@link #getDescription()} instead.
+ */
+public String getDescription(final Locale locale) {
+<span class="add">   return description.toString(locale);</span>
+}
+
+/**</pre></td></tr>
+<tr><td><pre> */
+public final String[] getCategoryNames(final Locale locale) throws IllegalStateException {
+    final InternationalString[] inter = getCategoryNames();
+<span class="del">    final String[] names = new String[inter.length];</span>
+<span class="del">    for (int i=0; i&lt;names.length; i++) {</span>
+        names[i] = inter[i].toString(locale);
+    }
+    return names;</pre></td>
+<td><pre> */
+public final String[] getCategoryNames(final Locale locale) throws IllegalStateException {
+    final InternationalString[] inter = getCategoryNames();
+<span class="add">   final int length = inter.length;</span>
+<span class="add">   final String[] names = new String[length];</span>
+<span class="add">   for (int i = 0; i &lt; length; i++) {</span>
+        names[i] = inter[i].toString(locale);
+    }
+    return names;</pre></td></tr>
+<tr><td><pre>                                     final double[] values)
+{
+    if (values != null) {
+<span class="del">        for (int i=0; i&lt;values.length; i++) {</span>
+            final double v = values[i];
+            if (v&gt;=lower &amp;&amp; v&lt;upper) {
+                return true;</pre></td>
+<td><pre>                                     final double[] values)
+{
+    if (values != null) {
+<span class="add">     final int length = values.length;</span>
+<span class="add">     for (int i = 0; i &lt; length; i++) {</span>
+            final double v = values[i];
+            if (v&gt;=lower &amp;&amp; v&lt;upper) {
+                return true;</pre></td></tr>
+<tr><td><pre>}
+if (inverse == null) {
+    if (categories != null) {
+<span class="del">        inverse = new GridSampleDimension(categories.inverse);</span>
+        inverse.inverse = this;
+    } else {
+        /*</pre></td>
+<td><pre>}
+if (inverse == null) {
+    if (categories != null) {
+<span class="add">  inverse = new GridSampleDimension(description,</span>
+<span class="add">         categories.inverse);</span>
+        inverse.inverse = this;
+    } else {
+        /*</pre></td></tr>
+<tr><td><pre>if (color instanceof IndexColorModel) {
+    final IndexColorModel cm = (IndexColorModel) color;
+    final int[][] colors = new int[cm.getMapSize()][];
+<span class="del">    for (int i=0; i&lt;colors.length; i++) {</span>
+        colors[i] = new int[] {cm.getRed(i), cm.getGreen(i), cm.getBlue(i)};
+    }
+    return colors;</pre></td>
+<td><pre>if (color instanceof IndexColorModel) {
+    final IndexColorModel cm = (IndexColorModel) color;
+    final int[][] colors = new int[cm.getMapSize()][];
+<span class="add"> final int length = colors.length;</span>
+<span class="add"> for (int i = 0; i &lt; length; i++) {</span>
+        colors[i] = new int[] {cm.getRed(i), cm.getGreen(i), cm.getBlue(i)};
+    }
+    return colors;</pre></td></tr>
+<tr><td><pre>final MathTransform1D sampleToGeophysics = Category.createLinearTransform(scale, offset);
+final Category[] categories = (Category[]) getCategories().toArray();
+final Category[] reference  = (Category[]) categories.clone();
+<span class="del">for (int i=0; i&lt;categories.length; i++) {</span>
+    if (categories[i].isQuantitative()) {
+        categories[i] = categories[i].rescale(sampleToGeophysics);
+    }</pre></td>
+<td><pre> final MathTransform1D sampleToGeophysics = Category.createLinearTransform(scale, offset);
+ final Category[] categories = (Category[]) getCategories().toArray();
+ final Category[] reference  = (Category[]) categories.clone();
+<span class="add">final int length = categories.length;</span>
+<span class="add">for (int i = 0; i &lt; length; i++) {</span>
+     if (categories[i].isQuantitative()) {
+         categories[i] = categories[i].rescale(sampleToGeophysics);
+     }</pre></td></tr>
+<tr><td><pre>    if (Arrays.equals(categories, reference)) {
+        return this;
+    }
+<span class="del">    return new GridSampleDimension(categories, getUnits());</span>
+}
+
+/**</pre></td>
+<td><pre>    if (Arrays.equals(categories, reference)) {
+        return this;
+    }
+<span class="add">   return new GridSampleDimension(description, categories, getUnits());</span>
+}
+
+/**</pre></td></tr>
+</table>
+    </div>
+  </body>
+</html>

Added: sis/ip-review/rev/24925/CategoryList.xhtml
URL: http://svn.apache.org/viewvc/sis/ip-review/rev/24925/CategoryList.xhtml?rev=1847794&view=auto
==============================================================================
--- sis/ip-review/rev/24925/CategoryList.xhtml (added)
+++ sis/ip-review/rev/24925/CategoryList.xhtml Fri Nov 30 09:52:08 2018
@@ -0,0 +1,39 @@
+<!DOCTYPE html>
+<html xmlns="http://www.w3.org/1999/xhtml">
+  <head>
+    <meta charset="UTF-8"/>
+    <title>CategoryList changes for revisions 24924:24925</title>
+    <style type="text/css" media="all">
+      @import url("../../reports.css");
+    </style>
+  </head>
+  <body>
+    <div>
+      <h1>CategoryList changes for revisions 24924:24925</h1>
+<p>This commit propagates the package names change which was done in GeoAPI.
+There is no way such change could be done differently,
+since not renaming the packages cause a compilation error.</p>
+<p><b>Command line:</b></p>
+<blockquote><code>svn diff --extensions "--unified --ignore-space-change --ignore-all-space --ignore-eol-style" -r24924:24925 http://svn.osgeo.org/geotools/trunk/modules/library/coverage/src/main/java/org/geotools/coverage/CategoryList.java</code></blockquote>
+<table class="changes">
+<tr><th>Revision 24924</th><th>Revision 24925</th></tr>
+<tr><td><pre>import org.opengis.referencing.operation.MathTransform1D;
+import org.opengis.referencing.operation.Matrix;
+import org.opengis.referencing.operation.TransformException;
+<span class="del">import org.opengis.spatialschema.geometry.DirectPosition;</span>
+<span class="del">import org.opengis.spatialschema.geometry.MismatchedDimensionException;</span>
+import org.opengis.util.InternationalString;
+
+// Geotools dependencies</pre></td>
+<td><pre>import org.opengis.referencing.operation.MathTransform1D;
+import org.opengis.referencing.operation.Matrix;
+import org.opengis.referencing.operation.TransformException;
+<span class="add">import org.opengis.geometry.DirectPosition;</span>
+<span class="add">import org.opengis.geometry.MismatchedDimensionException;</span>
+import org.opengis.util.InternationalString;
+
+// Geotools dependencies</pre></td></tr>
+</table>
+    </div>
+  </body>
+</html>

Added: sis/ip-review/rev/29037/HEADER.html
URL: http://svn.apache.org/viewvc/sis/ip-review/rev/29037/HEADER.html?rev=1847794&view=auto
==============================================================================
--- sis/ip-review/rev/29037/HEADER.html (added)
+++ sis/ip-review/rev/29037/HEADER.html Fri Nov 30 09:52:08 2018
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html xmlns="http://www.w3.org/1999/xhtml">
+  <head>
+    <meta charset="UTF-8"/>
+    <title>Revision 29037</title>
+  </head>
+  <body>
+    <div>
+      <h1>Revision 29037</h1>
+<table>
+  <tr><td><b>Author:</b></td><td>simboss</td></tr>
+  <tr><td><b>Date:</b></td><td>2008-02-01</td></tr>
+  <tr><td><b>Message:</b></td><td>-improving bands creations for simple rasters</td></tr>
+</table>
+    </div>
+  </body>
+</html>

Added: sis/ip-review/rev/29037/SampleDimension.xhtml
URL: http://svn.apache.org/viewvc/sis/ip-review/rev/29037/SampleDimension.xhtml?rev=1847794&view=auto
==============================================================================
--- sis/ip-review/rev/29037/SampleDimension.xhtml (added)
+++ sis/ip-review/rev/29037/SampleDimension.xhtml Fri Nov 30 09:52:08 2018
@@ -0,0 +1,37 @@
+<!DOCTYPE html>
+<html xmlns="http://www.w3.org/1999/xhtml">
+  <head>
+    <meta charset="UTF-8"/>
+    <title>SampleDimension changes for revisions 29036:29037</title>
+    <style type="text/css" media="all">
+      @import url("../../reports.css");
+    </style>
+  </head>
+  <body>
+    <div>
+      <h1>SampleDimension changes for revisions 29036:29037</h1>
+
+<p>Fix for a spelling error in a comment. If not fixed by this commit, this error can be identified by IDE spell checker.</p>
+
+<p><b>Command line:</b></p>
+<blockquote><code>svn diff --extensions "--unified --ignore-space-change --ignore-all-space --ignore-eol-style" -r29036:29037 http://svn.osgeo.org/geotools/trunk/modules/library/coverage/src/main/java/org/geotools/coverage/GridSampleDimension.java</code></blockquote>
+<table class="changes">
+<tr><th>Revision 29036</th><th>Revision 29037</th></tr>
+<tr><td><pre>/*
+ * Checks the supplied description to see if it is null. In such a case it
+ * builds up a new description by using the list of categories supplied.
+<span class="del"> * This secondo description is much less human readable and it is therefore</span>
+ * much better if the user provide a meaningful name for this sample
+ * dimension.
+ */</pre></td>
+<td><pre>/*
+ * Checks the supplied description to see if it is null. In such a case it
+ * builds up a new description by using the list of categories supplied.
+<span class="add"> * This second description is much less human readable and it is therefore</span>
+ * much better if the user provide a meaningful name for this sample
+ * dimension.
+ */</pre></td></tr>
+</table>
+    </div>
+  </body>
+</html>



Mime
View raw message