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

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Sat Jun 26 12:02:50 CEST 2010


Author: alfonx
Date: 2010-06-26 12:02:49 +0200 (Sat, 26 Jun 2010)
New Revision: 912

Modified:
   trunk/src/schmitzm/geotools/gui/XMapPane.java
Log:
Annica reported an exception in the preview zoom method, so i added a try/catch as a first thing

Hi,
I have a 'strange' problem in Geopublisher with the zoom-in tool.
I can't zoom in to a scale below 100m.
The strange thing is that if I only change place (drag n' drop) of any of
the layers in the map-legend the zoom-in tool works...or if I open the
internal folder of any layer from 'properties', the zoom starts to work..But
when I save the map and re-open it I've still got the same problem.
Is it possible that this got to do with the settings of my files? maybe the
base-layer (a raster DTM) in the map-legend?
In Geopublisher 1.5 I don't get any error-message but in version 1.6, when I
double-click a detailed layer in the legend, the zooming stops at 100m and I
get this error:

java.lang.NegativeArraySizeException
	at java.awt.image.DataBufferInt.<init>(Unknown Source)
	at java.awt.image.Raster.createPackedRaster(Unknown Source)
	at
java.awt.image.DirectColorModel.createCompatibleWritableRaster(Unknown
Source)
	at java.awt.image.BufferedImage.<init>(Unknown Source)
	at sun.java2d.pipe.DrawImage.renderImageXform(Unknown Source)
	at sun.java2d.d3d.D3DDrawImage.renderImageXform(Unknown Source)
	at sun.java2d.pipe.DrawImage.transformImage(Unknown Source)
	at sun.java2d.pipe.DrawImage.scaleImage(Unknown Source)
	at sun.java2d.pipe.DrawImage.scaleImage(Unknown Source)
	at sun.java2d.pipe.ValidatePipe.scaleImage(Unknown Source)
	at sun.java2d.SunGraphics2D.drawImage(Unknown Source)
	at
schmitzm.geotools.gui.XMapPane.drawScaledPreviewImage_Zoom(XMapPane.java:110
7)
	at schmitzm.geotools.gui.XMapPane.paintComponent(XMapPane.java:1644)
	at javax.swing.JComponent.paint(Unknown Source)
	at javax.swing.JComponent.paintToOffscreen(Unknown Source)
	at
javax.swing.RepaintManager$PaintManager.paintDoubleBuffered(Unknown Source)
	at javax.swing.RepaintManager$PaintManager.paint(Unknown Source)
	at javax.swing.RepaintManager.paint(Unknown Source)
	at javax.swing.JComponent._paintImmediately(Unknown Source)
	at javax.swing.JComponent.paintImmediately(Unknown Source)
	at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
	at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
	at javax.swing.RepaintManager.seqPaintDirtyRegions(Unknown Source)
	at
javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(Unknown
Source)
	at java.awt.event.InvocationEvent.dispatch(Unknown Source)
	at java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown
Source)
	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown
Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.run(Unknown Source) 
 

Annica


Modified: trunk/src/schmitzm/geotools/gui/XMapPane.java
===================================================================
--- trunk/src/schmitzm/geotools/gui/XMapPane.java	2010-06-20 22:11:28 UTC (rev 911)
+++ trunk/src/schmitzm/geotools/gui/XMapPane.java	2010-06-26 10:02:49 UTC (rev 912)
@@ -25,6 +25,7 @@
 import java.util.Map;
 import java.util.Vector;
 
+import javax.management.RuntimeErrorException;
 import javax.swing.JList;
 import javax.swing.Timer;
 import javax.swing.border.Border;
@@ -774,8 +775,7 @@
 	 * corrected. This change implies, that setMapArea() will most of the time
 	 * not allow setting to a wrong aspectRatio.
 	 * 
-	 * @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons
-	 *         Tzeggai</a>
+	 * @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons Tzeggai</a>
 	 */
 	public ReferencedEnvelope bestAllowedMapArea(ReferencedEnvelope env) {
 
@@ -969,8 +969,7 @@
 	 * 
 	 * Removes all {@link JMapPaneListener}s that are registered
 	 * 
-	 * @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons
-	 *         Tzeggai</a>
+	 * @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons Tzeggai</a>
 	 */
 	public void dispose() {
 		if (isDisposed())
@@ -1085,37 +1084,43 @@
 		if (getPreFinalImage() == null)
 			return false;
 
-		final Rectangle visibleArea = getVisibleRect();
+		try {
 
-		// Calculate the oldMapArea in the current WindowCoordinates:
-		final Envelope oldMapWindow = tranformGeoToWindow(oldMapArea.getMinX(),
-				oldMapArea.getMinY(), oldMapArea.getMaxX(), oldMapArea
-						.getMaxY());
+			final Rectangle visibleArea = getVisibleRect();
 
-		final int xx1 = (int) Math.round(oldMapWindow.getMinX());
-		final int yy1 = (int) Math.round(oldMapWindow.getMinY());
-		final int xx2 = (int) Math.round(oldMapWindow.getMaxX());
-		final int yy2 = (int) Math.round(oldMapWindow.getMaxY());
+			// Calculate the oldMapArea in the current WindowCoordinates:
+			final Envelope oldMapWindow = tranformGeoToWindow(oldMapArea
+					.getMinX(), oldMapArea.getMinY(), oldMapArea.getMaxX(),
+					oldMapArea.getMaxY());
 
-		graphics.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
-				RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR);
-		graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
-				RenderingHints.VALUE_ANTIALIAS_OFF);
-		graphics.setRenderingHint(RenderingHints.KEY_RENDERING,
-				RenderingHints.VALUE_RENDER_SPEED);
+			final int xx1 = (int) Math.round(oldMapWindow.getMinX());
+			final int yy1 = (int) Math.round(oldMapWindow.getMinY());
+			final int xx2 = (int) Math.round(oldMapWindow.getMaxX());
+			final int yy2 = (int) Math.round(oldMapWindow.getMaxY());
 
-		graphics.drawImage(getPreFinalImage(), xx1, yy1, xx2, yy2,
-				(int) visibleArea.getMinX(), (int) visibleArea.getMinY(),
-				(int) visibleArea.getMaxX(), (int) visibleArea.getMaxY(),
-				getMapBackgroundColor(), null);
+			graphics.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
+					RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR);
+			graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
+					RenderingHints.VALUE_ANTIALIAS_OFF);
+			graphics.setRenderingHint(RenderingHints.KEY_RENDERING,
+					RenderingHints.VALUE_RENDER_SPEED);
 
-		final Rectangle painedArea = new Rectangle(xx1, yy1, xx2 - xx1, yy2
-				- yy1);
+			graphics.drawImage(getPreFinalImage(), xx1, yy1, xx2, yy2,
+					(int) visibleArea.getMinX(), (int) visibleArea.getMinY(),
+					(int) visibleArea.getMaxX(), (int) visibleArea.getMaxY(),
+					getMapBackgroundColor(), null);
 
-		SwingUtil.clearAround(graphics, painedArea, visibleArea,
-				getMapBackgroundColor());
+			final Rectangle painedArea = new Rectangle(xx1, yy1, xx2 - xx1, yy2
+					- yy1);
 
-		addGadgets(graphics, true);
+			SwingUtil.clearAround(graphics, painedArea, visibleArea,
+					getMapBackgroundColor());
+			
+			addGadgets(graphics, true);
+		} catch (Exception e) {
+			// Annica reported exceptions here, so i assed a try catch to see whats happening.
+			LOGGER.error("Exception while painting a scaled preview: ", e);
+		}
 
 		// quickPreviewHint = 0;
 
@@ -1300,7 +1305,6 @@
 			if (!layer.isVisible())
 				continue;
 
-			
 			if (layer.getTitle().equals(SPECIAL_LINES_LAYER_ID))
 				continue;
 			/*
@@ -1348,8 +1352,7 @@
 	 * Retuns the maximum allowed zoom scale. This is the smaller number value
 	 * of the two. Defaults to {@link Double}.MIN_VALUE
 	 * 
-	 * @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons
-	 *         Tzeggai</a>
+	 * @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons Tzeggai</a>
 	 */
 	public Double getMaxZoomScale() {
 		return maxZoomScale;
@@ -1359,8 +1362,7 @@
 	 * Retuns the minimum allowed zoom scale. This is the bigger number value of
 	 * the two. Defaults to {@link Double}.MAX_VALUE
 	 * 
-	 * @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons
-	 *         Tzeggai</a>
+	 * @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons Tzeggai</a>
 	 */
 	public Double getMinZoomScale() {
 		return minZoomScale;
@@ -2041,12 +2043,10 @@
 	 * the two. If <code>null</code> is passed, Double.MINVALUE are used which
 	 * mean there is no restriction.
 	 * 
-	 * @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons
-	 *         Tzeggai</a>
+	 * @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons Tzeggai</a>
 	 */
 	public void setMaxZoomScale(final Double maxZoomScale) {
-		this.maxZoomScale = maxZoomScale == null ? Double.MIN_VALUE
-				: maxZoomScale;
+		this.maxZoomScale = maxZoomScale == null ? 1 : maxZoomScale;
 	}
 
 	// /** Stored the time used for the last real rendering in ms. **/
@@ -2063,8 +2063,7 @@
 	 * used which mean there is no restriction.
 	 * 
 	 * 
-	 * @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons
-	 *         Tzeggai</a>
+	 * @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons Tzeggai</a>
 	 */
 	public void setMinZoomScale(final Double minZoomScale) {
 		this.minZoomScale = minZoomScale == null ? Double.MAX_VALUE
@@ -2244,7 +2243,7 @@
 				repaint();
 			}
 		}
-		
+
 		if (getCursor() == SwingUtil.PANNING_CURSOR) {
 			// This cursor will reset itself
 			return;
@@ -2316,7 +2315,7 @@
 					- mapImage.getWidth() - 10, getVisibleRect().height
 					- mapImage.getHeight() - 10, null);
 		}
-		
+
 		int y = 17;
 
 		// If the rendering process is still running, indicate this is the image
@@ -2600,15 +2599,19 @@
 			// BB umrechnen von Layer-CRS in Map-CRS
 			final CoordinateReferenceSystem targetCRS = getMapContext()
 					.getCoordinateReferenceSystem();
-			CoordinateReferenceSystem sourceCRS = layer
-					.getFeatureSource().getSchema()
-					.getCoordinateReferenceSystem();
+			CoordinateReferenceSystem sourceCRS = layer.getFeatureSource()
+					.getSchema().getCoordinateReferenceSystem();
 
 			if (sourceCRS == null) {
-				sourceCRS = layer.getFeatureSource().getSchema().getGeometryDescriptor().getCoordinateReferenceSystem();
-				LOGGER.info("CRS for "+layer.getTitle()+" could not be determined from schema, trying GeometryDescriptor results: "+sourceCRS );
+				sourceCRS = layer.getFeatureSource().getSchema()
+						.getGeometryDescriptor().getCoordinateReferenceSystem();
+				LOGGER
+						.info("CRS for "
+								+ layer.getTitle()
+								+ " could not be determined from schema, trying GeometryDescriptor results: "
+								+ sourceCRS);
 			}
-			
+
 			Envelope mapAreaNew;
 			if (!CRS.equalsIgnoreMetadata(sourceCRS, targetCRS)) {
 				mapAreaNew = JTSUtil.transformEnvelope(layer.getFeatureSource()
@@ -2687,8 +2690,7 @@
 	 *            Index of the {@link MapLayer} in the {@link MapContext} (from
 	 *            back to top)
 	 * 
-	 * @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons
-	 *         Tzeggai</a>
+	 * @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons Tzeggai</a>
 	 */
 	public void zoomToLayer(int index) {
 		final MapContext context = getMapContext();
@@ -2710,8 +2712,7 @@
 	 *            Reverse index of the {@link MapLayer} in the
 	 *            {@link MapContext}
 	 * 
-	 * @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons
-	 *         Tzeggai</a>
+	 * @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons Tzeggai</a>
 	 */
 	public void zoomToLayerIdxReverse(int index) {
 		zoomToLayer(getMapContext().getLayerCount() - 1 - index);
@@ -2722,8 +2723,7 @@
 	 * {@link SelectableXMapPane}. AntiALiasing ist besonders fuer
 	 * Textbeschriftung sehr schoen, verbraucht aber auch mehr Performance.
 	 * 
-	 * @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons
-	 *         Tzeggai</a>
+	 * @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons Tzeggai</a>
 	 */
 	public void setAntiAliasing(final boolean aa) {
 		// LOGGER.info("Setting AntiAliasing for this JMapPane to " + aa);



More information about the Schmitzm-commits mailing list