[Schmitzm-commits] r965 - trunk/src/schmitzm/geotools/gui

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Thu Aug 12 10:17:57 CEST 2010


Author: alfonx
Date: 2010-08-12 10:17:57 +0200 (Thu, 12 Aug 2010)
New Revision: 965

Modified:
   trunk/src/schmitzm/geotools/gui/GridPanel.java
   trunk/src/schmitzm/geotools/gui/GridPanelFormatter.java
   trunk/src/schmitzm/geotools/gui/GridPanelFormatter_LatLon1.java
Log:
Fixing NPEs in GridPanelFormatter 

Modified: trunk/src/schmitzm/geotools/gui/GridPanel.java
===================================================================
--- trunk/src/schmitzm/geotools/gui/GridPanel.java	2010-08-12 08:13:02 UTC (rev 964)
+++ trunk/src/schmitzm/geotools/gui/GridPanel.java	2010-08-12 08:17:57 UTC (rev 965)
@@ -48,7 +48,7 @@
 
 /**
  * Diese Klasse stellt eine horizontale oder vertikale Koordinaten-Leiste (Grid)
- * dar, die an ein {@link SelectableXMapPane} gekoppelt ist.
+ * dar, die an ein {@link XMapPane} gekoppelt ist.
  * @author <a href="mailto:martin.schmitz at koeln.de">Martin Schmitz</a> (University of Bonn/Germany)
  * @version 1.0
  */
@@ -71,7 +71,7 @@
   private int orientation = 0;
 
   /** Karte, an der die Koordinaten-Leiste ausgerichtet wird. */
-  protected SelectableXMapPane mapPane = null;
+  protected XMapPane mapPane = null;
 
   /** Transformation von Karten-CRS zu CRS des Koordinaten-Rasters */
   protected MathTransform mapToGrid = null;
@@ -91,24 +91,24 @@
   protected boolean gridBarVisible = true;
   
   /**
-   * Erzeugt eine WGS84-Koordinaten-Leiste fuer ein {@link SelectableXMapPane}.
+   * Erzeugt eine WGS84-Koordinaten-Leiste fuer ein {@link XMapPane}.
    * @param orientation Orientierung ({@link #HORIZONTAL} oder {@link #VERTICAL})
    * @param mapPane     Karte an der die Koordinaten-Leiste ausgerichtet wird
    * @see GridPanelFormatter_LatLon1
    */
-  public GridPanel(int orientation, SelectableXMapPane mapPane) {
+  public GridPanel(int orientation, XMapPane mapPane) {
     this(orientation,mapPane,null);
   }
 
   /**
-   * Erzeugt eine Koordinaten-Leiste fuer ein {@link SelectableXMapPane}.
+   * Erzeugt eine Koordinaten-Leiste fuer ein {@link XMapPane}.
    * @param orientation Orientierung ({@link #HORIZONTAL} oder {@link #VERTICAL})
    * @param mapPane     Karte an der die Koordinaten-Leiste ausgerichtet wird
    * @param formatter   definiert das CRS und Koordinaten-Format fuer die Koordinaten
    *                    Leiste (wenn {@code null} wird ein {@link GridPanelFormatter_LatLon1}
    *                    verwendet)
    */
-  public GridPanel(int orientation, SelectableXMapPane mapPane, GridPanelFormatter formatter) {
+  public GridPanel(int orientation, XMapPane mapPane, GridPanelFormatter formatter) {
     this.orientation = orientation;
     this.mapPane     = mapPane;
     setGridFormatter(formatter);

Modified: trunk/src/schmitzm/geotools/gui/GridPanelFormatter.java
===================================================================
--- trunk/src/schmitzm/geotools/gui/GridPanelFormatter.java	2010-08-12 08:13:02 UTC (rev 964)
+++ trunk/src/schmitzm/geotools/gui/GridPanelFormatter.java	2010-08-12 08:17:57 UTC (rev 965)
@@ -31,6 +31,7 @@
 package schmitzm.geotools.gui;
 
 import java.awt.Font;
+import java.awt.Toolkit;
 import java.util.Locale;
 
 import org.apache.log4j.Logger;
@@ -59,8 +60,8 @@
 	private static final Logger LOGGER = LangUtil
 			.createLogger(GridPanelFormatter.class);
 
-	protected static ResourceProvider RESOURCE = ResourceProvider.newInstance(LangUtil
-			.extendPackagePath(GeotoolsGUIUtil.class,
+	protected static ResourceProvider RESOURCE = ResourceProvider.newInstance(
+			LangUtil.extendPackagePath(GeotoolsGUIUtil.class,
 					"resource.locales.GTResourceBundle"), Locale.ENGLISH);
 
 	public static GridPanelFormatter getFormatterByID(String ID) {
@@ -134,9 +135,14 @@
 	 * Returns the default height for a horizontal Grid
 	 */
 	public int getHeightForHorizontal(GridPanel panel) {
-//		return SwingUtilities2.getFontMetrics(panel, getFont()).getHeight() + 2;
-		
-		return panel.getGraphics().getFontMetrics(getFont()).getHeight() + 2;
+
+		return 2 + Toolkit.getDefaultToolkit().getFontMetrics(getFont())
+				.getHeight();
+
+		// return SwingUtilities2.getFontMetrics(panel, getFont()).getHeight() +
+		// 2;
+
+		// return panel.getGraphics().getFontMetrics(getFont()).getHeight() + 2;
 	}
 
 	/**

Modified: trunk/src/schmitzm/geotools/gui/GridPanelFormatter_LatLon1.java
===================================================================
--- trunk/src/schmitzm/geotools/gui/GridPanelFormatter_LatLon1.java	2010-08-12 08:13:02 UTC (rev 964)
+++ trunk/src/schmitzm/geotools/gui/GridPanelFormatter_LatLon1.java	2010-08-12 08:17:57 UTC (rev 965)
@@ -31,6 +31,7 @@
 package schmitzm.geotools.gui;
 
 import java.awt.Font;
+import java.awt.Toolkit;
 import java.text.DecimalFormat;
 
 import org.geotools.referencing.crs.DefaultGeographicCRS;
@@ -159,11 +160,18 @@
 		return RESOURCE
 				.getString("schmitzm.geotools.gui.GridPanelFormatter_LatLon1.title");
 	}
+	
+	final String DEMO_TEXT = "90\u00b030' N";
 
 	@Override
 	public int getWidthForVertical(GridPanel panel) {
-		return panel.getGraphics().getFontMetrics(getFont()).stringWidth(
-				"90\u00b030' N") + 2;
+		
+		return Toolkit.getDefaultToolkit().getFontMetrics(getFont()).stringWidth(DEMO_TEXT) + 2;
+		
+//		getFont().getLineMetrics(str, panel.get)
+		
+//		return panel.getGraphics().getFontMetrics(getFont()).stringWidth(
+//				"90\u00b030' N") + 2;
 
 		// return SwingUtilities2.getFontMetrics(panel, font).stringWidth(
 		// "90\u00b030' N") + 2;



More information about the Schmitzm-commits mailing list