Changeset 29950 in osm for applications/editors/josm/plugins/ElevationProfile/src/org
- Timestamp:
- 2013-09-24T00:51:57+02:00 (11 years ago)
- Location:
- applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/ElevationProfilePlugin.java
r29921 r29950 56 56 createColorMaps(); 57 57 58 MainMenu.add(Main.main.menu.viewMenu, action, false, 0); 58 // TODO: Disable this view as long as it is not stable 59 //MainMenu.add(Main.main.menu.viewMenu, action, false, 0); 59 60 } catch (Exception e1) { 60 61 System.err.println("Init of ElevationProfilePlugin failed: " + e1); -
applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui/DefaultElevationProfileRenderer.java
r29949 r29950 15 15 package org.openstreetmap.josm.plugins.elevation.gui; 16 16 17 import java.awt.BasicStroke; 17 18 import java.awt.Color; 18 19 import java.awt.GradientPaint; 19 20 import java.awt.Graphics; 20 21 import java.awt.Graphics2D; 22 import java.awt.MultipleGradientPaint.CycleMethod; 21 23 import java.awt.Point; 22 24 import java.awt.RadialGradientPaint; … … 24 26 import java.awt.RenderingHints; 25 27 import java.awt.Shape; 26 import java.awt. MultipleGradientPaint.CycleMethod;28 import java.awt.Stroke; 27 29 import java.awt.geom.AffineTransform; 28 30 import java.awt.geom.Point2D; … … 53 55 */ 54 56 private static final int BASIC_WPT_RADIUS = 1; 55 private static final int REGULAR_WPT_RADIUS = BASIC_WPT_RADIUS * 4; 56 private static final int BIG_WPT_RADIUS = BASIC_WPT_RADIUS * 8; 57 private static final int BIG_WPT_RADIUS = BASIC_WPT_RADIUS * 16; 57 58 58 59 // predefined colors … … 107 108 return Color.getHSBColor(0, 1.0f, 1.0f); // red 108 109 case ElevationGainLow: 109 return Color.getHSBColor(0.3f, 0. 5f, 1.0f); // green with low sat110 return Color.getHSBColor(0.3f, 0.7f, 1.0f); // green with low sat 110 111 case ElevationLossLow: 111 return Color.getHSBColor(0, 0. 5f, 1.0f); // red with low sat112 return Color.getHSBColor(0, 0.7f, 1.0f); // red with low sat 112 113 case FullHour: 113 114 return MARKER_POINT; … … 116 117 case MinElevation: 117 118 return LOW_COLOR; 118 119 119 case StartPoint: 120 120 return START_COLOR; 121 121 case EndPoint: 122 122 return END_POINT; 123 default: 123 default: 124 124 break; 125 125 } … … 165 165 } 166 166 } 167 168 /* (non-Javadoc) 169 * @see org.openstreetmap.josm.plugins.elevation.gui.IElevationProfileRenderer#renderWayPoints(java.awt.Graphics, org.openstreetmap.josm.plugins.elevation.gpx.IElevationProfile, org.openstreetmap.josm.gui.MapView, org.openstreetmap.josm.data.gpx.WayPoint, org.openstreetmap.josm.data.gpx.WayPoint) 170 */ 171 @Override 172 public void renderLine(Graphics g, IElevationProfile profile, 173 MapView mv, WayPoint wpt1, WayPoint wpt2, ElevationWayPointKind kind) { 174 175 CheckParameterUtil.ensureParameterNotNull(g, "graphics"); 176 CheckParameterUtil.ensureParameterNotNull(profile, "profile"); 177 CheckParameterUtil.ensureParameterNotNull(mv, "map view"); 178 179 if (wpt1 == null || wpt2 == null) { 180 System.err.println(String.format( 181 "Cannot paint line: mv=%s, prof=%s, kind = %s", mv, profile, kind)); 182 return; 183 } 184 185 // obtain and set color 186 g.setColor(getColorForWaypoint(profile, wpt2, kind)); 187 188 // transform to view 189 Point pnt1 = mv.getPoint(wpt1.getEastNorth()); 190 Point pnt2 = mv.getPoint(wpt2.getEastNorth()); 191 192 // use thick line, if possible 193 if (g instanceof Graphics2D) { 194 Graphics2D g2 = (Graphics2D) g; 195 Stroke oldS = g2.getStroke(); 196 try { 197 g2.setStroke(new BasicStroke(3, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND)); 198 g2.drawLine(pnt1.x, pnt1.y, pnt2.x, pnt2.y); 199 } finally { 200 // must be restored; otherwise other layers may using this style, too 201 g2.setStroke(oldS); 202 } 203 } else { 204 // only poor man's graphics 205 g.drawLine(pnt1.x, pnt1.y, pnt2.x, pnt2.y); 206 } 207 } 167 208 168 209 /** … … 184 225 185 226 Color c = getColorForWaypoint(profile, wpt, kind); 186 187 if (c == null) {188 System.err.println(String.format(189 "Cannot determine color: mv=%s, prof=%s, wpt=%s", mv,190 profile, wpt));191 }192 193 227 Point pnt = mv.getPoint(wpt.getEastNorth()); 194 int rad = REGULAR_WPT_RADIUS;195 int r2 = REGULAR_WPT_RADIUS / 2;196 228 197 g.setColor(c);198 g.fillOval(pnt.x - r2, pnt.y - r2, rad, rad);199 200 229 /* Paint full hour label */ 201 230 if (kind == ElevationWayPointKind.FullHour) { … … 547 576 // nothing to do currently 548 577 } 578 579 549 580 } -
applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui/ElevationProfileDialog.java
r29948 r29950 118 118 119 119 JPanel dataPanel = new JPanel(); 120 GridLayout gridLayout = new GridLayout( 3, 6);120 GridLayout gridLayout = new GridLayout(2, 6); 121 121 dataPanel.setLayout(gridLayout); 122 122 -
applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui/ElevationProfileLayer.java
r29949 r29950 27 27 import org.openstreetmap.josm.data.gpx.WayPoint; 28 28 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor; 29 import org.openstreetmap.josm.data.projection.Projection;30 29 import org.openstreetmap.josm.gui.MapView; 31 30 import org.openstreetmap.josm.gui.dialogs.LayerListPopup; … … 36 35 import org.openstreetmap.josm.tools.ImageProvider; 37 36 38 import sun.java2d.loops.FillRect;39 40 37 /** 41 38 * Layer class to show additional information on the elevation map, e. g. show … … 163 160 WayPoint lastWpt = null; 164 161 165 166 162 renderer.beginRendering(); 163 167 164 if (profile != null) { 168 165 // choose smaller font … … 172 169 173 170 try { 174 int npts = 0;175 171 // paint way points one by one 176 172 for (WayPoint wpt : profile.getWayPoints()) { … … 178 174 // determine way point 179 175 ElevationWayPointKind kind = classifyWayPoint(lastWpt, wpt); 180 181 // render way point 176 // render way point as line 177 renderer.renderLine(g, profile, mv, lastWpt, wpt, kind); 178 // render single way point 182 179 renderer.renderWayPoint(g, profile, mv, wpt, kind); 183 npts++;184 180 } // else first way point -> is paint later 185 181 186 // remember some thingsfor next iteration182 // remember last wpt for next iteration 187 183 lastWpt = wpt; 188 184 } 189 185 190 System.out.println("Rendered " + npts + ", " + profile.getWayPoints().size());191 186 // now we paint special way points in emphasized style 192 187 … … 249 244 if (actEle > lastEle) { // we went uphill? 250 245 // TODO: Provide parameters for high/low thresholds 251 if (slope > 3) kind =ElevationWayPointKind.ElevationGainLow;246 if (slope > 2) kind =ElevationWayPointKind.ElevationGainLow; 252 247 if (slope > 10) kind =ElevationWayPointKind.ElevationGainHigh; 253 248 } else { 254 if (slope > 3) kind =ElevationWayPointKind.ElevationLossLow;249 if (slope > 2) kind =ElevationWayPointKind.ElevationLossLow; 255 250 if (slope > 10) kind =ElevationWayPointKind.ElevationLossHigh; 256 251 } … … 268 263 @Override 269 264 public void visitBoundingBox(BoundingXYVisitor v) { 270 // TODO Auto-generated method stub265 // What to do here? 271 266 } 272 267 -
applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui/IElevationProfileRenderer.java
r29948 r29950 44 44 /** 45 45 * Renders the way point with the lowest elevation. 46 * 46 47 * @param g The graphics context. 47 48 * @param profile The elevation profile that contains the way point. 49 * @param mv the associated view 48 50 * @param wpt The way point to render. 49 * @param kind The way point kind (see {@link ElevationWayPointKind}). 51 * @param kind The way point kind (see {@link ElevationWayPointKind}). 50 52 */ 51 53 void renderWayPoint(Graphics g, IElevationProfile profile, MapView mv, WayPoint wpt, ElevationWayPointKind kind); 54 55 /** 56 * Render line between two way points. This is intended to render speed or slope. 57 * 58 * @param g The graphics context. 59 * @param profile The elevation profile that contains the way point. 60 * @param mv the associated view 61 * @param wpt1 the first way point 62 * @param wpt2 the second way point 63 */ 64 void renderLine(Graphics g, IElevationProfile profile, MapView mv, WayPoint wpt1, WayPoint wpt2, ElevationWayPointKind kind); 52 65 53 66 /**
Note:
See TracChangeset
for help on using the changeset viewer.