Changeset 13177 in josm for trunk/src/org


Ignore:
Timestamp:
2017-12-01T23:17:19+01:00 (7 years ago)
Author:
Don-vip
Message:

fix #15605 - fix display of way length in status bar during way creation

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

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/mapmode/DrawAction.java

    r13146 r13177  
    820820        mouseOnExistingWays = new HashSet<>();
    821821
    822         showStatusInfo(-1, -1, -1, snapHelper.isSnapOn());
    823 
    824822        if (!ctrl && mousePos != null) {
    825823            currentMouseNode = mv.getNearestNode(mousePos, OsmPrimitive::isSelectable);
     
    853851            return; // Don't create zero length way segments.
    854852
     853        showStatusInfo(-1, -1, -1, snapHelper.isSnapOn());
    855854
    856855        double curHdg = Utils.toDegrees(getCurrentBaseNode().getEastNorth()
  • trunk/src/org/openstreetmap/josm/gui/MapStatus.java

    r13159 r13177  
    7373import org.openstreetmap.josm.data.osm.OsmPrimitive;
    7474import org.openstreetmap.josm.data.osm.Way;
     75import org.openstreetmap.josm.data.osm.event.AbstractDatasetChangedEvent;
     76import org.openstreetmap.josm.data.osm.event.DataChangedEvent;
     77import org.openstreetmap.josm.data.osm.event.DataSetListener;
     78import org.openstreetmap.josm.data.osm.event.DatasetEventManager;
    7579import org.openstreetmap.josm.data.osm.event.DatasetEventManager.FireMode;
     80import org.openstreetmap.josm.data.osm.event.NodeMovedEvent;
     81import org.openstreetmap.josm.data.osm.event.PrimitivesAddedEvent;
     82import org.openstreetmap.josm.data.osm.event.PrimitivesRemovedEvent;
     83import org.openstreetmap.josm.data.osm.event.RelationMembersChangedEvent;
    7684import org.openstreetmap.josm.data.osm.event.SelectionEventManager;
     85import org.openstreetmap.josm.data.osm.event.TagsChangedEvent;
     86import org.openstreetmap.josm.data.osm.event.WayNodesChangedEvent;
    7787import org.openstreetmap.josm.data.preferences.AbstractProperty;
    7888import org.openstreetmap.josm.data.preferences.BooleanProperty;
     
    111121 */
    112122public final class MapStatus extends JPanel implements
    113     Helpful, Destroyable, PreferenceChangedListener, SoMChangeListener, SelectionChangedListener, ZoomChangeListener {
     123    Helpful, Destroyable, PreferenceChangedListener, SoMChangeListener, SelectionChangedListener, DataSetListener, ZoomChangeListener {
    114124
    115125    private final DecimalFormat DECIMAL_FORMAT = new DecimalFormat(Config.getPref().get("statusbar.decimal-format", "0.0"));
     
    941951
    942952        Config.getPref().addPreferenceChangeListener(this);
     953        DatasetEventManager.getInstance().addDatasetListener(this, FireMode.IN_EDT);
    943954        SelectionEventManager.getInstance().addSelectionListener(this, FireMode.IN_EDT_CONSOLIDATED);
    944955
     
    11261137        NavigatableComponent.removeZoomChangeListener(this);
    11271138        Config.getPref().removePreferenceChangeListener(this);
     1139        DatasetEventManager.getInstance().removeDatasetListener(this);
    11281140        SelectionEventManager.getInstance().removeSelectionListener(this);
    11291141        mv.removeComponentListener(mvComponentAdapter);
     
    11731185    }
    11741186
    1175     @Override
    1176     public void selectionChanged(Collection<? extends OsmPrimitive> newSelection) {
     1187    private void refreshDistText(Collection<? extends OsmPrimitive> newSelection) {
    11771188        if (newSelection.size() == 2) {
    11781189            Iterator<? extends OsmPrimitive> it = newSelection.iterator();
     
    11931204
    11941205    @Override
     1206    public void selectionChanged(Collection<? extends OsmPrimitive> newSelection) {
     1207        refreshDistText(newSelection);
     1208    }
     1209
     1210    @Override
    11951211    public void zoomChanged() {
    11961212        if (!GraphicsEnvironment.isHeadless()) {
     
    12021218        }
    12031219    }
     1220
     1221    @Override
     1222    public void wayNodesChanged(WayNodesChangedEvent event) {
     1223        DataSet ds = MainApplication.getLayerManager().getEditDataSet();
     1224        if (ds != null) {
     1225            Collection<OsmPrimitive> sel = ds.getSelected();
     1226            if (sel.size() == 1 && sel.contains(event.getChangedWay())) {
     1227                refreshDistText(sel);
     1228            }
     1229        }
     1230    }
     1231
     1232    @Override
     1233    public void nodeMoved(NodeMovedEvent event) {
     1234        DataSet ds = MainApplication.getLayerManager().getEditDataSet();
     1235        if (ds != null) {
     1236            Collection<OsmPrimitive> sel = ds.getSelected();
     1237            if (sel.size() == 2 && sel.contains(event.getNode())) {
     1238                refreshDistText(sel);
     1239            }
     1240        }
     1241    }
     1242
     1243    @Override
     1244    public void primitivesAdded(PrimitivesAddedEvent event) {
     1245        // Do nothing
     1246    }
     1247
     1248    @Override
     1249    public void primitivesRemoved(PrimitivesRemovedEvent event) {
     1250        // Do nothing
     1251    }
     1252
     1253    @Override
     1254    public void tagsChanged(TagsChangedEvent event) {
     1255        // Do nothing
     1256    }
     1257
     1258    @Override
     1259    public void relationMembersChanged(RelationMembersChangedEvent event) {
     1260        // Do nothing
     1261    }
     1262
     1263    @Override
     1264    public void otherDatasetChange(AbstractDatasetChangedEvent event) {
     1265        // Do nothing
     1266    }
     1267
     1268    @Override
     1269    public void dataChanged(DataChangedEvent event) {
     1270        // Do nothing
     1271    }
    12041272}
Note: See TracChangeset for help on using the changeset viewer.