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

desruisseaux 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 e49c660ef2 Adjustment in documentation, formatting and checks for null 
values. Removal of a new method which is not going to be used after all.
e49c660ef2 is described below

commit e49c660ef2f133a46fabbf06aee3872c51256248
Author: Martin Desruisseaux <[email protected]>
AuthorDate: Sat Mar 28 15:30:48 2026 +0100

    Adjustment in documentation, formatting and checks for null values.
    Removal of a new method which is not going to be used after all.
---
 .../org/apache/sis/portrayal/PlanarCanvas.java     |  7 ++---
 .../main/org/apache/sis/map/MapItem.java           |  8 ++----
 .../apache/sis/gui/coverage/CoverageCanvas.java    |  2 +-
 .../apache/sis/gui/coverage/CoverageExplorer.java  |  4 +--
 .../apache/sis/gui/coverage/ViewAndControls.java   | 12 +++++----
 .../org/apache/sis/gui/dataset/ResourceItem.java   | 10 ++++----
 .../org/apache/sis/gui/dataset/ResourceTree.java   | 30 +++++-----------------
 .../org/apache/sis/gui/dataset/RootResource.java   | 13 ++++++++--
 8 files changed, 39 insertions(+), 47 deletions(-)

diff --git 
a/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/portrayal/PlanarCanvas.java
 
b/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/portrayal/PlanarCanvas.java
index 5fc91a75e9..5842a823c8 100644
--- 
a/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/portrayal/PlanarCanvas.java
+++ 
b/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/portrayal/PlanarCanvas.java
@@ -107,9 +107,10 @@ public abstract class PlanarCanvas extends Canvas {
      * {@link Units#PIXEL} and coordinate values are usually (but not 
necessarily) integers.
      *
      * <p>This value may be {@code null} on newly created {@code Canvas}, 
before data are added and canvas
-     * is configured. It should not be {@code null} anymore once a {@code 
Canvas} is ready for displaying.
-     * The returned envelope is a copy; display changes happening after this 
method invocation will not be
-     * reflected in the returned envelope.</p>
+     * is configured. It should not be {@code null} anymore once a {@code 
Canvas} is ready for displaying.</p>
+     *
+     * <p>The returned envelope is a copy:
+     * display changes happening after this method invocation will not be 
reflected in the returned envelope.</p>
      *
      * @return size and location of the display device in pixel coordinates.
      *
diff --git 
a/incubator/src/org.apache.sis.portrayal.map/main/org/apache/sis/map/MapItem.java
 
b/incubator/src/org.apache.sis.portrayal.map/main/org/apache/sis/map/MapItem.java
index 2ba0cd4558..3b4404491e 100644
--- 
a/incubator/src/org.apache.sis.portrayal.map/main/org/apache/sis/map/MapItem.java
+++ 
b/incubator/src/org.apache.sis.portrayal.map/main/org/apache/sis/map/MapItem.java
@@ -44,10 +44,6 @@ import org.apache.sis.portrayal.Observable;
  * <h2>Synchronization</h2>
  * {@code MapItem} instances are not thread-safe. Synchronization, if desired, 
is caller responsibility.
  *
- * @todo Rename as {@code LayerNode}? "Item" suggests an element in a list, 
while {@link MapLayers} actually
- *       creates a tree. Furthermore, having {@code Layer} in the name would 
add emphasis that this is a tree
- *       of layers and not a tree of arbitrary objects.
- *
  * @author  Johann Sorel (Geomatys)
  */
 public abstract class MapItem extends Observable {
@@ -132,7 +128,7 @@ public abstract class MapItem extends Observable {
      *
      * @see #getUserProperties()
      */
-    private Map<String,Object> userMap;
+    private Map<String, Object> userMap;
 
     /**
      * Only used by classes in this package.
@@ -283,7 +279,7 @@ public abstract class MapItem extends Observable {
      *         are immediately reflected in this {@code MapItem}.
      */
     @SuppressWarnings("ReturnOfCollectionOrArrayField")
-    public Map<String,Object> getUserProperties() {
+    public Map<String, Object> getUserProperties() {
         if (userMap == null) {
             userMap = new HashMap<>();
         }
diff --git 
a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/coverage/CoverageCanvas.java
 
b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/coverage/CoverageCanvas.java
index 9f9e94320b..20ceee15a7 100644
--- 
a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/coverage/CoverageCanvas.java
+++ 
b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/coverage/CoverageCanvas.java
@@ -987,7 +987,7 @@ public class CoverageCanvas extends MapCanvasAWT {
                 resampledImage = canvas.resampledImage;
             }
             final Insets margin = canvas.imageMargin.get();
-            if (margin != null) {
+            if (margin != null && displayBounds != null) {
                 final double top  = margin.getTop();
                 final double left = margin.getLeft();
                 displayBounds.x      -= left;
diff --git 
a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/coverage/CoverageExplorer.java
 
b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/coverage/CoverageExplorer.java
index 17909fe1c0..71ac26f3b2 100644
--- 
a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/coverage/CoverageExplorer.java
+++ 
b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/coverage/CoverageExplorer.java
@@ -36,6 +36,7 @@ import javafx.beans.property.SimpleObjectProperty;
 import org.apache.sis.storage.DataStoreException;
 import org.apache.sis.storage.GridCoverageResource;
 import org.apache.sis.coverage.grid.GridCoverage;
+import org.apache.sis.portrayal.RenderException;
 import org.apache.sis.gui.Widget;
 import org.apache.sis.gui.internal.FontGIS;
 import org.apache.sis.gui.internal.DataStoreOpener;
@@ -43,7 +44,6 @@ import org.apache.sis.gui.internal.Resources;
 import org.apache.sis.gui.internal.ToolbarButton;
 import org.apache.sis.gui.internal.NonNullObjectProperty;
 import org.apache.sis.gui.internal.PrivateAccess;
-import org.apache.sis.portrayal.RenderException;
 import org.apache.sis.gui.referencing.RecentReferenceSystems;
 import org.apache.sis.gui.dataset.WindowHandler;
 import org.apache.sis.gui.map.StatusBar;
@@ -72,7 +72,7 @@ import org.apache.sis.gui.map.StatusBar;
  * implementation may generalize to {@link org.opengis.coverage.Coverage} 
instances.
  *
  * @author  Martin Desruisseaux (Geomatys)
- * @version 1.5
+ * @version 1.7
  *
  * @see CoverageCanvas
  * @see GridView
diff --git 
a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/coverage/ViewAndControls.java
 
b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/coverage/ViewAndControls.java
index 1f0b88e8e2..5c3d3d6817 100644
--- 
a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/coverage/ViewAndControls.java
+++ 
b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/coverage/ViewAndControls.java
@@ -32,7 +32,6 @@ import javafx.scene.text.Font;
 import javafx.scene.text.FontWeight;
 import javafx.collections.ObservableList;
 import org.apache.sis.gui.internal.Styles;
-import org.apache.sis.storage.Resource;
 import org.apache.sis.storage.GridCoverageResource;
 import org.apache.sis.coverage.grid.GridCoverage;
 import org.apache.sis.coverage.grid.GridGeometry;
@@ -43,10 +42,13 @@ import org.apache.sis.gui.map.StatusBar;
 
 /**
  * A {@link GridView} or {@link CoverageCanvas} together with the controls to 
show in a {@link CoverageExplorer}.
- * When the image or coverage is updated in a view, the {@link 
#coverageChanged(Resource, GridCoverage)} method
- * is invoked, which will in turn update the {@link CoverageExplorer} 
properties. Coverage changes are applied
- * on the view then propagated to {@code CoverageExplorer} rather than the 
opposite direction because loading
- * mechanisms are implemented in the view (different views may load a 
different amount of data).
+ * When the image or coverage is updated in a view, the {@link 
#load(ImageRequest)} method is invoked,
+ * which will in turn update the {@link CoverageExplorer} properties.
+ *
+ * <h2>Design note about events</h2>
+ * Coverage changes are applied on the view, which will then propagated the 
event to the {@code CoverageExplorer},
+ * rather than the opposite direction because loading mechanisms are 
implemented in the view: different views may
+ * load a different amount of data.
  *
  * @author  Martin Desruisseaux (Geomatys)
  */
diff --git 
a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/dataset/ResourceItem.java
 
b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/dataset/ResourceItem.java
index 47af0b4c88..89e574870d 100644
--- 
a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/dataset/ResourceItem.java
+++ 
b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/dataset/ResourceItem.java
@@ -94,9 +94,9 @@ final class ResourceItem extends TreeItem<Resource> {
     private boolean isLeaf;
 
     /**
-     * Whether the list of children has been determined. We use this flag in 
order
-     * to fetch children only when first requested, since this process is 
costly.
-     * This flag is ignored if {@link #isLeaf} is {@code true}.
+     * Whether the list of children has been determined or is about to be 
determined
+     * (pending completion of a background task). We use this flag in order to 
fetch
+     * children only when first requested, since this process is costly.
      *
      * @todo Register {@link org.apache.sis.storage.event.StoreListener} and 
reset
      *       this flag to {@code false} if the resource content or structure 
changed.
@@ -285,7 +285,7 @@ final class ResourceItem extends TreeItem<Resource> {
          */
         @Override
         protected void succeeded() {
-            getChildren().setAll(getValue());
+            ResourceItem.super.getChildren().setAll(getValue());
         }
 
         /**
@@ -296,7 +296,7 @@ final class ResourceItem extends TreeItem<Resource> {
         @Override
         @SuppressWarnings("unchecked")
         protected void failed() {
-            getChildren().setAll(new ResourceItem(getException()));
+            ResourceItem.super.getChildren().setAll(new 
ResourceItem(getException()));
         }
     }
 
diff --git 
a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/dataset/ResourceTree.java
 
b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/dataset/ResourceTree.java
index 8f472966a4..4bbe0a74e4 100644
--- 
a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/dataset/ResourceTree.java
+++ 
b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/dataset/ResourceTree.java
@@ -32,7 +32,6 @@ import javafx.concurrent.Task;
 import javafx.collections.ObservableList;
 import javafx.beans.property.ObjectProperty;
 import javafx.beans.property.SimpleObjectProperty;
-import javafx.beans.property.ReadOnlyStringProperty;
 import javafx.event.EventHandler;
 import javafx.scene.control.TreeItem;
 import javafx.scene.control.TreeView;
@@ -341,26 +340,6 @@ public class ResourceTree extends TreeView<Resource> {
         event.consume();
     }
 
-    /**
-     * Returns the text which is shown in the <abbr>GUI</abbr> for the given 
resource.
-     * This returned property may have a temporarily {@code null} value or a 
placeholder such as "Loading…",
-     * then be updated to its final value after a background process finished 
to fetch the resource's label.
-     *
-     * <p>This method must be invoked from the JavaFX application thread.</p>
-     *
-     * @param  resource  the resource for which to get the label, or {@code 
null}.
-     * @return the label of the given resource, or {@code null} if the 
resource has not been found.
-     *
-     * @since 1.7
-     */
-    public ReadOnlyStringProperty getLabelOf(final Resource resource) {
-        final TreeItem<Resource> item = findOrRemove(resource, false);
-        if (item instanceof ResourceItem) {
-            return ((ResourceItem) item).label;
-        }
-        return null;
-    }
-
     /**
      * Removes the given resource from this tree and closes the resource if it 
is a {@link DataStore} instance.
      * It is caller's responsibility to ensure that the given resource is not 
used anymore.
@@ -412,8 +391,13 @@ public class ResourceTree extends TreeView<Resource> {
 
     /**
      * Verifies if the given resource is one of the roots, and optionally 
removes it.
-     * If {@code remove} is {@code true}, then it is caller's responsibility 
to close
-     * the resource.
+     * This method is for locating {@link DataStore}s instead of arbitrary 
resources.
+     * If {@code remove} is {@code true}, then it is caller's responsibility 
to close the data store.
+     *
+     * <p>This method does not search recursively in sub-trees because listing 
the children is potentially
+     * costly, as it may cause the loading of resources. Note that even if we 
accepted to pay this cost,
+     * {@link ResourceItem#getChildren()} may return an initially empty list 
and populate it only later,
+     * after completion of a background thread. Therefore, it is difficult to 
iterate over the children.</p>
      *
      * <p>This method must be invoked from the JavaFX application thread.</p>
      *
diff --git 
a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/dataset/RootResource.java
 
b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/dataset/RootResource.java
index 0d92751c98..2793cefbfd 100644
--- 
a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/dataset/RootResource.java
+++ 
b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/dataset/RootResource.java
@@ -33,9 +33,11 @@ import org.apache.sis.storage.Resource;
  */
 final class RootResource implements Aggregate {
     /**
-     * The children to expose as an unmodifiable list of components.
+     * A modifiable list of children, but viewed in public <abbr>API</abbr> as 
an unmodifiable list.
      * The elements of this list should be {@link ResourceItem} instances,
      * but this class is tolerant to other classes.
+     *
+     * @see #components()
      */
     private final List<TreeItem<Resource>> components;
 
@@ -55,7 +57,14 @@ final class RootResource implements Aggregate {
 
     /**
      * Checks whether this root contains the given resource as a direct child.
-     * This method does not search recursively in sub-trees.
+     * This method does not search recursively in sub-trees because listing the
+     * children is potentially costly, as it may cause the loading of 
resources.
+     * This method is more for locating data stores than arbitrary resources.
+     *
+     * <p>Note that even if we accepted to pay the cost of computing the list 
of children,
+     * {@link ResourceItem#getChildren()} may return an initially empty list 
and populate
+     * it only later, after completion of a background thread. Therefore, it 
is difficult
+     * to iterate over the children anyway.</p>
      *
      * @param  resource  the resource to search.
      * @param  remove    whether to remove the resource if found.

Reply via email to