Ignore:
Timestamp:
2011-11-25T11:58:22+01:00 (13 years ago)
Author:
larry0ua
Message:

'PicLayer - fixing issues like #6068, #6123, #5002'

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

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/actions/newlayer/NewLayerFromFileAction.java

    r27120 r27147  
    6262
    6363            if ("zip".equalsIgnoreCase(fileExtension)) return true;
    64             // Unfortunately, getReaderFormatNames does not always return ALL extensions in 
     64            // Unfortunately, getReaderFormatNames does not always return ALL extensions in
    6565            // both lower and upper case, so we can not do a search in the array
    6666            for (String e: supportedExtensions)
    67                 if ( e.toLowerCase().equals(fileExtension) ) {
     67                if ( e.equalsIgnoreCase(fileExtension) ) {
    6868                    return true;
    6969                }
    70                    
     70
    7171            return false;
    7272        }
     
    7575        @Override
    7676        public String getDescription() {
    77             return tr("Supported image files");
     77            return tr("Supported image files + *.zip");
    7878        }
    7979
     80    }
     81
     82    private class AllFilesFilter extends FileFilter {
     83        @Override
     84        public String getDescription() {
     85            return tr("All Files");
     86        }
     87
     88        @Override
     89        public boolean accept(File f) {
     90            return true;
     91        }
    8092    }
    8193
     
    90102     * Action handler
    91103     */
     104    @Override
    92105    public void actionPerformed(ActionEvent arg0) {
    93106
     
    95108        JFileChooser fc = new JFileChooser(Main.pref.get(m_lastdirprefname));
    96109        fc.setAcceptAllFileFilterUsed( false );
    97         fc.setFileFilter( new ImageFileFilter() );
    98         fc.setMultiSelectionEnabled(true);
     110        //fc.setFileFilter( new ImageFileFilter() );
     111        fc.addChoosableFileFilter(new ImageFileFilter());
     112        fc.addChoosableFileFilter(new AllFilesFilter());
     113        fc.setMultiSelectionEnabled(true);
    99114        int result = fc.showOpenDialog( Main.parent );
    100115
     
    112127            for(File file : fc.getSelectedFiles() ) {
    113128                // TODO: we need a progress bar here, it can take quite some time
    114                
     129
    115130                // Create layer from file
    116131                PicLayerFromFile layer = new PicLayerFromFile( file );
     
    126141                }
    127142                Main.pref.put(m_lastdirprefname, file.getParent());
    128        
     143
    129144                Main.main.addLayer( layer );
    130145                Main.map.mapView.moveLayer(layer, newLayerPos++);
    131                
     146
    132147                if ( fc.getSelectedFiles().length == 1 && Main.pref.getInteger("piclayer.zoom-on-load", 1) != 0 ) {
    133148                    // if we are loading a single picture file, zoom on it, so that the user can see something
  • applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/layer/PicLayerAbstract.java

    r27144 r27147  
    384384        AffineTransform transform;
    385385
    386         double pos_x = Double.valueOf(props.getProperty(POSITION_X));
    387         double pos_y = Double.valueOf(props.getProperty(POSITION_Y));
     386        double pos_x = Double.valueOf(props.getProperty(POSITION_X, "0"));
     387        double pos_y = Double.valueOf(props.getProperty(POSITION_Y, "0"));
    388388
    389389        imagePosition = new EastNorth(pos_x, pos_y);
    390         initialImageScale = Double.valueOf(props.getProperty(INITIAL_SCALE)); //in_scale
     390        initialImageScale = Double.valueOf(props.getProperty(INITIAL_SCALE, "1")); //in_scale
    391391        if (props.containsKey(SCALEX)) {// old format
    392             double in_pos_x = Double.valueOf( props.getProperty(INITIAL_POS_X));
    393             double in_pos_y = Double.valueOf( props.getProperty(INITIAL_POS_Y));
    394             double angle = Double.valueOf( props.getProperty(ANGLE));
    395             double scale_x = Double.valueOf( props.getProperty(SCALEX));
    396             double scale_y = Double.valueOf( props.getProperty(SCALEY));
    397             double shear_x = Double.valueOf( props.getProperty(SHEARX));
    398             double shear_y = Double.valueOf( props.getProperty(SHEARY));
     392            double in_pos_x = Double.valueOf(props.getProperty(INITIAL_POS_X, "0"));
     393            double in_pos_y = Double.valueOf(props.getProperty(INITIAL_POS_Y, "0"));
     394            double angle = Double.valueOf(props.getProperty(ANGLE, "0"));
     395            double scale_x = Double.valueOf(props.getProperty(SCALEX, "1"));
     396            double scale_y = Double.valueOf(props.getProperty(SCALEY, "1"));
     397            double shear_x = Double.valueOf(props.getProperty(SHEARX, "0"));
     398            double shear_y = Double.valueOf(props.getProperty(SHEARY, "0"));
    399399
    400400            initialImagePosition.setLocation(in_pos_x, in_pos_y);
     
    407407            // initialize matrix
    408408            double[] matrix = new double[6];
    409             matrix[0] = Double.parseDouble(props.getProperty(MATRIXm00));
    410             matrix[1] = Double.parseDouble(props.getProperty(MATRIXm01));
    411             matrix[2] = Double.parseDouble(props.getProperty(MATRIXm10));
    412             matrix[3] = Double.parseDouble(props.getProperty(MATRIXm11));
    413             matrix[4] = Double.parseDouble(props.getProperty(MATRIXm02));
    414             matrix[5] = Double.parseDouble(props.getProperty(MATRIXm12));
     409            matrix[0] = Double.parseDouble(props.getProperty(MATRIXm00, "0"));
     410            matrix[1] = Double.parseDouble(props.getProperty(MATRIXm01, "0"));
     411            matrix[2] = Double.parseDouble(props.getProperty(MATRIXm10, "0"));
     412            matrix[3] = Double.parseDouble(props.getProperty(MATRIXm11, "0"));
     413            matrix[4] = Double.parseDouble(props.getProperty(MATRIXm02, "0"));
     414            matrix[5] = Double.parseDouble(props.getProperty(MATRIXm12, "0"));
    415415
    416416            transform = new AffineTransform(matrix);
Note: See TracChangeset for help on using the changeset viewer.