[Schmitzm-commits] r726 - trunk/src/skrueger/geotools

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Thu Feb 25 19:53:58 CET 2010


Author: alfonx
Date: 2010-02-25 19:53:58 +0100 (Thu, 25 Feb 2010)
New Revision: 726

Modified:
   trunk/src/skrueger/geotools/XMapPane.java
Log:
XMapPane.blink(...)  now works much nicer.

Modified: trunk/src/skrueger/geotools/XMapPane.java
===================================================================
--- trunk/src/skrueger/geotools/XMapPane.java	2010-02-25 18:40:44 UTC (rev 725)
+++ trunk/src/skrueger/geotools/XMapPane.java	2010-02-25 18:53:58 UTC (rev 726)
@@ -632,7 +632,7 @@
 
 		super(true);
 
-		blinkTimer = initBlinkTimer();
+		stopBlinkTimer = initBlinkTimer();
 
 		// A default setting
 		RenderingHints hintsJava2d = ImageUtilities.NN_INTERPOLATION_HINT;
@@ -1620,12 +1620,23 @@
 
 			g.drawImage(getFinalImage(), 0, 0, null);
 
+			blink((Graphics2D) g);
+
 			paintedSomething = true; // cand. for removal
 		}
 
 	}
 
 	/**
+	 * If {@link #blinkRenderer} is not <code>null</code>, the blinking features
+	 * are rendered into the {@link Graphics2D}
+	 */
+	private void blink(Graphics2D g2d) {
+		if (blinkRenderer != null)
+			blinkRenderer.paint(g2d, getVisibleRect(), getMapArea());
+	}
+
+	/**
 	 * Heavily works on releasing all resources related to the four
 	 * {@link Image}s used to cache the results of the different renderers.<br>
 	 * In November 2009 i had some memory leaking problems with {@link XMapPane}
@@ -2010,8 +2021,10 @@
 	private long lastRenderingDuration = 1000;
 	private XMapPaneTool tool = null;
 
-	private Timer blinkTimer;
+	private Timer stopBlinkTimer;
 
+	private StreamingRenderer blinkRenderer;
+
 	/**
 	 * Set the minimum (nearest) allowed zoom scale. This is the bigger number
 	 * value of the two. If <code>null</code> is passed, Double.MAXVALUE are
@@ -2106,7 +2119,7 @@
 		}
 
 		localExecuter.cancelTask();
-		
+
 		// Inform listeners that rendering has completed if have no requests to
 		// start again
 		if (!requestStartRendering)
@@ -2404,8 +2417,9 @@
 	 * 
 	 * @param features
 	 *            if <code>null</code> or size==0, the function doesn nothing.
-	 *            
-	 * @return <code>true</code> if the {@link #mapArea} has changed and rendering has been triggered.            
+	 * 
+	 * @return <code>true</code> if the {@link #mapArea} has changed and
+	 *         rendering has been triggered.
 	 */
 	public boolean zoomTo(
 			final FeatureCollection<SimpleFeatureType, SimpleFeature> features) {
@@ -2762,11 +2776,16 @@
 
 	final static int BLINK_TIMER_DEPLAY = 800;
 
+	/**
+	 * The job of the BlinkTimer is to remove the features painted in BLINK
+	 * style again.
+	 */
 	private Timer initBlinkTimer() {
 		Timer timer = new Timer(BLINK_TIMER_DEPLAY, new ActionListener() {
 
 			@Override
 			public void actionPerformed(ActionEvent e) {
+				blinkRenderer = null;
 				XMapPane.this.repaint(300);
 			}
 		});
@@ -2791,9 +2810,9 @@
 	public void blink(
 			FeatureCollection<SimpleFeatureType, SimpleFeature> features) {
 		{
-			blinkTimer.stop();
+			if (stopBlinkTimer != null)	stopBlinkTimer.stop();
 			repaint();
-			blinkTimer = initBlinkTimer();
+			stopBlinkTimer = initBlinkTimer();
 
 			DefaultMapContext mc = new DefaultMapContext(getMapContext()
 					.getCoordinateReferenceSystem());
@@ -2808,17 +2827,14 @@
 			DefaultMapLayer dml = new DefaultMapLayer(features, style);
 			mc.addLayer(dml);
 
-			GTRenderer renderer = new StreamingRenderer();
+			blinkRenderer = new StreamingRenderer();
 
-			renderer.setJava2DHints(getJava2dHints());
+			blinkRenderer.setJava2DHints(getJava2dHints());
 
-			renderer.setContext(mc);
+			blinkRenderer.setContext(mc);
 
-			Graphics2D g2d = (Graphics2D) getGraphics();
-			renderer.paint(g2d, getVisibleRect(), getMapArea());
+			stopBlinkTimer.start();
 
-			blinkTimer.start();
-
 		}
 
 	}



More information about the Schmitzm-commits mailing list