[Schmitzm-commits] r612 - in branches/2.0-RC1/src: schmitzm/geotools/gui schmitzm/geotools/gui/resource/locales skrueger/geotools

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Sat Dec 12 18:14:21 CET 2009


Author: alfonx
Date: 2009-12-12 18:14:17 +0100 (Sat, 12 Dec 2009)
New Revision: 612

Modified:
   branches/2.0-RC1/src/schmitzm/geotools/gui/GeoMapPane.java
   branches/2.0-RC1/src/schmitzm/geotools/gui/GeoPositionLabel.java
   branches/2.0-RC1/src/schmitzm/geotools/gui/resource/locales/GTResourceBundle.properties
   branches/2.0-RC1/src/schmitzm/geotools/gui/resource/locales/GTResourceBundle_de.properties
   branches/2.0-RC1/src/schmitzm/geotools/gui/resource/locales/GTResourceBundle_fr.properties
   branches/2.0-RC1/src/skrueger/geotools/XMapPane.java
Log:
Label und Tooltip der Maus KoordinatenAnzeige rechts ver?\195?\164ndert. Zeit im TT jetzt das CRS der Koordinaten an.


Modified: branches/2.0-RC1/src/schmitzm/geotools/gui/GeoMapPane.java
===================================================================
--- branches/2.0-RC1/src/schmitzm/geotools/gui/GeoMapPane.java	2009-12-12 16:38:32 UTC (rev 611)
+++ branches/2.0-RC1/src/schmitzm/geotools/gui/GeoMapPane.java	2009-12-12 17:14:17 UTC (rev 612)
@@ -62,7 +62,6 @@
  */
 public class GeoMapPane extends JPanel {
 
-
 	/**
 	 * Konstante fuer das vertikale Koordinaten-Grid.
 	 * 

Modified: branches/2.0-RC1/src/schmitzm/geotools/gui/GeoPositionLabel.java
===================================================================
--- branches/2.0-RC1/src/schmitzm/geotools/gui/GeoPositionLabel.java	2009-12-12 16:38:32 UTC (rev 611)
+++ branches/2.0-RC1/src/schmitzm/geotools/gui/GeoPositionLabel.java	2009-12-12 17:14:17 UTC (rev 612)
@@ -34,12 +34,18 @@
 import java.awt.event.MouseMotionListener;
 import java.awt.geom.Point2D;
 import java.text.DecimalFormat;
+import java.util.Locale;
 
 import javax.swing.JLabel;
 import javax.swing.event.MouseInputListener;
 
+import org.geotools.geometry.DirectPosition2D;
+import org.geotools.resources.CRSUtilities;
 import org.geotools.swing.event.MapMouseEvent;
 
+import schmitzm.lang.LangUtil;
+import schmitzm.lang.ResourceProvider;
+
 /**
  * Diese Klasse stellt ein {@link JLabel} dar, in dem (2dimensionale) Geo-Koordinaten
  * angezeigt werden. Dabei werden die Koordinaten auf eine bestimmte Anzahl
@@ -77,6 +83,14 @@
   protected Point2D selStartCoord = null;
 
   /**
+   * Ein Text der vor die Koorinatendarstellung geschrieben wird, z.b.: Koordinate:
+   */
+  private String preText = GeotoolsGUIUtil.RESOURCE
+	.getString(GeoPositionLabel.class
+			.getName()
+			+ ".LABEL_PREFIX");
+
+  /**
    * Erzeugt ein neues Label. Die Koordinaten werden ohne Nachkommastellen
    * dargestellt.
    */
@@ -84,6 +98,10 @@
     this(0);
   }
 
+	protected static ResourceProvider RESOURCE = new ResourceProvider(LangUtil
+			.extendPackagePath(GeotoolsGUIUtil.class,
+					"resource.locales.GTResourceBundle"), Locale.ENGLISH);
+
   /**
    * Erzeugt ein neues Label.
    * @param fracDigits Anzahl an Nachkommastellen, auf die die Koordinaten gerundet
@@ -110,7 +128,7 @@
       return;
 
     // aktuelle Geo-Position ermitteln und runden
-    final Point2D actCoord = SelectableXMapPane.getMapCoordinatesFromEvent(e);
+    DirectPosition2D actCoord = SelectableXMapPane.getMapCoordinatesFromEvent(e);
     if ( actCoord == null )
       return;
     final double actLat = Math.round(actCoord.getX() * fracFactor) / fracFactor;
@@ -122,11 +140,24 @@
       startLat = Math.round(selStartCoord.getX() * fracFactor) / fracFactor;
       startLon = Math.round(selStartCoord.getY() * fracFactor) / fracFactor;
     }
+    
+    // Wir erfahren erst jetzt das CRS und setzen den ToolTip
+    if (getToolTipText() == null) {
+    	setToolTipText( preText+RESOURCE.getString(
+				"schmitzm.geotools.gui.GridPanelFormatter.ToolTipTemplate",
+				GeotoolsGUIUtil.getTitleForCRS(actCoord.getCoordinateReferenceSystem()), CRSUtilities.getUnit(actCoord.getCoordinateReferenceSystem()
+						.getCoordinateSystem())));
+    }
+    
+
+    
     // Label setzen
-    setText(createGeoPositionString(
+    setText(preText+createGeoPositionString(
         new Point2D.Double(actLat, actLon),
         selStartCoord == null ? null : new Point2D.Double(startLat, startLon)
     ));
+    
+    
   }
 
   /**
@@ -144,8 +175,8 @@
     // selektiert wird), sind in selStartCoord die Startkoordinaten
     // gespeichert
     if ( selStartCoord != null )
-      coordText = "("+decForm.format(selStartCoord.getX())+" / "+decForm.format(selStartCoord.getY())+") - ";
-    coordText = coordText + "("+decForm.format(actCoord.getX())+" / "+decForm.format(actCoord.getY())+")";
+      coordText = decForm.format(selStartCoord.getX())+" / "+decForm.format(selStartCoord.getY())+" - ";
+    coordText = coordText + decForm.format(actCoord.getX())+" / "+decForm.format(actCoord.getY());
 
     return coordText;
   }

Modified: branches/2.0-RC1/src/schmitzm/geotools/gui/resource/locales/GTResourceBundle.properties
===================================================================
--- branches/2.0-RC1/src/schmitzm/geotools/gui/resource/locales/GTResourceBundle.properties	2009-12-12 16:38:32 UTC (rev 611)
+++ branches/2.0-RC1/src/schmitzm/geotools/gui/resource/locales/GTResourceBundle.properties	2009-12-12 17:14:17 UTC (rev 612)
@@ -155,3 +155,4 @@
 schmitzm.geotools.gui.GridPanelFormatter_LatLon1.title=deegree\u00b0 minute' (N|E|S|W)
 schmitzm.geotools.gui.GridPanelFormatter.ToolTipTemplate=${0} in unit ${1}
 
+schmitzm.geotools.gui.GeoPositionLabel.LABEL_PREFIX=Mouse coordinate:  
\ No newline at end of file

Modified: branches/2.0-RC1/src/schmitzm/geotools/gui/resource/locales/GTResourceBundle_de.properties
===================================================================
--- branches/2.0-RC1/src/schmitzm/geotools/gui/resource/locales/GTResourceBundle_de.properties	2009-12-12 16:38:32 UTC (rev 611)
+++ branches/2.0-RC1/src/schmitzm/geotools/gui/resource/locales/GTResourceBundle_de.properties	2009-12-12 17:14:17 UTC (rev 612)
@@ -152,3 +152,5 @@
 #nice to have: schmitzm.geotools.gui.GridPanelFormatter_LatLon3.title=Grad\u00b0 Minute' Hundertstel (N|O|S|W)
 
 schmitzm.geotools.gui.GridPanelFormatter.ToolTipTemplate=${0} in Einheit ${1}
+
+schmitzm.geotools.gui.GeoPositionLabel.LABEL_PREFIX=Maus-Koordinate: 
\ No newline at end of file

Modified: branches/2.0-RC1/src/schmitzm/geotools/gui/resource/locales/GTResourceBundle_fr.properties
===================================================================
--- branches/2.0-RC1/src/schmitzm/geotools/gui/resource/locales/GTResourceBundle_fr.properties	2009-12-12 16:38:32 UTC (rev 611)
+++ branches/2.0-RC1/src/schmitzm/geotools/gui/resource/locales/GTResourceBundle_fr.properties	2009-12-12 17:14:17 UTC (rev 612)
@@ -145,3 +145,5 @@
 
 #missing schmitzm.geotools.gui.GridPanelFormatter_DHDN.title=DHDN - 1,234,567 (H|R)
 #missing schmitzm.geotools.gui.GridPanelFormatter_LatLon1.title=Grad\u00b0 Minute' (N|O|S|W)
+
+schmitzm.geotools.gui.GeoPositionLabel.LABEL_PREFIX=Coordonn\u00e9es: 
\ No newline at end of file

Modified: branches/2.0-RC1/src/skrueger/geotools/XMapPane.java
===================================================================
--- branches/2.0-RC1/src/skrueger/geotools/XMapPane.java	2009-12-12 16:38:32 UTC (rev 611)
+++ branches/2.0-RC1/src/skrueger/geotools/XMapPane.java	2009-12-12 17:14:17 UTC (rev 612)
@@ -33,6 +33,7 @@
 import org.apache.log4j.Logger;
 import org.geotools.factory.GeoTools;
 import org.geotools.feature.FeatureCollection;
+import org.geotools.geometry.DirectPosition2D;
 import org.geotools.geometry.jts.JTS;
 import org.geotools.geometry.jts.ReferencedEnvelope;
 import org.geotools.map.DefaultMapContext;
@@ -251,11 +252,11 @@
 	 * @param e
 	 *            Maus-Ereignis
 	 */
-	public static Point2D getMapCoordinatesFromEvent(final MouseEvent e) {
+	public static DirectPosition2D getMapCoordinatesFromEvent(final MouseEvent e) {
 		// aktuelle Geo-Position aus GeoMouseEvent ermitteln
 		if (e != null && e instanceof MapMouseEvent)
 			try {
-				return ((MapMouseEvent) e).getMapPosition().toPoint2D();
+				return ((MapMouseEvent) e).getMapPosition();
 			} catch (final Exception err) {
 				LOGGER
 						.error(
@@ -272,14 +273,18 @@
 				return null;
 
 			final AffineTransform at = xMapPane.getScreenToWorld();
-			if (at != null)
-				return at.transform(e.getPoint(), null);
+			if (at != null) {
+				Point2D transformed = at.transform(e.getPoint(), null);
+				return new DirectPosition2D(xMapPane.getMapContext().getCoordinateReferenceSystem(), transformed.getX(), transformed.getY());
+			}
 			return null;
 		}
 		throw new IllegalArgumentException(
 				"MouseEvent has to be of instance MapMouseEvent or come from an XMapPane");
 	}
+	
 
+
 	/**
 	 * Listens to changes of the "background" {@link MapContext} and triggers
 	 * repaints where needed.



More information about the Schmitzm-commits mailing list