Re: [josm-dev] Register for keys/shortcuts

2010-05-17 Thread Sebastian Klein
Matthias Meißer wrote:
 Sorry folks for my newbie questions but I doesn't get a working solution 
 to get callbacks if somebody presses the cursor keys in the main window.
 
 main.parent.addkeyeventlistener(this); doesn't work, too :(
 
 Is there some kind of Input map or does I have to use another approach 
 like creating an own JOSM mode?
 
 Matthias

It's done countless times in JOSM source code. The direct approach would be
 
Main.contentPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT,0),
 
actionname);

Aren't you computer science student? ;)


Sebastian

___
josm-dev mailing list
josm-dev@openstreetmap.org
http://lists.openstreetmap.org/listinfo/josm-dev


Re: [josm-dev] [PATCH] Image Direction / Compass Camera images

2010-05-17 Thread Florian Lohoff
On Sat, May 15, 2010 at 11:30:01PM +0200, Sebastian Klein wrote:
 Sure, if you donate a camera, I'll fully implement it. ;)
 
 Seriously, there is a lot to do and we cannot add each extension that is 
 used by a single hardware model. But it's a damn cool feature. 
 Hopefully, there will be other vendors and models supporting this!

Don't tell anyone i touched java - I have something rudimentary working
which draws a little triangle arrow below the camera icon when activating it 
e.g. clicking on the picture icon - It does only so when there is a
GPS Image Direction tag in the exif header. I had no clue about java but
someone might hint me through some design/style issues ... Especially
i think there is some overhead in the exception reading the exif tags as
this 

+Metadata metadata = 
JpegMetadataReader.readMetadata(e.getFile());
+Directory directory = 
metadata.getDirectory(GpsDirectory.class);

is called twice ... Probably unnecessary 

Here is a small screenshot how it will look:

http://silicon-verl.de/home/flo/tmp/screenshot-josm3260-imgdir1.png


diff --git a/src/org/openstreetmap/josm/gui/layer/geoimage/GeoImageLayer.java 
b/src/org/openstreetmap/josm/gui/layer/geoimage/GeoImageLayer.java
index eb56404..28a06b3 100644
--- a/src/org/openstreetmap/josm/gui/layer/geoimage/GeoImageLayer.java
+++ b/src/org/openstreetmap/josm/gui/layer/geoimage/GeoImageLayer.java
@@ -467,9 +468,36 @@ public class GeoImageLayer extends Layer implements 
PropertyChangeListener {
 g.setColor(new Color(128, 0, 0, 122));
 g.fillRect(p.x - d.width / 2, p.y - d.height / 2, d.width, 
d.height);
 } else {
+   if (e.getExifImgDir() != null) {
+   double arrowlength = 25;
+   double arrowwidth = 18;
+
+   double dir = e.getExifImgDir();
+   // Rotate 90° CCW 
+   double headdir = ( dir  90 ) ? dir + 270 : dir 
- 90;
+   double leftdir = ( headdir  90 ) ? headdir + 
270 : headdir - 90;
+   double rightdir = ( headdir  270 ) ? headdir - 
270 : headdir + 90;
+
+   double ptx = p.x + 
Math.cos(Math.toRadians(headdir)) * arrowlength;
+   double pty = p.y + 
Math.sin(Math.toRadians(headdir)) * arrowlength;
+
+   double ltx = p.x + 
Math.cos(Math.toRadians(leftdir)) * arrowwidth/2;
+   double lty = p.y + 
Math.sin(Math.toRadians(leftdir)) * arrowwidth/2;
+
+   double rtx = p.x + 
Math.cos(Math.toRadians(rightdir)) * arrowwidth/2;
+   double rty = p.y + 
Math.sin(Math.toRadians(rightdir)) * arrowwidth/2;
+
+   g.setColor(Color.white);
+   int[] xar = {(int) ltx, (int) ptx, (int) rtx, 
(int) ltx};
+   int[] yar = {(int) lty, (int) pty, (int) rty, 
(int) lty};
+   g.fillPolygon(xar, yar, 4);
+   }
+
 selectedIcon.paintIcon(mv, g,
 p.x - selectedIcon.getIconWidth() / 2,
 p.y - selectedIcon.getIconHeight() / 2);
+
+ 
 }
 }
 }
@@ -536,6 +564,15 @@ public class GeoImageLayer extends Layer implements 
PropertyChangeListener {
 e.setExifCoor(null);
 e.setPos(null);
 }
+
+   try {
+Metadata metadata = JpegMetadataReader.readMetadata(e.getFile());
+Directory directory = metadata.getDirectory(GpsDirectory.class);
+Rational direction = 
directory.getRational(GpsDirectory.TAG_GPS_IMG_DIRECTION);
+
+   e.setExifImgDir(direction.doubleValue());
+   } catch (CompoundException p) {
+   }
 }
 
 public void showNextPhoto() {
diff --git a/src/org/openstreetmap/josm/gui/layer/geoimage/ImageEntry.java 
b/src/org/openstreetmap/josm/gui/layer/geoimage/ImageEntry.java
index 2b199e9..a73297a 100644
--- a/src/org/openstreetmap/josm/gui/layer/geoimage/ImageEntry.java
+++ b/src/org/openstreetmap/josm/gui/layer/geoimage/ImageEntry.java
@@ -19,6 +19,7 @@ import org.openstreetmap.josm.data.coor.LatLon;
 final public class ImageEntry implements ComparableImageEntry, Cloneable {
 private File file;
 private LatLon exifCoor;
+private Double exifImgDir;
 private Date exifTime;
 Image thumbnail;
 
@@ -77,6 +78,10 @@ final public class ImageEntry implements 
ComparableImageEntry, Cloneable {
 LatLon getExifCoor() {
 return exifCoor;
 }
+public Double getExifImgDir() {
+   return exifImgDir;
+}
+
 /**
  * setter methods
  */
@@ -104,6 +109,9 @@ final public class ImageEntry implements 

[josm-dev] JOSM unreliable network connections

2010-05-17 Thread Russ Nelson
Hi.  My Internet connection is very unreliable lately.  The leaves
have come back on the trees and they're now tall enough to seriously
interfere with my wifi connection.  That hasn't stopped me from
wanting to edit OSM, of course.  Unfortunately, JOSM's behavior in the
face of an unreliable connection HAS made me want to stop editing.
Cancel doesn't work if you're at the step where it says Downloading
OSM data... 1KB.  And if you've made edits?  They're lost.

I'd file a bug, but see the subject of this email.  This email will
eventually get sent, but interactive use is frustrating at best.

I think a workaround is to constantly save before hitting the 'net,
but it's a workaround, not a fix.

-- 
--my blog is athttp://blog.russnelson.com
Crynwr supports open source software
521 Pleasant Valley Rd. | +1 315-600-8815
Potsdam, NY 13676-3213  | Sheepdog   

___
josm-dev mailing list
josm-dev@openstreetmap.org
http://lists.openstreetmap.org/listinfo/josm-dev