Changeset 23759 in osm


Ignore:
Timestamp:
2010-10-23T00:37:00+02:00 (14 years ago)
Author:
oliverw
Message:
  • Bugfix: Remove layer data when no GPX layer is left
  • Removed some debug output
Location:
applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui/ElevationProfileDialog.java

    r23754 r23759  
    6363                ComponentListener {
    6464
     65        private static final String EMPTY_DATA_STRING = "-";
    6566        /**
    6667         *
     
    246247        public void setModel(IElevationProfile model) {
    247248                if (this.profile != model) {
    248                         if (model != null) {
    249                                 // System.out.println("Set model " + model);
    250                                 this.profile = model;
    251                                 profPanel.setElevationModel(model);
    252                                 updateView();
    253                         }
     249                        this.profile = model;
     250                        profPanel.setElevationModel(model);
     251                       
     252                        updateView();
    254253                }
    255254        }
     
    282281         */
    283282        private void updateView() {
    284                 if (profile == null) { // emergency exit
    285                         setTitle(String.format("%s: (No data)", tr("Elevation Profile")));
    286                         return;
    287                 }
    288                
    289                 // Show name of profile in title
    290                 setTitle(String.format("%s: %s", tr("Elevation Profile"), profile.getName()));
    291                
    292                 if (profile.hasElevationData()) {
     283                if (profile != null) {
     284                        // Show name of profile in title
     285                        setTitle(String.format("%s: %s", tr("Elevation Profile"), profile.getName()));
     286
     287                        if (profile.hasElevationData()) {
    293288                        // Show elevation data
    294289                        minHeightLabel.setText(
     
    300295                        elevationGainLabel.setText(
    301296                                        NavigatableComponent.getSystemOfMeasurement().getDistText(profile.getGain()));
    302                 } else { // no elevation data
    303                         minHeightLabel.setText("-");
    304                         maxHeightLabel.setText("-");
    305                         avrgHeightLabel.setText("-");
    306                         elevationGainLabel.setText("-");
    307                 }
    308 
    309                 // compute values for time and distance
    310                 long diff = profile.getTimeDifference();
    311                 long minutes = diff / (1000 * 60);
    312                 long hours = minutes / 60;
    313                 minutes = minutes % 60;
    314                
    315                 double dist = profile.getDistance();
    316 
    317                 totalTimeLabel.setText(String.format("%d:%d h", hours, minutes));
    318                 distLabel.setText(NavigatableComponent.getSystemOfMeasurement().getDistText(dist));
     297                        }
     298                       
     299                        // compute values for time and distance
     300                        long diff = profile.getTimeDifference();
     301                        long minutes = diff / (1000 * 60);
     302                        long hours = minutes / 60;
     303                        minutes = minutes % 60;
     304                       
     305                        double dist = profile.getDistance();
     306
     307                        totalTimeLabel.setText(String.format("%d:%d h", hours, minutes));
     308                        distLabel.setText(NavigatableComponent.getSystemOfMeasurement().getDistText(dist));
     309                } else { // no elevation data, -> switch back to empty view
     310                        setTitle(String.format("%s: (No data)", tr("Elevation Profile")));
     311                       
     312                        minHeightLabel.setText(EMPTY_DATA_STRING);
     313                        maxHeightLabel.setText(EMPTY_DATA_STRING);
     314                        avrgHeightLabel.setText(EMPTY_DATA_STRING);
     315                        elevationGainLabel.setText(EMPTY_DATA_STRING);
     316                        totalTimeLabel.setText(EMPTY_DATA_STRING);
     317                        distLabel.setText(EMPTY_DATA_STRING);
     318                }
    319319               
    320320                fireModelChanged();
     
    414414                        }
    415415                       
    416                         System.out.println("Active layer: " + newLayer.getName());
    417416                        ElevationModel em = layerMap.get(newLayer);
    418417                        em.setSliceSize(slices);
     
    424423        public void layerAdded(Layer newLayer) {
    425424                createLayer(newLayer);
    426                 System.out.println("layerAdded: " + newLayer.getName());
    427425        }
    428426
     
    432430                        layerMap.remove(oldLayer);
    433431                }
    434 
     432                if (layerMap.size() == 0) {
     433                        setModel(null);
     434                        profileLayer.setProfile(null);
     435                }
    435436        }
    436437
  • applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui/ElevationProfileLayer.java

    r23757 r23759  
    158158                int index = 0;
    159159
    160                 if (profile != null) {
    161                         renderer.beginRendering();
     160                renderer.beginRendering();
     161                if (profile != null) {                 
    162162                        for (WayPoint wpt : profile.getWayPoints()) {
    163163                                int ele = (int) WayPointHelper.getElevation(wpt);
     
    206206                        renderer.renderWayPoint(g, profile, mv, profile.getMinWayPoint(),
    207207                                        ElevationWayPointKind.MinElevation);
    208                 } else {
    209                         System.err.println("Layer#paint: No profile");
    210                 }
     208                }
    211209               
    212210                renderer.finishRendering();
Note: See TracChangeset for help on using the changeset viewer.