[Schmitzm-commits] r521 - branches/1.0-gt2-2.6/src/gtmig/org/geotools/swing

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Tue Nov 17 13:51:38 CET 2009


Author: alfonx
Date: 2009-11-17 13:51:37 +0100 (Tue, 17 Nov 2009)
New Revision: 521

Modified:
   branches/1.0-gt2-2.6/src/gtmig/org/geotools/swing/XMapPane.java
Log:
* Some cleanup in XMapPane

Modified: branches/1.0-gt2-2.6/src/gtmig/org/geotools/swing/XMapPane.java
===================================================================
--- branches/1.0-gt2-2.6/src/gtmig/org/geotools/swing/XMapPane.java	2009-11-17 12:50:05 UTC (rev 520)
+++ branches/1.0-gt2-2.6/src/gtmig/org/geotools/swing/XMapPane.java	2009-11-17 12:51:37 UTC (rev 521)
@@ -1300,12 +1300,11 @@
 		SwingUtil.clearAround(graphics, painedArea, visibleArea);
 
 		addGadgets(graphics);
-		// graphics.drawImage(getGadgetsImage(), 0,0, (int)
-		// visibleArea.getMaxX(), (int) visibleArea.getMaxY(),null);
 
 		quickPreviewHint = 0;
 
 		graphics.dispose();
+		
 		// Something has been drawn
 		return true;
 	}
@@ -1329,7 +1328,9 @@
 			graphics.setColor(Color.BLACK);
 
 			graphics.setFont(waitFont);
-			graphics.drawString("Wait...", 40, 70);
+			graphics.drawString("Wait...", 40, 70); //i8n
+			
+			graphics.setColor(getMapBackgroundColor());
 		}
 
 	}
@@ -1352,6 +1353,7 @@
 
 			preFinalG.drawImage(getBgImage(), 0, 0, getMapBackgroundColor(),
 					null);
+			
 			// // Draw the local layers image
 			preFinalG.drawImage(getLocalImage(), 0, 0, null);
 			preFinalG.dispose();
@@ -1360,19 +1362,6 @@
 		finalG.drawImage(getPreFinalImage(), imageOrigin.x, imageOrigin.y,
 				getMapBackgroundColor(), null);
 
-		// System.out.println(new Date().getTime() - startTime +
-		// "ms for update");
-		//
-		// if (finalImageFrame == null) {
-		// finalImageFrame = new JFrame();
-		// finalImageFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
-		// SwingUtil.setRelativeFramePosition(finalImageFrame, 0, 0);
-		// }
-		// finalImageFrame.setContentPane(new JLabel(new
-		// ImageIcon(finalImage)));
-		// finalImageFrame.pack();
-		// finalImageFrame.setVisible(true);
-
 		final int finalImageHeight = getFinalImage().getHeight(null);
 		final int finalImageWidth = getFinalImage().getWidth(null);
 
@@ -1381,22 +1370,12 @@
 		SwingUtil.clearAround(finalG, painedArea, getVisibleRect());
 
 		addGadgets(finalG);
-		// finalG.drawImage(getGadgetsImage(), 0, 0, null);
 
 		finalG.dispose();
 
 		return finalImage;
 	}
 
-	/*
-	 * Set alpha composite. For example, pass in 1.0f to have 100% opacity pass
-	 * in 0.25f to have 25% opacity.
-	 */
-	private AlphaComposite makeComposite(float alpha) {
-		int type = AlphaComposite.SRC_OVER;
-		return (AlphaComposite.getInstance(type, alpha));
-	}
-
 	private Image getFinalImage() {
 
 		if (finalImage == null) {
@@ -1411,7 +1390,6 @@
 	}
 
 	private Image getPreFinalImage() {
-
 		if (preFinalImage == null) {
 			preFinalImage = null;
 			Rectangle curPaintArea = getVisibleRect();
@@ -1444,39 +1422,12 @@
 
 		if (localExecuter != null)
 			localExecuter.cancelTask();
-		//
-		//
-		// LOGGER.debug("stopping any running renderes:");
-		// int count = 0;
-		// while (bgExecuter.isRunning() || localExecuter.isRunning()) {
-		// LOGGER.debug("waiting for threads to stop");
-		//
-		// bgExecuter.cancelTask();
-		// localExecuter.cancelTask();
-		//
-		// count++;
-		//
-		// try {
-		// Thread.sleep(100);
-		// } catch (InterruptedException e) {
-		// LOGGER.error(e);
-		// }
-		//
-		// if (count > 100) {
-		// throw new RuntimeException(
-		// "Unable to stop rendering thread for 10secs");
-		// }
-		// }
-		// LOGGER.debug(" threads stopped after " + count / 10. + "secs");
-
+	
 		Rectangle curPaintArea = getVisibleRect();
 
 		labelCache.clear();
 
 		/**
-		 */
-
-		/**
 		 * We have to set new renderer
 		 */
 
@@ -1503,10 +1454,6 @@
 		}
 
 		updateCursor();
-//
-//		// start regular repaints until all renderers are done.
-//		repainterTimer.setRepeats(true);
-//		repainterTimer.restart();
 
 	}
 
@@ -1516,8 +1463,6 @@
 	private BufferedImage getBgImage() {
 
 		if (bgImage == null) {
-//			LOGGER.debug("creating a new background image");
-
 			Rectangle curPaintArea = getVisibleRect();
 
 			bgImage = new BufferedImage(curPaintArea.width + 1,
@@ -1550,7 +1495,6 @@
 	 */
 	public void setMapImage(BufferedImage mapImage) {
 		this.mapImage = mapImage;
-		// gadgetsImage = null;
 	}
 
 	/**
@@ -1560,8 +1504,6 @@
 
 		if (localImage == null) {
 
-//			LOGGER.debug("creating a new local image");
-
 			Rectangle curPaintArea = getVisibleRect();
 
 			localImage = new BufferedImage(curPaintArea.width + 1,
@@ -1571,32 +1513,6 @@
 		return localImage;
 	}
 
-	//
-	// /**
-	// * Lazyly initializes a {@link BufferedImage} for the background renderer.
-	// */
-	// private BufferedImage getGadgetsImage() {
-	//
-	// if (gadgetsImage == null) {
-	// LOGGER.debug("creating a new gadgets image");
-	//
-	// Rectangle curPaintArea = getVisibleRect();
-	// // allow a single pixel margin at the right and bottom edges
-	// curPaintArea.width -= 1;
-	// curPaintArea.height -= 1;
-	//
-	// gadgetsImage = new BufferedImage(curPaintArea.width + 1,
-	// curPaintArea.height + 1, BufferedImage.TYPE_INT_ARGB);
-	//
-	// if (mapImage != null)
-	// gadgetsImage.getGraphics().drawImage(mapImage,
-	// curPaintArea.width - mapImage.getWidth() - 10,
-	// curPaintArea.height - mapImage.getHeight() - 10, this);
-	//			
-	// }
-	//
-	// return gadgetsImage;
-	// }
 
 	/**
 	 * Called by the {@linkplain XMapPane.RenderingTask} when rendering has been
@@ -1632,9 +1548,6 @@
 	 * @see MapPaneListener#onRenderingStopped(org.geotools.swing.event.MapPaneEvent)
 	 */
 	public void onRenderingFailed(Exception renderingError) {
-		// MapPaneEvent ev = new MapPaneEvent(this,
-		// MapPaneEvent.Type.RENDERING_STOPPED);
-		// publishEvent(ev);
 		LOGGER.warn("Rendering failed", renderingError);
 		updateFinalImage();
 		repaint();
@@ -1662,7 +1575,6 @@
 		}
 	}
 
-	// xulu.sn
 	/**
 	 * Korrigiert den {@link Envelope} aka {@code mapArea} auf die beste
 	 * erlaubte Flaeche damit die Massstabsbeschaenkungen noch eingehalten
@@ -1831,7 +1743,6 @@
 							false);
 				}
 			}
-
 		}
 
 		return newArea;
@@ -2032,24 +1943,16 @@
 		}
 
 		startRenderThreadsTimer.stop();
-//		repainterTimer.stop();
 
 		if (bgImage != null)
 			bgImage.flush();
 		if (localImage != null)
 			localImage.flush();
-		// if (gadgetsImage != null)
-		// gadgetsImage.flush();
 		if (finalImage != null)
 			finalImage.flush();
 		if (preFinalImage != null)
 			preFinalImage.flush();
 
-		// if (dragWaitCursorListener != null)
-		// this.removeMouseListener(dragWaitCursorListener);
-		// if (mouseWheelZoomListener != null)
-		// this.removeMouseWheelListener(mouseWheelZoomListener);
-
 		// Alle mapPaneListener entfernen
 		mapPaneListeners.clear();
 
@@ -2216,6 +2119,9 @@
 	 */
 	protected void drawRectangle(final Graphics graphics, Point startPos,
 			Point e) {
+		
+		if (!isWellDefined()) return;
+		
 		// undraw last box/draw new box
 		final int left = Math.min(startPos.x, e.x);
 		final int right = Math.max(startPos.x, e.x);
@@ -2253,9 +2159,9 @@
 	}
 
 	public void onRenderingPending() {
-		LOGGER.debug("Pending rendering updates the preview...");
+//		LOGGER.debug("Pending rendering updates the preview...");
 		updateFinalImage();
-		XMapPane.this.repaint();
+		repaint();
 	}
 
 }



More information about the Schmitzm-commits mailing list