Ignore:
Timestamp:
2009-10-11T16:33:29+02:00 (15 years ago)
Author:
stoecker
Message:

first partial support for sub preferences, not yet functional

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

Legend:

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

    r2114 r2272  
    44import static org.openstreetmap.josm.tools.I18n.tr;
    55
     6import java.awt.GridBagLayout;
     7import java.util.Collection;
     8import java.util.Collections;
     9
     10import javax.swing.JComboBox;
     11import javax.swing.JLabel;
     12import javax.swing.JPanel;
     13
     14import org.openstreetmap.josm.Main;
    615import org.openstreetmap.josm.data.Bounds;
    716import org.openstreetmap.josm.data.coor.EastNorth;
    817import org.openstreetmap.josm.data.coor.LatLon;
     18import org.openstreetmap.josm.tools.GBC;
    919
    1020/**
     
    1424 * code based on JavaScript from Chuck Taylor
    1525 */
    16 public class UTM implements Projection {
     26public class UTM implements Projection, ProjectionSubPrefs {
     27
     28    private int zone = 33;
    1729
    1830    final private double UTMScaleFactor = 0.9996;
     
    336348
    337349    @Override public String toString() {
    338         return tr("UTM Zone {0}", getzone());
    339     }
    340 
    341     /* TODO - support all UTM's not only zone 33 */
     350        return tr("UTM");
     351    }
     352
    342353    public int getzone()
    343354    {
    344         return 33;
     355        return zone;
    345356    }
    346357
    347358    public String toCode() {
    348         return "EPSG:325833";
     359        return "EPSG:"+ (325800 + getzone());
    349360    }
    350361
    351362    public String getCacheDirectoryName() {
    352         return "epsg325833";
     363        return "epsg"+ (325800 + getzone());
    353364    }
    354365
     
    364375        return 10;
    365376    }
     377
     378    private JPanel prefpanel = null;
     379    private JComboBox prefcb = null;
     380    public JPanel getPreferencePanel() {
     381        if(prefpanel != null)
     382            return prefpanel;
     383
     384        prefcb = new JComboBox();
     385        for(int i = 1; i <= 60; i++) {
     386            prefcb.addItem(i);
     387        }
     388
     389        prefcb.setSelectedIndex(zone - 1);
     390        prefpanel = new JPanel(new GridBagLayout());
     391        prefpanel.add(new JLabel(tr("UTM Zone")), GBC.std().insets(5,5,0,5));
     392        prefpanel.add(GBC.glue(1, 0), GBC.std().fill(GBC.HORIZONTAL));
     393        prefpanel.add(prefcb, GBC.eop().fill(GBC.HORIZONTAL));
     394        prefpanel.add(GBC.glue(1, 1), GBC.eol().fill(GBC.BOTH));
     395        return prefpanel;
     396    }
     397
     398    public Collection<String> getPreferences() {
     399        if(prefcb == null)
     400            return null;
     401        int zone = prefcb.getSelectedIndex() + 1;
     402        return Collections.singleton(Integer.toString(zone));
     403    }
     404
     405    public void destroyCachedPanel() {
     406        prefpanel = null;
     407        prefcb = null;
     408    }
     409
     410    public void setPreferences(Collection<String> args)
     411    {
     412        /* TODO: parse args instead of fixed value */
     413        zone = 33;
     414    }
     415
     416    public Collection<String> getPreferencesFromCode(String code)
     417    {
     418        /* TODO: implement */
     419        return null;
     420    }
    366421}
Note: See TracChangeset for help on using the changeset viewer.