[Schmitzm-commits] r416 - in branches/1.0-gt2-2.6/src/schmitzm/geotools: gui gui/resource/locales io

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Fri Sep 25 15:58:56 CEST 2009


Author: alfonx
Date: 2009-09-25 15:58:55 +0200 (Fri, 25 Sep 2009)
New Revision: 416

Added:
   branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/GridPanelFormatter_LatLon1.java
Removed:
   branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/GridPanelFormatter_WGS84.java
Modified:
   branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/GeoMapPane.java
   branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/GeotoolsGUIUtil.java
   branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/GridPanel.java
   branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/GridPanelFormatter.java
   branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/GridPanelFormatter_DHDN.java
   branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/resource/locales/GTResourceBundle.properties
   branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/resource/locales/GTResourceBundle_de.properties
   branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/resource/locales/GTResourceBundle_fr.properties
   branches/1.0-gt2-2.6/src/schmitzm/geotools/io/GeoExportUtil.java
Log:
* GP/AV Features: Many small improvements abound the new possibility to configure the map margin
* The GridPanel is rendering more nicely now.
* AtlasML.xsd now stores/loads the map frame settings

Modified: branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/GeoMapPane.java
===================================================================
--- branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/GeoMapPane.java	2009-09-24 17:58:32 UTC (rev 415)
+++ branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/GeoMapPane.java	2009-09-25 13:58:55 UTC (rev 416)
@@ -99,7 +99,7 @@
 	/** Karten-Bereich des {@code GeoMapPane}. */
 	protected JMapPane mapPane = null;
 	/** Massstab-Balken */
-	protected ScalePane scalePane = null;
+	private ScalePane scalePane = null;
 	/**
 	 * Vertikale Koordinaten-Leiste (Grid). Zeigt die Latitude-Koordinate in
 	 * Grad und Minutenm an.
@@ -164,7 +164,7 @@
 		this.setHorGrid((hGrid != null) ? hGrid : new GridPanel(
 				GridPanel.HORIZONTAL, this.mapPane));
 		// Massstab-Balken
-		this.scalePane = (scalePane != null) ? scalePane : new ScalePane();
+		this.setScalePane((scalePane != null) ? scalePane : new ScalePane());
 
 		// Standard-Werte fuer GUI-Anordnung setzen
 		layoutConstraints.put(DLC_MAP, new GridBagConstraints(1, 0, 1, 1, 1.0,
@@ -202,7 +202,7 @@
 			public void performMapPaneEvent(JMapPaneEvent e) {
 				if (e instanceof ScaleChangedEvent) {
 					ScaleChangedEvent sce = (ScaleChangedEvent) e;
-					scalePane.setScale(sce.getNewScale());
+					getScalePane().setScale(sce.getNewScale());
 				}
 				if (e instanceof MapAreaChangedEvent) {
 					getVertGrid().repaint();
@@ -214,7 +214,7 @@
 		// Komponenten in Layout anordnen
 		this.add(getVertGrid(), layoutConstraints.get(DLC_VGRID));
 		this.add(getHorGrid(), layoutConstraints.get(DLC_HGRID));
-		this.add(scalePane, layoutConstraints.get(DLC_SCALE));
+		this.add(getScalePane(), layoutConstraints.get(DLC_SCALE));
 		// WICHTIG: mapPane als LETZTES einfuegen, damit es beim Re-Paint ALS
 		// ERSTES
 		// aktualisiert wird und die Aenderungen (Area, Scale) im
@@ -243,9 +243,9 @@
 	 */
 	public void paint(Graphics g) {
 		super.paint(g);
-		if (scalePane.getScaleInMeters() != mapPane.getScale()
+		if (getScalePane().getScaleInMeters() != mapPane.getScale()
 				&& mapPane.getScale() > 0)
-			scalePane.setScale(mapPane.getScale());
+			getScalePane().setScale(mapPane.getScale());
 	}
 
 	/**
@@ -356,5 +356,13 @@
 		return horGrid;
 	}
 
+	public void setScalePane(ScalePane scalePane) {
+		this.scalePane = scalePane;
+	}
 
+	public ScalePane getScalePane() {
+		return scalePane;
+	}
+
+
 }

Modified: branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/GeotoolsGUIUtil.java
===================================================================
--- branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/GeotoolsGUIUtil.java	2009-09-24 17:58:32 UTC (rev 415)
+++ branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/GeotoolsGUIUtil.java	2009-09-25 13:58:55 UTC (rev 416)
@@ -42,6 +42,8 @@
 import org.apache.log4j.Logger;
 import org.geotools.coverage.grid.GridCoverage2D;
 import org.geotools.feature.FeatureCollection;
+import org.opengis.referencing.ReferenceIdentifier;
+import org.opengis.referencing.crs.CoordinateReferenceSystem;
 
 import schmitzm.geotools.io.GeoExportUtil;
 import schmitzm.io.IOUtil;
@@ -267,4 +269,36 @@
     }
   }
 
+  /**
+	 * @return a good guess for a human readable string description of this CRS. An empty string in the worst case.
+	 */
+	public static String getTitleForCRS(CoordinateReferenceSystem crs) {
+		// try {
+		// final ReferenceIdentifier name = mapCrs.getName();
+		// if (name != null)
+		// return name.getCode();
+		// else
+		// return mapCrs.toString();
+		// } catch (final Exception e) {
+		// return mapCrs.toString();
+		// }
+		
+		String layerCrsName = "";
+		
+		if (crs == null) return layerCrsName;
+		
+		try {
+			final ReferenceIdentifier name = crs.getName();
+			if (name != null)
+				layerCrsName = name.getCode();
+			else
+				layerCrsName = crs.toString();
+		} catch (final Exception e) {
+			layerCrsName = crs.toString();
+		}
+
+		return layerCrsName;
+
+	}
+
 }

Modified: branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/GridPanel.java
===================================================================
--- branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/GridPanel.java	2009-09-24 17:58:32 UTC (rev 415)
+++ branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/GridPanel.java	2009-09-25 13:58:55 UTC (rev 416)
@@ -31,7 +31,10 @@
 
 import java.awt.Color;
 import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.RenderingHints;
 import java.awt.geom.AffineTransform;
+import java.util.Locale;
 
 import javax.measure.unit.Unit;
 
@@ -44,6 +47,7 @@
 import org.opengis.referencing.operation.MathTransform;
 
 import schmitzm.lang.LangUtil;
+import schmitzm.lang.ResourceProvider;
 import schmitzm.swing.JPanel;
 import schmitzm.swing.SwingUtil;
 
@@ -91,7 +95,7 @@
    * Erzeugt eine WGS84-Koordinaten-Leiste fuer ein {@link JMapPane}.
    * @param orientation Orientierung ({@link #HORIZONTAL} oder {@link #VERTICAL})
    * @param mapPane     Karte an der die Koordinaten-Leiste ausgerichtet wird
-   * @see GridPanelFormatter_WGS84
+   * @see GridPanelFormatter_LatLon1
    */
   public GridPanel(int orientation, JMapPane mapPane) {
     this(orientation,mapPane,null);
@@ -102,7 +106,7 @@
    * @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_WGS84}
+   *                    Leiste (wenn {@code null} wird ein {@link GridPanelFormatter_LatLon1}
    *                    verwendet)
    */
   public GridPanel(int orientation, JMapPane mapPane, GridPanelFormatter formatter) {
@@ -112,9 +116,9 @@
     setXYIndexSwitchForced(false);
     
     if ( isVertical() )
-      SwingUtil.setPreferredWidth(this,getGridFormatter().getWidthForVertical());
+      SwingUtil.setPreferredWidth(this,getGridFormatter().getWidthForVertical(this));
     else
-      SwingUtil.setPreferredHeight(this,getGridFormatter().getHeightForHorizontal());
+      SwingUtil.setPreferredHeight(this,getGridFormatter().getHeightForHorizontal(this));
   }
 
   /**
@@ -152,12 +156,12 @@
    * Aendert den {@link GridPanelFormatter}, mit dem die Darstellung der
    * Koordinaten bestimmt wird.
    * @param formatter neuer {@link GridPanelFormatter} (wenn {@code null}
-   *                  wird ein {@link GridPanelFormatter_WGS84} verwendet)
+   *                  wird ein {@link GridPanelFormatter_LatLon1} verwendet)
    */
   public void setGridFormatter(GridPanelFormatter formatter) {
 //    GridPanelFormatter oldFormatter = getGridFormatter();
     if ( formatter == null )
-      formatter = new GridPanelFormatter_WGS84();
+      formatter = new GridPanelFormatter_LatLon1();
     this.formatter = formatter;
     // wenn sich der Formatter geaendert hat, die Transformation initialisieren,
     // diese beim naechsten paint(.) erneuert werden
@@ -169,21 +173,19 @@
 //    }
       
       if ( isVertical() )
-        SwingUtil.setPreferredWidth(this,getGridFormatter().getWidthForVertical());
+        SwingUtil.setPreferredWidth(this,getGridFormatter().getWidthForVertical(this));
       else
-        SwingUtil.setPreferredHeight(this,getGridFormatter().getHeightForHorizontal());
+        SwingUtil.setPreferredHeight(this,getGridFormatter().getHeightForHorizontal(this));
 
-      
+      /**
+       * Die Component darüber muss die neue preferred width/height beachten
+       */
       if (getParent() != null) {
     	  getParent().invalidate();
     	  getParent().repaint();
       }
       
-      Unit<?> unit = CRSUtilities.getUnit( formatter.getCRS().getCoordinateSystem() );
-      if (unit != null) {
-    	  setToolTipText("Einheit: "+unit.toString()); //TODO i8n
-      } else setToolTipText(null);
-    
+   	  setToolTipText(formatter.getTooltip());
   }
   
   /**
@@ -204,10 +206,16 @@
 
   /**
    * Zeichnet die Koordinaten-Leiste.
-   * @param g Graphics
+   * @param g2 Graphics
    */
   public void paint(Graphics g) {
     super.paint(g);
+    
+    Graphics2D g2 = (Graphics2D)g;
+    g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
+    g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
+    
+    
     if ( getParent() == null || mapPane.getMapArea() == null )
       return;
 
@@ -309,9 +317,9 @@
    double gridDist = formatter.determineGridDistance(this, mapMin,mapMax,maxSize);
    // Leiste zeichnen
    if ( isHorizontal() )
-     g.drawLine(0,0,maxSize,0);
+     g2.drawLine(0,0,maxSize,0);
    else
-     g.drawLine(formatter.getWidthForVertical()-1,0,formatter.getWidthForVertical()-1,maxSize);
+     g2.drawLine(formatter.getWidthForVertical(this)-1,0,formatter.getWidthForVertical(this)-1,maxSize);
 
    // Abschnitte zeichnen
    double   firstGrid = Math.ceil(mapMin/gridDist)*gridDist; // 1. Abschnitt in Lat bzw. Lon
@@ -331,20 +339,20 @@
      }
     
      // Grid-Abschnitt zeichnen
-     int x1 = isVertical() ? formatter.getWidthForVertical()-GRID_LINE_SIZE : (int)grid_WINDOW[0];
+     int x1 = isVertical() ? formatter.getWidthForVertical(this)-GRID_LINE_SIZE : (int)grid_WINDOW[0];
      int y1 = isVertical() ? (int)grid_WINDOW[1] : 0;
      int x2 = isVertical() ? x1+GRID_LINE_SIZE : x1;
      int y2 = isVertical() ? y1 : y1+GRID_LINE_SIZE;
-     g.drawLine(x1,y1,x2,y2);
+     g2.drawLine(x1,y1,x2,y2);
      
      // Koordinate anzeigen, evt. Font setzen
      if (formatter.getFont()  != null) {
-    	 g.setFont( formatter.getFont() );
+    	 g2.setFont( formatter.getFont() );
      }
      String coordStr = formatter.formatCoordinate(this, grid_GCRS[idx]);
      x1 = isVertical() ?    5 : x1 + 5;
      y1 = isVertical() ? y1-2 : y1 + 12;
-     g.drawString( coordStr, x1, y1 );
+     g2.drawString( coordStr, x1, y1 );
    }
   }
 

Modified: branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/GridPanelFormatter.java
===================================================================
--- branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/GridPanelFormatter.java	2009-09-24 17:58:32 UTC (rev 415)
+++ branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/GridPanelFormatter.java	2009-09-25 13:58:55 UTC (rev 416)
@@ -1,28 +1,28 @@
 /*******************************************************************************
  * Copyright (c) 2009 Martin O. J. Schmitz.
- * 
- * This file is part of the SCHMITZM library - a collection of utility 
- * classes based on Java 1.6, focusing (not only) on Java Swing 
+ *
+ * This file is part of the SCHMITZM library - a collection of utility
+ * classes based on Java 1.6, focusing (not only) on Java Swing
  * and the Geotools library.
- * 
+ *
  * The SCHMITZM project is hosted at:
  * http://wald.intevation.org/projects/schmitzm/
- * 
+ *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
  * as published by the Free Software Foundation; either version 3
  * of the License, or (at your option) any later version.
- * 
+ *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU Lesser General Public License (license.txt)
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  * or try this link: http://www.gnu.org/licenses/lgpl.html
- * 
+ *
  * Contributors:
  *     Martin O. J. Schmitz - initial API and implementation
  *     Stefan A. Krüger - additional utility classes
@@ -31,12 +31,15 @@
 package schmitzm.geotools.gui;
 
 import java.awt.Font;
-import java.util.Vector;
+import java.util.Locale;
 
 import org.apache.log4j.Logger;
+import org.geotools.resources.CRSUtilities;
 import org.opengis.referencing.crs.CoordinateReferenceSystem;
 
 import schmitzm.lang.LangUtil;
+import schmitzm.lang.ResourceProvider;
+import sun.swing.SwingUtilities2;
 
 /**
  * This class defines how the {@link GridPanel} shows the coordinate grid and
@@ -45,29 +48,42 @@
  * @author <a href="mailto:martin.schmitz at koeln.de">Martin Schmitz</a>
  */
 public abstract class GridPanelFormatter {
+	private static final Font defaultFont = new Font(Font.MONOSPACED,
+			Font.PLAIN, 11);
+
+	/**
+	 * @return List of instances of all available formatters.
+	 */
+	public final static Class<? extends GridPanelFormatter>[] FORMATTERS = new Class[] {
+			GridPanelFormatter_LatLon1.class, GridPanelFormatter_DHDN.class };
+
 	private static final Logger LOGGER = LangUtil
 			.createLogger(GridPanelFormatter.class);
-	
-	/** A human readable title**/
-	public abstract String getTitle();
 
-	/** CRS the formatter is created for. */
-	protected CoordinateReferenceSystem crs = null;
+	protected static ResourceProvider RESOURCE = new ResourceProvider(LangUtil
+			.extendPackagePath(GeotoolsGUIUtil.class,
+					"resource.locales.GTResourceBundle"), Locale.ENGLISH);
 
-	/**
-	 * @return List of instances of all available formatters.
-	 */
-	static public Vector<GridPanelFormatter> getAvailableFormatters() {
-		Vector<GridPanelFormatter> formatters = new Vector<GridPanelFormatter>();
-		formatters.add(new GridPanelFormatter_WGS84());
-		try {
-			formatters.add(new GridPanelFormatter_DHDN());
-		} catch (Exception e) {
-			LOGGER.error("No able to create the default DHDN CRS", e);
+	public static GridPanelFormatter getFormatterByID(String ID) {
+		for (Class<? extends GridPanelFormatter> x : FORMATTERS) {
+
+			GridPanelFormatter newInstance;
+			try {
+				newInstance = x.newInstance();
+			} catch (Exception e) {
+				throw new RuntimeException(e);
+			}
+
+			if (newInstance.getId().equals(ID))
+				return newInstance;
 		}
-		return formatters;
+
+		return null;
 	}
 
+	/** CRS the formatter is created for. */
+	protected CoordinateReferenceSystem crs = null;
+
 	/**
 	 * Creates a new formatter.
 	 * 
@@ -79,20 +95,6 @@
 	}
 
 	/**
-	 * Returns the CRS the formatter can format.
-	 */
-	public CoordinateReferenceSystem getCRS() {
-		return crs;
-	}
-
-	/**
-	 * Returns the CRS the formatter can format.
-	 */
-	public void setCRS(CoordinateReferenceSystem crs) {
-		this.crs = crs;
-	}
-
-	/**
 	 * Determines a "fitting" fragmentation for the grid.
 	 * 
 	 * @param gridPanel
@@ -119,17 +121,49 @@
 	public abstract String formatCoordinate(GridPanel panel, double coord);
 
 	/**
-	 * Returns the default width for a vertical Grid
+	 * Returns the CRS the formatter can format.
 	 */
-	public abstract int getWidthForVertical();
+	public CoordinateReferenceSystem getCRS() {
+		return crs;
+	}
 
+	public Font getFont() {
+		return defaultFont;
+	}
+
 	/**
 	 * Returns the default height for a horizontal Grid
 	 */
-	public abstract int getHeightForHorizontal();
+	public int getHeightForHorizontal(GridPanel panel) {
+		return SwingUtilities2.getFontMetrics(panel, getFont()).getHeight() + 2;
+	}
 
-	public Font getFont() {
-		return null;
+	/**
+	 * A String ID that can be used to identify a Formatter-class. Take care,
+	 * that the string is compatible with XML and doesn't containg freaky chars.
+	 */
+	public abstract String getId();
+
+	/** A human readable title **/
+	public abstract String getTitle();
+
+	/**
+	 * Returns the default width for a vertical Grid
+	 */
+	public abstract int getWidthForVertical(GridPanel panel);
+
+	/**
+	 * Returns the CRS the formatter can format.
+	 */
+	public void setCRS(CoordinateReferenceSystem crs) {
+		this.crs = crs;
 	}
+	
+	/**
+	 * Returns a tooltip String to applied to the {@link GridPanel}s. May be <code>null</code> 
+	 */
+	public String getTooltip(){
+		return RESOURCE.getString("schmitzm.geotools.gui.GridPanelFormatter.ToolTipTemplate", GeotoolsGUIUtil.getTitleForCRS(getCRS()), CRSUtilities.getUnit(getCRS().getCoordinateSystem()));
+	}
 
 }

Modified: branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/GridPanelFormatter_DHDN.java
===================================================================
--- branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/GridPanelFormatter_DHDN.java	2009-09-24 17:58:32 UTC (rev 415)
+++ branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/GridPanelFormatter_DHDN.java	2009-09-25 13:58:55 UTC (rev 416)
@@ -5,35 +5,40 @@
 import java.text.DecimalFormatSymbols;
 import java.util.Locale;
 
-import javax.swing.JLabel;
-
 import org.geotools.referencing.CRS;
+import org.geotools.referencing.crs.DefaultGeographicCRS;
 import org.opengis.referencing.FactoryException;
 import org.opengis.referencing.NoSuchAuthorityCodeException;
 
 public class GridPanelFormatter_DHDN extends GridPanelFormatter {
+	private static final Font font = new Font(Font.MONOSPACED, Font.BOLD, 11);
+	final DecimalFormat numFormat = new DecimalFormat("###,###,###", new DecimalFormatSymbols(Locale.getDefault()));
 
 	/**
 	 * Creates a new formatter with DHDN / 3-degree Gauss zone 1 as CRS
-	 * 
+	 *
 	 * @param crs
 	 *            the CRS the formatter can format
 	 * @throws FactoryException
 	 * @throws NoSuchAuthorityCodeException
 	 */
-	public GridPanelFormatter_DHDN() throws NoSuchAuthorityCodeException,
-			FactoryException {
+	public GridPanelFormatter_DHDN()  {
 
 		// # DHDN / 3-degree Gauss zone 1
 		// <31461> +proj=tmerc +lat_0=0 +lon_0=3 +k=1.000000 +x_0=1500000 +y_0=0
 
-		super(CRS.decode("EPSG:31461"));
+		super(DefaultGeographicCRS.WGS84);
+
+		try {
+			setCRS(CRS.decode("EPSG:31461"));
+		} catch (final Exception e) {
+			throw new RuntimeException(e);
+		}
 	}
-
 	@Override
-	public double determineGridDistance(GridPanel panel, double mapMinCoord,
-			double mapMaxCoord, int panelSize) {
-		double diff = Math.abs(mapMinCoord - mapMaxCoord);
+	public double determineGridDistance(final GridPanel panel, final double mapMinCoord,
+			final double mapMaxCoord, final int panelSize) {
+		final double diff = Math.abs(mapMinCoord - mapMaxCoord);
 
 		double dist;
 		if (diff > 100000) {
@@ -62,9 +67,8 @@
 		return dist;
 	}
 
-	DecimalFormat numFormat = new DecimalFormat("###,###,###", new DecimalFormatSymbols(Locale.getDefault()));
 	@Override
-	public String formatCoordinate(GridPanel panel, double coord) {
+	public String formatCoordinate(final GridPanel panel, final double coord) {
 
 
 		if (panel.isVertical()) {
@@ -75,26 +79,27 @@
 
 	}
 
-	private static final Font font = new Font(Font.MONOSPACED, Font.PLAIN, 11);
-
 	@Override
 	public Font getFont() {
 		return font;
 	}
 
+
 	@Override
-	public int getHeightForHorizontal() {
-		return new JLabel().getFontMetrics(font).getHeight() + 2;
+	public String getId() {
+		return 	"10_DHDN";
+
 	}
 
 	@Override
-	public int getWidthForVertical() {
-		return 80;
+	public String getTitle() {
+		return RESOURCE.getString("schmitzm.geotools.gui.GridPanelFormatter_DHDN.title");
 	}
 
 	@Override
-	public String getTitle() {
-		// TODO localize
-		return numFormat.format(1234567)+" R";
+	public int getWidthForVertical(final GridPanel panel) {
+		return 80;
 	}
+
+
 }

Copied: branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/GridPanelFormatter_LatLon1.java (from rev 415, branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/GridPanelFormatter_WGS84.java)
===================================================================
--- branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/GridPanelFormatter_WGS84.java	2009-09-24 17:58:32 UTC (rev 415)
+++ branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/GridPanelFormatter_LatLon1.java	2009-09-25 13:58:55 UTC (rev 416)
@@ -0,0 +1,165 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Martin O. J. Schmitz.
+ *
+ * This file is part of the SCHMITZM library - a collection of utility
+ * classes based on Java 1.6, focusing (not only) on Java Swing
+ * and the Geotools library.
+ *
+ * The SCHMITZM project is hosted at:
+ * http://wald.intevation.org/projects/schmitzm/
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License (license.txt)
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ * or try this link: http://www.gnu.org/licenses/lgpl.html
+ *
+ * Contributors:
+ *     Martin O. J. Schmitz - initial API and implementation
+ *     Stefan A. Krüger - additional utility classes
+ ******************************************************************************/
+
+package schmitzm.geotools.gui;
+
+import java.awt.Font;
+
+import org.geotools.referencing.crs.DefaultGeographicCRS;
+import org.opengis.referencing.crs.CoordinateReferenceSystem;
+
+import schmitzm.lang.ResourceProvider;
+import sun.swing.SwingUtilities2;
+
+/**
+ * This class defines a {@link GridPanelFormatter} for the WGS84
+ * {@link CoordinateReferenceSystem}. The coordinates are formated in degrees
+ * and minutes along with the wind direction abbreviation (E/W, N/S). grid and
+ * the coordinates. * @author <a href="mailto:martin.schmitz at koeln.de">Martin
+ * Schmitz</a>
+ */
+public class GridPanelFormatter_LatLon1 extends GridPanelFormatter {
+	private static final Font font = new Font(Font.MONOSPACED, Font.PLAIN, 11);
+	private static final ResourceProvider RES = GeotoolsGUIUtil.RESOURCE;
+
+	/**
+	 * Creates a new formatter.
+	 * 
+	 * @param crs
+	 *            the CRS the formatter can format
+	 */
+	public GridPanelFormatter_LatLon1() {
+		super(DefaultGeographicCRS.WGS84);
+	}
+
+	/**
+	 * Determines a "fitting" fragmentation for the grid.
+	 * 
+	 * @param mapMin_LL
+	 *            minimal Lat/Lon coordinate to show in the grid
+	 * @param mapMax_LL
+	 *            maximal Lat/Lon coordinate to show in the grid
+	 * @param panelSize
+	 *            size of the grid panel in pixels
+	 */
+	@Override
+	public double determineGridDistance(GridPanel panel, double mapMin_LL,
+			double mapMax_LL, int panelSize) {
+		// Differenz zwischen Min/Max-Koordinaten = darzustellender Bereich in
+		// Grad
+		double diff = Math.abs(mapMin_LL - mapMax_LL);
+		// Distanz zwischen zwei Unterteilungen in Grad
+		double dist = 0.0;
+		if (diff < 10 / 60.0) // < 10 Min. --> 1 Min.-Aufteilung
+			dist = 1 / 60.0;
+		else if (diff < 30 / 60.0) // < 30 Min. --> 5 Min.-Aufteilung
+			dist = 5 / 60.0;
+		else if (diff < 1) // < 1? --> 10 Min.-Aufteilung
+			dist = 10 / 60.0;
+		else if (diff < 3) // < 3? --> 15 Min.-Aufteilung
+			dist = 15 / 60.0;
+		else if (diff < 5) // < 5? --> 30 Min.-Aufteilung
+			dist = 30 / 60.0;
+		else if (diff < 11) // < 11? --> 1?-Aufteilung
+			dist = 1;
+		else
+			// sonst --> 2?-Aufteilung
+			dist = 2.;
+
+		// Solange der Abstand zwischen 2 Unterteilungen weniger als 40 Pixel
+		// betraegt --> Unterteilung verdoppeln
+		while (diff != 0 && dist != 0 && panelSize / (diff / dist) < 40)
+			dist *= 2.;
+
+		// Solange der Abstand zwischen 2 Unterteilungen mehr als 120 Pixel
+		// betraegt --> Unterteilung * 0.5
+		while (diff != 0 && dist != 0 && panelSize / (diff / dist) > 120)
+			dist /= 2.;
+
+		return dist;
+	}
+
+	/**
+	 * Formats a coordinate to degrees and minutes.
+	 * 
+	 * @param coord
+	 *            the lat/lon coordinate
+	 * @param gridPanel
+	 *            indicates (amongst others) the grid orientation
+	 * @return
+	 */
+	@Override
+	public String formatCoordinate(GridPanel panel, double coord) {
+		int degrees = (int) coord;
+		int minutes = (int) Math.round((coord - degrees) * 60);
+		// Aufgrund des Minuten-Systems kann schlecht im Vorhinein gerundet
+		// werden. Deshalb wird im Nachhinein ein etwaiger Rundungsfehler
+		// ausgeglichen
+		if (Math.abs(minutes) >= 60) {
+			degrees += Math.signum(minutes);
+			minutes -= Math.signum(minutes) * 60;
+		}
+		String coordStr = Math.abs(degrees) + "°" + Math.abs(minutes) + "'";
+		if (degrees != 0 || minutes != 0) {
+			if (panel.isVertical())
+				coordStr += RES
+						.getString((coord < 0) ? "schmitzm.geotools.gui.GeotoolsGUIUtil.SOUTH.Abb"
+								: "schmitzm.geotools.gui.GeotoolsGUIUtil.NORTH.Abb");
+			else
+				coordStr += RES
+						.getString((coord < 0) ? "schmitzm.geotools.gui.GeotoolsGUIUtil.WEST.Abb"
+								: "schmitzm.geotools.gui.GeotoolsGUIUtil.EAST.Abb");
+		}
+		return coordStr;
+	}
+
+	@Override
+	public Font getFont() {
+		return font;
+	}
+
+	@Override
+	public String getId() {
+		return "1_lat_lon";
+	}
+
+	@Override
+	public String getTitle() {
+		return RESOURCE
+				.getString("schmitzm.geotools.gui.GridPanelFormatter_LatLon1.title");
+	}
+
+	@Override
+	public int getWidthForVertical(GridPanel panel) {
+		return SwingUtilities2.getFontMetrics(panel, font).stringWidth(
+				"90°30' N") + 2;
+	}
+
+}

Deleted: branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/GridPanelFormatter_WGS84.java
===================================================================
--- branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/GridPanelFormatter_WGS84.java	2009-09-24 17:58:32 UTC (rev 415)
+++ branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/GridPanelFormatter_WGS84.java	2009-09-25 13:58:55 UTC (rev 416)
@@ -1,164 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Martin O. J. Schmitz.
- * 
- * This file is part of the SCHMITZM library - a collection of utility 
- * classes based on Java 1.6, focusing (not only) on Java Swing 
- * and the Geotools library.
- * 
- * The SCHMITZM project is hosted at:
- * http://wald.intevation.org/projects/schmitzm/
- * 
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 3
- * of the License, or (at your option) any later version.
- * 
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public License (license.txt)
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- * or try this link: http://www.gnu.org/licenses/lgpl.html
- * 
- * Contributors:
- *     Martin O. J. Schmitz - initial API and implementation
- *     Stefan A. Krüger - additional utility classes
- ******************************************************************************/
-
-package schmitzm.geotools.gui;
-
-import java.awt.Font;
-import java.text.DecimalFormat;
-
-import javax.swing.JLabel;
-
-import org.geotools.referencing.crs.DefaultGeographicCRS;
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
-
-import schmitzm.lang.ResourceProvider;
-
-/**
- * This class defines a {@link GridPanelFormatter} for the WGS84
- * {@link CoordinateReferenceSystem}. The coordinates are formated in degrees
- * and minutes along with the wind direction abbreviation (E/W, N/S). grid and
- * the coordinates. * @author <a href="mailto:martin.schmitz at koeln.de">Martin
- * Schmitz</a>
- */
-public class GridPanelFormatter_WGS84 extends GridPanelFormatter {
-	private static final ResourceProvider RES = GeotoolsGUIUtil.RESOURCE;
-	private static final DecimalFormat numFormat = new DecimalFormat(
-			"###,###,##0");
-
-	/**
-	 * Creates a new formatter.
-	 * 
-	 * @param crs
-	 *            the CRS the formatter can format
-	 */
-	public GridPanelFormatter_WGS84() {
-		// super(GTUtil.WGS84);
-		super(DefaultGeographicCRS.WGS84);
-	}
-
-	/**
-	 * Formats a coordinate to degrees and minutes.
-	 * 
-	 * @param coord
-	 *            the lat/lon coordinate
-	 * @param gridPanel
-	 *            indicates (amongst others) the grid orientation
-	 * @return
-	 */
-	@Override
-	public String formatCoordinate(GridPanel panel, double coord) {
-		int degrees = (int) coord;
-		int minutes = (int) Math.round((coord - degrees) * 60);
-		// Aufgrund des Minuten-Systems kann schlecht im Vorhinein gerundet
-		// werden. Deshalb wird im Nachhinein ein etwaiger Rundungsfehler
-		// ausgeglichen
-		if (Math.abs(minutes) >= 60) {
-			degrees += Math.signum(minutes);
-			minutes -= Math.signum(minutes) * 60;
-		}
-		String coordStr = Math.abs(degrees) + "°" + Math.abs(minutes) + "'";
-		if (degrees != 0 || minutes != 0) {
-			if (panel.isVertical())
-				coordStr += RES
-						.getString((coord < 0) ? "schmitzm.geotools.gui.GeotoolsGUIUtil.SOUTH.Abb"
-								: "schmitzm.geotools.gui.GeotoolsGUIUtil.NORTH.Abb");
-			else
-				coordStr += RES
-						.getString((coord < 0) ? "schmitzm.geotools.gui.GeotoolsGUIUtil.WEST.Abb"
-								: "schmitzm.geotools.gui.GeotoolsGUIUtil.EAST.Abb");
-		}
-		return coordStr;
-	}
-
-	/**
-	 * Determines a "fitting" fragmentation for the grid.
-	 * 
-	 * @param mapMin_LL
-	 *            minimal Lat/Lon coordinate to show in the grid
-	 * @param mapMax_LL
-	 *            maximal Lat/Lon coordinate to show in the grid
-	 * @param panelSize
-	 *            size of the grid panel in pixels
-	 */
-	@Override
-	public double determineGridDistance(GridPanel panel, double mapMin_LL,
-			double mapMax_LL, int panelSize) {
-		// Differenz zwischen Min/Max-Koordinaten = darzustellender Bereich in
-		// Grad
-		double diff = Math.abs(mapMin_LL - mapMax_LL);
-		// Distanz zwischen zwei Unterteilungen in Grad
-		double dist = 0.0;
-		if (diff < 10 / 60.0) // < 10 Min. --> 1 Min.-Aufteilung
-			dist = 1 / 60.0;
-		else if (diff < 30 / 60.0) // < 30 Min. --> 5 Min.-Aufteilung
-			dist = 5 / 60.0;
-		else if (diff < 1) // < 1? --> 10 Min.-Aufteilung
-			dist = 10 / 60.0;
-		else if (diff < 3) // < 3? --> 15 Min.-Aufteilung
-			dist = 15 / 60.0;
-		else if (diff < 5) // < 5? --> 30 Min.-Aufteilung
-			dist = 30 / 60.0;
-		else if (diff < 11) // < 11? --> 1?-Aufteilung
-			dist = 1;
-		else
-			// sonst --> 2?-Aufteilung
-			dist = 2;
-
-		// Solange der Abstand zwischen 2 Unterteilungen weniger als 40 Pixel
-		// betraegt --> Unterteilung verdoppeln
-		while (diff != 0 && dist != 0 && panelSize / (diff / dist) < 40)
-			dist *= 2;
-
-		return dist;
-	}
-
-	private static final Font font = new Font(Font.MONOSPACED, Font.PLAIN, 11);
-
-	@Override
-	public Font getFont() {
-		return font;
-	}
-
-	@Override
-	public int getHeightForHorizontal() {
-		return new JLabel().getFontMetrics(font).getHeight() + 2;
-	}
-
-	@Override
-	public int getWidthForVertical() {
-		return new JLabel().getFontMetrics(font).stringWidth("90°30' N") + 2;
-	}
-
-	@Override
-	public String getTitle() {
-		// TODO localize		
-		return "22°33'44 N";
-	}
-}

Modified: branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/resource/locales/GTResourceBundle.properties
===================================================================
--- branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/resource/locales/GTResourceBundle.properties	2009-09-24 17:58:32 UTC (rev 415)
+++ branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/resource/locales/GTResourceBundle.properties	2009-09-25 13:58:55 UTC (rev 416)
@@ -150,3 +150,7 @@
 schmitzm.geotools.gui.SelectableFeatureTablePane.selectionStatus.polygons=polygons
 schmitzm.geotools.gui.SelectableFeatureTablePane.selectionStatus.points=points
 schmitzm.geotools.gui.SelectableFeatureTablePane.selectionStatus.lines=lines
+
+schmitzm.geotools.gui.GridPanelFormatter_DHDN.title=1,234,567 (H|R)
+schmitzm.geotools.gui.GridPanelFormatter_LatLon1.title=deegree° minute' (N|E|S|W)
+schmitzm.geotools.gui.GridPanelFormatter.ToolTipTemplate=${0} in unit ${1}
\ No newline at end of file

Modified: branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/resource/locales/GTResourceBundle_de.properties
===================================================================
--- branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/resource/locales/GTResourceBundle_de.properties	2009-09-24 17:58:32 UTC (rev 415)
+++ branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/resource/locales/GTResourceBundle_de.properties	2009-09-25 13:58:55 UTC (rev 416)
@@ -170,3 +170,11 @@
 schmitzm.geotools.gui.SelectableFeatureTablePane.selectionStatus.polygons=Polygonen
 schmitzm.geotools.gui.SelectableFeatureTablePane.selectionStatus.points=Punkten
 schmitzm.geotools.gui.SelectableFeatureTablePane.selectionStatus.lines=Linien
+
+
+schmitzm.geotools.gui.GridPanelFormatter_DHDN.title=DHDN - 1,234,567 (H|R)
+schmitzm.geotools.gui.GridPanelFormatter_LatLon1.title=Grad° Minute' (N|O|S|W)
+#nice to have: schmitzm.geotools.gui.GridPanelFormatter_LatLon2.title=Grad° Minute' Sek.'' (N|O|S|W)
+#nice to have: schmitzm.geotools.gui.GridPanelFormatter_LatLon3.title=Grad° Minute' Hundertstel (N|O|S|W)
+
+schmitzm.geotools.gui.GridPanelFormatter.ToolTipTemplate=${0} in Einheit ${1}
\ No newline at end of file

Modified: branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/resource/locales/GTResourceBundle_fr.properties
===================================================================
--- branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/resource/locales/GTResourceBundle_fr.properties	2009-09-24 17:58:32 UTC (rev 415)
+++ branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/resource/locales/GTResourceBundle_fr.properties	2009-09-25 13:58:55 UTC (rev 416)
@@ -168,3 +168,6 @@
 schmitzm.geotools.gui.SelectableFeatureTablePane.selectionStatus.polygons=polygones
 schmitzm.geotools.gui.SelectableFeatureTablePane.selectionStatus.points=points
 schmitzm.geotools.gui.SelectableFeatureTablePane.selectionStatus.lines=lignes
+
+#missing schmitzm.geotools.gui.GridPanelFormatter_DHDN.title=DHDN - 1,234,567 (H|R)
+#missing schmitzm.geotools.gui.GridPanelFormatter_LatLon1.title=Grad° Minute' (N|O|S|W)

Modified: branches/1.0-gt2-2.6/src/schmitzm/geotools/io/GeoExportUtil.java
===================================================================
--- branches/1.0-gt2-2.6/src/schmitzm/geotools/io/GeoExportUtil.java	2009-09-24 17:58:32 UTC (rev 415)
+++ branches/1.0-gt2-2.6/src/schmitzm/geotools/io/GeoExportUtil.java	2009-09-25 13:58:55 UTC (rev 416)
@@ -268,15 +268,19 @@
 	 * 
 	 * @param crs
 	 *            Koordinaten-System
-	 * @param output
+	 * @param outputFile
 	 *            Datei in die die Projektion geschrieben wird
 	 * @exception IOException
 	 *                falls die Datei nicht geschrieben werden kann
 	 */
 	public static void writeProjectionFilePrefereEPSG(
-			CoordinateReferenceSystem crs, File output) throws IOException {
-		PrintWriter out = new PrintWriter(output);
+			CoordinateReferenceSystem crs, File outputFile) throws IOException {
 
+		// Directories will be created if needed.
+		outputFile.getParentFile().mkdirs();
+		
+		PrintWriter out = new PrintWriter(outputFile);
+
 		try {
 
 			String whatToWrite = null;



More information about the Schmitzm-commits mailing list