Changeset 1245 in josm


Ignore:
Timestamp:
2009-01-11T16:14:58+01:00 (16 years ago)
Author:
stoecker
Message:

added link to presets, fix #1675

Location:
trunk
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/presets/presets.xml

    r1234 r1245  
    135135        </item>
    136136        <item name="Secondary" icon="presets/way_secondary.png">
     137            <link href="http://wiki.openstreetmap.org/wiki/Tag:highway=secondary"/>
    137138            <label text="Edit a Secondary Road" />
    138139            <space />
  • trunk/src/org/openstreetmap/josm/actions/CreateCircleAction.java

    r1169 r1245  
    7070
    7171    public void actionPerformed(ActionEvent e) {
    72         int numberOfNodesInCircle = Integer.parseInt(Main.pref.get("createcircle.nodecount", "8"));
     72        int numberOfNodesInCircle = Main.pref.getInteger("createcircle.nodecount", 8);
    7373        if (numberOfNodesInCircle < 1) {
    7474            numberOfNodesInCircle = 1;
  • trunk/src/org/openstreetmap/josm/actions/audio/AudioBackAction.java

    r1222 r1245  
    1515public class AudioBackAction extends JosmAction {
    1616
    17     private double amount; // note, normally negative, i.e. jump backwards in time
    18 
    1917    public AudioBackAction() {
    2018        super(tr("Back"), "audio-back", tr("Jump back."),
    2119        Shortcut.registerShortcut("audio:back", tr("Audio: {0}", tr("Back")), KeyEvent.VK_F6, Shortcut.GROUP_DIRECT), true);
    22         amount = -Main.pref.getDouble("audio.forwardbackamount","10.0");
    2320        this.putValue("help", "Action/Back");
    2421    }
     
    2724        try {
    2825            if (AudioPlayer.playing() || AudioPlayer.paused())
    29                 AudioPlayer.play(AudioPlayer.url(), AudioPlayer.position() + amount);
     26                AudioPlayer.play(AudioPlayer.url(), AudioPlayer.position()
     27                - Main.pref.getDouble("audio.forwardbackamount","10.0"));
    3028            else
    3129                MarkerLayer.playAudio();
  • trunk/src/org/openstreetmap/josm/actions/audio/AudioFastSlowAction.java

    r1180 r1245  
    1515    public AudioFastSlowAction(String name, String iconName, String tooltip, Shortcut shortcut, boolean fast) {
    1616        super(name, iconName, tooltip, shortcut, true);
    17         try {
    18             multiplier = Double.parseDouble(Main.pref.get("audio.fastfwdmultiplier","1.3"));
    19         } catch (NumberFormatException e) {
    20             multiplier = 1.3;
    21         }
     17        multiplier = Main.pref.getDouble("audio.fastfwdmultiplier","1.3");
    2218        if (! fast)
    2319            multiplier = 1.0 / multiplier;
  • trunk/src/org/openstreetmap/josm/actions/audio/AudioFwdAction.java

    r1222 r1245  
    1414
    1515public class AudioFwdAction extends JosmAction {
    16 
    17     private double amount;
    18 
    1916    public AudioFwdAction() {
    2017        super(tr("Forward"), "audio-fwd", tr("Jump forward"),
    2118        Shortcut.registerShortcut("audio:forward", tr("Audio: {0}", tr("Forward")), KeyEvent.VK_F7, Shortcut.GROUP_DIRECT), true);
    22         amount = Main.pref.getDouble("audio.forwardbackamount","10.0");
    2319    }
    2420
     
    2622        try {
    2723            if (AudioPlayer.playing() || AudioPlayer.paused())
    28                 AudioPlayer.play(AudioPlayer.url(), AudioPlayer.position() + amount);
     24                AudioPlayer.play(AudioPlayer.url(), AudioPlayer.position()
     25                + Main.pref.getDouble("audio.forwardbackamount","10.0"));
    2926            else
    3027                MarkerLayer.playAudio();
  • trunk/src/org/openstreetmap/josm/actions/mapmode/DrawAction.java

    r1221 r1245  
    536536                    B.north() + q * (A.north() - B.north()));
    537537
    538             int snapToIntersectionThreshold=0;
    539             try { snapToIntersectionThreshold = Integer.parseInt(Main.pref.get("edit.snap-intersection-threshold","10")); } catch (NumberFormatException x) {}
     538            int snapToIntersectionThreshold
     539            = Main.pref.getInteger("edit.snap-intersection-threshold",10);
    540540
    541541            // only adjust to intersection if within snapToIntersectionThreshold pixel of mouse click; otherwise
  • trunk/src/org/openstreetmap/josm/actions/mapmode/SelectAction.java

    r1115 r1245  
    7373     * counts as a move, in milliseconds
    7474     */
    75     private int initialMoveDelay = 200;
     75    private int initialMoveDelay;
    7676
    7777    /**
     
    7979     * counts as a move, in pixels
    8080     */
    81     private int initialMoveThreshold = 15;
     81    private int initialMoveThreshold;
    8282    private boolean initialMoveThresholdExceeded = false;
    8383    /**
     
    9292        putValue("help", "Action/Move/Move");
    9393        selectionManager = new SelectionManager(this, false, mapFrame.mapView);
    94         try { initialMoveDelay = Integer.parseInt(Main.pref.get("edit.initial-move-delay","200")); } catch (NumberFormatException x) {}
    95         try { initialMoveThreshold = Integer.parseInt(Main.pref.get("edit.initial-move-threshold","5")); } catch (NumberFormatException x) {}
    96 
     94        initialMoveDelay = Main.pref.getInteger("edit.initial-move-delay",200);
     95        initialMoveThreshold = Main.pref.getInteger("edit.initial-move-threshold",5);
    9796    }
    9897
  • trunk/src/org/openstreetmap/josm/data/Preferences.java

    r1243 r1245  
    433433        putDefault(key, def);
    434434        String v = get(key);
    435         try {
    436             return Double.parseDouble(v == null ? def : v);
    437         } catch(NumberFormatException e) {
    438             // fall out
    439         }
     435        if(v != null && v.length() != 0)
     436            try { return Double.parseDouble(v); } catch(NumberFormatException e) {}
     437        try { return Double.parseDouble(def); } catch(NumberFormatException e) {}
    440438        return 0.0;
    441439    }
  • trunk/src/org/openstreetmap/josm/gui/download/DownloadDialog.java

    r1169 r1245  
    138138
    139139        try {
    140             tabpane.setSelectedIndex(Integer.parseInt(Main.pref.get("download.tab", "0")));
     140            tabpane.setSelectedIndex(Main.pref.getInteger("download.tab", 0));
    141141        } catch (Exception ex) {
    142             Main.pref.put("download.tab", "0");
     142            Main.pref.putInteger("download.tab", 0);
    143143        }
    144144
  • trunk/src/org/openstreetmap/josm/gui/layer/GpxLayer.java

    r1221 r1245  
    378378        boolean forceLines = Main.pref.getBoolean("draw.rawgps.lines.force");                     // also draw lines between points belonging to different segments
    379379        boolean direction = Main.pref.getBoolean("draw.rawgps.direction");                        // draw direction arrows on the lines
    380         int maxLineLength = -1;
    381         try {
    382             maxLineLength = Integer.parseInt(Main.pref.get("draw.rawgps.max-line-length", "-1"));   // don't draw lines if longer than x meters
    383         } catch (java.lang.NumberFormatException e) {
    384             Main.pref.put("draw.rawgps.max-line-length", "-1");
    385         }
     380        int maxLineLength = Main.pref.getInteger("draw.rawgps.max-line-length", -1);
     381        // don't draw lines if longer than x meters
    386382        boolean lines = Main.pref.getBoolean("draw.rawgps.lines");                                // draw line between points, global setting
    387383        String linesKey = "draw.rawgps.lines.layer "+name;
     
    391387        boolean colored = Main.pref.getBoolean("draw.rawgps.colors");                             // color the lines
    392388        boolean alternatedirection = Main.pref.getBoolean("draw.rawgps.alternatedirection");      // paint direction arrow with alternate math. may be faster
    393         int delta = 0;
    394         try {
    395             delta = Integer.parseInt(Main.pref.get("draw.rawgps.min-arrow-distance", "0"));         // don't draw arrows nearer to each other than this
    396         } catch (java.lang.NumberFormatException e) {
    397             Main.pref.put("draw.rawgps.min-arrow-distance", "0");
    398         }
     389        int delta = Main.pref.getInteger("draw.rawgps.min-arrow-distance", 0);
     390        // don't draw arrows nearer to each other than this
    399391
    400392        /****************************************************************
  • trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/PlayHeadMarker.java

    r1195 r1245  
    4646    private boolean enabled;
    4747    private boolean wasPlaying = false;
    48     private int dropTolerance = 50; /* pixels */
     48    private int dropTolerance; /* pixels */
    4949
    5050    public static PlayHeadMarker create() {
     
    6565        enabled = Main.pref.getBoolean("marker.traceaudio", true);
    6666        if (! enabled) return;
    67         try { dropTolerance = Integer.parseInt(Main.pref.get("marker.playHeadDropTolerance", "50")); }
    68         catch(NumberFormatException x) { dropTolerance = 50; }
     67        dropTolerance = Main.pref.getInteger("marker.playHeadDropTolerance", 50);
    6968        Main.map.mapView.addMouseListener(new MouseAdapter() {
    7069            @Override public void mousePressed(MouseEvent ev) {
     
    8786    @Override public boolean containsPoint(Point p) {
    8887        Point screen = Main.map.mapView.getPoint(eastNorth);
    89         Rectangle r = new Rectangle(screen.x, screen.y, symbol.getIconWidth(), symbol.getIconHeight());
     88        Rectangle r = new Rectangle(screen.x, screen.y, symbol.getIconWidth(),
     89        symbol.getIconHeight());
    9090        return r.contains(p);
    9191    }
  • trunk/src/org/openstreetmap/josm/gui/preferences/AudioPreference.java

    r1180 r1245  
    145145        gui.audio.add(audioFastForwardMultiplier, GBC.eol().fill(GBC.HORIZONTAL).insets(5,0,0,5));
    146146
    147         audioLeadIn.setText(Main.pref.get("audio.leadin", "1"));
     147        audioLeadIn.setText(Main.pref.get("audio.leadin", "1.0"));
    148148        audioLeadIn.setToolTipText(tr("Playback starts this number of seconds before (or after, if negative) the audio track position requested"));
    149149        gui.audio.add(new JLabel(tr("Lead-in time (seconds)")), GBC.std());
  • trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPreset.java

    r1234 r1245  
    88import java.awt.Image;
    99import java.awt.event.ActionEvent;
     10import java.awt.event.ActionListener;
    1011import java.io.BufferedReader;
    1112import java.io.InputStreamReader;
     
    2425import javax.swing.Action;
    2526import javax.swing.ImageIcon;
     27import javax.swing.JButton;
    2628import javax.swing.JComboBox;
    2729import javax.swing.JComponent;
     
    4345import org.openstreetmap.josm.tools.GBC;
    4446import org.openstreetmap.josm.tools.ImageProvider;
     47import org.openstreetmap.josm.tools.OpenBrowser;
    4548import org.openstreetmap.josm.tools.XmlObjectParser;
    4649import org.xml.sax.SAXException;
     
    179182        public String text;
    180183        public String locale_text;
    181         public boolean default_ = false; // not used!
     184        public boolean default_ = false; // only used for tagless objects
    182185        public boolean use_last_as_default = false;
    183186
     
    196199            for (String s : usage.values) oneValue = s;
    197200            if (usage.values.size() < 2 && (oneValue == null || OsmUtils.trueval.equals(oneValue) || OsmUtils.falseval.equals(oneValue))) {
     201                if(default_)
     202                {
     203                    for (OsmPrimitive s : sel)
     204                        if(s.keys != null && s.keys.size() > 0) default_ = false;
     205                }
     206
    198207                // all selected objects share the same value which is either true or false or unset,
    199208                // we can display a standard check box.
     
    202211                            OsmUtils.falseval.equals(oneValue) ?
    203212                            QuadStateCheckBox.State.NOT_SELECTED :
    204                             QuadStateCheckBox.State.UNSET;
     213                            default_ ? QuadStateCheckBox.State.SELECTED
     214                            : QuadStateCheckBox.State.UNSET;
    205215                check = new QuadStateCheckBox(locale_text, initialState,
    206216                        new QuadStateCheckBox.State[] {
     
    357367    }
    358368
     369    public static class Link extends Item {
     370        public String href;
     371        public String text;
     372        public String locale_text;
     373
     374        @Override public void addToPanel(JPanel p, Collection<OsmPrimitive> sel) {
     375            if(locale_text == null)
     376                locale_text = text == null ? tr("Open map features in browser") : tr(text);
     377            JButton b = new JButton(locale_text);
     378            b.addActionListener(new ActionListener(){
     379                public void actionPerformed(ActionEvent e) {
     380                    OpenBrowser.displayUrl(href);
     381                }
     382            });
     383            p.add(b, GBC.eol().anchor(GBC.EAST));
     384        }
     385        @Override public void addCommands(Collection<OsmPrimitive> sel, List<Command> cmds) {}
     386    }
     387
    359388    public static class Optional extends Item {
    360389        // TODO: Draw a box around optional stuff
     
    458487        parser.mapBoth("group", TaggingPresetMenu.class);
    459488        parser.map("text", Text.class);
     489        parser.map("link", Link.class);
    460490        parser.mapOnStart("optional", Optional.class);
    461491        parser.map("check", Check.class);
  • trunk/src/org/openstreetmap/josm/tools/AudioPlayer.java

    r1169 r1245  
    197197        command = new Execute();
    198198        playingUrl = null;
    199         try {
    200             leadIn = Double.parseDouble(Main.pref.get("audio.leadin", "1.0" /* default, seconds */));
    201         } catch (NumberFormatException e) {
    202             leadIn = 1.0; // failed to parse
    203         }
    204         try {
    205             calibration = Double.parseDouble(Main.pref.get("audio.calibration", "1.0" /* default, ratio */));
    206         } catch (NumberFormatException e) {
    207             calibration = 1.0; // failed to parse
    208         }
     199        leadIn = Main.pref.getDouble("audio.leadin", "1.0" /* default, seconds */);
     200        calibration = Main.pref.getDouble("audio.calibration", "1.0" /* default, ratio */);
    209201        start();
    210202        while (state == State.INITIALIZING) { yield(); }
Note: See TracChangeset for help on using the changeset viewer.