This is an automated email from the ASF dual-hosted git repository.

asf-gitbox-commits pushed a commit to branch geoapi-4.0
in repository https://gitbox.apache.org/repos/asf/sis.git


The following commit(s) were added to refs/heads/geoapi-4.0 by this push:
     new b79a2bb608 Move `Summarizer` to an internal non-shared package. 
Refactor for removing an unnecessary inner class.
b79a2bb608 is described below

commit b79a2bb6085c5ba97135dcc003d4446f305de8a9
Author: Martin Desruisseaux <[email protected]>
AuthorDate: Sat Aug 8 12:07:54 2026 +0200

    Move `Summarizer` to an internal non-shared package.
    Refactor for removing an unnecessary inner class.
---
 .../apache/sis/coverage/grid/GridCoverage2D.java   |   4 +-
 .../main/org/apache/sis/image/PlanarImage.java     |   2 +-
 .../image/internal/{shared => }/Summarizer.java    | 149 +++++++++------------
 .../apache/sis/image/internal/package-info.java    |  28 ++++
 .../org/apache/sis/util/resources/Vocabulary.java  |  17 ++-
 .../sis/util/resources/Vocabulary.properties       |   3 +-
 .../sis/util/resources/Vocabulary_fr.properties    |   3 +-
 7 files changed, 112 insertions(+), 94 deletions(-)

diff --git 
a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/GridCoverage2D.java
 
b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/GridCoverage2D.java
index 8c9e4362e0..2b16babc7a 100644
--- 
a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/GridCoverage2D.java
+++ 
b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/GridCoverage2D.java
@@ -42,9 +42,9 @@ import org.opengis.referencing.operation.TransformException;
 import org.opengis.referencing.operation.MathTransform1D;
 import org.apache.sis.image.DataType;
 import org.apache.sis.coverage.SampleDimension;
+import org.apache.sis.image.internal.Summarizer;
 import org.apache.sis.image.internal.shared.ImageUtilities;
 import org.apache.sis.image.internal.shared.ReshapedImage;
-import org.apache.sis.image.internal.shared.Summarizer;
 import org.apache.sis.feature.internal.Resources;
 import org.apache.sis.util.ArraysExt;
 import org.apache.sis.util.Debug;
@@ -719,6 +719,6 @@ public class GridCoverage2D extends GridCoverage {
     void appendDataLayout(TreeTable.Node root, final Vocabulary vocabulary, 
final TableColumn<CharSequence> column) {
         root = root.newChild();
         root.setValue(column, 
vocabulary.getString(Vocabulary.Keys.RenderedImage));
-        new Summarizer(root, vocabulary, column).layout(data);
+        Summarizer.layout(data, root, column, vocabulary);
     }
 }
diff --git 
a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/image/PlanarImage.java
 
b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/image/PlanarImage.java
index c6e50e198b..d57e48e447 100644
--- 
a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/image/PlanarImage.java
+++ 
b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/image/PlanarImage.java
@@ -34,9 +34,9 @@ import org.apache.sis.util.Disposable;
 import org.apache.sis.util.resources.Errors;
 import org.apache.sis.coverage.SampleDimension;
 import org.apache.sis.coverage.grid.GridGeometry;       // For javadoc
+import org.apache.sis.image.internal.Summarizer;
 import org.apache.sis.image.internal.shared.ImageUtilities;
 import org.apache.sis.image.internal.shared.TileOpExecutor;
-import org.apache.sis.image.internal.shared.Summarizer;
 import org.apache.sis.feature.internal.Resources;
 import org.apache.sis.pending.jdk.JDK18;
 
diff --git 
a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/image/internal/shared/Summarizer.java
 
b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/image/internal/Summarizer.java
similarity index 67%
rename from 
endorsed/src/org.apache.sis.feature/main/org/apache/sis/image/internal/shared/Summarizer.java
rename to 
endorsed/src/org.apache.sis.feature/main/org/apache/sis/image/internal/Summarizer.java
index 87b25accda..0d4036a4d9 100644
--- 
a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/image/internal/shared/Summarizer.java
+++ 
b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/image/internal/Summarizer.java
@@ -14,124 +14,106 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.sis.image.internal.shared;
+package org.apache.sis.image.internal;
 
-import java.util.Locale;
 import java.text.NumberFormat;
 import java.awt.Image;
 import java.awt.image.RenderedImage;
 import org.apache.sis.image.PlanarImage;
 import org.apache.sis.util.CharSequences;
 import org.apache.sis.util.Classes;
-import org.apache.sis.util.Localized;
 import org.apache.sis.util.collection.DefaultTreeTable;
 import org.apache.sis.util.collection.TableColumn;
 import org.apache.sis.util.collection.TreeTable;
 import org.apache.sis.util.resources.Messages;
 import org.apache.sis.util.resources.Vocabulary;
 import org.apache.sis.feature.internal.Resources;
+import org.apache.sis.image.internal.shared.ColorModelFactory;
+import org.apache.sis.image.internal.shared.ImageUtilities;
 
 
 /**
  * Helper class for formatting a description of an image.
  * Used mostly for implementation of {@code toString()} methods for debugging 
purposes.
  *
+ * <p><b>Implementation details:</b>
+ * an instance of this class represents one row in the tree to format.
+ *
  * @author  Martin Desruisseaux (Geomatys)
  */
-public final class Summarizer implements Localized {
+public final class Summarizer {
     /**
-     * Root of the tree where to add a branch.
+     * A {@link Vocabulary.Keys} constant to use a label in the beginning of a 
row, or 0 if none.
      */
-    private final TreeTable.Node root;
+    private final short key;
 
     /**
-     * Localized resources for vocabulary.
+     * Label created from the vocabulary key.
      */
-    private final Vocabulary vocabulary;
+    private String label;
 
     /**
-     * The single column where to write texts.
+     * Description to write after the label.
      */
-    private final TableColumn<CharSequence> column;
+    private final String desc;
 
     /**
-     * Creates a new formatter for appending the image description in an 
existing tree.
-     *
-     * @param  root        root of the tree where to add a branch.
-     * @param  vocabulary  localized resources for vocabulary.
-     * @param  column      the single column where to write texts.
+     * Optional note as a child of the description.
      */
-    public Summarizer(final TreeTable.Node root, final Vocabulary vocabulary, 
final TableColumn<CharSequence> column) {
-        this.root       = root;
-        this.vocabulary = vocabulary;
-        this.column     = column;
-    }
+    private String note;
 
     /**
-     * Returns the locale used by this formatter.
-     *
-     * @return the locale.
+     * Prepares information about a new node.
      */
-    @Override
-    public final Locale getLocale() {
-        return vocabulary.getLocale();
+    private Summarizer(final short key, final CharSequence desc) {
+        this.key  = key;
+        this.desc = desc.toString();
     }
 
     /**
-     * A row to format.
+     * Resolves {@code #label} and returns its length.
      */
-    private static final class Row {
-        /** A {@link Vocabulary.Keys} constant, or 0 if none. */
-        private final short key;
-
-        /** Label created from the vocabulary key. */
-        private String label;
-
-        /** Description to write after the label. */
-        private final String desc;
-
-        /** Optional note as a child of the description. */
-        String note;
-
-        /** Prepares a new node. */
-        Row(final short key, final CharSequence desc) {
-            this.key  = key;
-            this.desc = desc.toString();
-        }
-
-        /** Resolves {@code #label} and returns its length. */
-        final int formatLabel(final Vocabulary vocabulary) {
-            if (key == 0) return 0;
-            label = vocabulary.getLabel(key);
-            return label.length();
-        }
+    private int formatLabel(final Vocabulary vocabulary) {
+        if (key == 0) return 0;
+        label = vocabulary.getLabel(key);
+        return label.length();
+    }
 
-        /** Returns a string representation using the given buffer as a 
temporary buffer. */
-        final String toString(final StringBuilder buffer, final int margin) {
-            if (label != null) {
-                buffer.append(label).append(CharSequences.spaces(margin - 
label.length()));
-            }
-            return buffer.append(desc).toString();
+    /**
+     * Returns a string representation using the given buffer as a temporary 
buffer.
+     */
+    private String toString(final StringBuilder buffer, final int margin) {
+        if (label != null) {
+            buffer.append(label).append(CharSequences.spaces(margin - 
label.length()));
         }
+        return buffer.append(desc).toString();
     }
 
     /**
      * Appends a "data layout" branch to the tree representation of an image 
description.
      * Contains information about image location, image size, tile size, 
sample model, color model.
      *
-     * @param  data  the image to describe.
+     * @param  data        the image to describe.
+     * @param  root        root of the tree where to add a branch.
+     * @param  column      the single column where to write texts.
+     * @param  vocabulary  localized resources for vocabulary.
      */
-    public void layout(final RenderedImage data) {
+    public static void layout(final RenderedImage data,
+                              final TreeTable.Node root,
+                              final TableColumn<CharSequence> column,
+                              final Vocabulary vocabulary)
+    {
         final int width     = data.getWidth();
         final int height    = data.getHeight();
         final var model     = data.getSampleModel();
-        final var nf        = NumberFormat.getIntegerInstance(getLocale());
-        final var resources = Resources.forLocale(getLocale());
+        final var locale    = vocabulary.getLocale();
+        final var nf        = NumberFormat.getIntegerInstance(locale);
+        final var resources = Resources.forLocale(locale);
         final var buffer    = new StringBuilder();
-        final var rows      = new Row[8];
+        final var rows      = new Summarizer[8];
         int count = 0;
         for (int c = 0; c < rows.length; c++) {
-            final Row row;
+            final Summarizer row;
             switch (c) {
                 /*
                  * Image name defined by a property (optional).
@@ -139,8 +121,8 @@ public final class Summarizer implements Localized {
                 case 0: {
                     final Object name = 
data.getProperty(PlanarImage.SOURCE_NAME_KEY);
                     if (name == null || name == Image.UndefinedProperty) 
continue;
-                    row = new Row(Vocabulary.Keys.Name,
-                                  
vocabulary.getString(Vocabulary.Keys.Quoted_1, name));
+                    row = new Summarizer(Vocabulary.Keys.Name,
+                            vocabulary.getString(Vocabulary.Keys.Quoted_1, 
name));
                     break;
                 }
                 /*
@@ -150,9 +132,9 @@ public final class Summarizer implements Localized {
                     final int x = data.getMinX();
                     final int y = data.getMinY();
                     if ((x | y) == 0) continue;
-                    row = new Row(Vocabulary.Keys.Origin,
-                                  buffer.append(nf.format(x)).append(", ")
-                                        .append(nf.format(y)));
+                    row = new Summarizer(Vocabulary.Keys.Origin,
+                            buffer.append(nf.format(x)).append(", ")
+                                  .append(nf.format(y)));
                     break;
                 }
                 /*
@@ -165,7 +147,7 @@ public final class Summarizer implements Localized {
                         buffer.append(" × ")
                               
.append(resources.getString(Resources.Keys.BandCount_1, model.getNumBands()));
                     }
-                    row = new Row(Vocabulary.Keys.ImageSize, buffer);
+                    row = new Summarizer(Vocabulary.Keys.Size, buffer);
                     break;
                 }
                 /*
@@ -179,7 +161,8 @@ public final class Summarizer implements Localized {
                     if (nx == 1 && ny == 1 && tx == width && ty == height) 
continue;
                     final String n = appendCount(buffer, nf, nx, 
ny).toString(); buffer.setLength(0);
                     final String s = appendCount(buffer, nf, tx, 
ty).toString();
-                    row = new Row(Vocabulary.Keys.Tiling, 
resources.getString(Resources.Keys.TileCountAndSize_2, n, s));
+                    row = new Summarizer(Vocabulary.Keys.Tiling,
+                            
resources.getString(Resources.Keys.TileCountAndSize_2, n, s));
                     break;
                 }
                 /*
@@ -199,7 +182,7 @@ public final class Summarizer implements Localized {
                         
buffer.append(vocabulary.getString(Vocabulary.Keys.InBetweenWords))
                               .append('‘').append(type).append('’');
                     }
-                    row = new Row(Vocabulary.Keys.DataType, buffer);
+                    row = new Summarizer(Vocabulary.Keys.Pixel, buffer);
                     break;
                 }
                 /*
@@ -207,8 +190,8 @@ public final class Summarizer implements Localized {
                  * some placeholder will be shown for suggesting that there is 
a problem.
                  */
                 case 5: {
-                    row = new Row(Vocabulary.Keys.Layout,
-                                  
CharSequences.camelCaseToSentence(Classes.getShortClassName(model)));
+                    row = new Summarizer(Vocabulary.Keys.Layout,
+                            
CharSequences.camelCaseToSentence(Classes.getShortClassName(model)));
                     break;
                 }
                 /*
@@ -224,7 +207,7 @@ public final class Summarizer implements Localized {
                         desc = note;
                         note = null;
                     }
-                    row = new Row(Vocabulary.Keys.Colors, desc);
+                    row = new Summarizer(Vocabulary.Keys.Colors, desc);
                     row.note = note;
                     break;
                 }
@@ -235,8 +218,8 @@ public final class Summarizer implements Localized {
                     if (!(data instanceof PlanarImage)) continue;
                     String warning = ((PlanarImage) data).verify();
                     if (warning == null) continue;
-                    row = new Row((short) 0,
-                            
Messages.forLocale(getLocale()).getString(Messages.Keys.PossibleInconsistency_1,
 warning));
+                    row = new Summarizer((short) 0,
+                            
Messages.forLocale(locale).getString(Messages.Keys.PossibleInconsistency_1, 
warning));
                     break;
                 }
                 /*
@@ -253,7 +236,7 @@ public final class Summarizer implements Localized {
         }
         margin++;
         for (int i=0; i<count; i++) {
-            final Row row = rows[i];
+            final Summarizer row = rows[i];
             final TreeTable.Node child = root.newChild();
             child.setValue(column, row.toString(buffer, margin));
             buffer.setLength(0);
@@ -274,15 +257,15 @@ public final class Summarizer implements Localized {
     /**
      * Returns a summary of the given image as a tree.
      *
-     * @param  image  the image to summarize.
+     * @param  data  the image to summarize.
      * @return a tree presentation of the properties of the image.
      */
-    public static String toString(final RenderedImage image) {
+    public static String toString(final RenderedImage data) {
         final TableColumn<CharSequence> column = TableColumn.VALUE_AS_TEXT;
         final var tree = new DefaultTreeTable(column);
-        final var c = new Summarizer(tree.getRoot(), 
Vocabulary.forLocale(null), column);
-        c.root.setValue(column, Classes.getShortClassName(image));
-        c.layout(image);
+        final TreeTable.Node root = tree.getRoot();
+        root.setValue(column, Classes.getShortClassName(data));
+        layout(data, root, column, Vocabulary.forLocale(null));
         return tree.toString();
     }
 }
diff --git 
a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/image/internal/package-info.java
 
b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/image/internal/package-info.java
new file mode 100644
index 0000000000..3e69db9474
--- /dev/null
+++ 
b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/image/internal/package-info.java
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * A set of helper classes for rendered images internal to this module.
+ *
+ * <p><strong>Do not use!</strong></p>
+ *
+ * This package is for internal use by SIS only. Classes in this package
+ * may change in incompatible ways in any future version without notice.
+ *
+ * @author  Martin Desruisseaux (Geomatys)
+ */
+package org.apache.sis.image.internal;
diff --git 
a/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/resources/Vocabulary.java
 
b/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/resources/Vocabulary.java
index d054704d1d..321ef59cc1 100644
--- 
a/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/resources/Vocabulary.java
+++ 
b/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/resources/Vocabulary.java
@@ -648,11 +648,6 @@ public class Vocabulary extends IndexedResourceBundle {
          */
         public static final short Identity = 101;
 
-        /**
-         * Image
-         */
-        public static final short Image = 102;
-
         /**
          * Image size
          */
@@ -1048,6 +1043,11 @@ public class Vocabulary extends IndexedResourceBundle {
          */
         public static final short Paths = 159;
 
+        /**
+         * Pixel
+         */
+        public static final short Pixel = 293;
+
         /**
          * Plug-ins
          */
@@ -1136,7 +1136,7 @@ public class Vocabulary extends IndexedResourceBundle {
         /**
          * Rendered image
          */
-        public static final short RenderedImage = 103;
+        public static final short RenderedImage = 102;
 
         /**
          * Representative value
@@ -1198,6 +1198,11 @@ public class Vocabulary extends IndexedResourceBundle {
          */
         public static final short Simplified = 180;
 
+        /**
+         * Size
+         */
+        public static final short Size = 103;
+
         /**
          * {0}/{1}
          */
diff --git 
a/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/resources/Vocabulary.properties
 
b/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/resources/Vocabulary.properties
index 39ccbb51ac..56275c8c10 100644
--- 
a/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/resources/Vocabulary.properties
+++ 
b/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/resources/Vocabulary.properties
@@ -131,7 +131,6 @@ Height                  = Height
 Identifier              = Identifier
 Identifiers             = Identifiers
 Identity                = Identity
-Image                   = Image
 Image_1                 = Image #{0}
 ImageSize               = Image size
 Implementation          = Implementation
@@ -211,6 +210,7 @@ Page_2                  = Page {0} of {1}
 Panchromatic            = Panchromatic
 Parenthesis_2           = {0} ({1})
 Paths                   = Paths
+Pixel                   = Pixel
 Plugins                 = Plug-ins
 PlusDependencies_1      = {0} + dependencies
 Preprocessing           = Preprocessing
@@ -241,6 +241,7 @@ SameDatumEnsemble       = Same datum ensemble
 SampleDimensions        = Sample dimensions
 Scale                   = Scale
 Simplified              = Simplified
+Size                    = Size
 SlashSeparatedList_2    = {0}/{1}
 Slower                  = Slower
 Slowness                = Slowness
diff --git 
a/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/resources/Vocabulary_fr.properties
 
b/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/resources/Vocabulary_fr.properties
index fee589028b..447860c87c 100644
--- 
a/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/resources/Vocabulary_fr.properties
+++ 
b/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/resources/Vocabulary_fr.properties
@@ -138,7 +138,6 @@ Height                  = Hauteur
 Identifier              = Identifiant
 Identifiers             = Identifiants
 Identity                = Identit\u00e9
-Image                   = Image
 Image_1                 = Image {0}
 ImageSize               = Taille de l\u2019image
 Implementation          = Impl\u00e9mentation
@@ -218,6 +217,7 @@ Page_2                  = Page {0} de {1}
 Panchromatic            = Panchromatique
 Parenthesis_2           = {0} ({1})
 Paths                   = Chemins
+Pixel                   = Pixel
 Plugins                 = Modules d\u2019extension
 PlusDependencies_1      = {0} + d\u00e9pendances
 Preprocessing           = Pr\u00e9traitement
@@ -248,6 +248,7 @@ SameDatumEnsemble       = M\u00eame ensemble de 
r\u00e9f\u00e9rentiels
 SampleDimensions        = Dimensions d\u2019\u00e9chantillonnage
 Scale                   = \u00c9chelle
 Simplified              = Simplifi\u00e9
+Size                    = Taille
 SlashSeparatedList_2    = {0}/{1}
 Slower                  = Plus lent
 Slowness                = Lenteur

Reply via email to