- Timestamp:
- 2014-12-30T11:22:07+01:00 (10 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui/layer/geoimage
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/layer/geoimage/GeoImageLayer.java
r7788 r7912 6 6 7 7 import java.awt.AlphaComposite; 8 import java.awt.BasicStroke; 8 9 import java.awt.Color; 9 10 import java.awt.Composite; … … 13 14 import java.awt.Point; 14 15 import java.awt.Rectangle; 16 import java.awt.RenderingHints; 15 17 import java.awt.event.MouseAdapter; 16 18 import java.awt.event.MouseEvent; … … 496 498 Point p = mv.getPoint(e.getPos()); 497 499 500 int imgWidth = 100; 501 int imgHeight = 100; 498 502 if (useThumbs && e.thumbnail != null) { 499 503 Dimension d = scaledDimension(e.thumbnail); 504 imgWidth = d.width; 505 imgHeight = d.height; 506 } 507 else { 508 imgWidth = selectedIcon.getIconWidth(); 509 imgHeight = selectedIcon.getIconHeight(); 510 } 511 512 if (e.getExifImgDir() != null) { 513 // Multiplier must be larger than sqrt(2)/2=0.71. 514 double arrowlength = Math.max(25, Math.max(imgWidth, imgHeight) * 0.85); 515 double arrowwidth = arrowlength / 1.4; 516 517 double dir = e.getExifImgDir(); 518 // Rotate 90 degrees CCW 519 double headdir = ( dir < 90 ) ? dir + 270 : dir - 90; 520 double leftdir = ( headdir < 90 ) ? headdir + 270 : headdir - 90; 521 double rightdir = ( headdir > 270 ) ? headdir - 270 : headdir + 90; 522 523 double ptx = p.x + Math.cos(Math.toRadians(headdir)) * arrowlength; 524 double pty = p.y + Math.sin(Math.toRadians(headdir)) * arrowlength; 525 526 double ltx = p.x + Math.cos(Math.toRadians(leftdir)) * arrowwidth/2; 527 double lty = p.y + Math.sin(Math.toRadians(leftdir)) * arrowwidth/2; 528 529 double rtx = p.x + Math.cos(Math.toRadians(rightdir)) * arrowwidth/2; 530 double rty = p.y + Math.sin(Math.toRadians(rightdir)) * arrowwidth/2; 531 532 g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); 533 g.setColor(new Color(255, 255, 255, 192)); 534 int[] xar = {(int) ltx, (int) ptx, (int) rtx, (int) ltx}; 535 int[] yar = {(int) lty, (int) pty, (int) rty, (int) lty}; 536 g.fillPolygon(xar, yar, 4); 537 g.setColor(Color.black); 538 g.setStroke(new BasicStroke(1.2f)); 539 g.drawPolyline(xar, yar, 3); 540 } 541 542 if (useThumbs && e.thumbnail != null) { 500 543 g.setColor(new Color(128, 0, 0, 122)); 501 g.fillRect(p.x - d.width / 2, p.y - d.height / 2, d.width, d.height);544 g.fillRect(p.x - imgWidth / 2, p.y - imgHeight / 2, imgWidth, imgHeight); 502 545 } else { 503 if (e.getExifImgDir() != null) {504 double arrowlength = 25;505 double arrowwidth = 18;506 507 double dir = e.getExifImgDir();508 // Rotate 90 degrees CCW509 double headdir = ( dir < 90 ) ? dir + 270 : dir - 90;510 double leftdir = ( headdir < 90 ) ? headdir + 270 : headdir - 90;511 double rightdir = ( headdir > 270 ) ? headdir - 270 : headdir + 90;512 513 double ptx = p.x + Math.cos(Math.toRadians(headdir)) * arrowlength;514 double pty = p.y + Math.sin(Math.toRadians(headdir)) * arrowlength;515 516 double ltx = p.x + Math.cos(Math.toRadians(leftdir)) * arrowwidth/2;517 double lty = p.y + Math.sin(Math.toRadians(leftdir)) * arrowwidth/2;518 519 double rtx = p.x + Math.cos(Math.toRadians(rightdir)) * arrowwidth/2;520 double rty = p.y + Math.sin(Math.toRadians(rightdir)) * arrowwidth/2;521 522 g.setColor(Color.white);523 int[] xar = {(int) ltx, (int) ptx, (int) rtx, (int) ltx};524 int[] yar = {(int) lty, (int) pty, (int) rty, (int) lty};525 g.fillPolygon(xar, yar, 4);526 }527 528 546 selectedIcon.paintIcon(mv, g, 529 p.x - selectedIcon.getIconWidth()/ 2,530 p.y - selectedIcon.getIconHeight()/ 2);547 p.x - imgWidth / 2, 548 p.y - imgHeight / 2); 531 549 532 550 } … … 576 594 e.setPos(null); 577 595 return; 596 } 597 598 try { 599 double speed = dirGps.getDouble(GpsDirectory.TAG_GPS_SPEED); 600 String speedRef = dirGps.getString(GpsDirectory.TAG_GPS_SPEED_REF); 601 if (speedRef != null) { 602 if (speedRef.equalsIgnoreCase("M")) { 603 // miles per hour 604 speed *= 1.609344; 605 } else if (speedRef.equalsIgnoreCase("N")) { 606 // knots == nautical miles per hour 607 speed *= 1.852; 608 } 609 // default is K (km/h) 610 } 611 e.setSpeed(speed); 612 } catch (Exception ex) { 613 Main.debug(ex.getMessage()); 578 614 } 579 615 -
trunk/src/org/openstreetmap/josm/gui/layer/geoimage/ImageDisplay.java
r6792 r7912 469 469 public void setOsdText(String text) { 470 470 this.osdText = text; 471 repaint(); 471 472 } 472 473 -
trunk/src/org/openstreetmap/josm/gui/layer/geoimage/ImageEntry.java
r7509 r7912 33 33 */ 34 34 private CachedLatLon pos; 35 /** Speed in kilometer per second*/35 /** Speed in kilometer per hour */ 36 36 private Double speed; 37 37 /** Elevation (altitude) in meters */ -
trunk/src/org/openstreetmap/josm/gui/layer/geoimage/ImageViewerDialog.java
r7892 r7912 303 303 } 304 304 if (entry.getSpeed() != null) { 305 osd.append(tr("\n {0} km/h", Math.round(entry.getSpeed())));305 osd.append(tr("\nSpeed: {0} km/h", Math.round(entry.getSpeed()))); 306 306 } 307 307 if (entry.getExifImgDir() != null) {
Note:
See TracChangeset
for help on using the changeset viewer.