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

Commits:

20 changed files:

Changes:

  • client/src/main/java/fr/ird/observe/client/ui/actions/UIActionSupport.java
    ... ... @@ -32,6 +32,7 @@ import java.awt.event.ActionEvent;
    32 32
     import java.awt.event.InputEvent;
    
    33 33
     import javax.swing.AbstractAction;
    
    34 34
     import javax.swing.AbstractButton;
    
    35
    +import javax.swing.Action;
    
    35 36
     import javax.swing.ActionMap;
    
    36 37
     import javax.swing.Icon;
    
    37 38
     import javax.swing.InputMap;
    
    ... ... @@ -131,8 +132,14 @@ public abstract class UIActionSupport extends AbstractAction {
    131 132
             KeyStroke keyStroke = getAcceleratorKey();
    
    132 133
             if (keyStroke != null) {
    
    133 134
                 String actionCommandKey = getActionCommandKey();
    
    135
    +            register(this, inputMap, actionMap,keyStroke, actionCommandKey);
    
    136
    +        }
    
    137
    +    }
    
    138
    +
    
    139
    +    public static void register(Action action, InputMap inputMap, ActionMap actionMap, KeyStroke keyStroke , String actionCommandKey ) {
    
    140
    +        if (keyStroke != null) {
    
    134 141
                 inputMap.put(keyStroke, actionCommandKey);
    
    135
    -            actionMap.put(actionCommandKey, this);
    
    142
    +            actionMap.put(actionCommandKey, action);
    
    136 143
             }
    
    137 144
         }
    
    138 145
     
    

  • client/src/main/java/fr/ird/observe/client/ui/actions/tripMap/ExportPngUIAction.java
    1
    +package fr.ird.observe.client.ui.actions.tripMap;
    
    2
    +
    
    3
    +/*-
    
    4
    + * #%L
    
    5
    + * ObServe :: Client
    
    6
    + * %%
    
    7
    + * Copyright (C) 2008 - 2017 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.ObserveSwingTechnicalException;
    
    26
    +import fr.ird.observe.client.ui.ObserveMainUI;
    
    27
    +import fr.ird.observe.client.ui.util.UIHelper;
    
    28
    +import fr.ird.observe.client.ui.util.tripMap.TripMapUI;
    
    29
    +import java.awt.image.BufferedImage;
    
    30
    +import java.io.File;
    
    31
    +import java.io.IOException;
    
    32
    +import javax.imageio.ImageIO;
    
    33
    +import javax.swing.KeyStroke;
    
    34
    +
    
    35
    +
    
    36
    +import static org.nuiton.i18n.I18n.t;
    
    37
    +
    
    38
    +/**
    
    39
    + * Created by tchemit on 25/08/17.
    
    40
    + *
    
    41
    + * @author Tony Chemit - dev@tchemit.fr
    
    42
    + */
    
    43
    +public class ExportPngUIAction extends TripMapActionSupport {
    
    44
    +
    
    45
    +    public static final String ACTION_NAME = ExportPngUIAction.class.getName();
    
    46
    +
    
    47
    +    public ExportPngUIAction(ObserveMainUI mainUI) {
    
    48
    +        super(mainUI,
    
    49
    +              ACTION_NAME,
    
    50
    +              t("observe.content.map.action.exportPng"),
    
    51
    +              t("observe.content.map.action.exportPng.tip"),
    
    52
    +              "save",
    
    53
    +              KeyStroke.getKeyStroke("ctrl pressed S"));
    
    54
    +    }
    
    55
    +
    
    56
    +    @Override
    
    57
    +    protected void actionPerformed(TripMapUI view) {
    
    58
    +
    
    59
    +        File file = UIHelper.chooseFile(
    
    60
    +                view,
    
    61
    +                t("observe.content.map.export.chooseFile.title"),
    
    62
    +                t("observe.content.map.export.chooseFile.ok"),
    
    63
    +                null,
    
    64
    +                "^.+\\.png|.+\\.PNG$",
    
    65
    +                t("observe.content.map.export.chooseFile.png"));
    
    66
    +
    
    67
    +        if (file != null && UIHelper.confirmOverwriteFileIfExist(view, file)) {
    
    68
    +
    
    69
    +            BufferedImage im = new BufferedImage(view.getWidth(), view.getHeight(), BufferedImage.TYPE_INT_ARGB);
    
    70
    +            view.paint(im.getGraphics());
    
    71
    +            try {
    
    72
    +                ImageIO.write(im, "PNG", file);
    
    73
    +            } catch (IOException e) {
    
    74
    +                throw new ObserveSwingTechnicalException("unable to export map ", e);
    
    75
    +            }
    
    76
    +
    
    77
    +            UIHelper.displayInfo(t("observe.content.map.export.success", file));
    
    78
    +        }
    
    79
    +    }
    
    80
    +}

  • client/src/main/java/fr/ird/observe/client/ui/actions/tripMap/TripMapActionSupport.java
    1
    +package fr.ird.observe.client.ui.actions.tripMap;
    
    2
    +
    
    3
    +/*-
    
    4
    + * #%L
    
    5
    + * ObServe :: Client
    
    6
    + * %%
    
    7
    + * Copyright (C) 2008 - 2017 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.ui.ObserveMainUI;
    
    26
    +import fr.ird.observe.client.ui.actions.UIActionSupport;
    
    27
    +import fr.ird.observe.client.ui.content.open.TripUI;
    
    28
    +import fr.ird.observe.client.ui.util.tripMap.TripMapUI;
    
    29
    +import java.awt.event.ActionEvent;
    
    30
    +import javax.swing.JComponent;
    
    31
    +import javax.swing.KeyStroke;
    
    32
    +import org.apache.commons.logging.Log;
    
    33
    +import org.apache.commons.logging.LogFactory;
    
    34
    +
    
    35
    +/**
    
    36
    + * Created by tchemit on 25/08/17.
    
    37
    + *
    
    38
    + * @author Tony Chemit - dev@tchemit.fr
    
    39
    + */
    
    40
    +public abstract class TripMapActionSupport extends UIActionSupport {
    
    41
    +
    
    42
    +    /** Logger. */
    
    43
    +    private static final Log log = LogFactory.getLog(TripMapActionSupport.class);
    
    44
    +
    
    45
    +    private TripMapUI ui;
    
    46
    +    protected ActionEvent e;
    
    47
    +
    
    48
    +    protected abstract void actionPerformed(TripMapUI ui);
    
    49
    +
    
    50
    +    TripMapActionSupport(ObserveMainUI mainUI, String actionCommandKey, String label, String shortDescription, String actionIcon, KeyStroke acceleratorKey) {
    
    51
    +        super(mainUI, actionCommandKey, label, shortDescription, actionIcon, acceleratorKey);
    
    52
    +    }
    
    53
    +
    
    54
    +    public void setUi(TripMapUI ui) {
    
    55
    +        this.ui = ui;
    
    56
    +    }
    
    57
    +
    
    58
    +    @Override
    
    59
    +    public final void actionPerformed(ActionEvent e) {
    
    60
    +        if (!canExecuteAction()) {
    
    61
    +            return;
    
    62
    +        }
    
    63
    +        this.e = e;
    
    64
    +
    
    65
    +        if (ui != null) {
    
    66
    +            actionPerformed(ui);
    
    67
    +            return;
    
    68
    +        }
    
    69
    +        TripUI source = (TripUI) e.getSource();
    
    70
    +        actionPerformed(source.getTripMap());
    
    71
    +    }
    
    72
    +
    
    73
    +    private boolean canExecuteAction() {
    
    74
    +        JComponent editor = getEditor();
    
    75
    +        if ((editor == null || (editor.isVisible() && editor.isEnabled() && editor.isShowing()))) {
    
    76
    +            return true;
    
    77
    +        }
    
    78
    +        if (log.isInfoEnabled()) {
    
    79
    +            log.info("Disabled action: " + getActionCommandKey() + " :: " + this);
    
    80
    +        }
    
    81
    +        return false;
    
    82
    +    }
    
    83
    +}

  • client/src/main/java/fr/ird/observe/client/ui/actions/tripMap/ZoomItUIAction.java
    1
    +package fr.ird.observe.client.ui.actions.tripMap;
    
    2
    +
    
    3
    +/*-
    
    4
    + * #%L
    
    5
    + * ObServe :: Client
    
    6
    + * %%
    
    7
    + * Copyright (C) 2008 - 2017 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.ui.ObserveMainUI;
    
    26
    +import fr.ird.observe.client.ui.util.tripMap.TripMapUI;
    
    27
    +import javax.swing.KeyStroke;
    
    28
    +import org.geotools.geometry.jts.ReferencedEnvelope;
    
    29
    +import org.geotools.swing.JMapPane;
    
    30
    +
    
    31
    +
    
    32
    +import static org.nuiton.i18n.I18n.t;
    
    33
    +
    
    34
    +/**
    
    35
    + * Created by tchemit on 25/08/17.
    
    36
    + *
    
    37
    + * @author Tony Chemit - dev@tchemit.fr
    
    38
    + */
    
    39
    +public class ZoomItUIAction extends TripMapActionSupport {
    
    40
    +
    
    41
    +    public static final String ACTION_NAME = ZoomItUIAction.class.getName();
    
    42
    +
    
    43
    +    public ZoomItUIAction(ObserveMainUI mainUI) {
    
    44
    +        super(mainUI,
    
    45
    +              ACTION_NAME,
    
    46
    +              t("observe.content.map.action.zoomIt"),
    
    47
    +              t("observe.content.map.action.zoomIt.tip"),
    
    48
    +              "center",
    
    49
    +              KeyStroke.getKeyStroke("ctrl pressed I"));
    
    50
    +    }
    
    51
    +
    
    52
    +    @Override
    
    53
    +    protected void actionPerformed(TripMapUI view) {
    
    54
    +
    
    55
    +        ReferencedEnvelope tripArea = view.getHandler().getTripArea();
    
    56
    +        if (!tripArea.isEmpty()) {
    
    57
    +            JMapPane mapPane = view.getObserveMapPane();
    
    58
    +            mapPane.setDisplayArea(tripArea);
    
    59
    +        }
    
    60
    +    }
    
    61
    +}

  • client/src/main/java/fr/ird/observe/client/ui/actions/tripMap/ZoomMoinsUIAction.java
    1
    +package fr.ird.observe.client.ui.actions.tripMap;
    
    2
    +
    
    3
    +/*-
    
    4
    + * #%L
    
    5
    + * ObServe :: Client
    
    6
    + * %%
    
    7
    + * Copyright (C) 2008 - 2017 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.ui.ObserveMainUI;
    
    26
    +import fr.ird.observe.client.ui.util.tripMap.TripMapUI;
    
    27
    +import fr.ird.observe.client.ui.util.tripMap.TripMapUIHandler;
    
    28
    +import java.awt.Point;
    
    29
    +import javax.swing.KeyStroke;
    
    30
    +import org.geotools.geometry.jts.ReferencedEnvelope;
    
    31
    +
    
    32
    +
    
    33
    +import static fr.ird.observe.client.ui.util.tripMap.TripMapUIHandler.ZOOM_STEP_RATIO;
    
    34
    +import static org.nuiton.i18n.I18n.t;
    
    35
    +
    
    36
    +/**
    
    37
    + * Created by tchemit on 25/08/17.
    
    38
    + *
    
    39
    + * @author Tony Chemit - dev@tchemit.fr
    
    40
    + */
    
    41
    +public class ZoomMoinsUIAction extends TripMapActionSupport {
    
    42
    +
    
    43
    +    public static final String ACTION_NAME = ZoomMoinsUIAction.class.getName();
    
    44
    +
    
    45
    +    public ZoomMoinsUIAction(ObserveMainUI mainUI) {
    
    46
    +        super(mainUI,
    
    47
    +              ACTION_NAME,
    
    48
    +              t("observe.content.map.action.zoomMoins"),
    
    49
    +              t("observe.content.map.action.zoomMoins.tip"),
    
    50
    +              "center",
    
    51
    +              KeyStroke.getKeyStroke("ctrl pressed L"));
    
    52
    +    }
    
    53
    +
    
    54
    +    @Override
    
    55
    +    protected void actionPerformed(TripMapUI view) {
    
    56
    +
    
    57
    +        TripMapUIHandler handler = view.getHandler();
    
    58
    +        ReferencedEnvelope tripArea = handler.getTripArea();
    
    59
    +
    
    60
    +        if (!tripArea.isEmpty()) {
    
    61
    +            int notches = 1;
    
    62
    +            ReferencedEnvelope displayArea = view.getObserveMapPane().getDisplayArea();
    
    63
    +            double w = displayArea.getMedian(0);
    
    64
    +            double h = displayArea.getMedian(1);
    
    65
    +            Point zoomCenter = new Point((int) w, (int) h);
    
    66
    +            handler.setZoomCenter(zoomCenter);
    
    67
    +            handler.setZoomRatio(handler.getZoomRatio() * (1 + (ZOOM_STEP_RATIO * notches * -1)));
    
    68
    +            handler.zoomApply();
    
    69
    +        }
    
    70
    +
    
    71
    +    }
    
    72
    +}

  • client/src/main/java/fr/ird/observe/client/ui/actions/tripMap/ZoomPlusUIAction.java
    1
    +package fr.ird.observe.client.ui.actions.tripMap;
    
    2
    +
    
    3
    +/*-
    
    4
    + * #%L
    
    5
    + * ObServe :: Client
    
    6
    + * %%
    
    7
    + * Copyright (C) 2008 - 2017 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.ui.ObserveMainUI;
    
    26
    +import fr.ird.observe.client.ui.util.tripMap.TripMapUI;
    
    27
    +import fr.ird.observe.client.ui.util.tripMap.TripMapUIHandler;
    
    28
    +import java.awt.Point;
    
    29
    +import javax.swing.KeyStroke;
    
    30
    +import org.geotools.geometry.jts.ReferencedEnvelope;
    
    31
    +
    
    32
    +
    
    33
    +import static fr.ird.observe.client.ui.util.tripMap.TripMapUIHandler.ZOOM_STEP_RATIO;
    
    34
    +import static org.nuiton.i18n.I18n.t;
    
    35
    +
    
    36
    +/**
    
    37
    + * Created by tchemit on 25/08/17.
    
    38
    + *
    
    39
    + * @author Tony Chemit - dev@tchemit.fr
    
    40
    + */
    
    41
    +public class ZoomPlusUIAction extends TripMapActionSupport {
    
    42
    +
    
    43
    +    public static final String ACTION_NAME = ZoomPlusUIAction.class.getName();
    
    44
    +
    
    45
    +    public ZoomPlusUIAction(ObserveMainUI mainUI) {
    
    46
    +        super(mainUI,
    
    47
    +              ACTION_NAME,
    
    48
    +              t("observe.content.map.action.zoomPlus"),
    
    49
    +              t("observe.content.map.action.zoomPlus.tip"),
    
    50
    +              "zoomPlus",
    
    51
    +              KeyStroke.getKeyStroke("ctrl pressed P"));
    
    52
    +    }
    
    53
    +
    
    54
    +    @Override
    
    55
    +    protected void actionPerformed(TripMapUI view) {
    
    56
    +
    
    57
    +        TripMapUIHandler handler = view.getHandler();
    
    58
    +        ReferencedEnvelope tripArea = handler.getTripArea();
    
    59
    +
    
    60
    +        if (!tripArea.isEmpty()) {
    
    61
    +            int notches = 1;
    
    62
    +            ReferencedEnvelope displayArea = view.getObserveMapPane().getDisplayArea();
    
    63
    +            double w = displayArea.getMedian(0);
    
    64
    +            double h = displayArea.getMedian(1);
    
    65
    +            Point zoomCenter = new Point((int) w, (int) h);
    
    66
    +            handler.setZoomCenter(zoomCenter);
    
    67
    +            handler.setZoomRatio(handler.getZoomRatio() * (1 - (ZOOM_STEP_RATIO * notches * -1)));
    
    68
    +            handler.zoomApply();
    
    69
    +        }
    
    70
    +
    
    71
    +    }
    
    72
    +}

  • client/src/main/java/fr/ird/observe/client/ui/content/open/TripUI.java
    1
    +package fr.ird.observe.client.ui.content.open;
    
    2
    +
    
    3
    +/*-
    
    4
    + * #%L
    
    5
    + * ObServe :: Client
    
    6
    + * %%
    
    7
    + * Copyright (C) 2008 - 2017 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.ui.util.tripMap.TripMapUI;
    
    26
    +
    
    27
    +/**
    
    28
    + * Created by tchemit on 25/08/17.
    
    29
    + *
    
    30
    + * @author Tony Chemit - dev@tchemit.fr
    
    31
    + */
    
    32
    +public interface TripUI {
    
    33
    +
    
    34
    +    TripMapUI getTripMap();
    
    35
    +
    
    36
    +}

  • client/src/main/java/fr/ird/observe/client/ui/content/open/longline/TripLonglineUI.jaxx
    ... ... @@ -23,7 +23,8 @@
    23 23
     <fr.ird.observe.client.ui.content.open.ContentOpenableUI
    
    24 24
         i18nFormat="observe.common.TripLonglineDto.%s"
    
    25 25
         superGenericType='TripLonglineDto, TripLonglineUI'
    
    26
    -    contentTitle='{n("observe.common.TripLonglineDto.title")}'>
    
    26
    +    contentTitle='{n("observe.common.TripLonglineDto.title")}'
    
    27
    +    implements="fr.ird.observe.client.ui.content.open.TripUI">
    
    27 28
     
    
    28 29
       <style source="../../Common.jcss"/>
    
    29 30
     
    

  • client/src/main/java/fr/ird/observe/client/ui/content/open/seine/TripSeineUI.jaxx
    ... ... @@ -23,7 +23,8 @@
    23 23
     <fr.ird.observe.client.ui.content.open.ContentOpenableUI
    
    24 24
         i18nFormat="observe.common.TripSeineDto.%s"
    
    25 25
         superGenericType='TripSeineDto, TripSeineUI'
    
    26
    -    contentTitle='{n("observe.common.TripSeineDto.title")}'>
    
    26
    +    contentTitle='{n("observe.common.TripSeineDto.title")}'
    
    27
    +    implements="fr.ird.observe.client.ui.content.open.TripUI">
    
    27 28
     
    
    28 29
       <style source="../../Common.jcss"/>
    
    29 30
     
    

  • client/src/main/java/fr/ird/observe/client/ui/content/open/seine/TripSeineUIHandler.java
    ... ... @@ -42,6 +42,7 @@ import fr.ird.observe.services.dto.seine.TripSeineDto;
    42 42
     import fr.ird.observe.services.dto.seine.TripSeineHelper;
    
    43 43
     import java.util.Date;
    
    44 44
     import java.util.List;
    
    45
    +import javax.swing.JComponent;
    
    45 46
     import javax.swing.JTabbedPane;
    
    46 47
     import javax.swing.SwingUtilities;
    
    47 48
     import org.apache.commons.logging.Log;
    
    ... ... @@ -102,6 +103,7 @@ class TripSeineUIHandler extends ContentOpenableUIHandler<TripSeineDto, TripSein
    102 103
             ClientConfig config = ObserveSwingApplicationContext.get().getConfig();
    
    103 104
     
    
    104 105
             tripMap.getHandler().setConfig(config);
    
    106
    +        tripMap.getHandler().init(ui.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW));
    
    105 107
     
    
    106 108
             ui.getMainTabbedPane().addChangeListener(e -> {
    
    107 109
                 JTabbedPane tripSeineTabPane = (JTabbedPane) e.getSource();
    

  • client/src/main/java/fr/ird/observe/client/ui/util/tripMap/TripMapUI.jaxx
    ... ... @@ -19,20 +19,27 @@
    19 19
       <http://www.gnu.org/licenses/gpl-3.0.html>.
    
    20 20
       #L%
    
    21 21
       -->
    
    22
    -<JPanel id="tripMap" layout="{new CardLayout()}">
    
    22
    +<JPanel id="tripMap" layout="{new BorderLayout()}">
    
    23 23
     
    
    24 24
       <import>
    
    25
    +    fr.ird.observe.client.ui.actions.tripMap.ExportPngUIAction
    
    26
    +    fr.ird.observe.client.ui.actions.tripMap.ZoomItUIAction
    
    27
    +    fr.ird.observe.client.ui.actions.tripMap.ZoomMoinsUIAction
    
    28
    +    fr.ird.observe.client.ui.actions.tripMap.ZoomPlusUIAction
    
    25 29
         java.awt.CardLayout
    
    26
    -    static org.nuiton.i18n.I18n.n
    
    27 30
       </import>
    
    28 31
     
    
    29
    -  <JPopupMenu id='mapPopupMenu'>
    
    30
    -    <JMenuItem id='zoomIt' onActionPerformed='getHandler().zoomIt()'/>
    
    31
    -    <JMenuItem id='exportPng' onActionPerformed='getHandler().exportPng()'/>
    
    32
    -  </JPopupMenu>
    
    32
    +  <CardLayout id="contentLayout"/>
    
    33
    +  <JToolBar constraints="BorderLayout.NORTH">
    
    34
    +    <JButton id='zoomIt'/>
    
    35
    +    <JButton id='zoomPlus'/>
    
    36
    +    <JButton id='zoomMoins'/>
    
    37
    +    <JButton id='exportPng'/>
    
    38
    +  </JToolBar>
    
    33 39
     
    
    34
    -  <JLabel id="waitLoadingLabel"/>
    
    35
    -
    
    36
    -  <ObserveMapPane id='observeMapPane' constraints="BorderLayout.CENTER"/>
    
    40
    +  <JPanel id="content" layout="{contentLayout}" constraints="BorderLayout.CENTER">
    
    41
    +    <JLabel id="waitLoadingLabel"/>
    
    42
    +    <ObserveMapPane id='observeMapPane'/>
    
    43
    +  </JPanel>
    
    37 44
     
    
    38 45
     </JPanel>

  • client/src/main/java/fr/ird/observe/client/ui/util/tripMap/TripMapUI.jcss
    ... ... @@ -28,13 +28,17 @@
    28 28
     }
    
    29 29
     
    
    30 30
     #zoomIt {
    
    31
    -  text: "observe.content.map.action.zoomIt";
    
    32
    -  toolTipText: "observe.content.map.action.zoomIt.tip";
    
    33
    -  actionIcon: center;
    
    31
    +  _observeAction:{ZoomItUIAction.ACTION_NAME};
    
    32
    +}
    
    33
    +
    
    34
    +#zoomMoins {
    
    35
    +  _observeAction:{ZoomMoinsUIAction.ACTION_NAME};
    
    36
    +}
    
    37
    +
    
    38
    +#zoomPlus {
    
    39
    +  _observeAction:{ZoomPlusUIAction.ACTION_NAME};
    
    34 40
     }
    
    35 41
     
    
    36 42
     #exportPng {
    
    37
    -  text: "observe.content.map.action.exportPng";
    
    38
    -  toolTipText: "observe.content.map.action.exportPng.tip";
    
    39
    -  actionIcon: save;
    
    43
    +  _observeAction:{ExportPngUIAction.ACTION_NAME};
    
    40 44
     }

  • client/src/main/java/fr/ird/observe/client/ui/util/tripMap/TripMapUIHandler.java
    ... ... @@ -26,12 +26,13 @@ import com.google.common.collect.Lists;
    26 26
     import fr.ird.observe.client.ObserveSwingApplicationContext;
    
    27 27
     import fr.ird.observe.client.ObserveSwingTechnicalException;
    
    28 28
     import fr.ird.observe.client.configuration.ClientConfig;
    
    29
    -import fr.ird.observe.client.ui.util.UIHelper;
    
    29
    +import fr.ird.observe.client.ui.actions.tripMap.TripMapActionSupport;
    
    30
    +import fr.ird.observe.client.ui.content.ObserveActionMap;
    
    30 31
     import fr.ird.observe.common.TripMapPoint;
    
    31 32
     import fr.ird.observe.services.dto.IdHelper;
    
    32 33
     import fr.ird.observe.services.dto.TripMapDto;
    
    33
    -import java.awt.CardLayout;
    
    34 34
     import java.awt.Point;
    
    35
    +import java.awt.event.KeyEvent;
    
    35 36
     import java.awt.event.MouseEvent;
    
    36 37
     import java.awt.event.MouseListener;
    
    37 38
     import java.awt.event.MouseMotionListener;
    
    ... ... @@ -39,11 +40,13 @@ import java.awt.event.MouseWheelEvent;
    39 40
     import java.awt.event.MouseWheelListener;
    
    40 41
     import java.awt.geom.AffineTransform;
    
    41 42
     import java.awt.geom.Point2D;
    
    42
    -import java.awt.image.BufferedImage;
    
    43 43
     import java.io.File;
    
    44
    -import java.io.IOException;
    
    45 44
     import java.util.List;
    
    46
    -import javax.imageio.ImageIO;
    
    45
    +import java.util.Objects;
    
    46
    +import javax.swing.AbstractButton;
    
    47
    +import javax.swing.InputMap;
    
    48
    +import javax.swing.JComponent;
    
    49
    +import javax.swing.KeyStroke;
    
    47 50
     import org.apache.commons.logging.Log;
    
    48 51
     import org.apache.commons.logging.LogFactory;
    
    49 52
     import org.geotools.geometry.DirectPosition2D;
    
    ... ... @@ -54,7 +57,7 @@ import org.geotools.swing.event.MapPaneListener;
    54 57
     import org.nuiton.jaxx.runtime.spi.UIHandler;
    
    55 58
     
    
    56 59
     
    
    57
    -import static org.nuiton.i18n.I18n.t;
    
    60
    +import static fr.ird.observe.client.ui.content.ContentUIInitializer.OBSERVE_ACTION;
    
    58 61
     
    
    59 62
     /**
    
    60 63
      * @author Tony Chemit - dev@tchemit.fr
    
    ... ... @@ -65,12 +68,12 @@ public class TripMapUIHandler implements UIHandler<TripMapUI> {
    65 68
     
    
    66 69
         private static final Log log = LogFactory.getLog(TripMapUIHandler.class);
    
    67 70
     
    
    68
    -    protected TripMapUI view;
    
    69
    -
    
    71
    +    private TripMapUI ui;
    
    70 72
         private ClientConfig config;
    
    71
    -    protected ReferencedEnvelope tripArea;
    
    72
    -
    
    73
    -    protected boolean rendererRunning;
    
    73
    +    private ReferencedEnvelope tripArea;
    
    74
    +    private boolean rendererRunning;
    
    75
    +    private double zoomRatio = 1;
    
    76
    +    private Point zoomCenter;
    
    74 77
     
    
    75 78
         public void setConfig(ClientConfig config) {
    
    76 79
             this.config = config;
    
    ... ... @@ -79,14 +82,14 @@ public class TripMapUIHandler implements UIHandler<TripMapUI> {
    79 82
             mapPane.setBackground(config.getMapBackgroundColor());
    
    80 83
         }
    
    81 84
     
    
    82
    -    protected ObserveMapPane getObserveMapPane() {
    
    83
    -        return view.getObserveMapPane();
    
    85
    +    private ObserveMapPane getObserveMapPane() {
    
    86
    +        return ui.getObserveMapPane();
    
    84 87
         }
    
    85 88
     
    
    86 89
         public void doOpenMap(TripMapDto tripMapDto) {
    
    87 90
     
    
    88 91
             try {
    
    89
    -            ((CardLayout) view.getLayout()).first(view);
    
    92
    +            flipContent();
    
    90 93
                 ObserveSwingApplicationContext.get().getMainUI().getModel().setBusy(true);
    
    91 94
     
    
    92 95
                 ObserveMapPane mapPane = getObserveMapPane();
    
    ... ... @@ -137,45 +140,15 @@ public class TripMapUIHandler implements UIHandler<TripMapUI> {
    137 140
     
    
    138 141
         }
    
    139 142
     
    
    140
    -    public void doCloseMap() {
    
    141
    -        ((CardLayout) view.getLayout()).first(view);
    
    142
    -    }
    
    143
    -
    
    144
    -    public void zoomIt() {
    
    145
    -        if (!tripArea.isEmpty()) {
    
    146
    -            JMapPane mapPane = getObserveMapPane();
    
    147
    -            mapPane.setDisplayArea(tripArea);
    
    148
    -        }
    
    143
    +    private void flipContent() {
    
    144
    +        ui.getContentLayout().first(ui.getContent());
    
    149 145
         }
    
    150 146
     
    
    151
    -    public void exportPng() {
    
    152
    -
    
    153
    -        File file = UIHelper.chooseFile(
    
    154
    -                view,
    
    155
    -                t("observe.content.map.export.chooseFile.title"),
    
    156
    -                t("observe.content.map.export.chooseFile.ok"),
    
    157
    -                null,
    
    158
    -                "^.+\\.png|.+\\.PNG$",
    
    159
    -                t("observe.content.map.export.chooseFile.png"));
    
    160
    -
    
    161
    -        if (file != null && UIHelper.confirmOverwriteFileIfExist(view, file)) {
    
    162
    -
    
    163
    -            BufferedImage im = new BufferedImage(view.getWidth(), view.getHeight(), BufferedImage.TYPE_INT_ARGB);
    
    164
    -            view.paint(im.getGraphics());
    
    165
    -            try {
    
    166
    -                ImageIO.write(im, "PNG", file);
    
    167
    -            } catch (IOException e) {
    
    168
    -                throw new ObserveSwingTechnicalException("unable to export map ", e);
    
    169
    -            }
    
    170
    -
    
    171
    -            UIHelper.displayInfo(t("observe.content.map.export.success", file));
    
    172
    -        }
    
    147
    +    public void doCloseMap() {
    
    148
    +        flipContent();
    
    173 149
         }
    
    174 150
     
    
    175
    -    protected double zoomRatio = 1;
    
    176
    -    protected Point zoomCenter;
    
    177
    -
    
    178
    -    protected void zoomApply() {
    
    151
    +    public void zoomApply() {
    
    179 152
             if (zoomRatio != 1 && !rendererRunning) {
    
    180 153
     
    
    181 154
                 JMapPane mapPane = getObserveMapPane();
    
    ... ... @@ -221,7 +194,7 @@ public class TripMapUIHandler implements UIHandler<TripMapUI> {
    221 194
     
    
    222 195
         @Override
    
    223 196
         public void beforeInit(TripMapUI ui) {
    
    224
    -        this.view = ui;
    
    197
    +        this.ui = ui;
    
    225 198
         }
    
    226 199
     
    
    227 200
         @Override
    
    ... ... @@ -235,12 +208,36 @@ public class TripMapUIHandler implements UIHandler<TripMapUI> {
    235 208
             mapPane.addMouseListener(mouseMapListener);
    
    236 209
             mapPane.addMapPaneListener(new TripMapListener());
    
    237 210
     
    
    238
    -        mapPane.setComponentPopupMenu(view.getMapPopupMenu());
    
    239
    -
    
    240 211
             rendererRunning = false;
    
    241 212
     
    
    242 213
         }
    
    243 214
     
    
    215
    +    public void init(InputMap inputMap) {
    
    216
    +        ObserveActionMap actionMap = ObserveSwingApplicationContext.get().getActionMap();
    
    217
    +
    
    218
    +        init(actionMap, inputMap, ui.zoomIt);
    
    219
    +        init(actionMap, inputMap, ui.zoomMoins);
    
    220
    +        init(actionMap, inputMap, ui.zoomPlus);
    
    221
    +        init(actionMap, inputMap, ui.exportPng);
    
    222
    +
    
    223
    +    }
    
    224
    +
    
    225
    +    public ReferencedEnvelope getTripArea() {
    
    226
    +        return tripArea;
    
    227
    +    }
    
    228
    +
    
    229
    +    public double getZoomRatio() {
    
    230
    +        return zoomRatio;
    
    231
    +    }
    
    232
    +
    
    233
    +    public void setZoomRatio(double zoomRatio) {
    
    234
    +        this.zoomRatio = zoomRatio;
    
    235
    +    }
    
    236
    +
    
    237
    +    public void setZoomCenter(Point zoomCenter) {
    
    238
    +        this.zoomCenter = zoomCenter;
    
    239
    +    }
    
    240
    +
    
    244 241
         private class MouseMapListener implements MouseWheelListener, MouseListener, MouseMotionListener {
    
    245 242
     
    
    246 243
             @Override
    
    ... ... @@ -256,9 +253,9 @@ public class TripMapUIHandler implements UIHandler<TripMapUI> {
    256 253
     
    
    257 254
             }
    
    258 255
     
    
    259
    -        protected Point2D startPointInWorld;
    
    260
    -        protected AffineTransform startScreenToWorldTransform;
    
    261
    -        protected ReferencedEnvelope startDisplayArea;
    
    256
    +        Point2D startPointInWorld;
    
    257
    +        AffineTransform startScreenToWorldTransform;
    
    258
    +        ReferencedEnvelope startDisplayArea;
    
    262 259
     
    
    263 260
             @Override
    
    264 261
             public void mousePressed(MouseEvent e) {
    
    ... ... @@ -294,7 +291,7 @@ public class TripMapUIHandler implements UIHandler<TripMapUI> {
    294 291
     
    
    295 292
             }
    
    296 293
     
    
    297
    -        protected void startMove(Point2D startPointInScreen) {
    
    294
    +        void startMove(Point2D startPointInScreen) {
    
    298 295
                 JMapPane mapPane = getObserveMapPane();
    
    299 296
     
    
    300 297
                 startDisplayArea = mapPane.getDisplayArea();
    
    ... ... @@ -307,7 +304,7 @@ public class TripMapUIHandler implements UIHandler<TripMapUI> {
    307 304
     
    
    308 305
             }
    
    309 306
     
    
    310
    -        protected void endMove(Point2D endPointInScreen) {
    
    307
    +        void endMove(Point2D endPointInScreen) {
    
    311 308
     
    
    312 309
                 Point2D endPointInWorld = new Point2D.Double();
    
    313 310
     
    
    ... ... @@ -332,7 +329,7 @@ public class TripMapUIHandler implements UIHandler<TripMapUI> {
    332 329
     
    
    333 330
         protected class TripMapListener implements MapPaneListener {
    
    334 331
     
    
    335
    -        protected boolean firstRendering;
    
    332
    +        boolean firstRendering;
    
    336 333
     
    
    337 334
             @Override
    
    338 335
             public void onNewMapContent(MapPaneEvent ev) {
    
    ... ... @@ -352,8 +349,13 @@ public class TripMapUIHandler implements UIHandler<TripMapUI> {
    352 349
             public void onRenderingStopped(MapPaneEvent ev) {
    
    353 350
                 rendererRunning = false;
    
    354 351
                 if (firstRendering) {
    
    355
    -                zoomIt();
    
    356
    -                ((CardLayout) view.getLayout()).last(view);
    
    352
    +
    
    353
    +                if (!tripArea.isEmpty()) {
    
    354
    +                    JMapPane mapPane = getObserveMapPane();
    
    355
    +                    mapPane.setDisplayArea(tripArea);
    
    356
    +                }
    
    357
    +
    
    358
    +                ui.getContentLayout().last(ui.getContent());
    
    357 359
                     firstRendering = false;
    
    358 360
                 } else {
    
    359 361
                     zoomApply();
    
    ... ... @@ -361,4 +363,20 @@ public class TripMapUIHandler implements UIHandler<TripMapUI> {
    361 363
             }
    
    362 364
         }
    
    363 365
     
    
    366
    +    protected void init(ObserveActionMap actionMap, InputMap inputMap, AbstractButton editor) {
    
    367
    +        String actionId = (String) editor.getClientProperty(OBSERVE_ACTION);
    
    368
    +
    
    369
    +        // on a trouve une action commune
    
    370
    +        TripMapActionSupport action = (TripMapActionSupport) actionMap.get(actionId);
    
    371
    +        Objects.requireNonNull(action, "action [" + actionId + "] not found for ui " + ui.getClass().getName());
    
    372
    +
    
    373
    +        if (log.isDebugEnabled()) {
    
    374
    +            log.debug("init common action " + actionId);
    
    375
    +        }
    
    376
    +
    
    377
    +        action.setUi(ui);
    
    378
    +        action.initForMainUi(editor, inputMap, actionMap);
    
    379
    +
    
    380
    +    }
    
    381
    +
    
    364 382
     }

  • client/src/main/resources/i18n/client_en_GB.properties
    ... ... @@ -1204,6 +1204,10 @@ observe.content.map.action.exportPng=Export
    1204 1204
     observe.content.map.action.exportPng.tip=Export map in PNG format
    
    1205 1205
     observe.content.map.action.zoomIt=Center
    
    1206 1206
     observe.content.map.action.zoomIt.tip=Center map on the trip
    
    1207
    +observe.content.map.action.zoomMoins=Zoom out
    
    1208
    +observe.content.map.action.zoomMoins.tip=Zoom out
    
    1209
    +observe.content.map.action.zoomPlus=Zoom in
    
    1210
    +observe.content.map.action.zoomPlus.tip=Zoom in
    
    1207 1211
     observe.content.map.east=East
    
    1208 1212
     observe.content.map.export.chooseFile.ok=Exporter
    
    1209 1213
     observe.content.map.export.chooseFile.png=PNG image
    

  • client/src/main/resources/i18n/client_es_ES.properties
    ... ... @@ -1204,6 +1204,10 @@ observe.content.map.action.exportPng=Exportar
    1204 1204
     observe.content.map.action.exportPng.tip=Exportar el mapa en el formato PNG
    
    1205 1205
     observe.content.map.action.zoomIt=Centrar
    
    1206 1206
     observe.content.map.action.zoomIt.tip=Centrar el mapa sobre la marea
    
    1207
    +observe.content.map.action.zoomMoins=Zoom out \#TODO
    
    1208
    +observe.content.map.action.zoomMoins.tip=Zoom out \#TODO
    
    1209
    +observe.content.map.action.zoomPlus=Zoom in \#TODO
    
    1210
    +observe.content.map.action.zoomPlus.tip=Zoom in \#TODO
    
    1207 1211
     observe.content.map.east=Este
    
    1208 1212
     observe.content.map.export.chooseFile.ok=Exportar
    
    1209 1213
     observe.content.map.export.chooseFile.png=imagen PNG
    

  • client/src/main/resources/i18n/client_fr_FR.properties
    ... ... @@ -1204,6 +1204,10 @@ observe.content.map.action.exportPng=Exporter
    1204 1204
     observe.content.map.action.exportPng.tip=Exporter la carte au format PNG
    
    1205 1205
     observe.content.map.action.zoomIt=Centrer
    
    1206 1206
     observe.content.map.action.zoomIt.tip=Centrer la carte sur la marée
    
    1207
    +observe.content.map.action.zoomMoins=Réduire
    
    1208
    +observe.content.map.action.zoomMoins.tip=Réduire
    
    1209
    +observe.content.map.action.zoomPlus=Agrandir
    
    1210
    +observe.content.map.action.zoomPlus.tip=Agrandir
    
    1207 1211
     observe.content.map.east=Est
    
    1208 1212
     observe.content.map.export.chooseFile.ok=Exporter
    
    1209 1213
     observe.content.map.export.chooseFile.png=image PNG
    

  • client/src/main/resources/icons/action-zoomMoins.png
    No preview for this file type
  • client/src/main/resources/icons/action-zoomPlus.png
    No preview for this file type
  • client/src/main/resources/observe-ui.properties
    ... ... @@ -105,6 +105,8 @@ icon.action.data-calcule=action-data-calcule.png
    105 105
     icon.action.numbereditor-reset=action-numbereditor-reset.png
    
    106 106
     icon.action.numbereditor-calculator=action-numbereditor-calculator.png
    
    107 107
     icon.action.center=action-center.png
    
    108
    +icon.action.zoomPlus=action-zoomPlus.png
    
    109
    +icon.action.zoomMoins=action-zoomMoins.png
    
    108 110
     icon.action.config=action-config.png
    
    109 111
     icon.action.consolidate=action-data-calcule.png
    
    110 112
     icon.action.connected=action-connected.png
    

  • services/src/main/java/fr/ird/observe/services/decoration/ObserveI18nLabelsBuilder.java
    1 1
     package fr.ird.observe.services.decoration;
    
    2 2
     
    
    3
    +/*-
    
    4
    + * #%L
    
    5
    + * ObServe :: Services
    
    6
    + * %%
    
    7
    + * Copyright (C) 2008 - 2017 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
    +
    
    3 25
     import com.google.common.collect.ImmutableMap;
    
    4 26
     import fr.ird.observe.services.ObserveDtoInitializer;
    
    5 27
     import fr.ird.observe.services.dto.referential.I18nReferentialDto;