Ignore:
Timestamp:
2013-06-06T01:48:06+02:00 (11 years ago)
Author:
Don-vip
Message:

see #8752 - update distance text in status line when rescaling ways

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/MapStatus.java

    r5966 r5991  
    3131import javax.swing.AbstractAction;
    3232import javax.swing.BorderFactory;
    33 import javax.swing.JButton;
    3433import javax.swing.JCheckBoxMenuItem;
    3534import javax.swing.JLabel;
     
    5049import org.openstreetmap.josm.data.osm.DataSet;
    5150import org.openstreetmap.josm.data.osm.OsmPrimitive;
     51import org.openstreetmap.josm.data.osm.Way;
    5252import org.openstreetmap.josm.gui.help.Helpful;
    5353import org.openstreetmap.josm.gui.progress.PleaseWaitProgressMonitor;
     
    835835        headingText.setText(h < 0 ? "--" : Math.round(h*10)/10.0 + " \u00B0");
    836836    }
     837    /**
     838     * Sets the distance text to the given value
     839     * @param dist The distance value to display, in meters
     840     */
    837841    public void setDist(double dist) {
    838842        distText.setText(dist < 0 ? "--" : NavigatableComponent.getDistText(dist));
    839843    }
     844    /**
     845     * Sets the distance text to the total sum of given ways length
     846     * @param ways The ways to consider for the total distance
     847     * @since 5991
     848     */
     849    public void setDist(Collection<Way> ways) {
     850        double dist = -1;
     851        // Compute total length of selected way(s) until an arbitrary limit set to 250 ways
     852        // in order to prevent performance issue if a large number of ways are selected (old behaviour kept in that case, see #8403)
     853        int maxWays = Math.max(1, Main.pref.getInteger("selection.max-ways-for-statusline", 250));
     854        if (!ways.isEmpty() && ways.size() <= maxWays) {
     855            dist = 0.0;
     856            for (Way w : ways) {
     857                dist += w.getLength();
     858            }
     859        }
     860        setDist(dist);
     861    }
    840862    public void activateAnglePanel(boolean activeFlag) {
    841863        angleText.setBackground(activeFlag ? ImageLabel.backColorActive : ImageLabel.backColor);
Note: See TracChangeset for help on using the changeset viewer.