Changeset 25262 in osm for applications


Ignore:
Timestamp:
2011-02-08T20:07:25+01:00 (14 years ago)
Author:
stoecker
Message:

update to josm 3872

Location:
applications/editors/josm/plugins/epsg31287
Files:
1 deleted
2 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/epsg31287/build.xml

    r25199 r25262  
    3737    <property name="commit.message" value="fixed proj4 Parameters (thanks to Hetzi + Mikael Rittri)" />
    3838    <!-- enter the *lowest* JOSM version this plugin is currently compatible with -->
    39     <property name="plugin.main.version" value="3835" />
     39    <property name="plugin.main.version" value="3872" />
    4040
    4141
  • applications/editors/josm/plugins/epsg31287/src/org/openstreetmap/josm/plugins/epsg31287/Epsg31287.java

    r23660 r25262  
    33package org.openstreetmap.josm.plugins.epsg31287;
    44
    5 import static org.openstreetmap.josm.tools.I18n.tr;
    6 import static org.openstreetmap.josm.tools.I18n.marktr;
    7 
    8 import java.awt.event.ActionEvent;
    9 import java.awt.event.KeyEvent;
    10 
    11 import javax.swing.JMenu;
    12 import javax.swing.JMenuItem;
    13 import javax.swing.JOptionPane;
    14 
    15 import org.openstreetmap.josm.Main;
    16 import org.openstreetmap.josm.actions.JosmAction;
    17 import org.openstreetmap.josm.actions.UploadAction;
    18 import org.openstreetmap.josm.data.Bounds;
    19 import org.openstreetmap.josm.data.projection.Mercator;
    20 import org.openstreetmap.josm.data.projection.Projection;
    21 import org.openstreetmap.josm.gui.MainMenu;
    22 import org.openstreetmap.josm.gui.preferences.ProjectionPreference;
     5import org.openstreetmap.josm.data.projection.Projections;
    236import org.openstreetmap.josm.plugins.Plugin;
    247import org.openstreetmap.josm.plugins.PluginInformation;
    258
    269public class Epsg31287 extends Plugin {
    27 
    28     private JMenu mMenu;
    29     private Projection oldProj;
    30     private final String projCode;
    31 
    3210    public Epsg31287(PluginInformation info) {
    3311        super(info);
    34         projCode = ProjectionEPSG31287.getProjCode();
    35         refreshMenu();
     12        Projections.addProjection(new ProjectionEPSG31287());
    3613    }
    37 
    38     public void toggleProjection()
    39     {
    40         Bounds b = (Main.map != null && Main.map.mapView != null) ? Main.map.mapView.getRealBounds() : null;
    41 
    42         try {
    43             // toggle projection
    44             if (Main.proj.toCode().equals(projCode)) {
    45                 // use JOSM built in to fire Listeners
    46                 ProjectionPreference.setProjection(oldProj.getClass().getName(), null);
    47 
    48                 //Main.proj = oldProj;
    49                 //UploadAction.unregisterUploadHook(uploadHook);
    50                 //uploadHook = null;
    51             } else {
    52                 oldProj = Main.proj;
    53                 Main.proj = new ProjectionEPSG31287();
    54                 //TODO use JOSM built in to fire Listeners, does not work currently due to classnotfound ex
    55                 //     ProjectionPreference.setProjection(ProjectionEPSG31287.class.getName(), null);
    56                 UploadAction.registerUploadHook(new EPSG31287UploadHook(this));
    57             }
    58             // toggle Menu
    59             refreshMenu();
    60             // show info
    61             JOptionPane.showMessageDialog(
    62                     Main.parent,
    63                     tr("Current projection is set to {0}", Main.proj.toString()) +
    64                     (Main.proj.toCode().equals(projCode) ?
    65                             tr("\nPlease adjust WMS layer manually by using known exact objects/traces/... before starting to map")
    66                             : ""),
    67                             tr("Info"),
    68                             JOptionPane.INFORMATION_MESSAGE
    69             );
    70         } catch (final Exception e) {
    71             JOptionPane.showMessageDialog(
    72                     Main.parent,
    73                     tr("The projection {0} could not be activated. Using Mercator", projCode),
    74                     tr("Error"),
    75                     JOptionPane.ERROR_MESSAGE
    76             );
    77             Main.proj = new Mercator();
    78         }
    79         if((b != null) && (oldProj != null) && (!Main.proj.getClass().getName().equals(oldProj.getClass().getName()) || Main.proj.hashCode() != oldProj.hashCode()))
    80         {
    81             Main.map.mapView.zoomTo(b);
    82             /* TODO - remove layers with fixed projection */
    83         }
    84     }
    85 
    86     public void refreshMenu() {
    87         MainMenu menu = Main.main.menu;
    88 
    89         if (mMenu == null)
    90             mMenu = menu.addMenu(marktr("EPSG31287"), KeyEvent.VK_S, menu.defaultMenuPos, null);
    91         else
    92             mMenu.removeAll();
    93         // toggle menu text based on current projection
    94         if (Main.proj.toCode().equals(projCode)) {
    95             mMenu.add(new JMenuItem(new
    96                     JosmAction(tr("set {0}",oldProj.toString())
    97                             ,"wmsmenu.png"
    98                             ,tr("set projection from {0} to {1}",projCode,oldProj.toString())
    99                             , null, false)
    100             {
    101                 private static final long serialVersionUID = 7610502878925107647L;
    102                 @Override
    103                 public void actionPerformed(ActionEvent ev) {
    104                     toggleProjection();
    105                 }
    106             }));
    107         } else {
    108             mMenu.add(new JMenuItem(new
    109                     JosmAction(tr("set {0}",projCode)
    110                             ,"wmsmenu_off.png"
    111                             ,tr("set projection from {0} to {1}",Main.proj.toString() ,projCode)
    112                             , null, false)
    113             {
    114                 private static final long serialVersionUID = 7610502878925107646L;
    115                 @Override
    116                 public void actionPerformed(ActionEvent ev) {
    117                     toggleProjection();
    118                 }
    119             }));
    120         }
    121     }
    122 
    12314}
Note: See TracChangeset for help on using the changeset viewer.