Ignore:
Timestamp:
2009-11-22T14:55:15+01:00 (10 years ago)
Author:
stoecker
Message:

see #3989 - subprojection fixes

Location:
trunk/src/org/openstreetmap/josm/data/projection
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/projection/ProjectionSubPrefs.java

    r2491 r2499  
    2323     * @return
    2424     */
    25     public JPanel getPreferencePanel();
     25    public void setupPreferencePanel(JPanel p);
    2626
    2727    /**
    2828     * Will be called if the preference dialog is dismissed.
    2929     */
    30     public Collection<String> getPreferences();
     30    public Collection<String> getPreferences(JPanel p);
    3131
    3232    /**
     
    4040     */
    4141    public void setPreferences(Collection<String> args);
    42 
    43     /**
    44      * Resets all variables related to the projection preferences so they may
    45      * update the next time getPreferencePanel is called.
    46      */
    47     public void destroyCachedPanel();
    4842}
  • trunk/src/org/openstreetmap/josm/data/projection/UTM.java

    r2496 r2499  
    377377    }
    378378
    379     private JPanel prefpanel = null;
    380     private JComboBox prefcb = null;
    381     public JPanel getPreferencePanel() {
    382         if(prefpanel != null)
    383             return prefpanel;
    384 
    385         prefcb = new JComboBox();
     379    public void setupPreferencePanel(JPanel p) {
     380        JComboBox prefcb = new JComboBox();
    386381        for(int i = 1; i <= 60; i++) {
    387382            prefcb.addItem(i);
     
    389384
    390385        prefcb.setSelectedIndex(zone - 1);
    391         prefpanel = new JPanel(new GridBagLayout());
    392         prefpanel.add(new JLabel(tr("UTM Zone")), GBC.std().insets(5,5,0,5));
    393         prefpanel.add(GBC.glue(1, 0), GBC.std().fill(GBC.HORIZONTAL));
    394         prefpanel.add(prefcb, GBC.eop().fill(GBC.HORIZONTAL));
    395         prefpanel.add(GBC.glue(1, 1), GBC.eol().fill(GBC.BOTH));
    396         return prefpanel;
    397     }
    398 
    399     public Collection<String> getPreferences() {
    400         if(prefcb == null)
     386        p.setLayout(new GridBagLayout());
     387        p.add(new JLabel(tr("UTM Zone")), GBC.std().insets(5,5,0,5));
     388        p.add(GBC.glue(1, 0), GBC.std().fill(GBC.HORIZONTAL));
     389        /* Note: we use component position 2 below to find this again */
     390        p.add(prefcb, GBC.eop().fill(GBC.HORIZONTAL));
     391        p.add(GBC.glue(1, 1), GBC.eol().fill(GBC.BOTH));
     392    }
     393
     394    public Collection<String> getPreferences(JPanel p) {
     395        Object prefcb = p.getComponent(2);
     396        if(!(prefcb instanceof JComboBox))
    401397            return null;
    402         int zone = prefcb.getSelectedIndex() + 1;
     398        int zone = ((JComboBox)prefcb).getSelectedIndex() + 1;
    403399        return Collections.singleton(Integer.toString(zone));
    404     }
    405 
    406     public void destroyCachedPanel() {
    407         prefpanel = null;
    408         prefcb = null;
    409400    }
    410401
Note: See TracChangeset for help on using the changeset viewer.