Changeset 24812 in osm for applications


Ignore:
Timestamp:
2010-12-20T13:04:26+01:00 (14 years ago)
Author:
upliner
Message:

Add imageryadjust plugin that enables old-style imagery adjust mapmode

Location:
applications/editors/josm/plugins/imageryadjust
Files:
2 added
1 edited
4 copied

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/imageryadjust

    • Property svn:ignore set to
      bin
      build
  • applications/editors/josm/plugins/imageryadjust/.classpath

    r24713 r24812  
    33        <classpathentry kind="src" path="src"/>
    44        <classpathentry including="images/" kind="src" path=""/>
    5         <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JDK 6"/>
     5        <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
    66        <classpathentry combineaccessrules="false" kind="src" path="/JOSM"/>
    7         <classpathentry combineaccessrules="false" kind="src" path="/remotecontrol"/>
    87        <classpathentry kind="output" path="build"/>
    98</classpath>
  • applications/editors/josm/plugins/imageryadjust/.project

    r24713 r24812  
    11<?xml version="1.0" encoding="UTF-8"?>
    22<projectDescription>
    3         <name>wmsplugin</name>
     3        <name>imageryadjust</name>
    44        <comment></comment>
    55        <projects>
  • applications/editors/josm/plugins/imageryadjust/build.xml

    r23263 r24812  
    2828**
    2929-->
    30 <project name="myPluginName" default="dist" basedir=".">
     30<project name="imageryadjust" default="dist" basedir=".">
    3131
    3232    <!-- enter the SVN commit message -->
     
    100100    -->
    101101            <manifest>
    102                 <attribute name="Author" value="..."/>
    103                 <attribute name="Plugin-Class" value="..."/>
     102                <attribute name="Author" value="Upliner"/>
     103                <attribute name="Plugin-Class" value="imageryadjust.ImageryAdjustPlugin"/>
    104104                <attribute name="Plugin-Date" value="${version.entry.commit.date}"/>
    105                 <attribute name="Plugin-Description" value="..."/>
    106                 <attribute name="Plugin-Icon" value="..."/>
    107                 <attribute name="Plugin-Link" value="..."/>
     105                <attribute name="Plugin-Description" value="WMSPlugin-style imagery adjustment mapmode"/>
     106                <attribute name="Plugin-Icon" value="mapmode/adjustimg.png"/>
     107                <attribute name="Plugin-Link" value="http://wiki.openstreetmap.org/wiki/JOSM/Plugins/WMSPlugin"/>
    108108                <attribute name="Plugin-Mainversion" value="${plugin.main.version}"/>
    109109                <attribute name="Plugin-Version" value="${version.entry.commit.revision}"/>
  • applications/editors/josm/plugins/imageryadjust/src/imageryadjust/ImageryAdjustMapMode.java

    r24713 r24812  
    1 package wmsplugin;
     1package imageryadjust;
    22
    33import static org.openstreetmap.josm.tools.I18n.tr;
     
    2525import org.openstreetmap.josm.gui.ExtendedDialog;
    2626import org.openstreetmap.josm.gui.MapFrame;
     27import org.openstreetmap.josm.gui.layer.ImageryLayer;
    2728import org.openstreetmap.josm.gui.layer.Layer;
    2829import org.openstreetmap.josm.tools.GBC;
    2930import org.openstreetmap.josm.tools.ImageProvider;
    3031
    31 
    32 public class WMSAdjustAction extends MapMode implements MouseListener, MouseMotionListener{
    33     //static private final Logger logger = Logger.getLogger(WMSAdjustAction.class.getName());
    34 
    35     GeorefImage selectedImage;
     32public class ImageryAdjustMapMode extends MapMode implements MouseListener, MouseMotionListener{
    3633    boolean mouseDown;
    3734    EastNorth prevEastNorth;
    38     private WMSLayer adjustingLayer;
     35    private ImageryLayer adjustingLayer;
    3936
    40     public WMSAdjustAction(MapFrame mapFrame) {
    41         super(tr("Adjust WMS"), "adjustwms",
    42                 tr("Adjust the position of the selected WMS layer"), mapFrame,
     37    public ImageryAdjustMapMode(MapFrame mapFrame) {
     38        super(tr("Adjust imagery"), "adjustimg",
     39                tr("Adjust the position of the selected imagery layer"), mapFrame,
    4340                ImageProvider.getCursor("normal", "move"));
    4441    }
    4542
    46 
    47 
    4843    @Override public void enterMode() {
    4944        super.enterMode();
    50         if (!hasWMSLayersToAdjust()) {
    51             warnNoWMSLayers();
     45        if (!hasImageryLayersToAdjust()) {
     46            warnNoImageryLayers();
    5247            return;
    5348        }
    54         List<WMSLayer> wmsLayers = Main.map.mapView.getLayersOfType(WMSLayer.class);
    55         if (wmsLayers.size() == 1) {
    56             adjustingLayer = wmsLayers.get(0);
     49        List<ImageryLayer> layers = Main.map.mapView.getLayersOfType(ImageryLayer.class);
     50        if (layers.size() == 1) {
     51            adjustingLayer = layers.get(0);
    5752        } else {
    58             adjustingLayer = (WMSLayer)askAdjustLayer(Main.map.mapView.getLayersOfType(WMSLayer.class));
     53            adjustingLayer = (ImageryLayer)askAdjustLayer(Main.map.mapView.getLayersOfType(ImageryLayer.class));
    5954        }
    6055        if (adjustingLayer == null)
     
    8075        if (adjustingLayer.isVisible()) {
    8176            prevEastNorth=Main.map.mapView.getEastNorth(e.getX(),e.getY());
    82             selectedImage = adjustingLayer.findImage(prevEastNorth);
    83             if(selectedImage!=null) {
    84                 Main.map.mapView.setCursor
    85                 (Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR));
    86             }
     77            Main.map.mapView.setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR));
    8778        }
    8879    }
    8980
    9081    @Override public void mouseDragged(MouseEvent e) {
    91         if(selectedImage!=null) {
    92             EastNorth eastNorth=
    93                 Main.map.mapView.getEastNorth(e.getX(),e.getY());
    94             adjustingLayer.displace(
    95                     eastNorth.east()-prevEastNorth.east(),
    96                     eastNorth.north()-prevEastNorth.north()
    97             );
    98             prevEastNorth = eastNorth;
    99             Main.map.mapView.repaint();
    100         }
     82        if (adjustingLayer == null || prevEastNorth == null) return;
     83        EastNorth eastNorth=
     84            Main.map.mapView.getEastNorth(e.getX(),e.getY());
     85        adjustingLayer.displace(
     86                eastNorth.east()-prevEastNorth.east(),
     87                eastNorth.north()-prevEastNorth.north()
     88        );
     89        prevEastNorth = eastNorth;
     90        Main.map.mapView.repaint();
    10191    }
    10292
     
    10494        Main.map.mapView.repaint();
    10595        Main.map.mapView.setCursor(Cursor.getDefaultCursor());
    106         selectedImage = null;
    10796        prevEastNorth = null;
    10897    }
    10998
    110     @Override
    111     public void mouseEntered(MouseEvent e) {
    112     }
    113 
    114     @Override
    115     public void mouseExited(MouseEvent e) {
    116     }
    117 
    118     @Override
    119     public void mouseMoved(MouseEvent e) {
    120     }
    121 
    122     @Override public void mouseClicked(MouseEvent e) {
    123     }
    124 
    12599    @Override public boolean layerIsSupported(Layer l) {
    126         return hasWMSLayersToAdjust();
     100        return hasImageryLayersToAdjust();
    127101    }
    128102
     
    168142        JPanel pnl = new JPanel();
    169143        pnl.setLayout(new GridBagLayout());
    170         pnl.add(new JLabel(tr("Please select the WMS layer to adjust.")), GBC.eol());
     144        pnl.add(new JLabel(tr("Please select the imagery layer to adjust.")), GBC.eol());
    171145        pnl.add(layerList, GBC.eol());
    172146
    173147        ExtendedDialog diag = new ExtendedDialog(
    174148                Main.parent,
    175                 tr("Select WMS layer"),
     149                tr("Select imagery layer"),
    176150                new String[] { tr("Start adjusting"),tr("Cancel") }
    177151        );
    178152        diag.setContent(pnl);
    179         diag.setButtonIcons(new String[] { "mapmode/adjustwms", "cancel" });
     153        diag.setButtonIcons(new String[] { "mapmode/adjustimg", "cancel" });
    180154        diag.showDialog();
    181155        int decision = diag.getValue();
     
    187161
    188162    /**
    189      * Displays a warning message if there are no WMS layers to adjust
     163     * Displays a warning message if there are no imagery layers to adjust
    190164     *
    191165     */
    192     protected void warnNoWMSLayers() {
     166    protected void warnNoImageryLayers() {
    193167        JOptionPane.showMessageDialog(
    194168                Main.parent,
    195                 tr("There are currently no WMS layer to adjust."),
     169                tr("There are currently no imagery layer to adjust."),
    196170                tr("No layers to adjust"),
    197171                JOptionPane.WARNING_MESSAGE
     
    200174
    201175    /**
    202      * Replies true if there is at least one WMS layer
     176     * Replies true if there is at least one imagery layer
    203177     *
    204      * @return true if there is at least one WMS layer
     178     * @return true if there is at least one imagery layer
    205179     */
    206     protected boolean hasWMSLayersToAdjust() {
     180    protected boolean hasImageryLayersToAdjust() {
    207181        if (Main.map == null) return false;
    208182        if (Main.map.mapView == null) return false;
    209         return ! Main.map.mapView.getLayersOfType(WMSLayer.class).isEmpty();
     183        return ! Main.map.mapView.getLayersOfType(ImageryLayer.class).isEmpty();
    210184    }
    211185
    212186    @Override
    213187    protected void updateEnabledState() {
    214         setEnabled(hasWMSLayersToAdjust());
     188        setEnabled(hasImageryLayersToAdjust());
    215189    }
    216190}
Note: See TracChangeset for help on using the changeset viewer.