[Schmitzm-commits] r677 - in branches/2.0-RC2/src: schmitzm/geotools/gui skrueger/geotools

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Fri Feb 5 16:03:19 CET 2010


Author: alfonx
Date: 2010-02-05 16:03:17 +0100 (Fri, 05 Feb 2010)
New Revision: 677

Modified:
   branches/2.0-RC2/src/schmitzm/geotools/gui/SelectableXMapPane.java
   branches/2.0-RC2/src/skrueger/geotools/StyledLayerUtil.java
   branches/2.0-RC2/src/skrueger/geotools/XMapPane.java
Log:
* Small SimplyHTML imporvement (inser image dialog was wrongly positioned)
* Removed a potential loop in XMapPane.setMapExtend

Modified: branches/2.0-RC2/src/schmitzm/geotools/gui/SelectableXMapPane.java
===================================================================
--- branches/2.0-RC2/src/schmitzm/geotools/gui/SelectableXMapPane.java	2010-02-05 12:37:13 UTC (rev 676)
+++ branches/2.0-RC2/src/schmitzm/geotools/gui/SelectableXMapPane.java	2010-02-05 15:03:17 UTC (rev 677)
@@ -179,7 +179,7 @@
 	 *            ).
 	 */
 	public SelectableXMapPane(MapContext context) {
-		this(context, null);
+		super(context, null);
 	}
 
 	/**
@@ -200,185 +200,10 @@
 	 *            ).
 	 */
 	public SelectableXMapPane() {
-		this(null, null);
+		super(null, null);
 	}
 
-	// /**
-	// * This {@link MouseListener} is managing all selection related tasks
-	// */
-	// protected final SelectXMapPaneMouseListener selectMapPaneMouseListener =
-	// new SelectXMapPaneMouseListener(
-	// this);
-
 	/**
-	 * Erzeugt ein neues MapPane.
-	 * 
-	 * @param renderer
-	 *            Renderer fuer die graphische Darestellung (z.B.
-	 *            {@link StreamingRenderer})
-	 * @param context
-	 *            Verwaltung der einzelnen Layer (z.B. {@link DefaultMapContext}
-	 *            ).
-	 * @param rendererHints
-	 *            A {@link Map} with hints for the renderer. May be
-	 *            <code>null</code>.
-	 */
-	public SelectableXMapPane(MapContext context,
-			Map<Object, Object> rendererHints) {
-		super(null, rendererHints);
-
-		// Dieser Hint sorgt wohl dafuer, dass die Rasterpixel nicht
-		// interpoliert werden
-		// Ueber die Methode enableAntiAliasing(boolean) kann das
-		// rechenintensive AntiAliasing fuer Text un Vectoren eingeschaltet
-		// werden
-		RenderingHints hintsJava2d = ImageUtilities.NN_INTERPOLATION_HINT;
-		setJava2dHints(hintsJava2d);
-
-		//
-		// // CRS wird immer vom ersten in die Karte eingefuegten Layer
-		// uebernommen
-		// // Wenn noch keine MapArea gesetzt wurde, wird diese vom Layer
-		// // uebernommen
-		// getLocalContext().addMapLayerListListener(new MapLayerListAdapter() {
-		// public void layerAdded(MapLayerListEvent e) {
-		// if (getLocalContext().getLayerCount() == 1) {
-		// CoordinateReferenceSystem crs = null;
-		// // CRS aus Layer ermitteln
-		// try {
-		// crs = e.getLayer().getFeatureSource().getSchema()
-		// .getGeometryDescriptor()
-		// .getCoordinateReferenceSystem();
-		// // wenn noch keine MapArea gesetzt wurde, den
-		// // Ausdehnungsbereich des ersten Layers
-		// // verwenden, so dass die erste
-		// // Karte komplett angezeigt wird
-		// if (getMapArea() == null) {
-		// // Envelope newMapArea = new Envelope(e.getLayer()
-		// // .getFeatureSource().getBounds());
-		// Envelope newMapArea = getMaxExtend();
-		// setMapArea(newMapArea);
-		// // in layerAdded(.) der Oberklasse wird
-		// // mapArea nochmal neu gesetzt, wenn das
-		// // erste Layer
-		// // eingefuegt wird
-		// // >> hier nur die AreaOfInterest setzen
-		// getLocalContext().setAreaOfInterest(newMapArea, crs);
-		// }
-		// } catch (Exception err) {
-		// LOGGER
-		// .warn("CRS could not be determined from map layer. "
-		// + GeoImportUtil.getDefaultCRS()
-		// .getName() + "  used.");
-		// // err.printStackTrace();
-		// crs = GeoImportUtil.getDefaultCRS();
-		// }
-		// // CRS dem MapContext zuweisen
-		// try {
-		// getLocalContext().setCoordinateReferenceSystem(crs);
-		// // LOGGER.debug("MapContext-CRS set to: "+crs);
-		// } catch (Exception err) {
-		// LOGGER.error(
-		// "CRS could not be assigned to map context.",
-		// err);
-		// }
-		// }
-		// }
-		// });
-
-		// Solved without just with the access methods
-		// // The default is to regard a layer on selection
-		// // actions
-		// getContext().addMapLayerListListener(
-		// new MapLayerListAdapter() {
-		// @Override
-		// public void layerAdded(MapLayerListEvent e) {
-		// setMapLayerSelectable(e.getLayer(),true);
-		// }
-		// @Override
-		// public void layerRemoved(MapLayerListEvent e) {
-		// // remove reference to layer
-		// mapLayerSelectable.remove(e.getLayer());
-		// }
-		// });
-		// /**
-		// * Adding the #selectionMapPaneMouseListener
-		// */
-		// this.addMouseListener(selectMapPaneMouseListener);
-		// this.addMouseMotionListener(selectMapPaneMouseListener);
-		// this.addMouseWheelListener(selectMapPaneMouseListener);
-
-//		setState(ZOOM_IN);
-
-		//
-		// // CRS wird immer vom ersten in die Karte eingefuegten Layer
-		// uebernommen
-		// // Wenn noch keine MapArea gesetzt wurde, wird diese vom Layer
-		// // uebernommen
-		// getLocalContext().addMapLayerListListener(new MapLayerListAdapter() {
-		// public void layerAdded(MapLayerListEvent e) {
-		// if (getLocalContext().getLayerCount() == 1) {
-		// CoordinateReferenceSystem crs = null;
-		// // CRS aus Layer ermitteln
-		// try {
-		// crs = e.getLayer().getFeatureSource().getSchema()
-		// .getGeometryDescriptor()
-		// .getCoordinateReferenceSystem();
-		// // wenn noch keine MapArea gesetzt wurde, den
-		// // Ausdehnungsbereich des ersten Layers
-		// // verwenden, so dass die erste
-		// // Karte komplett angezeigt wird
-		// if (getMapArea() == null) {
-		// // Envelope newMapArea = new Envelope(e.getLayer()
-		// // .getFeatureSource().getBounds());
-		// Envelope newMapArea = getMaxExtend();
-		// setMapArea(newMapArea);
-		// // in layerAdded(.) der Oberklasse wird
-		// // mapArea nochmal neu gesetzt, wenn das
-		// // erste Layer
-		// // eingefuegt wird
-		// // >> hier nur die AreaOfInterest setzen
-		// getLocalContext().setAreaOfInterest(newMapArea, crs);
-		// }
-		// } catch (Exception err) {
-		// LOGGER
-		// .warn("CRS could not be determined from map layer. "
-		// + GeoImportUtil.getDefaultCRS()
-		// .getName() + "  used.");
-		// // err.printStackTrace();
-		// crs = GeoImportUtil.getDefaultCRS();
-		// }
-		// // CRS dem MapContext zuweisen
-		// try {
-		// getLocalContext().setCoordinateReferenceSystem(crs);
-		// // LOGGER.debug("MapContext-CRS set to: "+crs);
-		// } catch (Exception err) {
-		// LOGGER.error(
-		// "CRS could not be assigned to map context.",
-		// err);
-		// }
-		// }
-		// }
-		// });
-
-		// Solved without just with the access methods
-		// // The default is to regard a layer on selection
-		// // actions
-		// getContext().addMapLayerListListener(
-		// new MapLayerListAdapter() {
-		// @Override
-		// public void layerAdded(MapLayerListEvent e) {originalStyle
-		// setMapLayerSelectable(e.getLayer(),true);
-		// }
-		// @Override
-		// public void layerRemoved(MapLayerListEvent e) {
-		// // remove reference to layer
-		// mapLayerSelectable.remove(e.getLayer());
-		// }
-		// });
-	}
-
-	/**
 	 * Liefert die Anzahl der Einheiten, die ein Bildschirm-Pixel darstellt. Die
 	 * Einheit ist die Grundeinheit des CRS
 	 */

Modified: branches/2.0-RC2/src/skrueger/geotools/StyledLayerUtil.java
===================================================================
--- branches/2.0-RC2/src/skrueger/geotools/StyledLayerUtil.java	2010-02-05 12:37:13 UTC (rev 676)
+++ branches/2.0-RC2/src/skrueger/geotools/StyledLayerUtil.java	2010-02-05 15:03:17 UTC (rev 677)
@@ -307,11 +307,11 @@
 	 * 
 	 * @param element
 	 *            {@link Element} to parse
-	 *            
+	 * 
 	 *            TODO Since GP 1.3 the {@link AttributeMetadata} class has more
 	 *            attributes which are not used by Xulu/ISDSS. GP
 	 *            exports/imports the AMD via AMLExporter and AMLImporter
-	 *            classes. (SK, 3.2.2010)	 *            
+	 *            classes. (SK, 3.2.2010) *
 	 */
 	public static AttributeMetadataMap parseAttributeMetaDataMap(
 			final Element element) {
@@ -1229,8 +1229,8 @@
 	 * After loading an atlas, the AttribteMetaData contains whatever is written
 	 * in the XML. But the DBF may have changed!
 	 */
-	public static void checkAttribMetaData(AttributeMetadataMap attributeMetaDataMap,
-			SimpleFeatureType schema) {
+	public static void checkAttribMetaData(
+			AttributeMetadataMap attributeMetaDataMap, SimpleFeatureType schema) {
 
 		ArrayList<Name> willRemove = new ArrayList<Name>();
 
@@ -1256,7 +1256,7 @@
 
 		// Remove the ones that were not findable in the schema
 		for (Name removeName : willRemove) {
-			if (attributeMetaDataMap.remove(removeName) == null){
+			if (attributeMetaDataMap.remove(removeName) == null) {
 				LOGGER.warn("removing the AMData didn't work");
 			}
 		}
@@ -1267,10 +1267,28 @@
 				continue;
 			if (!attributeMetaDataMap.containsKey(ad.getName())) {
 				attributeMetaDataMap.put(ad.getName(), new AttributeMetadata(
-						ad, schema.getAttributeDescriptors().indexOf(ad), attributeMetaDataMap
-								.getLanguages()));
+						ad, schema.getAttributeDescriptors().indexOf(ad),
+						attributeMetaDataMap.getLanguages()));
 			}
 		}
 	}
 
+	/**
+	 * Checks every attribute name in the {@link AttributeMetadataMap} for its
+	 * binding type. It the type is textual, add the mrpty string as a NODATA
+	 * value.
+	 * 
+	 * @param attributeMetaDataMap
+	 * @param schema
+	 */
+	public static void addEmptyStringToAllTextualAttributes(
+			AttributeMetadataMap attributeMetaDataMap, SimpleFeatureType schema) {
+
+		for (Name name : attributeMetaDataMap.keySet()) {
+			if (String.class.isAssignableFrom(schema.getDescriptor(name)
+					.getType().getBinding())) {
+				attributeMetaDataMap.get(name).getNodataValues().add("");
+			}
+		}
+	}
 }

Modified: branches/2.0-RC2/src/skrueger/geotools/XMapPane.java
===================================================================
--- branches/2.0-RC2/src/skrueger/geotools/XMapPane.java	2010-02-05 12:37:13 UTC (rev 676)
+++ branches/2.0-RC2/src/skrueger/geotools/XMapPane.java	2010-02-05 15:03:17 UTC (rev 677)
@@ -48,6 +48,7 @@
 import org.geotools.renderer.lite.LabelCache;
 import org.geotools.renderer.lite.RendererUtilities;
 import org.geotools.renderer.lite.StreamingRenderer;
+import org.geotools.resources.image.ImageUtilities;
 import org.geotools.swing.JMapPane;
 import org.geotools.swing.event.MapMouseEvent;
 import org.geotools.swing.event.MapPaneEvent;
@@ -611,6 +612,10 @@
 			final Map<Object, Object> rendererHints) {
 		super(true);
 
+		// A default setting
+		RenderingHints hintsJava2d = ImageUtilities.NN_INTERPOLATION_HINT;
+		setJava2dHints(hintsJava2d);
+
 		setRendererHints(rendererHints);
 
 		setOpaque(true);
@@ -812,16 +817,24 @@
 
 		final Envelope maxAllowedExtend = getMaxExtend();
 
+		/*
+		 * If a maxAllowedExtend is set, we have to honour that...
+		 */
+		Envelope lastCalculatedArea = null;
 		while (maxAllowedExtend != null && !maxAllowedExtend.contains(newArea)
 				&& newArea != null && !newArea.isNull()
 				&& !Double.isNaN(newArea.getMinX())
 				&& !Double.isNaN(newArea.getMaxX())
 				&& !Double.isNaN(newArea.getMinY())
-				&& !Double.isNaN(newArea.getMaxY())) {
-			/*
-			 * If a maxExtend is set, we have to honour that...
-			 */
-
+				&& !Double.isNaN(newArea.getMaxY())
+				 ) // Due to Double precision problems, this may iterate for ever 
+		{
+			
+			if (newArea.equals(lastCalculatedArea))
+				break;
+			// Check that we are not iterating for ever due to double precision rounding errors
+			lastCalculatedArea = newArea;
+			
 			// Exceeds top? Move down and maybe cut
 			if (newArea.getMaxY() > maxAllowedExtend.getMaxY()) {
 				final double divY = newArea.getMaxY()
@@ -925,6 +938,8 @@
 									.getCoordinateReferenceSystem()), false);
 				}
 			}
+			
+			
 		}
 
 		return new ReferencedEnvelope(newArea, env



More information about the Schmitzm-commits mailing list