Changeset 28149 in osm for applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap
- Timestamp:
- 2012-03-26T18:20:51+02:00 (13 years ago)
- Location:
- applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/ElevationProfilePlugin.java
r27426 r28149 46 46 eleMode = new ElevationMapMode("Elevation profile", Main.map); 47 47 eleModeButton = new IconToggleButton(eleMode); 48 eleModeButton.setAutoHideDisabledButton(true);49 48 } catch (Exception e1) { 50 49 System.err.println("Init of ElevationProfilePlugin failed: " + e1); -
applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui/DefaultElevationProfileRenderer.java
r26509 r28149 35 35 import org.openstreetmap.josm.plugins.elevation.IElevationProfile; 36 36 import org.openstreetmap.josm.plugins.elevation.WayPointHelper; 37 import org.openstreetmap.josm.tools.CheckParameterUtil; 37 38 38 39 /** … … 133 134 MapView mv, WayPoint wpt, ElevationWayPointKind kind) { 134 135 135 if (mv == null || profile == null || wpt == null) { 136 CheckParameterUtil.ensureParameterNotNull(g, "graphics"); 137 CheckParameterUtil.ensureParameterNotNull(profile, "profile"); 138 CheckParameterUtil.ensureParameterNotNull(mv, "map view"); 139 140 if (wpt == null) { 136 141 System.err.println(String.format( 137 "Cannot paint: mv=%s, prof=%s, wpt=%s", mv, profile, wpt)); 138 if (wpt == null) { 139 throw new RuntimeException("WPT must not be null, profile " + profile); 140 } 142 "Cannot paint: mv=%s, prof=%s, wpt=%s", mv, profile, wpt)); 141 143 return; 142 144 } -
applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui/ElevationProfileLayer.java
r26817 r28149 43 43 public class ElevationProfileLayer extends 44 44 org.openstreetmap.josm.gui.layer.Layer implements IElevationProfileSelectionListener { 45 private static final double Level_Factor = 100.0; 45 46 private IElevationProfile profile; 46 47 private IElevationProfileRenderer renderer = new DefaultElevationProfileRenderer(); … … 159 160 renderer.beginRendering(); 160 161 if (profile != null) { 162 // paint way points one by one 161 163 for (WayPoint wpt : profile.getWayPoints()) { 162 164 int ele = (int) WayPointHelper.getElevation(wpt); 163 165 164 166 if (lastWpt != null) { 165 /* 166 int h1 = WayPointHelper.getHourOfWayPoint(wpt); 167 int h2 = WayPointHelper.getHourOfWayPoint(lastWpt); 168 */ 169 int ele1 = (int)(ele / 100.0); 170 int ele2 = (int)(lastEle / 100.0); 167 // normalize to levels 168 int ele1 = (int)(ele / Level_Factor); 169 int ele2 = (int)(lastEle / Level_Factor); 171 170 172 // Check, if we passed an elevation level 171 // plain way point by default 172 ElevationWayPointKind kind = ElevationWayPointKind.Plain; 173 // check, if we passed an elevation level 174 // We assume, that we cannot pass more than one levels between two way points ;-) 173 175 if (ele1 != ele2 && Math.abs(ele1 - ele2) == 1) { 174 176 if (ele1 > ele2) { // we went down? 175 renderer.renderWayPoint(g, profile, mv, wpt, 176 ElevationWayPointKind.ElevationLevelGain); 177 kind =ElevationWayPointKind.ElevationLevelGain; 177 178 } else { 178 renderer.renderWayPoint(g, profile, mv, wpt, 179 ElevationWayPointKind.ElevationLevelLoss); 179 kind =ElevationWayPointKind.ElevationLevelLoss; 180 180 } 181 181 } else { // check for elevation gain or loss 182 182 if (ele > lastEle) { // we went down? 183 renderer.renderWayPoint(g, profile, mv, wpt, 184 ElevationWayPointKind.ElevationGain); 183 kind =ElevationWayPointKind.ElevationGain; 185 184 } else { 186 renderer.renderWayPoint(g, profile, mv, wpt, 187 ElevationWayPointKind.ElevationLoss); 185 kind =ElevationWayPointKind.ElevationLoss; 188 186 } 189 187 } 188 189 // render way point 190 renderer.renderWayPoint(g, profile, mv, wpt, kind); 190 191 } 191 192 … … 194 195 lastWpt = wpt; 195 196 } 196 197 198 // now we paint special way points in emphasized style 199 197 200 // paint selected way point, if available 198 201 if (selWayPoint != null) {
Note:
See TracChangeset
for help on using the changeset viewer.