[Schmitzm-commits] r560 - in branches/1.0-gt2-2.6/src: schmitzm/geotools/gui skrueger/geotools skrueger/geotools/selection

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Tue Nov 24 15:57:11 CET 2009


Author: alfonx
Date: 2009-11-24 15:57:05 +0100 (Tue, 24 Nov 2009)
New Revision: 560

Modified:
   branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/SelectableXMapPane.java
   branches/1.0-gt2-2.6/src/skrueger/geotools/GeomFilterGenerator.java
   branches/1.0-gt2-2.6/src/skrueger/geotools/SelectXMapPaneMouseListener.java
   branches/1.0-gt2-2.6/src/skrueger/geotools/XMapPane.java
   branches/1.0-gt2-2.6/src/skrueger/geotools/selection/FeatureMapLayerSelectionSynchronizer.java
Log:
* Selection mit Click funktioniert wieder

Modified: branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/SelectableXMapPane.java
===================================================================
--- branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/SelectableXMapPane.java	2009-11-24 14:12:41 UTC (rev 559)
+++ branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/SelectableXMapPane.java	2009-11-24 14:57:05 UTC (rev 560)
@@ -358,7 +358,7 @@
 		// getContext().addMapLayerListListener(
 		// new MapLayerListAdapter() {
 		// @Override
-		// public void layerAdded(MapLayerListEvent e) {
+		// public void layerAdded(MapLayerListEvent e) {originalStyle
 		// setMapLayerSelectable(e.getLayer(),true);
 		// }
 		// @Override
@@ -369,14 +369,8 @@
 		// });
 	}
 
-	/**
-	 * Triggers to repaint (fast) and re-render (slow) the JMapPane
-	 */
-	public void refresh() {
-		mapImageInvalid = true;
-		repaint();
-	}
 
+
 	/**
 	 * Aktiviert oder deaktiviert das AntiAliasing for diese
 	 * {@link SelectableXMapPane}. AntiALiasing ist besonders fuer

Modified: branches/1.0-gt2-2.6/src/skrueger/geotools/GeomFilterGenerator.java
===================================================================
--- branches/1.0-gt2-2.6/src/skrueger/geotools/GeomFilterGenerator.java	2009-11-24 14:12:41 UTC (rev 559)
+++ branches/1.0-gt2-2.6/src/skrueger/geotools/GeomFilterGenerator.java	2009-11-24 14:57:05 UTC (rev 560)
@@ -191,7 +191,7 @@
 		 * @param basePoint
 		 *            defines the point for the "near point" constraint
 		 * @param dist
-		 *            defines the distance around the base point
+		 *            defines the distance around the base point in base point CRS
 		 * @param crs
 		 *            defines the CRS of base point
 		 */

Modified: branches/1.0-gt2-2.6/src/skrueger/geotools/SelectXMapPaneMouseListener.java
===================================================================
--- branches/1.0-gt2-2.6/src/skrueger/geotools/SelectXMapPaneMouseListener.java	2009-11-24 14:12:41 UTC (rev 559)
+++ branches/1.0-gt2-2.6/src/skrueger/geotools/SelectXMapPaneMouseListener.java	2009-11-24 14:57:05 UTC (rev 560)
@@ -40,7 +40,7 @@
 				.getState() == XMapPane.PAN))
 			return false;
 		if (xMapPane.getState() == XMapPane.NONE)
-			;
+			return false;
 		return enabled;
 	}
 
@@ -63,6 +63,7 @@
 	 *         Kr&uuml;ger</a>
 	 */
 	public void mouseClicked(MouseEvent e) {
+
 		if (!isEnabled())
 			return;
 
@@ -91,9 +92,10 @@
 				* (xMapPane.getMapArea().getWidth() + xMapPane.getMapArea()
 						.getHeight()) / 2;
 
+		PointFilterGenerator filterGenerator = new PointFilterGenerator(geoCoord, radius,
+				xMapPane.getMapContext().getCoordinateReferenceSystem());
 		Hashtable<MapLayer, FeatureCollection<SimpleFeatureType, SimpleFeature>> result = xMapPane
-				.findVisibleFeatures(new PointFilterGenerator(geoCoord, radius,
-						xMapPane.getMapContext().getCoordinateReferenceSystem()),
+				.findVisibleFeatures(filterGenerator,
 						state, new Envelope(geoCoord.getX(), geoCoord.getX(),
 								geoCoord.getY(), geoCoord.getY()));
 		
@@ -213,16 +215,19 @@
 				|| event.getButton() == MouseEvent.BUTTON3) {
 			xMapPane.performPan();
 		} else if (xMapPane.getState() == XMapPane.SELECT_ALL
-				|| xMapPane.getState() == XMapPane.SELECT_TOP) {
-			xMapPane.drawRectangle(xMapPane.getGraphics(), startPos, event
-					.getPoint());
-
+				|| xMapPane.getState() == XMapPane.SELECT_TOP
+//				|| xMapPane.getState() == XMapPane.SELECT_ONE_FROM_TOP
+				) {
+			
 			Point mp = event.getPoint();
 
 			// keine wirkliche Selektion, sondern nur ein Klick
 			if (startPos.x == mp.x || startPos.y == mp.y) {
-				mouseClicked(event);
-				return;
+//				mouseClicked(event);
+//				return;
+			} else {
+				xMapPane.drawRectangle(xMapPane.getGraphics(), startPos, event
+						.getPoint());
 			}
 
 			// SELECTION!

Modified: branches/1.0-gt2-2.6/src/skrueger/geotools/XMapPane.java
===================================================================
--- branches/1.0-gt2-2.6/src/skrueger/geotools/XMapPane.java	2009-11-24 14:12:41 UTC (rev 559)
+++ branches/1.0-gt2-2.6/src/skrueger/geotools/XMapPane.java	2009-11-24 14:57:05 UTC (rev 560)
@@ -26,6 +26,7 @@
 import java.util.Map;
 import java.util.Vector;
 
+import javax.jws.soap.SOAPBinding.Style;
 import javax.swing.Timer;
 
 import org.apache.log4j.Logger;
@@ -140,7 +141,7 @@
 	 * the {@link #repaintTimer} is regularly updating the {@link #finalImage}
 	 * with previews.
 	 */
-	public static final int REPEATING_REPAINT_DELAY = 600;
+	public static final int REPEATING_REPAINT_DELAY = 500;
 
 	/**
 	 * Default delay (milliseconds) before the map will be redrawn when resizing
@@ -395,20 +396,21 @@
 		public void layerAdded(final MapLayerListEvent event) {
 			event.getLayer().addMapLayerListener(localMapLayerListener);
 
-			localRenderer.setContext(getMapContext());
+			getLocalRenderer().setContext(getMapContext());
 			requestStartRendering();
 
 		}
 
 		@Override
 		public void layerChanged(final MapLayerListEvent event) {
-			localRenderer.setContext(getMapContext());
+//			localRenderer = GTUtil.createGTRenderer();
+			getLocalRenderer().setContext(getMapContext());
 			requestStartRendering();
 		}
 
 		@Override
 		public void layerMoved(final MapLayerListEvent event) {
-			localRenderer.setContext(getMapContext());
+			getLocalRenderer().setContext(getMapContext());
 			requestStartRendering();
 		}
 
@@ -416,7 +418,7 @@
 		public void layerRemoved(final MapLayerListEvent event) {
 			if (event.getLayer() != null)
 				event.getLayer().removeMapLayerListener(localMapLayerListener);
-			localRenderer.setContext(getMapContext());
+			getLocalRenderer().setContext(getMapContext());
 			requestStartRendering();
 		}
 	};
@@ -429,7 +431,7 @@
 
 		@Override
 		public void layerChanged(final MapLayerEvent event) {
-			localRenderer.setContext(getMapContext()); // betters for SLD
+			getLocalRenderer().setContext(getMapContext()); // betters for SLD
 			// changes?!
 			requestStartRendering();
 		}
@@ -445,7 +447,7 @@
 		}
 	};
 
-	private final GTRenderer localRenderer = GTUtil.createGTRenderer();
+	final private GTRenderer localRenderer = GTUtil.createGTRenderer();
 
 	private final GTRenderer bgRenderer = GTUtil.createGTRenderer();
 
@@ -518,7 +520,7 @@
 	private int quickPreviewHint = 0;
 
 	private Map<Object, Object> rendererHints = GTUtil
-			.getDefaultGTRendererHints(localRenderer);
+			.getDefaultGTRendererHints(getLocalRenderer());
 
 	/**
 	 * If set to <code>true</code>, the {@link #startRenderThreadsTimer} will
@@ -1151,9 +1153,11 @@
 	 * If no parent component is available, WHITE is returned.
 	 **/
 	public Color getMapBackgroundColor() {
-		if (mapBackgroundColor == null){
-			if (getParent() != null) return getParent().getBackground();
-			else return Color.WHITE;
+		if (mapBackgroundColor == null) {
+			if (getParent() != null)
+				return getParent().getBackground();
+			else
+				return Color.WHITE;
 		}
 		return mapBackgroundColor;
 	}
@@ -1477,7 +1481,7 @@
 		if (!isWellDefined())
 			return;
 
-		// super.paintComponent(g); // candidate for removal
+//		 super.paintComponent(g); // candidate for removal
 
 		boolean paintedSomething = false;
 
@@ -1703,7 +1707,7 @@
 
 			// setMapArea(localContext.getAreaOfInterest());
 
-			localRenderer.setContext(localContext);
+			getLocalRenderer().setContext(localContext);
 
 			this.localContext.addMapLayerListListener(localContextListener);
 
@@ -1717,11 +1721,31 @@
 
 	}
 
+	/**
+	 * Triggers to repaint (fast) and re-render (slow) the JMapPane.
+	 */
+	public void refresh() {
+		mapImageInvalid = true;
+		repaint();
+	}
+
+	// /**
+	// * Triggers to use new {@link GTRenderer} and refresh the map. Should be
+	// * called after {@link Style}s have been changed because GTRenderer is
+	// * otherwise not working well.
+	// */
+	// public void refreshRenderers() {
+	// localRenderer = GTUtil.createGTRenderer();
+	// setLocalContext(getMapContext());
+	// mapImageInvalid = true;
+	// repaint();
+	// }
+
 	public boolean setMapArea(final Envelope newMapArea) {
 		if (newMapArea == null)
 			return false;
-		if (getMapContext()
-				.getCoordinateReferenceSystem() == null) return false;
+		if (getMapContext().getCoordinateReferenceSystem() == null)
+			return false;
 		return setMapArea(new ReferencedEnvelope(newMapArea, getMapContext()
 				.getCoordinateReferenceSystem()));
 	}
@@ -1967,12 +1991,12 @@
 			// localExecuter = new RenderingExecutor(this, 150l);
 			// LOGGER.debug("starting local renderer:");
 
-			localRenderer.setJava2DHints(getJava2dHints());
-			localRenderer.setRendererHints(getRendererHints());
+			getLocalRenderer().setJava2DHints(getJava2dHints());
+			getLocalRenderer().setRendererHints(getRendererHints());
 
 			final boolean submitted = localExecuter.submit(getMapArea(),
 					curPaintArea, (Graphics2D) getLocalImage().getGraphics(),
-					localRenderer);
+					getLocalRenderer());
 			if (submitted)
 				repaintTimer.restart();
 			else
@@ -2194,7 +2218,7 @@
 				if (errStr == null)
 					errStr = "unknown error: " + ex.getClass().getSimpleName();
 
-				graphics.setColor(Color.WHITE);
+				graphics.setColor(getMapBackgroundColor());
 				graphics.drawString(errStr, 5, y);
 				graphics.setColor(Color.RED);
 				graphics.drawString(errStr, 6, y + 1);
@@ -2364,4 +2388,8 @@
 		return showExceptions;
 	}
 
+	public GTRenderer getLocalRenderer() {
+		return localRenderer;
+	}
+
 }

Modified: branches/1.0-gt2-2.6/src/skrueger/geotools/selection/FeatureMapLayerSelectionSynchronizer.java
===================================================================
--- branches/1.0-gt2-2.6/src/skrueger/geotools/selection/FeatureMapLayerSelectionSynchronizer.java	2009-11-24 14:12:41 UTC (rev 559)
+++ branches/1.0-gt2-2.6/src/skrueger/geotools/selection/FeatureMapLayerSelectionSynchronizer.java	2009-11-24 14:57:05 UTC (rev 560)
@@ -323,12 +323,12 @@
 	}
 
 	/**
-	 * Analyses whether the selection has changed in comparison to the selection
+	 * Analyzes whether the selection has changed in comparison to the selection
 	 * stored in the mapLayer.Style
 	 * 
-	 * @param newSelection
-	 * @param originalStyle
-	 * @return
+	 * @param newSelection a List<String> of all newly selected FIDs
+	 * @param originalStyle the original {@link Style} that has an earlier selection coded into the {@link Style}
+	 * @return <code>true</code> if changed.
 	 */
 	private boolean selectionChanged(Vector<String> newSelection,
 			Style originalStyle) {



More information about the Schmitzm-commits mailing list