Changeset 23756 in osm for applications/editors/josm/plugins/ElevationProfile/src/org
- Timestamp:
- 2010-10-22T22:10:52+02:00 (14 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/ElevationWayPointKind.java
r23721 r23756 28 28 ElevationGain, // Elevation gain 29 29 ElevationLoss, // Elevation loss 30 ElevationLevel, // Elevation level (e. g. crossed 300m) 30 31 FullHour // Full Hour 31 32 } -
applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui/DefaultElevationProfileRenderer.java
r23755 r23756 87 87 switch (kind) { 88 88 case Plain: 89 case ElevationLevel: 89 90 if (z > profile.getAverageHeight()) { 90 91 return HIGH_COLOR; … … 111 112 } 112 113 113 return null;114 throw new RuntimeException("Unknown way point kind: " + kind); 114 115 } 115 116 … … 185 186 } 186 187 188 if (kind == ElevationWayPointKind.ElevationLevel) { 189 int ele = ((int)Math.rint(WayPointHelper.getElevation(wpt) / 100.0)) * 100; 190 drawLabel(String.format("%dm", ele), pnt.x, pnt.y + g.getFontMetrics().getHeight(), g, c); 191 } 192 187 193 if (kind == ElevationWayPointKind.Highlighted) { 188 194 int eleH = (int) WayPointHelper.getElevation(wpt); … … 190 196 int min = WayPointHelper.getMinuteOfWayPoint(wpt); 191 197 drawSphere(g, Color.WHITE, c, pnt.x, pnt.y, BIG_WPT_RADIUS); 192 drawLabel(String.format("%02d:%02d", hour, min), pnt.x, pnt.y - g.getFontMetrics().getHeight() , g);193 drawLabel(String.format("%dm", eleH), pnt.x, pnt.y + g.getFontMetrics().getHeight() , g);198 drawLabel(String.format("%02d:%02d", hour, min), pnt.x, pnt.y - g.getFontMetrics().getHeight() - 5, g); 199 drawLabel(String.format("%dm", eleH), pnt.x, pnt.y + g.getFontMetrics().getHeight() + 5, g); 194 200 } 195 201 } … … 238 244 DefaultElevationProfileRenderer.TRIANGLE_BASESIZE); 239 245 240 drawLabel(String.format("%dm", eleH), pnt.x, pnt.y + g.getFontMetrics().getHeight(), g );246 drawLabel(String.format("%dm", eleH), pnt.x, pnt.y + g.getFontMetrics().getHeight(), g, c); 241 247 } 242 248 … … 383 389 */ 384 390 private void drawLabel(String s, int x, int y, Graphics g) { 391 drawLabel(s, x, y, g, Color.BLACK); 392 } 393 /** 394 * Draws a label. 395 * @param s The text to draw. 396 * @param x The x coordinate of the label. 397 * @param y The y coordinate of the label. 398 * @param g The graphics context. 399 * @param secondGradColor The second color of the gradient. 400 */ 401 private void drawLabel(String s, int x, int y, Graphics g, Color secondGradColor) { 385 402 Graphics2D g2d = (Graphics2D) g; 386 403 … … 392 409 393 410 GradientPaint gradient = new GradientPaint(x, y, Color.WHITE, x, y 394 + height, Color.BLACK, false);411 + height, secondGradColor, false); 395 412 g2d.setPaint(gradient); 396 413 397 Rectangle r = new Rectangle(x - (width / 2) - 5, y - (height / 2) + 1, width, height);398 g2d.fillR ect(r.x, r.y, r.width, r.height);414 Rectangle r = new Rectangle(x - (width / 2), y - (height / 2), width, height); 415 g2d.fillRoundRect(r.x, r.y, r.width, r.height, ROUND_RECT_RADIUS, ROUND_RECT_RADIUS); 399 416 400 417 g2d.setColor(Color.BLACK); 401 418 402 g2d.drawRoundRect(r.x, r.y, r.width, r.height, ROUND_RECT_RADIUS, ROUND_RECT_RADIUS); 403 g2d.drawString(s, x - width / 2, y + (height / 2) - 2);419 g2d.drawRoundRect(r.x, r.y, r.width, r.height, ROUND_RECT_RADIUS, ROUND_RECT_RADIUS); 420 g2d.drawString(s, x - (width / 2) + 5, y + (height / 2) - 3); 404 421 } 405 422 } -
applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui/ElevationProfileLayer.java
r23734 r23756 161 161 int ele = (int) WayPointHelper.getElevation(wpt); 162 162 163 if (lastWpt != null) { 163 if (lastWpt != null) { 164 /* 164 165 int h1 = WayPointHelper.getHourOfWayPoint(wpt); 165 166 int h2 = WayPointHelper.getHourOfWayPoint(lastWpt); 166 if (h1 != h2) { // hour changed? 167 */ 168 int ele1 = (int)(ele / 100.0); 169 int ele2 = (int)(lastEle / 100.0); 170 if (ele1 != ele2) { // hour changed? 167 171 renderer.renderWayPoint(g, profile, mv, wpt, 168 ElevationWayPointKind. FullHour);172 ElevationWayPointKind.ElevationLevel); 169 173 } else { // check for elevation gain 170 174 if (ele > lastEle) {
Note:
See TracChangeset
for help on using the changeset viewer.