Ignore:
Timestamp:
2010-09-15T18:54:18+02:00 (14 years ago)
Author:
stoecker
Message:

remove tabs

Location:
applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer
Files:
19 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/CalibrationFileFilter.java

    r20217 r23190  
    3030 */
    3131public class CalibrationFileFilter extends FileFilter {
    32        
    33         // Extension used by calibration files
    34         public static final String EXTENSION = ".cal";
    3532
    36         @Override
    37         public boolean accept(File f) {
    38             String ext3 = ( f.getName().length() > 4 ) ?  f.getName().substring( f.getName().length() - 4 ).toLowerCase() : "";
     33    // Extension used by calibration files
     34    public static final String EXTENSION = ".cal";
    3935
    40             // TODO: check what is supported by Java :)
    41             return ( f.isDirectory()
    42                 ||      ext3.equals( EXTENSION )
    43                 );
    44         }
     36    @Override
     37    public boolean accept(File f) {
     38        String ext3 = ( f.getName().length() > 4 ) ?  f.getName().substring( f.getName().length() - 4 ).toLowerCase() : "";
    4539
    46         @Override
    47         public String getDescription() {
    48                 return tr("Calibration Files")+ " (*" + EXTENSION + ")";
    49         }
     40        // TODO: check what is supported by Java :)
     41        return ( f.isDirectory()
     42            ||  ext3.equals( EXTENSION )
     43            );
     44    }
     45
     46    @Override
     47    public String getDescription() {
     48        return tr("Calibration Files")+ " (*" + EXTENSION + ")";
     49    }
    5050}
  • applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/LoadPictureCalibrationAction.java

    r20217 r23190  
    4444public class LoadPictureCalibrationAction extends JosmAction {
    4545
    46         // Owner layer of the action
    47         PicLayerAbstract m_owner = null;
    48        
    49         /**
    50         * Constructor
    51         */
    52         public LoadPictureCalibrationAction( PicLayerAbstract owner ) {
    53                 super(tr("Load Picture Calibration..."), null, tr("Loads calibration data to a file"), null, false);
    54                 // Remember the owner...
    55                 m_owner = owner;
    56         }
    57        
    58         /**
    59         * Action handler
    60         */
    61         public void actionPerformed(ActionEvent arg0) {
    62                 // Save dialog
    63                 final JFileChooser fc = new JFileChooser();
    64                 fc.setAcceptAllFileFilterUsed( false );
    65                 fc.setFileFilter( new CalibrationFileFilter() );
    66                 fc.setSelectedFile( new File(m_owner.getPicLayerName() + CalibrationFileFilter.EXTENSION));
    67                 int result = fc.showOpenDialog(Main.parent );
     46    // Owner layer of the action
     47    PicLayerAbstract m_owner = null;
     48   
     49    /**
     50    * Constructor
     51    */
     52    public LoadPictureCalibrationAction( PicLayerAbstract owner ) {
     53        super(tr("Load Picture Calibration..."), null, tr("Loads calibration data to a file"), null, false);
     54        // Remember the owner...
     55        m_owner = owner;
     56    }
     57   
     58    /**
     59    * Action handler
     60    */
     61    public void actionPerformed(ActionEvent arg0) {
     62        // Save dialog
     63        final JFileChooser fc = new JFileChooser();
     64        fc.setAcceptAllFileFilterUsed( false );
     65        fc.setFileFilter( new CalibrationFileFilter() );
     66        fc.setSelectedFile( new File(m_owner.getPicLayerName() + CalibrationFileFilter.EXTENSION));
     67        int result = fc.showOpenDialog(Main.parent );
    6868
    69                 if ( result == JFileChooser.APPROVE_OPTION ) {
    70                                        
    71                         // Load
    72                         try {
    73                                 Properties props = new Properties();
    74                                 props.load(new FileInputStream(fc.getSelectedFile()));
    75                                 m_owner.loadCalibration(props);
    76                         } catch (Exception e) {
    77                                 // Error
    78                                 e.printStackTrace();
    79                                 JOptionPane.showMessageDialog(Main.parent , tr("Loading file failed: {0}", e.getMessage()));
    80                         }
    81                 }
    82         }
     69        if ( result == JFileChooser.APPROVE_OPTION ) {
     70                   
     71            // Load
     72            try {
     73                Properties props = new Properties();
     74                props.load(new FileInputStream(fc.getSelectedFile()));
     75                m_owner.loadCalibration(props);
     76            } catch (Exception e) {
     77                // Error
     78                e.printStackTrace();
     79                JOptionPane.showMessageDialog(Main.parent , tr("Loading file failed: {0}", e.getMessage()));
     80            }
     81        }
     82    }
    8383}
  • applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/MovePictureAction.java

    r20217 r23190  
    3838 * This class handles the input during moving the picture.
    3939 */
    40 public class MovePictureAction extends MapMode implements MouseListener, MouseMotionListener 
     40public class MovePictureAction extends MapMode implements MouseListener, MouseMotionListener
    4141{
    42         // Action ongoing?
    43         private boolean mb_dragging = false;
    44        
    45         // Last mouse position
    46         private EastNorth m_prevEastNorth;
    47        
    48         // The layer we're working on
    49         private PicLayerAbstract m_currentLayer = null;
    50        
    51         /**
    52          * Constructor
    53          */
    54         public MovePictureAction(MapFrame frame) {
    55                 super(tr("PicLayer move"), "move", tr("Drag to move the picture"), frame, ImageProvider.getCursor("crosshair", null));
    56         }
     42    // Action ongoing?
     43    private boolean mb_dragging = false;
    5744
    58     @Override
     45    // Last mouse position
     46    private EastNorth m_prevEastNorth;
     47
     48    // The layer we're working on
     49    private PicLayerAbstract m_currentLayer = null;
     50
     51    /**
     52     * Constructor
     53     */
     54    public MovePictureAction(MapFrame frame) {
     55        super(tr("PicLayer move"), "move", tr("Drag to move the picture"), frame, ImageProvider.getCursor("crosshair", null));
     56    }
     57
     58    @Override
    5959    public void enterMode() {
    6060        super.enterMode();
     
    6363    }
    6464
    65     @Override 
     65    @Override
    6666    public void exitMode() {
    6767        super.exitMode();
    6868        Main.map.mapView.removeMouseListener(this);
    6969        Main.map.mapView.removeMouseMotionListener(this);
    70     }   
    71        
    72     @Override 
     70    }
     71
     72    @Override
    7373    public void mousePressed(MouseEvent e) {
    74        
    75         // If everything is OK, we start dragging/moving the picture
    76         if ( Main.map.mapView.getActiveLayer() instanceof PicLayerAbstract ) {
    77                 m_currentLayer = (PicLayerAbstract)Main.map.mapView.getActiveLayer();
    78                
    79                 if ( m_currentLayer != null && e.getButton() == MouseEvent.BUTTON1 ) {
    80                         mb_dragging = true;
    81                         m_prevEastNorth=Main.map.mapView.getEastNorth(e.getX(),e.getY());
    82                 }
    83         }
    84     }   
    85    
    86     @Override 
     74
     75        // If everything is OK, we start dragging/moving the picture
     76        if ( Main.map.mapView.getActiveLayer() instanceof PicLayerAbstract ) {
     77            m_currentLayer = (PicLayerAbstract)Main.map.mapView.getActiveLayer();
     78
     79            if ( m_currentLayer != null && e.getButton() == MouseEvent.BUTTON1 ) {
     80                mb_dragging = true;
     81                m_prevEastNorth=Main.map.mapView.getEastNorth(e.getX(),e.getY());
     82            }
     83        }
     84    }
     85
     86    @Override
    8787    public void mouseDragged(MouseEvent e) {
    88         // Picture moving is ongoing
     88        // Picture moving is ongoing
    8989        if(mb_dragging) {
    9090            EastNorth eastNorth = Main.map.mapView.getEastNorth(e.getX(),e.getY());
    9191            m_currentLayer.movePictureBy(
    92                 eastNorth.east()-m_prevEastNorth.east(),
     92                eastNorth.east()-m_prevEastNorth.east(),
    9393                eastNorth.north()-m_prevEastNorth.north()
    9494            );
     
    9696            Main.map.mapView.repaint();
    9797        }
    98     }   
    99    
    100     @Override 
     98    }
     99
     100    @Override
    101101    public void mouseReleased(MouseEvent e) {
    102         // Stop moving
    103         mb_dragging = false;
    104     }   
     102        // Stop moving
     103        mb_dragging = false;
     104    }
    105105
    106106}
  • applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/NewLayerFromClipboardAction.java

    r22549 r23190  
    3535 */
    3636public class NewLayerFromClipboardAction extends JosmAction {
    37        
    38         /**
    39          * Constructor...
    40          */
    41         public NewLayerFromClipboardAction() {
    42                 super(tr("New picture layer from clipboard"), null, null, null, false);
    43         }
    4437
    45         /**
    46          * Action handler
    47          */
    48         public void actionPerformed(ActionEvent arg0) {
    49                 // Create layer from clipboard
    50                 PicLayerFromClipboard layer = new PicLayerFromClipboard();
    51                 // Add layer only if successfully initialized
    52                 try {
    53                         layer.initialize();
    54                 }
    55                 catch (IOException e) {
    56                         // Failed
    57                         System.out.println( "NewLayerFromClipboardAction::actionPerformed - " + e.getMessage() );
    58                         JOptionPane.showMessageDialog(null, e.getMessage() ); 
    59                         return;
    60                 }
    61                 // Add layer
    62                 Main.main.addLayer( layer );
    63         }
     38    /**
     39     * Constructor...
     40     */
     41    public NewLayerFromClipboardAction() {
     42        super(tr("New picture layer from clipboard"), null, null, null, false);
     43    }
     44
     45    /**
     46     * Action handler
     47     */
     48    public void actionPerformed(ActionEvent arg0) {
     49        // Create layer from clipboard
     50        PicLayerFromClipboard layer = new PicLayerFromClipboard();
     51        // Add layer only if successfully initialized
     52        try {
     53            layer.initialize();
     54        }
     55        catch (IOException e) {
     56            // Failed
     57            System.out.println( "NewLayerFromClipboardAction::actionPerformed - " + e.getMessage() );
     58            JOptionPane.showMessageDialog(null, e.getMessage() );
     59            return;
     60        }
     61        // Add layer
     62        Main.main.addLayer( layer );
     63    }
    6464}
  • applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/NewLayerFromFileAction.java

    r22549 r23190  
    3939 */
    4040public class NewLayerFromFileAction extends JosmAction {
    41        
    42         /**
    43          * Provides filtering of only image files.
    44          */
    45         private class ImageFileFilter extends FileFilter {
    4641
    47                 @Override
    48                 public boolean accept(File f) {
    49                    
    50                     String ext3 = ( f.getName().length() > 4 ) ?  f.getName().substring( f.getName().length() - 4 ).toLowerCase() : "";
    51                     String ext4 = ( f.getName().length() > 5 ) ?  f.getName().substring( f.getName().length() - 5 ).toLowerCase() : "";
     42    /**
     43     * Provides filtering of only image files.
     44     */
     45    private class ImageFileFilter extends FileFilter {
    5246
    53                     // TODO: check what is supported by Java :)
    54                     return ( f.isDirectory()
    55                         ||      ext3.equals( ".jpg" )
    56                         ||      ext4.equals( ".jpeg" )
    57                         ||      ext3.equals( ".png" )
    58                         );
    59                 }
     47        @Override
     48        public boolean accept(File f) {
     49
     50            String ext3 = ( f.getName().length() > 4 ) ?  f.getName().substring( f.getName().length() - 4 ).toLowerCase() : "";
     51            String ext4 = ( f.getName().length() > 5 ) ?  f.getName().substring( f.getName().length() - 5 ).toLowerCase() : "";
     52
     53            // TODO: check what is supported by Java :)
     54            return ( f.isDirectory()
     55                ||  ext3.equals( ".jpg" )
     56                ||  ext4.equals( ".jpeg" )
     57                ||  ext3.equals( ".png" )
     58                );
     59        }
    6060
    6161
    62                 @Override
    63                 public String getDescription() {
    64                         return tr("Image files");
    65                 }
    66                
    67         }
    68        
    69         /**
    70          * Constructor...
    71          */
    72         public NewLayerFromFileAction() {
    73                 super(tr("New picture layer from file..."), null, null, null, false);
    74         }
     62        @Override
     63        public String getDescription() {
     64            return tr("Image files");
     65        }
    7566
    76         /**
    77          * Action handler
    78          */
    79         public void actionPerformed(ActionEvent arg0) {
    80                
    81                 // Choose a file
    82                 JFileChooser fc = new JFileChooser();
    83                 fc.setAcceptAllFileFilterUsed( false );
    84                 fc.setFileFilter( new ImageFileFilter() );
    85                 int result = fc.showOpenDialog( Main.parent );
    86                
    87                 // Create a layer?
    88                 if ( result == JFileChooser.APPROVE_OPTION ) {
    89                         // Create layer from file
    90                         PicLayerFromFile layer = new PicLayerFromFile( fc.getSelectedFile() );
    91                         // Add layer only if successfully initialized
    92                         try {
    93                                 layer.initialize();
    94                         }
    95                         catch (IOException e) {
    96                                 // Failed
    97                                 System.out.println( "NewLayerFromFileAction::actionPerformed - " + e.getMessage() );
    98                                 JOptionPane.showMessageDialog(null, e.getMessage() ); 
    99                                 return;
    100                         }
    101                         // Add layer
    102                         Main.main.addLayer( layer );
    103                 }
    104                
    105         }
     67    }
     68
     69    /**
     70     * Constructor...
     71     */
     72    public NewLayerFromFileAction() {
     73        super(tr("New picture layer from file..."), null, null, null, false);
     74    }
     75
     76    /**
     77     * Action handler
     78     */
     79    public void actionPerformed(ActionEvent arg0) {
     80
     81        // Choose a file
     82        JFileChooser fc = new JFileChooser();
     83        fc.setAcceptAllFileFilterUsed( false );
     84        fc.setFileFilter( new ImageFileFilter() );
     85        int result = fc.showOpenDialog( Main.parent );
     86
     87        // Create a layer?
     88        if ( result == JFileChooser.APPROVE_OPTION ) {
     89            // Create layer from file
     90            PicLayerFromFile layer = new PicLayerFromFile( fc.getSelectedFile() );
     91            // Add layer only if successfully initialized
     92            try {
     93                layer.initialize();
     94            }
     95            catch (IOException e) {
     96                // Failed
     97                System.out.println( "NewLayerFromFileAction::actionPerformed - " + e.getMessage() );
     98                JOptionPane.showMessageDialog(null, e.getMessage() );
     99                return;
     100            }
     101            // Add layer
     102            Main.main.addLayer( layer );
     103        }
     104
     105    }
    106106}
  • applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/PicLayerAbstract.java

    r22549 r23190  
    275275     */
    276276    public void saveCalibration( Properties props ) {
    277         // Save
    278         props.put(INITIAL_POS_X, "" + m_initial_position.getX());
    279         props.put(INITIAL_POS_Y, "" + m_initial_position.getY());
    280         props.put(POSITION_X, "" + m_position.getX());
    281         props.put(POSITION_Y, "" + m_position.getY());
    282         props.put(INITIAL_SCALE, "" + m_initial_scale);
    283         props.put(SCALEX, "" + m_scalex);
    284         props.put(SCALEY, "" + m_scaley);
    285         props.put(ANGLE, "" + m_angle);
     277        // Save
     278        props.put(INITIAL_POS_X, "" + m_initial_position.getX());
     279        props.put(INITIAL_POS_Y, "" + m_initial_position.getY());
     280        props.put(POSITION_X, "" + m_position.getX());
     281        props.put(POSITION_Y, "" + m_position.getY());
     282        props.put(INITIAL_SCALE, "" + m_initial_scale);
     283        props.put(SCALEX, "" + m_scalex);
     284        props.put(SCALEY, "" + m_scaley);
     285        props.put(ANGLE, "" + m_angle);
    286286    }
    287287
     
    292292     */
    293293    public void loadCalibration( Properties props ) {
    294         // Load
    295                 double pos_x = Double.valueOf( props.getProperty(POSITION_X));
    296                 double pos_y = Double.valueOf( props.getProperty(POSITION_Y));
    297                 double in_pos_x = Double.valueOf( props.getProperty(INITIAL_POS_X));
    298                 double in_pos_y = Double.valueOf( props.getProperty(INITIAL_POS_Y));
    299                 double angle = Double.valueOf( props.getProperty(ANGLE));
    300                 double in_scale = Double.valueOf( props.getProperty(INITIAL_SCALE));
    301                 double scale_x = Double.valueOf( props.getProperty(SCALEX));
    302                 double scale_y = Double.valueOf( props.getProperty(SCALEY));
    303                         m_position.setLocation(pos_x, pos_y);
    304                 m_initial_position.setLocation(pos_x, pos_y);
    305                 m_angle = angle;
    306                 m_scalex = scale_x;
    307                 m_scaley = scale_y;
    308                 m_initial_scale = in_scale;
    309                 // Refresh
     294        // Load
     295            double pos_x = Double.valueOf( props.getProperty(POSITION_X));
     296            double pos_y = Double.valueOf( props.getProperty(POSITION_Y));
     297            double in_pos_x = Double.valueOf( props.getProperty(INITIAL_POS_X));
     298            double in_pos_y = Double.valueOf( props.getProperty(INITIAL_POS_Y));
     299            double angle = Double.valueOf( props.getProperty(ANGLE));
     300            double in_scale = Double.valueOf( props.getProperty(INITIAL_SCALE));
     301            double scale_x = Double.valueOf( props.getProperty(SCALEX));
     302            double scale_y = Double.valueOf( props.getProperty(SCALEY));
     303            m_position.setLocation(pos_x, pos_y);
     304            m_initial_position.setLocation(pos_x, pos_y);
     305            m_angle = angle;
     306            m_scalex = scale_x;
     307            m_scaley = scale_y;
     308            m_initial_scale = in_scale;
     309            // Refresh
    310310            Main.map.mapView.repaint();
    311311    }
     
    313313    private class ResetSubmenuAction extends AbstractAction implements LayerAction {
    314314
    315         public ResetSubmenuAction() {
    316                 super(tr("Reset"));
    317                 }
    318 
    319                 public void actionPerformed(ActionEvent e) {
    320                 }
    321 
    322                 public Component createMenuComponent() {
    323                         JMenu reset_submenu = new JMenu(this);
    324                 reset_submenu.add( new ResetPictureAllAction( PicLayerAbstract.this ) );
    325                 reset_submenu.addSeparator();
    326                 reset_submenu.add( new ResetPicturePositionAction( PicLayerAbstract.this ) );
    327                 reset_submenu.add( new ResetPictureAngleAction( PicLayerAbstract.this ) );
    328                 reset_submenu.add( new ResetPictureScaleAction( PicLayerAbstract.this ) );
    329                 return reset_submenu;
    330                 }
    331 
    332                 public boolean supportLayers(List<Layer> layers) {
    333                         return layers.size() == 1 && layers.get(0) instanceof PicLayerAbstract;
    334                 }
     315        public ResetSubmenuAction() {
     316            super(tr("Reset"));
     317        }
     318
     319        public void actionPerformed(ActionEvent e) {
     320        }
     321
     322        public Component createMenuComponent() {
     323            JMenu reset_submenu = new JMenu(this);
     324            reset_submenu.add( new ResetPictureAllAction( PicLayerAbstract.this ) );
     325            reset_submenu.addSeparator();
     326            reset_submenu.add( new ResetPicturePositionAction( PicLayerAbstract.this ) );
     327            reset_submenu.add( new ResetPictureAngleAction( PicLayerAbstract.this ) );
     328            reset_submenu.add( new ResetPictureScaleAction( PicLayerAbstract.this ) );
     329            return reset_submenu;
     330        }
     331
     332        public boolean supportLayers(List<Layer> layers) {
     333            return layers.size() == 1 && layers.get(0) instanceof PicLayerAbstract;
     334        }
    335335
    336336    }
  • applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/PicLayerFromClipboard.java

    r20217 r23190  
    3535public class PicLayerFromClipboard extends PicLayerAbstract {
    3636
    37         @Override
    38         protected Image createImage() throws IOException {
    39                 // Return item
    40                 Image image = null;
    41                 // Access the clipboard
     37    @Override
     38    protected Image createImage() throws IOException {
     39        // Return item
     40        Image image = null;
     41        // Access the clipboard
    4242        Transferable t = Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null);
    4343        // Check result
    4444        if ( t == null ) {
    45                 throw new IOException(tr("Nothing in clipboard"));
     45            throw new IOException(tr("Nothing in clipboard"));
    4646        }
    47        
     47
    4848        // TODO: Why is it so slow?
    4949        // Try to make it an image data
     
    5252                image = (Image)t.getTransferData(DataFlavor.imageFlavor);
    5353            } else {
    54                 throw new IOException(tr("The clipboard data is not an image"));
     54                throw new IOException(tr("The clipboard data is not an image"));
    5555            }
    5656        } catch (UnsupportedFlavorException e) {
    57                 throw new IOException( e.getMessage() );
    58         } 
    59        
     57            throw new IOException( e.getMessage() );
     58        }
     59
    6060        return image;
    61         }
     61    }
    6262
    63         @Override
    64         protected String getPicLayerName() {
    65                 return "Clipboard";
    66         }
     63    @Override
     64    protected String getPicLayerName() {
     65        return "Clipboard";
     66    }
    6767
    6868}
  • applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/PicLayerFromFile.java

    r17327 r23190  
    3030 */
    3131public class PicLayerFromFile extends PicLayerAbstract {
    32        
    33         // File to load from.
    34         private File m_file;
    35         // Tooltip text
    36         private String m_tooltiptext;
     32
     33    // File to load from.
     34    private File m_file;
     35    // Tooltip text
     36    private String m_tooltiptext;
    3737
    3838    public PicLayerFromFile( File file ) {
    39         // Remember the file
    40         m_file = file;
    41         // Generate tooltip text
    42         m_tooltiptext = m_file.getAbsolutePath();
    43     }   
    44    
    45         @Override
    46         protected Image createImage() throws IOException {
     39        // Remember the file
     40        m_file = file;
     41        // Generate tooltip text
     42        m_tooltiptext = m_file.getAbsolutePath();
     43    }
     44
     45    @Override
     46    protected Image createImage() throws IOException {
    4747        // Try to load file
    48                 Image image = null;
    49                 image = ImageIO.read( m_file );
    50                 return image;
    51         }
     48        Image image = null;
     49        image = ImageIO.read( m_file );
     50        return image;
     51    }
    5252
    53         @Override
    54         protected String getPicLayerName() {
    55                 return m_tooltiptext;
    56         }       
     53    @Override
     54    protected String getPicLayerName() {
     55        return m_tooltiptext;
     56    }
    5757}
  • applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/PicLayerPlugin.java

    r20217 r23190  
    5959     */
    6060    public PicLayerPlugin(PluginInformation info) {
    61         super(info);
    62        
     61        super(info);
     62
    6363        // Create menu entry
    6464        if ( Main.main.menu != null ) {
  • applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/ResetPictureAllAction.java

    r20217 r23190  
    3535public class ResetPictureAllAction extends JosmAction {
    3636
    37         // Owner layer of the action
    38         PicLayerAbstract m_owner = null;
    39        
    40         /**
    41         * Constructor
    42         */
    43         public ResetPictureAllAction( PicLayerAbstract owner ) {
    44                 super(tr("All"), null, tr("Resets picture calibration"), null, false);
    45                 // Remember the owner...
    46                 m_owner = owner;
    47         }
    48        
    49         /**
    50         * Action handler
    51         */
    52         public void actionPerformed(ActionEvent arg0) {
    53                 // Reset
    54                 m_owner.resetAngle();
    55                 m_owner.resetPosition();
    56                 m_owner.resetScale();
    57                 // Redraw
     37    // Owner layer of the action
     38    PicLayerAbstract m_owner = null;
     39   
     40    /**
     41    * Constructor
     42    */
     43    public ResetPictureAllAction( PicLayerAbstract owner ) {
     44        super(tr("All"), null, tr("Resets picture calibration"), null, false);
     45        // Remember the owner...
     46        m_owner = owner;
     47    }
     48   
     49    /**
     50    * Action handler
     51    */
     52    public void actionPerformed(ActionEvent arg0) {
     53        // Reset
     54        m_owner.resetAngle();
     55        m_owner.resetPosition();
     56        m_owner.resetScale();
     57        // Redraw
    5858        Main.map.mapView.repaint();
    59         }
     59    }
    6060}
  • applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/ResetPictureAngleAction.java

    r20217 r23190  
    3535public class ResetPictureAngleAction extends JosmAction {
    3636
    37         // Owner layer of the action
    38         PicLayerAbstract m_owner = null;
    39        
    40         /**
    41         * Constructor
    42         */
    43         public ResetPictureAngleAction( PicLayerAbstract owner ) {
    44                 super(tr("Angle"), null, tr("Resets picture rotation"), null, false);
    45                 // Remember the owner...
    46                 m_owner = owner;
    47         }
    48        
    49         /**
    50         * Action handler
    51         */
    52         public void actionPerformed(ActionEvent arg0) {
    53                 // Reset
    54                 m_owner.resetAngle();
    55                 // Redraw
     37    // Owner layer of the action
     38    PicLayerAbstract m_owner = null;
     39   
     40    /**
     41    * Constructor
     42    */
     43    public ResetPictureAngleAction( PicLayerAbstract owner ) {
     44        super(tr("Angle"), null, tr("Resets picture rotation"), null, false);
     45        // Remember the owner...
     46        m_owner = owner;
     47    }
     48   
     49    /**
     50    * Action handler
     51    */
     52    public void actionPerformed(ActionEvent arg0) {
     53        // Reset
     54        m_owner.resetAngle();
     55        // Redraw
    5656        Main.map.mapView.repaint();
    57         }
     57    }
    5858}
  • applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/ResetPicturePositionAction.java

    r20217 r23190  
    3535public class ResetPicturePositionAction extends JosmAction {
    3636
    37         // Owner layer of the action
    38         PicLayerAbstract m_owner = null;
    39        
    40         /**
    41         * Constructor
    42         */
    43         public ResetPicturePositionAction( PicLayerAbstract owner ) {
    44                 super(tr("Reset position"), null, tr("Resets picture position"), null, false);
    45                 // Remember the owner...
    46                 m_owner = owner;
    47         }
    48        
    49         /**
    50         * Action handler
    51         */
    52         public void actionPerformed(ActionEvent arg0) {
    53                 // Reset
    54                 m_owner.resetPosition();
    55                 // Redraw
     37    // Owner layer of the action
     38    PicLayerAbstract m_owner = null;
     39   
     40    /**
     41    * Constructor
     42    */
     43    public ResetPicturePositionAction( PicLayerAbstract owner ) {
     44        super(tr("Reset position"), null, tr("Resets picture position"), null, false);
     45        // Remember the owner...
     46        m_owner = owner;
     47    }
     48   
     49    /**
     50    * Action handler
     51    */
     52    public void actionPerformed(ActionEvent arg0) {
     53        // Reset
     54        m_owner.resetPosition();
     55        // Redraw
    5656        Main.map.mapView.repaint();
    57         }
     57    }
    5858}
  • applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/ResetPictureScaleAction.java

    r20217 r23190  
    3535public class ResetPictureScaleAction extends JosmAction {
    3636
    37         // Owner layer of the action
    38         PicLayerAbstract m_owner = null;
    39        
    40         /**
    41         * Constructor
    42         */
    43         public ResetPictureScaleAction( PicLayerAbstract owner ) {
    44                 super(tr("Scale"), null, tr("Resets picture scale"), null, false);
    45                 // Remember the owner...
    46                 m_owner = owner;
    47         }
    48        
    49         /**
    50         * Action handler
    51         */
    52         public void actionPerformed(ActionEvent arg0) {
    53                 // Reset
    54                 m_owner.resetScale();
    55                 // Redraw
     37    // Owner layer of the action
     38    PicLayerAbstract m_owner = null;
     39   
     40    /**
     41    * Constructor
     42    */
     43    public ResetPictureScaleAction( PicLayerAbstract owner ) {
     44        super(tr("Scale"), null, tr("Resets picture scale"), null, false);
     45        // Remember the owner...
     46        m_owner = owner;
     47    }
     48   
     49    /**
     50    * Action handler
     51    */
     52    public void actionPerformed(ActionEvent arg0) {
     53        // Reset
     54        m_owner.resetScale();
     55        // Redraw
    5656        Main.map.mapView.repaint();
    57         }
     57    }
    5858}
  • applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/RotatePictureAction.java

    r20217 r23190  
    3737 * This class handles the input during rotating the picture.
    3838 */
    39 public class RotatePictureAction extends MapMode implements MouseListener, MouseMotionListener 
     39public class RotatePictureAction extends MapMode implements MouseListener, MouseMotionListener
    4040{
    41         // Action ongoing?
    42         private boolean mb_dragging = false;
    43        
    44         // Last mouse position
    45         private int m_prevY;
    46        
    47         // Layer we're working on
    48         private PicLayerAbstract m_currentLayer = null;
    49        
    50         /**
    51          * Constructor
    52          */
    53         public RotatePictureAction(MapFrame frame) {
    54                 super(tr("PicLayer rotate"), "rotate", tr("Drag to rotate the picture"), frame, ImageProvider.getCursor("crosshair", null));
    55                 // TODO Auto-generated constructor stub
    56         }
     41    // Action ongoing?
     42    private boolean mb_dragging = false;
    5743
    58     @Override
     44    // Last mouse position
     45    private int m_prevY;
     46
     47    // Layer we're working on
     48    private PicLayerAbstract m_currentLayer = null;
     49
     50    /**
     51     * Constructor
     52     */
     53    public RotatePictureAction(MapFrame frame) {
     54        super(tr("PicLayer rotate"), "rotate", tr("Drag to rotate the picture"), frame, ImageProvider.getCursor("crosshair", null));
     55        // TODO Auto-generated constructor stub
     56    }
     57
     58    @Override
    5959    public void enterMode() {
    6060        super.enterMode();
     
    6363    }
    6464
    65     @Override 
     65    @Override
    6666    public void exitMode() {
    6767        super.exitMode();
    6868        Main.map.mapView.removeMouseListener(this);
    6969        Main.map.mapView.removeMouseMotionListener(this);
    70     }   
    71        
    72     @Override 
     70    }
     71
     72    @Override
    7373    public void mousePressed(MouseEvent e) {
    74         // Start rotating
    75         if ( Main.map.mapView.getActiveLayer() instanceof PicLayerAbstract ) {
    76                 m_currentLayer = (PicLayerAbstract)Main.map.mapView.getActiveLayer();
    77                
    78                 if ( m_currentLayer != null && e.getButton() == MouseEvent.BUTTON1 ) {
    79                         mb_dragging = true;
    80                         m_prevY=e.getY();
    81                 }
    82         }
    83     }   
    84    
    85     @Override 
     74        // Start rotating
     75        if ( Main.map.mapView.getActiveLayer() instanceof PicLayerAbstract ) {
     76            m_currentLayer = (PicLayerAbstract)Main.map.mapView.getActiveLayer();
     77
     78            if ( m_currentLayer != null && e.getButton() == MouseEvent.BUTTON1 ) {
     79                mb_dragging = true;
     80                m_prevY=e.getY();
     81            }
     82        }
     83    }
     84
     85    @Override
    8686    public void mouseDragged(MouseEvent e) {
    87         // Rotate the picture
     87        // Rotate the picture
    8888        if(mb_dragging) {
    8989            // TODO: Magic number
     
    9292            Main.map.mapView.repaint();
    9393        }
    94     }   
    95    
     94    }
     95
    9696    @Override public void mouseReleased(MouseEvent e) {
    97         // End rotating
    98         mb_dragging = false;
    99     }   
     97        // End rotating
     98        mb_dragging = false;
     99    }
    100100
    101101}
  • applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/SavePictureCalibrationAction.java

    r20217 r23190  
    4343public class SavePictureCalibrationAction extends JosmAction {
    4444
    45         // Owner layer of the action
    46         PicLayerAbstract m_owner = null;
    47        
    48         /**
    49         * Constructor
    50         */
    51         public SavePictureCalibrationAction( PicLayerAbstract owner ) {
    52                 super(tr("Save Picture Calibration..."), null, tr("Saves calibration data to a file"), null, false);
    53                 // Remember the owner...
    54                 m_owner = owner;
    55         }
    56        
    57         /**
    58         * Action handler
    59         */
    60         public void actionPerformed(ActionEvent arg0) {
    61                 // Save dialog
    62                 final JFileChooser fc = new JFileChooser();
    63                 fc.setAcceptAllFileFilterUsed( false );
    64                 fc.setFileFilter( new CalibrationFileFilter() );
    65                 fc.setSelectedFile( new File(m_owner.getPicLayerName() + CalibrationFileFilter.EXTENSION));
    66                 int result = fc.showSaveDialog( Main.parent );
     45    // Owner layer of the action
     46    PicLayerAbstract m_owner = null;
     47   
     48    /**
     49    * Constructor
     50    */
     51    public SavePictureCalibrationAction( PicLayerAbstract owner ) {
     52        super(tr("Save Picture Calibration..."), null, tr("Saves calibration data to a file"), null, false);
     53        // Remember the owner...
     54        m_owner = owner;
     55    }
     56   
     57    /**
     58    * Action handler
     59    */
     60    public void actionPerformed(ActionEvent arg0) {
     61        // Save dialog
     62        final JFileChooser fc = new JFileChooser();
     63        fc.setAcceptAllFileFilterUsed( false );
     64        fc.setFileFilter( new CalibrationFileFilter() );
     65        fc.setSelectedFile( new File(m_owner.getPicLayerName() + CalibrationFileFilter.EXTENSION));
     66        int result = fc.showSaveDialog( Main.parent );
    6767
    68                 if ( result == JFileChooser.APPROVE_OPTION ) {
    69                         // Check file extension and force it to be valid
    70                         File file = fc.getSelectedFile();
    71                         String path = file.getAbsolutePath();
    72                         if ( path.length() < CalibrationFileFilter.EXTENSION.length()
    73                                 || !path.substring( path.length() - 4 ).equals(CalibrationFileFilter.EXTENSION)) {
    74                                 file = new File( path + CalibrationFileFilter.EXTENSION );
    75                         }
    76                                                
    77                         // Save
    78                         Properties props = new Properties();
    79                         m_owner.saveCalibration(props);
    80                         try {
    81                                 props.store(new FileOutputStream(file), tr("JOSM PicLayer plugin calibration data"));
    82                         } catch (Exception e) {
    83                                 // Error
    84                                 e.printStackTrace();
    85                                 JOptionPane.showMessageDialog(Main.parent , tr("Saving file failed: {0}", e.getMessage()));
    86                         }
    87                 }       
    88         }
     68        if ( result == JFileChooser.APPROVE_OPTION ) {
     69            // Check file extension and force it to be valid
     70            File file = fc.getSelectedFile();
     71            String path = file.getAbsolutePath();
     72            if ( path.length() < CalibrationFileFilter.EXTENSION.length()
     73                || !path.substring( path.length() - 4 ).equals(CalibrationFileFilter.EXTENSION)) {
     74                file = new File( path + CalibrationFileFilter.EXTENSION );
     75            }
     76                       
     77            // Save
     78            Properties props = new Properties();
     79            m_owner.saveCalibration(props);
     80            try {
     81                props.store(new FileOutputStream(file), tr("JOSM PicLayer plugin calibration data"));
     82            } catch (Exception e) {
     83                // Error
     84                e.printStackTrace();
     85                JOptionPane.showMessageDialog(Main.parent , tr("Saving file failed: {0}", e.getMessage()));
     86            }
     87        }   
     88    }
    8989}
  • applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/ScalePictureActionAbstract.java

    r17321 r23190  
    3535 * This class handles the input during scaling the picture.
    3636 */
    37 public abstract class ScalePictureActionAbstract extends MapMode implements MouseListener, MouseMotionListener 
     37public abstract class ScalePictureActionAbstract extends MapMode implements MouseListener, MouseMotionListener
    3838{
    39         // Scaling ongoing?
    40         private boolean mb_dragging = false;
    41        
    42         // Last mouse position
    43         private int m_prevY;
    44        
    45         // Layer we're working on
    46         protected PicLayerAbstract m_currentLayer = null;
    47        
    48         /**
    49          * Constructor
    50          */
    51         public ScalePictureActionAbstract (String name, String icon, String tooltip, MapFrame frame) {
    52                 super(name, icon, tooltip, frame, ImageProvider.getCursor("crosshair", null));
    53                 // TODO Auto-generated constructor stub
    54         }
     39    // Scaling ongoing?
     40    private boolean mb_dragging = false;
    5541
    56     @Override
     42    // Last mouse position
     43    private int m_prevY;
     44
     45    // Layer we're working on
     46    protected PicLayerAbstract m_currentLayer = null;
     47
     48    /**
     49     * Constructor
     50     */
     51    public ScalePictureActionAbstract (String name, String icon, String tooltip, MapFrame frame) {
     52        super(name, icon, tooltip, frame, ImageProvider.getCursor("crosshair", null));
     53        // TODO Auto-generated constructor stub
     54    }
     55
     56    @Override
    5757    public void enterMode() {
    5858        super.enterMode();
     
    6161    }
    6262
    63     @Override 
     63    @Override
    6464    public void exitMode() {
    6565        super.exitMode();
    6666        Main.map.mapView.removeMouseListener(this);
    6767        Main.map.mapView.removeMouseMotionListener(this);
    68     }   
    69        
    70     @Override 
     68    }
     69
     70    @Override
    7171    public void mousePressed(MouseEvent e) {
    72         // Start scaling
    73         if ( Main.map.mapView.getActiveLayer() instanceof PicLayerAbstract ) {
    74                 m_currentLayer = (PicLayerAbstract)Main.map.mapView.getActiveLayer();
    75                
    76                 if ( m_currentLayer != null && e.getButton() == MouseEvent.BUTTON1 ) {
    77                         mb_dragging = true;
    78                         m_prevY = e.getY();
    79                 }
    80         }
    81     }   
    82    
    83     @Override 
     72        // Start scaling
     73        if ( Main.map.mapView.getActiveLayer() instanceof PicLayerAbstract ) {
     74            m_currentLayer = (PicLayerAbstract)Main.map.mapView.getActiveLayer();
     75
     76            if ( m_currentLayer != null && e.getButton() == MouseEvent.BUTTON1 ) {
     77                mb_dragging = true;
     78                m_prevY = e.getY();
     79            }
     80        }
     81    }
     82
     83    @Override
    8484    public void mouseDragged(MouseEvent e) {
    85         // Scale the picture
     85        // Scale the picture
    8686        if(mb_dragging) {
    8787            doTheScale( ( e.getY() - m_prevY ) / 500.0 );
     
    9090        }
    9191    }
    92    
    93     @Override 
     92
     93    @Override
    9494    public void mouseReleased(MouseEvent e) {
    95         // Stop scaling
    96         mb_dragging = false;
     95        // Stop scaling
     96        mb_dragging = false;
    9797    }
    98    
     98
    9999    /**
    100100    * Does the actual scaling in the inherited class.
  • applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/ScaleXPictureAction.java

    r20217 r23190  
    3333 * This class handles the input during scaling the picture.
    3434 */
    35 public class ScaleXPictureAction extends ScalePictureActionAbstract 
     35public class ScaleXPictureAction extends ScalePictureActionAbstract
    3636{
    37         /*
    38         * Constructor
    39         */
    40         public ScaleXPictureAction(MapFrame frame) {
    41                 super(tr("PicLayer scale X"), "scale_x", tr("Drag to scale the picture in the X Axis"), frame);
    42                 // TODO Auto-generated constructor stub
    43         }
     37    /*
     38    * Constructor
     39    */
     40    public ScaleXPictureAction(MapFrame frame) {
     41        super(tr("PicLayer scale X"), "scale_x", tr("Drag to scale the picture in the X Axis"), frame);
     42        // TODO Auto-generated constructor stub
     43    }
    4444
    45         public void doTheScale( double scale ) {
     45    public void doTheScale( double scale ) {
    4646            m_currentLayer.scalePictureBy( scale, 0.0 );
    4747        }
  • applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/ScaleXYPictureAction.java

    r20217 r23190  
    3333 * This class handles the input during scaling the picture.
    3434 */
    35 public class ScaleXYPictureAction extends ScalePictureActionAbstract 
     35public class ScaleXYPictureAction extends ScalePictureActionAbstract
    3636{
    37         /*
    38         * Constructor
    39         */
    40         public ScaleXYPictureAction(MapFrame frame) {
    41                 super(tr("PicLayer scale"), "scale", tr("Drag to scale the picture in the X and Y Axis"), frame);
    42                 // TODO Auto-generated constructor stub
    43         }
     37    /*
     38    * Constructor
     39    */
     40    public ScaleXYPictureAction(MapFrame frame) {
     41        super(tr("PicLayer scale"), "scale", tr("Drag to scale the picture in the X and Y Axis"), frame);
     42        // TODO Auto-generated constructor stub
     43    }
    4444
    45         public void doTheScale( double scale ) {
     45    public void doTheScale( double scale ) {
    4646            m_currentLayer.scalePictureBy( scale, scale );
    4747        }
  • applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/ScaleYPictureAction.java

    r20217 r23190  
    3333 * This class handles the input during scaling the picture.
    3434 */
    35 public class ScaleYPictureAction extends ScalePictureActionAbstract 
     35public class ScaleYPictureAction extends ScalePictureActionAbstract
    3636{
    37         /*
    38         * Constructor
    39         */
    40         public ScaleYPictureAction(MapFrame frame) {
    41                 super(tr("PicLayer scale Y"), "scale_y", tr("Drag to scale the picture in the Y Axis"), frame);
    42                 // TODO Auto-generated constructor stub
    43         }
     37    /*
     38    * Constructor
     39    */
     40    public ScaleYPictureAction(MapFrame frame) {
     41        super(tr("PicLayer scale Y"), "scale_y", tr("Drag to scale the picture in the Y Axis"), frame);
     42        // TODO Auto-generated constructor stub
     43    }
    4444
    45         public void doTheScale( double scale ) {
     45    public void doTheScale( double scale ) {
    4646            m_currentLayer.scalePictureBy( 0.0, scale );
    4747        }
Note: See TracChangeset for help on using the changeset viewer.