Tony CHEMIT pushed to branch develop at ultreiaio / ird-observe

Commits:

9 changed files:

Changes:

  • client-core/src/main/java/fr/ird/observe/client/util/ObserveKeyStrokesSupport.java
    ... ... @@ -91,6 +91,7 @@ public abstract class ObserveKeyStrokesSupport {
    91 91
         public static final KeyStroke KEY_STROKE_SHOW_REFERENTIAL = KeyStroke.getKeyStroke("ctrl pressed F4");
    
    92 92
         public static final KeyStroke KEY_STROKE_SHOW_EMPTY_PROGRAM = KeyStroke.getKeyStroke("ctrl pressed F5");
    
    93 93
         public static final KeyStroke KEY_STROKE_SHOW_DISABLED_PROGRAM = KeyStroke.getKeyStroke("ctrl pressed F6");
    
    94
    +    public static final KeyStroke KEY_STROKE_TOGGLE_LEGEND = KeyStroke.getKeyStroke("ctrl pressed L");
    
    94 95
     
    
    95 96
         public static final KeyStroke KEY_STROKE_COPY_VALUES_AND_SAVE = KeyStroke.getKeyStroke("ctrl pressed T");
    
    96 97
         public static final KeyStroke KEY_STROKE_SAVE_TABLE_ENTRY = KeyStroke.getKeyStroke("ctrl pressed S");
    
    ... ... @@ -110,7 +111,7 @@ public abstract class ObserveKeyStrokesSupport {
    110 111
         public static final KeyStroke KEY_STROKE_MAP_EXPORT = KeyStroke.getKeyStroke("ctrl pressed S");
    
    111 112
         public static final KeyStroke KEY_STROKE_MAP_ZOOM_IT = KeyStroke.getKeyStroke("ctrl pressed I");
    
    112 113
         public static final KeyStroke KEY_STROKE_MAP_ZOOM_PLUS = KeyStroke.getKeyStroke("ctrl pressed P");
    
    113
    -    public static final KeyStroke KEY_STROKE_MAP_ZOOM_MINUS = KeyStroke.getKeyStroke("ctrl pressed L");
    
    114
    +    public static final KeyStroke KEY_STROKE_MAP_ZOOM_MINUS = KeyStroke.getKeyStroke("ctrl pressed R");
    
    114 115
     
    
    115 116
         public static final KeyStroke KEY_STROKE_SHIFT_ALT_ENTER = KeyStroke.getKeyStroke("alt shift pressed ENTER");
    
    116 117
         public static final KeyStroke KEY_STROKE_SHOW_TECHNICAL_INFORMATION = KeyStroke.getKeyStroke("shift pressed F1");
    

  • client-datasource-editor-common/src/main/i18n/getters/java.getter
    ... ... @@ -11,6 +11,8 @@ observe.content.map.export.chooseFile.ok
    11 11
     observe.content.map.export.chooseFile.png
    
    12 12
     observe.content.map.export.chooseFile.title
    
    13 13
     observe.content.map.export.success
    
    14
    +observe.content.map.legend
    
    15
    +observe.content.map.legend.tip
    
    14 16
     observe.content.map.miles
    
    15 17
     observe.content.map.north
    
    16 18
     observe.content.map.showLogbook
    

  • client-datasource-editor-common/src/main/java/fr/ird/observe/client/datasource/editor/content/data/trip/map/ObserveMapPane.java
    ... ... @@ -69,6 +69,7 @@ public class ObserveMapPane extends JMapPane {
    69 69
     
    
    70 70
         protected double rotation;
    
    71 71
         private long scaleInMiles;
    
    72
    +    private boolean showLegend = true;
    
    72 73
     
    
    73 74
         public ObserveMapPane() {
    
    74 75
             labelScaleUp = "0 m";
    
    ... ... @@ -95,6 +96,16 @@ public class ObserveMapPane extends JMapPane {
    95 96
             firePropertyChange("scaleInMiles", oldValue, scaleInMiles);
    
    96 97
         }
    
    97 98
     
    
    99
    +    public boolean isShowLegend() {
    
    100
    +        return showLegend;
    
    101
    +    }
    
    102
    +
    
    103
    +    public void setShowLegend(boolean showLegend) {
    
    104
    +        boolean oldValue = isShowLegend();
    
    105
    +        this.showLegend = showLegend;
    
    106
    +        firePropertyChange("showLegend", oldValue, showLegend);
    
    107
    +    }
    
    108
    +
    
    98 109
         protected void updateScale() {
    
    99 110
             ReferencedEnvelope displayArea = getDisplayArea();
    
    100 111
             double dpi = 2.54 / 100; // pour avoir l'echélle en metre/pixel
    
    ... ... @@ -226,7 +237,7 @@ public class ObserveMapPane extends JMapPane {
    226 237
     
    
    227 238
         protected void paintLegend(Graphics graphics) {
    
    228 239
     
    
    229
    -        if (legendItems != null) {
    
    240
    +        if (getLegendItems() != null && isShowLegend()) {
    
    230 241
     
    
    231 242
                 int x = 0;
    
    232 243
                 int y = getHeight() - ObserveMapPaneLegendItem.LEGEND_ITEM_HEIGHT * legendItems.size() - 2 * LEGEND_MARGIN;
    

  • client-datasource-editor-common/src/main/java/fr/ird/observe/client/datasource/editor/content/data/trip/map/TripMapUI.jaxx
    ... ... @@ -33,6 +33,7 @@
    33 33
           <JButton id='zoomPlus'/>
    
    34 34
           <JButton id='zoomMinus'/>
    
    35 35
           <JButton id='exportPng'/>
    
    36
    +      <JToggleButton id="toggleLegend"/>
    
    36 37
         </JToolBar>
    
    37 38
         <JPanel id="config" constraints="BorderLayout.SOUTH" layout="{new GridLayout(1,0)}" beanScope="tripMapConfig">
    
    38 39
           <BeanCheckBox id="addObservations"/>
    

  • client-datasource-editor-common/src/main/java/fr/ird/observe/client/datasource/editor/content/data/trip/map/TripMapUIHandler.java
    ... ... @@ -37,6 +37,7 @@ import org.geotools.swing.event.MapPaneEvent;
    37 37
     import org.geotools.swing.event.MapPaneListener;
    
    38 38
     import org.nuiton.jaxx.runtime.spi.UIHandler;
    
    39 39
     
    
    40
    +import javax.swing.SwingUtilities;
    
    40 41
     import java.awt.Point;
    
    41 42
     import java.awt.event.MouseEvent;
    
    42 43
     import java.awt.event.MouseListener;
    
    ... ... @@ -178,6 +179,7 @@ public class TripMapUIHandler implements UIHandler<TripMapUI> {
    178 179
         public void init() {
    
    179 180
             init(ui.getAddObservations());
    
    180 181
             init(ui.getAddLogbook());
    
    182
    +        ui.getToggleLegend().setSelected(true);
    
    181 183
         }
    
    182 184
     
    
    183 185
         public ReferencedEnvelope getTripArea() {
    
    ... ... @@ -206,6 +208,11 @@ public class TripMapUIHandler implements UIHandler<TripMapUI> {
    206 208
             editor.init(true, false);
    
    207 209
         }
    
    208 210
     
    
    211
    +    public void updateMap(boolean showLegend) {
    
    212
    +        getObserveMapPane().setShowLegend(showLegend);
    
    213
    +        SwingUtilities.invokeLater(getObserveMapPane()::repaint);
    
    214
    +    }
    
    215
    +
    
    209 216
         private class MouseMapListener implements MouseWheelListener, MouseListener, MouseMotionListener {
    
    210 217
     
    
    211 218
             Point2D startPointInWorld;
    

  • client-datasource-editor-common/src/main/java/fr/ird/observe/client/datasource/editor/content/data/trip/map/actions/ToggleLegend.java
    1
    +package fr.ird.observe.client.datasource.editor.content.data.trip.map.actions;
    
    2
    +
    
    3
    +/*-
    
    4
    + * #%L
    
    5
    + * ObServe :: Client DataSource Editor Common
    
    6
    + * %%
    
    7
    + * Copyright (C) 2008 - 2020 IRD, Code Lutin, Ultreia.io
    
    8
    + * %%
    
    9
    + * This program is free software: you can redistribute it and/or modify
    
    10
    + * it under the terms of the GNU General Public License as
    
    11
    + * published by the Free Software Foundation, either version 3 of the
    
    12
    + * License, or (at your option) any later version.
    
    13
    + *
    
    14
    + * This program is distributed in the hope that it will be useful,
    
    15
    + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    
    16
    + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    
    17
    + * GNU General Public License for more details.
    
    18
    + *
    
    19
    + * You should have received a copy of the GNU General Public
    
    20
    + * License along with this program.  If not, see
    
    21
    + * <http://www.gnu.org/licenses/gpl-3.0.html>.
    
    22
    + * #L%
    
    23
    + */
    
    24
    +
    
    25
    +import fr.ird.observe.client.datasource.editor.content.data.trip.map.TripMapUI;
    
    26
    +import fr.ird.observe.client.util.ObserveKeyStrokesSupport;
    
    27
    +import org.apache.logging.log4j.LogManager;
    
    28
    +import org.apache.logging.log4j.Logger;
    
    29
    +
    
    30
    +import java.awt.event.ActionEvent;
    
    31
    +
    
    32
    +import static io.ultreia.java4all.i18n.I18n.t;
    
    33
    +
    
    34
    +public class ToggleLegend extends TripMapUIActionSupport {
    
    35
    +    private static final Logger log = LogManager.getLogger(ToggleLegend.class);
    
    36
    +
    
    37
    +    public ToggleLegend() {
    
    38
    +        super(
    
    39
    +                t("observe.content.map.legend"),
    
    40
    +                t("observe.content.map.legend.tip"),
    
    41
    +                "show-help",
    
    42
    +                ObserveKeyStrokesSupport.KEY_STROKE_TOGGLE_LEGEND);
    
    43
    +
    
    44
    +    }
    
    45
    +
    
    46
    +    @Override
    
    47
    +    protected void doActionPerformed(ActionEvent e, TripMapUI ui) {
    
    48
    +        boolean selected = ui.getToggleLegend().isSelected();
    
    49
    +        log.info(String.format("Was showing legend? %b", selected));
    
    50
    +        boolean newValue = !selected;
    
    51
    +        ui.getToggleLegend().setSelected(newValue);
    
    52
    +        ui.getHandler().updateMap(newValue);
    
    53
    +    }
    
    54
    +}

  • observe-i18n/src/main/i18n/translations/observe_en_GB.properties
    ... ... @@ -741,12 +741,14 @@ observe.content.map.export.chooseFile.ok=Exporter
    741 741
     observe.content.map.export.chooseFile.png=PNG image
    
    742 742
     observe.content.map.export.chooseFile.title=Export map
    
    743 743
     observe.content.map.export.success=Map exported (%s)
    
    744
    +observe.content.map.legend=Legend
    
    744 745
     observe.content.map.legend.hauling=Hauling
    
    745 746
     observe.content.map.legend.logbook.hauling=Logbook - Hauling
    
    746 747
     observe.content.map.legend.logbook.setting=Logbook - setting
    
    747 748
     observe.content.map.legend.obs.hauling=Observation - Hauling
    
    748 749
     observe.content.map.legend.obs.setting=Observation - setting
    
    749 750
     observe.content.map.legend.setting=setting
    
    751
    +observe.content.map.legend.tip=To display or hide legend
    
    750 752
     observe.content.map.legend.tripBetweenTwoDays=Night trip
    
    751 753
     observe.content.map.legend.tripDay=Day trip
    
    752 754
     observe.content.map.miles=miles
    

  • observe-i18n/src/main/i18n/translations/observe_es_ES.properties
    ... ... @@ -741,12 +741,14 @@ observe.content.map.export.chooseFile.ok=Exportar
    741 741
     observe.content.map.export.chooseFile.png=imagen PNG
    
    742 742
     observe.content.map.export.chooseFile.title=Exportar el mapa
    
    743 743
     observe.content.map.export.success=Mapa exportada (%s)
    
    744
    +observe.content.map.legend=Legend \#TODO
    
    744 745
     observe.content.map.legend.hauling=Arrastre
    
    745 746
     observe.content.map.legend.logbook.hauling=Logbook - Arrastre
    
    746 747
     observe.content.map.legend.logbook.setting=Logbook - Calada
    
    747 748
     observe.content.map.legend.obs.hauling=Observation - Arrastre
    
    748 749
     observe.content.map.legend.obs.setting=Observation - Calada
    
    749 750
     observe.content.map.legend.setting=Calada
    
    751
    +observe.content.map.legend.tip=To display or hide legend \#TODO
    
    750 752
     observe.content.map.legend.tripBetweenTwoDays=Trayecto del noche
    
    751 753
     observe.content.map.legend.tripDay=Trayecto del día
    
    752 754
     observe.content.map.miles=milles
    

  • observe-i18n/src/main/i18n/translations/observe_fr_FR.properties
    ... ... @@ -741,12 +741,14 @@ observe.content.map.export.chooseFile.ok=Exporter
    741 741
     observe.content.map.export.chooseFile.png=image PNG
    
    742 742
     observe.content.map.export.chooseFile.title=Exporter la carte
    
    743 743
     observe.content.map.export.success=Carte exportée (%s)
    
    744
    +observe.content.map.legend=Légende
    
    744 745
     observe.content.map.legend.hauling=Virage
    
    745 746
     observe.content.map.legend.logbook.hauling=Livre de bord - Virage
    
    746 747
     observe.content.map.legend.logbook.setting=Livre de bord - Filage
    
    747 748
     observe.content.map.legend.obs.hauling=Observation - Virage
    
    748 749
     observe.content.map.legend.obs.setting=Observation - Filage
    
    749 750
     observe.content.map.legend.setting=Filage
    
    751
    +observe.content.map.legend.tip=Pour afficher ou masquer la légende
    
    750 752
     observe.content.map.legend.tripBetweenTwoDays=Trajet de nuit
    
    751 753
     observe.content.map.legend.tripDay=Trajet de jour
    
    752 754
     observe.content.map.miles=milles