Ignore:
Timestamp:
2008-09-12T11:57:49+02:00 (17 years ago)
Author:
stoecker
Message:

fixed automatic dowloading menu a bit

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/wmsplugin/src/wmsplugin/WMSLayer.java

    r10382 r10646  
    2121import javax.swing.ImageIcon;
    2222import javax.swing.JFileChooser;
     23import javax.swing.JCheckBoxMenuItem;
    2324import javax.swing.JMenuItem;
    2425import javax.swing.JOptionPane;
     
    5152
    5253        public int messageNum = 5; //limit for messages per layer
    53         protected boolean started = true;
    5454        protected boolean stopAfterPaint = false;
    5555        protected int ImageSize = 500;
     
    5959        protected double pixelPerDegree;
    6060        protected GeorefImage[][] images = new GeorefImage[dax][day];
     61        JCheckBoxMenuItem startstop = new JCheckBoxMenuItem(tr("Automatic downloading"), true);
    6162
    6263        protected String baseURL;
     
    8485                if (baseURL == null) return;
    8586                //set resolution
    86                 if(started || Math.round(pixelPerDegree/10000) != Math.round(_pixelPerDegree/10000))
     87                if(startstop.isSelected() || Math.round(pixelPerDegree/10000) != Math.round(_pixelPerDegree/10000))
    8788                        initializeImages();
    8889                pixelPerDegree = _pixelPerDegree;
    89                 if(!started)stopAfterPaint = true;
    90                 started = true;
     90                if(!startstop.isSelected()) stopAfterPaint = true;
     91                startstop.setSelected(true);
    9192        }
    9293
     
    9697
    9798        @Override public String getToolTipText() {
    98                 if(started)
     99                if(startstop.isSelected())
    99100                        return tr("WMS layer ({0}), automaticaly downloading in zoom {1}", name, Math.round(pixelPerDegree/10000));
    100101                else
     
    132133
    133134
    134                 if( !started || (pixelPerDegree / (mv.getWidth() / (b.max.lon() - b.min.lon())) > minZoom) ){ //don't download when it's too outzoomed
     135                if( !startstop.isSelected() || (pixelPerDegree / (mv.getWidth() / (b.max.lon() - b.min.lon())) > minZoom) ){ //don't download when it's too outzoomed
    135136                        for(int x = 0; x<dax; ++x)
    136137                                for(int y = 0; y<day; ++y){
     
    151152                }
    152153                if(stopAfterPaint){
    153                         started = false;
     154                        startstop.setSelected(false);
    154155                        stopAfterPaint = false;
    155156                }
     
    177178                                new JMenuItem(new SaveWmsAction()),
    178179                                new JSeparator(),
    179                                 new JMenuItem(new StartWmsAction()),
    180                                 new JMenuItem(new StopWmsAction()),
     180                                startstop,
    181181                                new JSeparator(),
    182182                                new JMenuItem(new LayerListPopup.InfoAction(this))};
     
    250250                                ois.close();
    251251                                fis.close();
    252                                 started = false;
     252                                startstop.setSelected(false);
    253253                        }
    254254                        catch (Exception ex) {
     
    261261                                return;
    262262                        }
    263                 }
    264         }
    265 
    266         public class StartWmsAction extends AbstractAction {
    267                 public StartWmsAction() {
    268                         super(tr("Start automatic downloading"), null);
    269                 }
    270                 public void actionPerformed(ActionEvent ev) {
    271                         started = true;
    272                 }
    273         }
    274 
    275         public class StopWmsAction extends AbstractAction {
    276                 public StopWmsAction() {
    277                         super(tr("Stop automatic downloading"), null);
    278                 }
    279                 public void actionPerformed(ActionEvent ev) {
    280                         started = false;
    281263                }
    282264        }
Note: See TracChangeset for help on using the changeset viewer.