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

jsorel 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 7602b6cb17 feat(JavaFx): add a simple tile matrix set panel in 
CoverageExplorer
7602b6cb17 is described below

commit 7602b6cb178b28e58967b1b099761c606e00d2db
Author: jsorel <[email protected]>
AuthorDate: Fri Oct 4 16:43:01 2024 +0200

    feat(JavaFx): add a simple tile matrix set panel in CoverageExplorer
---
 .../org/apache/sis/util/resources/Vocabulary.java  |   5 +
 .../sis/util/resources/Vocabulary.properties       |   1 +
 .../sis/util/resources/Vocabulary_fr.properties    |   1 +
 .../apache/sis/gui/coverage/TileMatrixSetPane.java | 128 +++++++++++++++++++++
 .../apache/sis/gui/dataset/ResourceExplorer.java   |  16 +++
 5 files changed, 151 insertions(+)

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 b4cddd1f8d..51f06ea65a 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
@@ -1249,6 +1249,11 @@ public class Vocabulary extends IndexedResourceBundle {
          */
         public static final short Thermal = 260;
 
+        /**
+         * Tile matrix sets
+         */
+        public static final short TileMatrixSets = 282;
+
         /**
          * Tile size
          */
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 6b870cc509..ce0dbaabdc 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
@@ -254,6 +254,7 @@ Temporal_1              = Temporal ({0})
 TemporalExtent          = Temporal extent
 TemporaryFiles          = Temporary files
 Thermal                 = Thermal
+TileMatrixSets          = Tile matrix sets
 TileSize                = Tile size
 Time                    = Time
 Time_1                  = {0} time
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 89762168e2..0075eb99e2 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
@@ -261,6 +261,7 @@ Temporal_1              = Temporel ({0})
 TemporalExtent          = Plage temporelle
 TemporaryFiles          = Fichiers temporaires
 Thermal                 = Thermique
+TileMatrixSets          = Set de matrices de tuile
 TileSize                = Taille des tuiles
 Time                    = Temps
 Time_1                  = Heure {0}
diff --git 
a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/coverage/TileMatrixSetPane.java
 
b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/coverage/TileMatrixSetPane.java
new file mode 100644
index 0000000000..453af8e00b
--- /dev/null
+++ 
b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/coverage/TileMatrixSetPane.java
@@ -0,0 +1,128 @@
+/*
+ * 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.
+ */
+package org.apache.sis.gui.coverage;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+import javafx.scene.control.TextArea;
+import javafx.scene.layout.BorderPane;
+import org.apache.sis.geometry.GeneralEnvelope;
+import org.apache.sis.referencing.IdentifiedObjects;
+import org.apache.sis.storage.DataStoreException;
+import org.apache.sis.storage.Resource;
+import org.apache.sis.storage.tiling.TileMatrix;
+import org.apache.sis.storage.tiling.TileMatrixSet;
+import org.apache.sis.storage.tiling.TiledResource;
+import org.apache.sis.util.Classes;
+
+/**
+ * A view to the internal tile matrices defined in a Resource.
+ *
+ * @todo change the text area to a split pane with a tree view on the left and 
a description pane on the right
+ * @todo if the resource is writable, add tiling modification controls
+ * @author Johann Sorel (Geomatys)
+ */
+public class TileMatrixSetPane extends BorderPane{
+
+    private final TextArea area = new TextArea();
+
+    public TileMatrixSetPane() {
+        area.setMaxSize(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY);
+        area.setEditable(false);
+        setCenter(area);
+    }
+
+    public void setContent(Resource resource) {
+        final StringBuilder sb = new StringBuilder();
+        if (resource instanceof TiledResource) {
+            final TiledResource tr = (TiledResource) resource;
+            try {
+                for (TileMatrixSet tms : tr.getTileMatrixSets()) {
+                    sb.append(toString(tms));
+                }
+            } catch (DataStoreException ex){
+                sb.append(ex.getMessage());
+            }
+        } else {
+            sb.append("Resource has no tile matrices.");
+        }
+
+        area.setText(sb.toString());
+    }
+
+    /**
+     * Pretty print output of given pyramid.
+     * @param pyramid not null
+     */
+    public static String toString(TileMatrixSet pyramid) {
+        final List<String> elements = new ArrayList<>();
+        elements.add("id : " + pyramid.getIdentifier());
+        elements.add("crs : " + 
IdentifiedObjects.getIdentifierOrName(pyramid.getCoordinateReferenceSystem()));
+        elements.add(toStringTree("matrices", 
pyramid.getTileMatrices().values().stream().map(TileMatrixSetPane::toString).toList()));
+        return toStringTree(Classes.getShortClassName(pyramid), elements);
+    }
+
+    /**
+     * Pretty print outut of given mosaic.
+     * @param matrix not null
+     */
+    public static String toString(TileMatrix matrix) {
+        final StringBuilder sb = new 
StringBuilder(Classes.getShortClassName(matrix));
+        sb.append("   id = ").append(matrix.getIdentifier());
+        sb.append("   resolution = 
").append(Arrays.toString(matrix.getTilingScheme().getResolution(true)));
+        sb.append("   gridSize = 
").append(matrix.getTilingScheme().getExtent());
+        sb.append("   bbox = ").append(new 
GeneralEnvelope(matrix.getTilingScheme().getEnvelope()).toString());
+        return sb.toString();
+    }
+
+    /**
+     * Returns a graphical representation of the specified objects. This 
representation can be
+     * printed to the {@linkplain System#out standard output stream} (for 
example) if it uses
+     * a monospaced font and supports unicode.
+     *
+     * @param  root  The root name of the tree to format.
+     * @param  objects The objects to format as root children.
+     * @return A string representation of the tree.
+     */
+    public static String toStringTree(String root, final Iterable<?> objects) {
+        final StringBuilder sb = new StringBuilder();
+        if (root != null) {
+            sb.append(root);
+        }
+        if (objects != null) {
+            final Iterator<?> ite = objects.iterator();
+            while (ite.hasNext()) {
+                sb.append('\n');
+                final Object next = ite.next();
+                final boolean last = !ite.hasNext();
+                sb.append(last ? "\u2514\u2500 " : "\u251C\u2500 ");
+
+                final String[] parts = String.valueOf(next).split("\n");
+                sb.append(parts[0]);
+                for (int k=1;k<parts.length;k++) {
+                    sb.append('\n');
+                    sb.append(last ? ' ' : '\u2502');
+                    sb.append("  ");
+                    sb.append(parts[k]);
+                }
+            }
+        }
+        return sb.toString();
+    }
+}
diff --git 
a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/dataset/ResourceExplorer.java
 
b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/dataset/ResourceExplorer.java
index 247357627a..53f0798734 100644
--- 
a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/dataset/ResourceExplorer.java
+++ 
b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/dataset/ResourceExplorer.java
@@ -50,6 +50,7 @@ import org.apache.sis.gui.metadata.MetadataTree;
 import org.apache.sis.gui.metadata.StandardMetadataTree;
 import org.apache.sis.gui.coverage.ImageRequest;
 import org.apache.sis.gui.coverage.CoverageExplorer;
+import org.apache.sis.gui.coverage.TileMatrixSetPane;
 import org.apache.sis.util.collection.TreeTable;
 import org.apache.sis.util.resources.Vocabulary;
 import org.apache.sis.gui.internal.BackgroundThreads;
@@ -92,12 +93,23 @@ public class ResourceExplorer extends Widget {
      */
     private final MetadataTree nativeMetadata;
 
+    /**
+     * The widget showing selected resource tile matrix sets.
+     * Its content will be updated only when the tab is visible.
+     */
+    private final TileMatrixSetPane matrices;
+
     /**
      * The tab containing {@link #nativeMetadata}.
      * The table title will change depending on the selected resource.
      */
     private final Tab nativeMetadataTab;
 
+    /**
+     * The tab containing TileMatrixSet view.
+     */
+    private final Tab tileMatrixSetTab;
+
     /**
      * Default label for {@link #nativeMetadataTab} when no resource is 
selected.
      */
@@ -190,6 +202,7 @@ public class ResourceExplorer extends Widget {
          */
         metadata = new MetadataSummary();
         nativeMetadata = new MetadataTree(metadata);
+        matrices = new TileMatrixSetPane();
         final LogViewer logging = new LogViewer(vocabulary);
         selectedResource = new ReadOnlyObjectWrapper<>(this, 
"selectedResource");
         logging.source.bind(selectedResource);
@@ -200,6 +213,7 @@ public class ResourceExplorer extends Widget {
             tableTab          = new 
Tab(vocabulary.getString(Vocabulary.Keys.Data)),
             metadataTab       = new 
Tab(vocabulary.getString(Vocabulary.Keys.Metadata), new 
StandardMetadataTree(metadata)),
             nativeMetadataTab = new 
Tab(vocabulary.getString(Vocabulary.Keys.Format),   nativeMetadata),
+            tileMatrixSetTab  = new 
Tab(vocabulary.getString(Vocabulary.Keys.TileMatrixSets),   matrices),
             loggingTab        = new 
Tab(vocabulary.getString(Vocabulary.Keys.Logs),     logging.getView()));
 
         tabs.setTabClosingPolicy(TabPane.TabClosingPolicy.UNAVAILABLE);
@@ -467,6 +481,7 @@ public class ResourceExplorer extends Widget {
      * @see #updateDataTabWithDefault(Resource)
      */
     private boolean updateDataTab(final Resource resource) {
+        if (resource != null) 
System.out.println(resource.getClass().getName());
         Region       image  = null;
         Region       table  = null;
         FeatureSet   data   = null;
@@ -487,6 +502,7 @@ public class ResourceExplorer extends Widget {
             }
             grid = new ImageRequest((GridCoverageResource) resource, null, 
null);
             cpanes = coverage.getControls(type);
+            matrices.setContent(resource);
         } else if (resource instanceof FeatureSet) {
             data = (FeatureSet) resource;
             if (features == null) {

Reply via email to