Changeset 23757 in osm for applications/editors/josm
- Timestamp:
- 2010-10-22T22:28:37+02:00 (14 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
r23756 r23757 27 27 import java.awt.geom.AffineTransform; 28 28 import java.awt.geom.Point2D; 29 import java.util.ArrayList; 30 import java.util.List; 29 31 30 32 import org.openstreetmap.josm.data.gpx.WayPoint; … … 45 47 * 46 48 */ 47 private static final int TRIANGLE_BASESIZE = 12;49 private static final int TRIANGLE_BASESIZE = 24; 48 50 /** 49 51 * … … 63 65 // private static final double RAD_270 = Math.PI * 1.5; 64 66 private static final double RAD_90 = Math.PI * 0.5; 67 68 private List<Rectangle> forbiddenRects = new ArrayList<Rectangle>(); 65 69 66 70 /* … … 405 409 int height = g.getFont().getSize() + g.getFontMetrics().getLeading() + 5; 406 410 411 Rectangle r = new Rectangle(x - (width / 2), y - (height / 2), width, height); 412 413 if (isForbiddenArea(r)) { 414 return; // no space left, skip this label 415 } 416 407 417 g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, 408 RenderingHints.VALUE_ANTIALIAS_ON); 409 418 RenderingHints.VALUE_ANTIALIAS_ON); 410 419 GradientPaint gradient = new GradientPaint(x, y, Color.WHITE, x, y 411 + height, secondGradColor, false);420 + (height/2), secondGradColor, false); 412 421 g2d.setPaint(gradient); 413 422 414 Rectangle r = new Rectangle(x - (width / 2), y - (height / 2), width, height);423 415 424 g2d.fillRoundRect(r.x, r.y, r.width, r.height, ROUND_RECT_RADIUS, ROUND_RECT_RADIUS); 416 425 … … 419 428 g2d.drawRoundRect(r.x, r.y, r.width, r.height, ROUND_RECT_RADIUS, ROUND_RECT_RADIUS); 420 429 g2d.drawString(s, x - (width / 2) + 5, y + (height / 2) - 3); 430 431 forbiddenRects.add(r); 432 } 433 434 /** 435 * Checks, if the rectangle has been 'reserved' by a previous draw action. 436 * @param r The area to check for. 437 * @return true; if area is already occupied by another rectangle. 438 */ 439 private boolean isForbiddenArea(Rectangle r) { 440 441 for (Rectangle rTest : forbiddenRects) { 442 if (r.intersects(rTest)) return true; 443 } 444 return false; 445 } 446 447 @Override 448 public void beginRendering() { 449 forbiddenRects.clear(); 450 } 451 452 @Override 453 public void finishRendering() { 454 // nothing to do currently 421 455 } 422 456 } -
applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui/ElevationProfileLayer.java
r23756 r23757 18 18 19 19 import java.awt.Graphics2D; 20 20 21 import javax.swing.Action; 21 22 import javax.swing.Icon; … … 44 45 private IElevationProfile profile; 45 46 private IElevationProfileRenderer renderer = new DefaultElevationProfileRenderer(); 46 private WayPoint selWayPoint = null; 47 private WayPoint selWayPoint = null; 47 48 48 49 /** … … 158 159 159 160 if (profile != null) { 161 renderer.beginRendering(); 160 162 for (WayPoint wpt : profile.getWayPoints()) { 161 163 int ele = (int) WayPointHelper.getElevation(wpt); … … 207 209 System.err.println("Layer#paint: No profile"); 208 210 } 211 212 renderer.finishRendering(); 209 213 } 210 214 -
applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui/IElevationProfileRenderer.java
r23709 r23757 50 50 */ 51 51 void renderWayPoint(Graphics g, IElevationProfile profile, MapView mv, WayPoint wpt, ElevationWayPointKind kind); 52 53 /** 54 * Notifies the renderer that rendering starts. 55 */ 56 void beginRendering(); 57 58 /** 59 * Notifies the renderer that rendering has been finished. 60 */ 61 void finishRendering(); 52 62 }
Note:
See TracChangeset
for help on using the changeset viewer.