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
commit 968f30a4fb22cb872ab1281d57cff0c94e2cf38e Author: Martin Desruisseaux <[email protected]> AuthorDate: Wed Apr 22 12:23:19 2026 +0200 Show the name of the map projection in multi-canvas views too. Before this commit, it was shown only in the overview. --- .../apache/sis/gui/coverage/CoverageControls.java | 5 +++ .../org/apache/sis/gui/internal/Resources.java | 2 +- .../apache/sis/gui/internal/Resources.properties | 2 +- .../sis/gui/internal/Resources_fr.properties | 2 +- .../main/org/apache/sis/gui/map/MultiCanvas.java | 45 +++++++++++++++++++++- 5 files changed, 51 insertions(+), 5 deletions(-) diff --git a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/coverage/CoverageControls.java b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/coverage/CoverageControls.java index 4a72073d0c..1a20a81632 100644 --- a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/coverage/CoverageControls.java +++ b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/coverage/CoverageControls.java @@ -79,6 +79,11 @@ final class CoverageControls extends ViewAndControls { final MapMenu menu = new MapMenu(view); menu.addReferenceSystems(owner.referenceSystems); menu.addCopyOptions(status); + /* + * Add listeners for showing the name of the selected CRS on the status bar. + * Note: this code is duplicated in the `MultiCanvas.Controls` constructor. + * For deduplicating, the code to remove should be this `CoverageControls`. + */ final ObservableObjectValue<String> mapCRS = menu.selectedReferenceSystem().orElse(null); if (mapCRS == null) { referenceSystemTooltip = null; diff --git a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/internal/Resources.java b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/internal/Resources.java index b2f6871bf9..c789f97385 100644 --- a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/internal/Resources.java +++ b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/internal/Resources.java @@ -397,7 +397,7 @@ public class Resources extends IndexedResourceBundle { public static final short SelectCRS = 30; /** - * For changing the projection, use contextual menu on the map. + * For changing the projection, use contextual menu. */ public static final short SelectCrsByContextMenu = 49; diff --git a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/internal/Resources.properties b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/internal/Resources.properties index d8fe843802..4af99abd0c 100644 --- a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/internal/Resources.properties +++ b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/internal/Resources.properties @@ -88,7 +88,7 @@ ReferenceByCellIndices = Reference by cell indices ReferenceByIdentifiers = Reference system by identifiers RemoveCanvasFromMosaic = Remove this map from the mosaic. SelectCRS = Select a coordinate reference system -SelectCrsByContextMenu = For changing the projection, use contextual menu on the map. +SelectCrsByContextMenu = For changing the projection, use contextual menu. SelectParentLogger = Select parent logger SendTo = Send to ShowTileReadEvents = Visual indication of tile readings diff --git a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/internal/Resources_fr.properties b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/internal/Resources_fr.properties index 91f843d95f..6a31005091 100644 --- a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/internal/Resources_fr.properties +++ b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/internal/Resources_fr.properties @@ -93,7 +93,7 @@ ReferenceByCellIndices = R\u00e9f\u00e9rencement par indices de cellules ReferenceByIdentifiers = Syst\u00e8me de r\u00e9f\u00e9rence par identifiants RemoveCanvasFromMosaic = Retirer cette carte de la mosa\u00efque. SelectCRS = Choisir un syst\u00e8me de r\u00e9f\u00e9rence des coordonn\u00e9es -SelectCrsByContextMenu = Pour changer la projection, utilisez le menu contextuel sur la carte. +SelectCrsByContextMenu = Pour changer la projection, utilisez le menu contextuel. SelectParentLogger = Choisir le journal parent SendTo = Envoyer vers ShowTileReadEvents = Indication visuelle des lectures de tuiles diff --git a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/map/MultiCanvas.java b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/map/MultiCanvas.java index 02151226af..eb56df9176 100644 --- a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/map/MultiCanvas.java +++ b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/map/MultiCanvas.java @@ -31,6 +31,7 @@ import javafx.beans.Observable; import javafx.beans.InvalidationListener; import javafx.beans.value.ChangeListener; import javafx.beans.value.ObservableValue; +import javafx.beans.value.ObservableObjectValue; import javafx.scene.Node; import javafx.scene.control.Label; import javafx.scene.control.Button; @@ -150,6 +151,12 @@ final class MultiCanvas extends Widget implements Observable { */ final List<GestureFollower> followers; + /** + * Tool tip for the name of the reference system shown in the status bar. + * The tip suggests to use the contextual menu for changing the <abbr>CRS</abbr>. + */ + private final Tooltip tooltip; + /** * Creates new controls for a new map canvas, then registers the listeners. * Note that these listeners create cyclic references: most references are from {@code canvas} to {@code owner} @@ -161,13 +168,47 @@ final class MultiCanvas extends Widget implements Observable { */ Controls(final MultiCanvas owner, final MapCanvas canvas) { followers = new ArrayList<>(); - title = new Label(); - status = new StatusBar(owner.referenceSystems); + title = new Label(); + status = new StatusBar(owner.referenceSystems); status.track(canvas); final var menu = new MapMenu(canvas); menu.addReferenceSystems(owner.referenceSystems); menu.addCopyOptions(status); getView(canvas).addEventHandler(MouseEvent.MOUSE_ENTERED, (event) -> owner.showStatusBar(canvas)); + /* + * Add listeners for showing the name of the selected CRS on the status bar. + */ + final ObservableObjectValue<String> mapCRS = menu.selectedReferenceSystem().orElse(null); + if (mapCRS == null) { + tooltip = null; + } else { + final Resources resources = Resources.forLocale(canvas.getLocale()); + tooltip = new Tooltip(resources.getString(Resources.Keys.SelectCrsByContextMenu)); + mapCRS.addListener((p,o,n) -> notifyReferenceSystemChanged(n, status.getReferenceSystemName().get(), true)); + status.getReferenceSystemName().addListener((p,o,n) -> notifyReferenceSystemChanged(mapCRS.get(), n, false)); + } + } + + /** + * Invoked in JavaFX thread after the reference system of the canvas or of the status bar changed. + * The {@code interim} argument is {@code true} if the change was in the <abbr>CRS</abbr> of the map, + * and the <abbr>CRS</abbr> shown in the status bar is expected to be updated to the same value soon. + * In the latter case, we avoid distracting the user with a message saying that the reference systems + * are not consistent. + * + * @param rendered the name of the reference system of the map canvas. + * @param written the name of the reference system of coordinates shown in the status bar. + * @param interim {@code true} if this event is expected to be followed soon by another event. + */ + private void notifyReferenceSystemChanged(String rendered, final String written, final boolean interim) { + if (rendered != null && written != null && !rendered.equals(written)) { + if (interim) { + status.setDefaultMessage(null, tooltip); + return; + } + rendered = Resources.format(Resources.Keys.MismatchedRS); + } + status.setDefaultMessage(rendered, rendered == null ? null : tooltip); } /**
