Ignore:
Timestamp:
2009-06-17T09:46:26+02:00 (15 years ago)
Author:
stoecker
Message:

fix build issues

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/WMSAdjustAction.java

    r15841 r15961  
    1 package cadastre_fr; 
     1package cadastre_fr;
    22
    33import static org.openstreetmap.josm.tools.I18n.tr;
     
    2020
    2121public class WMSAdjustAction extends MapMode implements
    22                 MouseListener, MouseMotionListener{
     22        MouseListener, MouseMotionListener{
    2323
    2424    private static final long serialVersionUID = 1L;
    2525    GeorefImage selectedImage;
    2626    private ArrayList<WMSLayer> modifiedLayers = new ArrayList<WMSLayer>();
    27         WMSLayer selectedLayer;
    28         private boolean rasterMoved;
    29         private EastNorth prevEastNorth;
     27    WMSLayer selectedLayer;
     28    private boolean rasterMoved;
     29    private EastNorth prevEastNorth;
    3030    enum Mode { moveXY, moveZ, rotate}
    3131    private Mode mode = null;
    3232
    33         public WMSAdjustAction(MapFrame mapFrame) {
    34                 super(tr("Adjust WMS"), "adjustxywms",
    35                                                 tr("Adjust the position of the WMS layer (raster images only)"), mapFrame,
    36                                                 ImageProvider.getCursor("normal", "move"));
    37         }
     33    public WMSAdjustAction(MapFrame mapFrame) {
     34        super(tr("Adjust WMS"), "adjustxywms",
     35                        tr("Adjust the position of the WMS layer (raster images only)"), mapFrame,
     36                        ImageProvider.getCursor("normal", "move"));
     37    }
    3838
    39         @Override public void enterMode() {
    40                 super.enterMode();
    41                 Main.map.mapView.addMouseListener(this);
    42                 Main.map.mapView.addMouseMotionListener(this);
    43                 rasterMoved = false;
    44                 /*/ FOR TEST
     39    @Override public void enterMode() {
     40        super.enterMode();
     41        Main.map.mapView.addMouseListener(this);
     42        Main.map.mapView.addMouseMotionListener(this);
     43        rasterMoved = false;
     44        /*/ FOR TEST
    4545        for (Layer layer : Main.map.mapView.getAllLayers()) {
    4646            if (layer.visible && layer instanceof WMSLayer) {
     
    5050        }
    5151        Main.map.mapView.repaint();*/
    52         }
     52    }
    5353
    54         @Override public void exitMode() {
    55                 super.exitMode();
    56                 Main.map.mapView.removeMouseListener(this);
    57                 Main.map.mapView.removeMouseMotionListener(this);
    58                 if (rasterMoved && CacheControl.cacheEnabled) {
    59             int reply = JOptionPane.showConfirmDialog(null, 
     54    @Override public void exitMode() {
     55        super.exitMode();
     56        Main.map.mapView.removeMouseListener(this);
     57        Main.map.mapView.removeMouseMotionListener(this);
     58        if (rasterMoved && CacheControl.cacheEnabled) {
     59            int reply = JOptionPane.showConfirmDialog(null,
    6060                    "Save the changes in cache ?",
    6161                    "Update cache",
    62                     JOptionPane.YES_NO_OPTION);             
     62                    JOptionPane.YES_NO_OPTION);
    6363            if (reply == JOptionPane.OK_OPTION) {
    6464                saveModifiedLayers();
    6565            }
    66                 }
    67                 modifiedLayers.clear();
    68         }
     66        }
     67        modifiedLayers.clear();
     68    }
    6969
    70         @Override
     70    @Override
    7171    public void mousePressed(MouseEvent e) {
    7272        if (e.getButton() != MouseEvent.BUTTON1)
     
    9393    }
    9494
    95         @Override public void mouseDragged(MouseEvent e) {
    96                 if(selectedImage != null && (mode == Mode.moveXY || mode == Mode.moveZ || mode == Mode.rotate)) {
     95    @Override public void mouseDragged(MouseEvent e) {
     96        if(selectedImage != null && (mode == Mode.moveXY || mode == Mode.moveZ || mode == Mode.rotate)) {
    9797            EastNorth newEastNorth = Main.map.mapView.getEastNorth(e.getX(),e.getY());
    98                     if (mode == Mode.moveXY) {
    99                         displace(prevEastNorth, newEastNorth);
    100                 } else if (mode == Mode.moveZ) {
    101                     resize(newEastNorth);
    102                 } else if (mode == Mode.rotate) {
    103                     rotate(prevEastNorth, newEastNorth);
    104                 }
     98            if (mode == Mode.moveXY) {
     99                displace(prevEastNorth, newEastNorth);
     100            } else if (mode == Mode.moveZ) {
     101                resize(newEastNorth);
     102            } else if (mode == Mode.rotate) {
     103                rotate(prevEastNorth, newEastNorth);
     104            }
    105105            rasterMoved = true;
    106106            if (!modifiedLayers.contains(selectedLayer))
     
    108108            Main.map.mapView.repaint();
    109109            prevEastNorth = newEastNorth;
    110                 }
    111         }
    112        
    113         private void displace(EastNorth start, EastNorth end) {
     110        }
     111    }
     112
     113    private void displace(EastNorth start, EastNorth end) {
    114114        selectedLayer.displace(end.east()-start.east(), end.north()-start.north());
    115         }
    116        
    117         private void resize(EastNorth newEastNorth) {
     115    }
     116
     117    private void resize(EastNorth newEastNorth) {
    118118        double dPrev = prevEastNorth.distance(selectedLayer.getRasterCenter().east(), selectedLayer.getRasterCenter().north());
    119119        double dNew = newEastNorth.distance(selectedLayer.getRasterCenter().east(), selectedLayer.getRasterCenter().north());
    120120        selectedLayer.resize(1 - dNew/dPrev);
    121         }
    122        
    123         private void rotate(EastNorth start, EastNorth end) {
    124             EastNorth pivot = selectedLayer.getRasterCenter();
    125             double startAngle = Math.atan2(start.east()-pivot.east(), start.north()-pivot.north());
    126             double endAngle = Math.atan2(end.east()-pivot.east(), end.north()-pivot.north());
     121    }
     122
     123    private void rotate(EastNorth start, EastNorth end) {
     124        EastNorth pivot = selectedLayer.getRasterCenter();
     125        double startAngle = Math.atan2(start.east()-pivot.east(), start.north()-pivot.north());
     126        double endAngle = Math.atan2(end.east()-pivot.east(), end.north()-pivot.north());
    127127        double rotationAngle = endAngle - startAngle;
    128         selectedLayer.rotate(rotationAngle);                       
    129         }
     128        selectedLayer.rotate(rotationAngle);
     129    }
    130130
    131         @Override public void mouseReleased(MouseEvent e) {
    132                 //Main.map.mapView.repaint();
    133                 Main.map.mapView.setCursor(Cursor.getDefaultCursor());
    134                 selectedImage = null;   
    135                 prevEastNorth = null;
    136                 selectedLayer = null;
    137                 mode = null;
    138         }
     131    @Override public void mouseReleased(MouseEvent e) {
     132        //Main.map.mapView.repaint();
     133        Main.map.mapView.setCursor(Cursor.getDefaultCursor());
     134        selectedImage = null;
     135        prevEastNorth = null;
     136        selectedLayer = null;
     137        mode = null;
     138    }
    139139
    140         public void mouseEntered(MouseEvent e) {
    141         }
    142         public void mouseExited(MouseEvent e) {
    143         }
    144         public void mouseMoved(MouseEvent e) {
    145         }
     140    public void mouseEntered(MouseEvent e) {
     141    }
     142    public void mouseExited(MouseEvent e) {
     143    }
     144    public void mouseMoved(MouseEvent e) {
     145    }
    146146
    147         @Override public void mouseClicked(MouseEvent e) {
    148         }
    149        
    150         private void saveModifiedLayers() {
     147    @Override public void mouseClicked(MouseEvent e) {
     148    }
     149
     150    private void saveModifiedLayers() {
    151151        for (WMSLayer wmsLayer : modifiedLayers) {
    152152            wmsLayer.saveNewCache();
    153153        }
    154         }
     154    }
    155155}
Note: See TracChangeset for help on using the changeset viewer.