From 766805752c6708f5fd44e01ded0d55dba6c806b9 Mon Sep 17 00:00:00 2001 From: Olivier Maury <Olivier.Maury@inrae.fr> Date: Thu, 5 Dec 2024 18:17:40 +0100 Subject: [PATCH] =?UTF-8?q?fix:=20Modifier=20la=20mention=20de=20la=20comp?= =?UTF-8?q?araison=20=C3=A0=20la=20normale=20dans=20l'infobulle.=20fixes?= =?UTF-8?q?=20#108?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../www/client/i18n/MapMessages.java | 19 +++++++++++++ .../agrometinfo/www/client/view/MapView.java | 28 ++++++++++--------- .../www/client/i18n/MapMessages_fr.properties | 1 + 3 files changed, 35 insertions(+), 13 deletions(-) diff --git a/www-client/src/main/java/fr/agrometinfo/www/client/i18n/MapMessages.java b/www-client/src/main/java/fr/agrometinfo/www/client/i18n/MapMessages.java index 31e435a..9d9e7fa 100644 --- a/www-client/src/main/java/fr/agrometinfo/www/client/i18n/MapMessages.java +++ b/www-client/src/main/java/fr/agrometinfo/www/client/i18n/MapMessages.java @@ -22,4 +22,23 @@ public interface MapMessages extends Messages { */ @DefaultMessage("{0}: {1,number} {2}<br/>PRA: {3}<br/>Period: {4,date,medium} − {5,date,medium}") String popupContent(String indicator, Double value, String unit, String pra, Date startDate, Date endDate); + + /** + * @param indicator indicator name + * @param sign value sign + * @param value indicator value + * @param unit unit + * @param pra Petite région agricole + * @param startDate start date of period + * @param endDate date of last computation + * @return translation + */ + @DefaultMessage(""" + {0}<br/> + Comparison with the normal: {1}{2,number} {3}<br/> + PRA: {4}<br/> + Period: {5,date,medium} − {6,date,medium} + """) + String popupContentWithNormal(String indicator, String sign, Double value, String unit, String pra, Date startDate, + Date endDate); } diff --git a/www-client/src/main/java/fr/agrometinfo/www/client/view/MapView.java b/www-client/src/main/java/fr/agrometinfo/www/client/view/MapView.java index d1da555..fcc9820 100644 --- a/www-client/src/main/java/fr/agrometinfo/www/client/view/MapView.java +++ b/www-client/src/main/java/fr/agrometinfo/www/client/view/MapView.java @@ -22,7 +22,6 @@ import fr.agrometinfo.www.client.App; import fr.agrometinfo.www.client.event.FeatureSelectEvent; import fr.agrometinfo.www.client.event.FeatureSelectHandler; import fr.agrometinfo.www.client.event.MapClickEvent; -import fr.agrometinfo.www.client.i18n.AppConstants; import fr.agrometinfo.www.client.i18n.MapConstants; import fr.agrometinfo.www.client.i18n.MapMessages; import fr.agrometinfo.www.client.presenter.MapPresenter; @@ -75,11 +74,6 @@ import ol.style.StyleOptions; * @author Olivier Maury */ public final class MapView extends HtmlContentBuilder<HTMLElement> implements FeatureSelectHandler, MapPresenter.View { - /** - * I18N constants. - */ - private static final AppConstants APP_CSTS = GWT.create(AppConstants.class); - /** * z-index for base layers. */ @@ -308,6 +302,7 @@ public final class MapView extends HtmlContentBuilder<HTMLElement> implements Fe * Unit of selected indicator. */ private String indicatorUnit; + /** * If indicator values are comparison to normal. */ @@ -395,17 +390,24 @@ public final class MapView extends HtmlContentBuilder<HTMLElement> implements Fe && !featureSelect.getFeatures().isEmpty() // && featureSelect.getFeatures().item(0) != null) { - final String title; - if (isComparisonToNormal) { - title = APP_CSTS.normalComparison() + "<br/>" + indicatorName; - } else { - title = indicatorName; - } + final String title = indicatorName; final var feature = featureSelect.getFeatures().item(0); final var date = getPropertyAsDate(feature, FeatureProperty.DATE); final var value = getPropertyAsDouble(feature, FeatureProperty.VALUE); final var praName = praNames.getOrDefault(feature.getId(), feature.getId() + "/" + praNames.size()); - final var content = MSGS.popupContent(title, value, indicatorUnit, praName, periodStartDate, date); + final String content; + if (isComparisonToNormal) { + final String sign; + if (value > 0) { + sign = "+"; + } else { + sign = ""; + } + content = MSGS.popupContentWithNormal(title, sign, value, indicatorUnit, praName, periodStartDate, + date); + } else { + content = MSGS.popupContent(title, value, indicatorUnit, praName, periodStartDate, date); + } final var extent = feature.getGeometry().getExtent(); tooltip.setPosition(extent); tooltip.setContent(content); diff --git a/www-client/src/main/resources/fr/agrometinfo/www/client/i18n/MapMessages_fr.properties b/www-client/src/main/resources/fr/agrometinfo/www/client/i18n/MapMessages_fr.properties index 0fb4df9..073b476 100644 --- a/www-client/src/main/resources/fr/agrometinfo/www/client/i18n/MapMessages_fr.properties +++ b/www-client/src/main/resources/fr/agrometinfo/www/client/i18n/MapMessages_fr.properties @@ -1,2 +1,3 @@ # Ce fichier est encodé en UTF-8. popupContent={0}\u00a0: {1,number}\u00a0{2}<br/>PRA\u00a0: {3}<br/>Période\u00a0: {4,date,medium} − {5,date,medium} +popupContentWithNormal={0}<br/>Comparaison à la normale\u00a0: {1}{2,number}\u00a0{3}<br/>PRA\u00a0: {4}<br/>Période\u00a0: {5,date,medium} − {6,date,medium} -- GitLab