Changeset 29949 in osm for applications/editors/josm/plugins/ElevationProfile/src
- Timestamp:
- 2013-09-24T00:03:48+02:00 (11 years ago)
- Location:
- applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui/DefaultElevationProfileRenderer.java
r29948 r29949 44 44 IElevationProfileRenderer { 45 45 46 private static final int ROUND_RECT_RADIUS = 8;46 private static final int ROUND_RECT_RADIUS = 6; 47 47 /** 48 48 * … … 52 52 * 53 53 */ 54 private static final int BASIC_WPT_RADIUS = 3;54 private static final int BASIC_WPT_RADIUS = 1; 55 55 private static final int REGULAR_WPT_RADIUS = BASIC_WPT_RADIUS * 4; 56 private static final int BIG_WPT_RADIUS = BASIC_WPT_RADIUS * 10;56 private static final int BIG_WPT_RADIUS = BASIC_WPT_RADIUS * 8; 57 57 58 58 // predefined colors … … 192 192 193 193 Point pnt = mv.getPoint(wpt.getEastNorth()); 194 int ele = ((int) Math.rint(ElevationHelper.getElevation(wpt) / 100.0)) * 100; 194 int rad = REGULAR_WPT_RADIUS; 195 int r2 = REGULAR_WPT_RADIUS / 2; 195 196 196 int rad = REGULAR_WPT_RADIUS;197 197 g.setColor(c); 198 drawSphere(g, Color.WHITE, c, pnt.x, pnt.y, rad);198 g.fillOval(pnt.x - r2, pnt.y - r2, rad, rad); 199 199 200 200 /* Paint full hour label */ … … 206 206 207 207 /* Paint label for elevation levels */ 208 if (kind == ElevationWayPointKind.ElevationLevelGain) { 208 if (kind == ElevationWayPointKind.ElevationLevelGain || kind == ElevationWayPointKind.ElevationLevelLoss) { 209 int ele = ((int) Math.rint(ElevationHelper.getElevation(wpt) / 100.0)) * 100; 209 210 drawLabelWithTriangle(ElevationHelper.getElevationText(ele), pnt.x, pnt.y 210 211 + g.getFontMetrics().getHeight(), g, c, 8, 211 getColorForWaypoint(profile, wpt, ElevationWayPointKind.ElevationGainHigh),212 getColorForWaypoint(profile, wpt, kind), 212 213 TriangleDir.Up); 213 }214 215 if (kind == ElevationWayPointKind.ElevationLevelLoss) {216 drawLabelWithTriangle(ElevationHelper.getElevationText(ele),217 pnt.x, pnt.y+ g.getFontMetrics().getHeight(), g, c, 8,218 getColorForWaypoint(profile, wpt, ElevationWayPointKind.ElevationLossHigh),219 TriangleDir.Down);220 214 } 221 215 -
applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui/ElevationProfileLayer.java
r29948 r29949 17 17 import static org.openstreetmap.josm.tools.I18n.tr; 18 18 19 import java.awt.Font; 19 20 import java.awt.Graphics2D; 20 21 … … 26 27 import org.openstreetmap.josm.data.gpx.WayPoint; 27 28 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor; 29 import org.openstreetmap.josm.data.projection.Projection; 28 30 import org.openstreetmap.josm.gui.MapView; 29 31 import org.openstreetmap.josm.gui.dialogs.LayerListPopup; … … 34 36 import org.openstreetmap.josm.tools.ImageProvider; 35 37 38 import sun.java2d.loops.FillRect; 39 36 40 /** 37 41 * Layer class to show additional information on the elevation map, e. g. show … … 159 163 WayPoint lastWpt = null; 160 164 165 161 166 renderer.beginRendering(); 162 if (profile != null) { 163 // paint way points one by one 164 for (WayPoint wpt : profile.getWayPoints()) { 165 166 167 if (lastWpt != null) { 168 // determine way point 169 ElevationWayPointKind kind = classifyWayPoint(lastWpt, wpt); 170 171 // render way point 172 renderer.renderWayPoint(g, profile, mv, wpt, kind); 173 } // else first way point -> is paint later 174 175 // remember some things for next iteration 176 lastWpt = wpt; 177 } 178 179 // now we paint special way points in emphasized style 180 181 // paint selected way point, if available 182 if (selWayPoint != null) { 183 renderer.renderWayPoint(g, profile, mv, selWayPoint, 184 ElevationWayPointKind.Highlighted); 185 } 186 187 // paint start/end 188 renderer.renderWayPoint(g, profile, mv, profile.getStartWayPoint(), 189 ElevationWayPointKind.StartPoint); 190 renderer.renderWayPoint(g, profile, mv, profile.getEndWayPoint(), 191 ElevationWayPointKind.EndPoint); 192 // paint min/max 193 renderer.renderWayPoint(g, profile, mv, profile.getMaxWayPoint(), 194 ElevationWayPointKind.MaxElevation); 195 renderer.renderWayPoint(g, profile, mv, profile.getMinWayPoint(), 196 ElevationWayPointKind.MinElevation); 197 } 198 167 if (profile != null) { 168 // choose smaller font 169 Font oldFont = g.getFont(); 170 Font lFont = g.getFont().deriveFont(9.0f); 171 g.setFont(lFont); 172 173 try { 174 int npts = 0; 175 // paint way points one by one 176 for (WayPoint wpt : profile.getWayPoints()) { 177 if (lastWpt != null) { 178 // determine way point 179 ElevationWayPointKind kind = classifyWayPoint(lastWpt, wpt); 180 181 // render way point 182 renderer.renderWayPoint(g, profile, mv, wpt, kind); 183 npts++; 184 } // else first way point -> is paint later 185 186 // remember some things for next iteration 187 lastWpt = wpt; 188 } 189 190 System.out.println("Rendered " + npts + ", " + profile.getWayPoints().size()); 191 // now we paint special way points in emphasized style 192 193 // paint start/end 194 renderer.renderWayPoint(g, profile, mv, profile.getStartWayPoint(), 195 ElevationWayPointKind.StartPoint); 196 renderer.renderWayPoint(g, profile, mv, profile.getEndWayPoint(), 197 ElevationWayPointKind.EndPoint); 198 // paint min/max 199 renderer.renderWayPoint(g, profile, mv, profile.getMaxWayPoint(), 200 ElevationWayPointKind.MaxElevation); 201 renderer.renderWayPoint(g, profile, mv, profile.getMinWayPoint(), 202 ElevationWayPointKind.MinElevation); 203 204 205 // paint selected way point, if available 206 if (selWayPoint != null) { 207 renderer.renderWayPoint(g, profile, mv, selWayPoint, 208 ElevationWayPointKind.Highlighted); 209 } 210 } finally { 211 g.setFont(oldFont); 212 } 213 } 199 214 renderer.finishRendering(); 200 215 } … … 263 278 } 264 279 } 265 266 280 } -
applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui/ElevationProfilePanel.java
r29948 r29949 58 58 private List<IElevationProfileSelectionListener> selectionChangedListeners = new ArrayList<IElevationProfileSelectionListener>(); 59 59 private boolean isPainting; 60 private int step = 0; 60 61 61 62 /** … … 137 138 IElevationProfile profile = model.getCurrentProfile(); 138 139 139 if (profile != null && profile.getWayPoints() != null && profile.getWayPoints().size() > this.selectedIndex) { 140 return profile.getWayPoints().get(this.selectedIndex); 140 int selWp = this.selectedIndex * step; 141 if (profile != null && profile.getWayPoints() != null && profile.getWayPoints().size() > selWp) { 142 return profile.getWayPoints().get(selWp); 141 143 } else { 142 144 return null; … … 410 412 411 413 if (n == 0) return; // nothing to draw 412 // step size 413 int step = profile.getNumberOfWayPoints() / n; 414 step = profile.getNumberOfWayPoints() / n; 414 415 415 416 // int y0 = plotArea.y + 1; … … 417 418 Color oldC = g.getColor(); 418 419 419 for (int i = 0; i < n; i += step) { 420 WayPoint wpt = profile.getWayPoints().get(i); 420 for (int i = 0, ip = 0; i < n; i++, ip += step) { 421 WayPoint wpt = profile.getWayPoints().get(ip); 421 422 int eleVal = (int) ElevationHelper.getElevation(wpt); 422 423 Color c = renderer.getColorForWaypoint(profile, wpt,
Note:
See TracChangeset
for help on using the changeset viewer.