[Schmitzm-commits] r180 - in trunk/src: schmitzm/geotools/gui schmitzm/geotools/styling skrueger/geotools

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Thu Jul 2 16:44:58 CEST 2009


Author: alfonx
Date: 2009-07-02 16:44:57 +0200 (Thu, 02 Jul 2009)
New Revision: 180

Modified:
   trunk/src/schmitzm/geotools/gui/GeoMapPane.java
   trunk/src/schmitzm/geotools/gui/GridPanel.java
   trunk/src/schmitzm/geotools/gui/MapPaneStatusBar.java
   trunk/src/schmitzm/geotools/gui/ScalePane.java
   trunk/src/schmitzm/geotools/styling/StylingUtil.java
   trunk/src/skrueger/geotools/MapPaneToolBar.java
Log:
* Added a special @Override paint() method to some of the GeoMapPane's components, so that when we create a screenshot in the Atlas, the backgrounds (of the GridPanel for example) will be white and not gray - that is much better for printing.
* Some more i8n n French

Modified: trunk/src/schmitzm/geotools/gui/GeoMapPane.java
===================================================================
--- trunk/src/schmitzm/geotools/gui/GeoMapPane.java	2009-07-02 14:23:36 UTC (rev 179)
+++ trunk/src/schmitzm/geotools/gui/GeoMapPane.java	2009-07-02 14:44:57 UTC (rev 180)
@@ -31,6 +31,7 @@
 import schmitzm.geotools.map.event.MapAreaChangedEvent;
 import schmitzm.geotools.map.event.ScaleChangedEvent;
 import schmitzm.swing.JPanel;
+import schmitzm.swing.SwingUtil;
 
 /**
  * Das {@code GeoMapPane} erweitert das {@link JMapPane} um einen
@@ -45,6 +46,7 @@
  */
 public class GeoMapPane extends JPanel {
 
+
 	/**
 	 * Konstante fuer das vertikale Koordinaten-Grid.
 	 * 
@@ -175,8 +177,7 @@
 
 		// Karten-Darestellung initialisieren
 		this.mapPane.setBorder(BorderFactory.createLoweredBevelBorder());
-		this.mapPane.setPreferredSize(new Dimension(200, mapPane
-				.getPreferredSize().height));
+		SwingUtil.setPreferredWidth(this.mapPane, 200);
 
 		// MapListener that listens to Scale and MapArea changes
 		this.mapPane.addMapPaneListener(new JMapPaneListener() {
@@ -278,6 +279,25 @@
 		removeAll();
 		disposed = true;
 	}
+	
+	/**
+	 * Nuetzlich wenn die Componente gedruckt (z.B. wenn ein Screenshot gemacht
+	 * wird) wird. Dann werden wird der Hintergrund auf WEISS gesetzt.
+	 * 
+	 * @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons
+	 *         Kr&uuml;ger</a>
+	 */
+	@Override
+	public void print(Graphics g) {
+		final Color orig = getBackground();
+		setBackground(Color.WHITE);
+		// wrap in try/finally so that we always restore the state
+		try {
+			super.print(g);
+		} finally {
+			setBackground(orig);
+		}
+	}
 
 	// /**
 	// * Trying to reproduce a bug #37

Modified: trunk/src/schmitzm/geotools/gui/GridPanel.java
===================================================================
--- trunk/src/schmitzm/geotools/gui/GridPanel.java	2009-07-02 14:23:36 UTC (rev 179)
+++ trunk/src/schmitzm/geotools/gui/GridPanel.java	2009-07-02 14:44:57 UTC (rev 180)
@@ -11,6 +11,7 @@
 
 package schmitzm.geotools.gui;
 
+import java.awt.Color;
 import java.awt.Graphics;
 import java.awt.geom.AffineTransform;
 import java.text.DecimalFormat;
@@ -353,4 +354,25 @@
 
     return diff0_GCRS > diff1_GCRS ? 0 : 1;
   }
+  
+  /**
+   * Nuetzlich wenn die Componente gedruckt (z.B. wenn ein Screenshot gemacht wird) wird. Dann werden wird der
+   * Hintergrund auf WEISS gesetzt.
+   *
+   * @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons
+   *         Kr&uuml;ger</a>
+   */
+  @Override
+  public void print(Graphics g) {
+      Color orig = getBackground();
+      setBackground(Color.WHITE);
+
+      // wrap in try/finally so that we always restore the state
+      try {
+          super.print(g);
+      } finally {
+          setBackground(orig);
+      }
+  }
+
 }

Modified: trunk/src/schmitzm/geotools/gui/MapPaneStatusBar.java
===================================================================
--- trunk/src/schmitzm/geotools/gui/MapPaneStatusBar.java	2009-07-02 14:23:36 UTC (rev 179)
+++ trunk/src/schmitzm/geotools/gui/MapPaneStatusBar.java	2009-07-02 14:44:57 UTC (rev 180)
@@ -12,6 +12,8 @@
 package schmitzm.geotools.gui;
 
 import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Graphics;
 
 import javax.swing.SwingConstants;
 
@@ -66,4 +68,23 @@
     mapPane.addMouseListener(geoPositionLabel);
     mapPane.addMouseMotionListener(geoPositionLabel);
   }
+  
+  /**
+   * Nuetzlich wenn die Componente gedruckt (z.B. wenn ein Screenshot gemacht wird) wird. Dann werden wird der
+   * Hintergrund auf WEISS gesetzt.
+   *
+   * @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons
+   *         Kr&uuml;ger</a>
+   */
+  @Override
+  public void print(Graphics g) {
+      Color orig = getBackground();
+      setBackground(Color.WHITE);
+      // wrap in try/finally so that we always restore the state
+      try {
+          super.print(g);
+      } finally {
+          setBackground(orig);
+      }
+  }
 }

Modified: trunk/src/schmitzm/geotools/gui/ScalePane.java
===================================================================
--- trunk/src/schmitzm/geotools/gui/ScalePane.java	2009-07-02 14:23:36 UTC (rev 179)
+++ trunk/src/schmitzm/geotools/gui/ScalePane.java	2009-07-02 14:44:57 UTC (rev 180)
@@ -11,6 +11,8 @@
 
 package schmitzm.geotools.gui;
 
+import java.awt.Color;
+import java.awt.Graphics;
 import java.awt.GridBagConstraints;
 import java.awt.GridBagLayout;
 import java.awt.Insets;
@@ -83,4 +85,28 @@
     scaleLabel.setText(pixels+" pixel = 1m");
     repaint();
   }
+  
+  /**
+   * Nuetzlich wenn die Componente gedruckt (z.B. wenn ein Screenshot gemacht wird) wird. Dann werden wird der
+   * Hintergrund auf WEISS gesetzt.
+   *
+   * @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons
+   *         Kr&uuml;ger</a>
+   */
+  @Override
+  public void print(Graphics g) {
+      final Color orig = getBackground();
+      setBackground(Color.WHITE);
+      // remove the informatil   xxx pixel = 1m
+      final String backupPixelText = scaleLabel.getText();
+      scaleLabel.setText("");
+      // wrap in try/finally so that we always restore the state
+      try {
+          super.print(g);
+      } finally {
+          setBackground(orig);
+          scaleLabel.setText(backupPixelText);
+      }
+  }
+
 }

Modified: trunk/src/schmitzm/geotools/styling/StylingUtil.java
===================================================================
--- trunk/src/schmitzm/geotools/styling/StylingUtil.java	2009-07-02 14:23:36 UTC (rev 179)
+++ trunk/src/schmitzm/geotools/styling/StylingUtil.java	2009-07-02 14:44:57 UTC (rev 180)
@@ -13,6 +13,7 @@
 
 import java.awt.Color;
 import java.awt.Dimension;
+import java.awt.Graphics;
 import java.awt.image.BufferedImage;
 import java.io.ByteArrayInputStream;
 import java.io.File;
@@ -32,6 +33,7 @@
 import java.util.TreeMap;
 
 import javax.swing.Box;
+import javax.swing.BoxLayout;
 import javax.swing.ImageIcon;
 import javax.swing.JLabel;
 import javax.units.Unit;
@@ -1628,8 +1630,28 @@
 	public static Box createLegendPanel(
 			FeatureTypeStyle[] featureTypeStyles, FeatureType featureType) {
 
-		Box box = Box.createVerticalBox();
+		Box box = new Box(BoxLayout.Y_AXIS){
 
+			/**
+			 * Nuetzlich wenn die Componente gedruckt (z.B. wenn ein Screenshot gemacht
+			 * wird) wird. Dann werden wird der Hintergrund auf WEISS gesetzt.
+			 * 
+			 * @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons
+			 *         Kr&uuml;ger</a>
+			 */
+			@Override
+			public void print(Graphics g) {
+				final Color orig = getBackground();
+				setBackground(Color.WHITE);
+				// wrap in try/finally so that we always restore the state
+				try {
+					super.print(g);
+				} finally {
+					setBackground(orig);
+				}
+			}
+		};
+
 		for (FeatureTypeStyle ftStyle : featureTypeStyles) {
 
 			// One child-node for every rule
@@ -1644,8 +1666,28 @@
 						.size() == rule.getSymbolizers().length)
 					continue;
 
-				Box hbox = Box.createHorizontalBox();
+				Box hbox = new Box( BoxLayout.X_AXIS){
 
+					/**
+					 * Nuetzlich wenn die Componente gedruckt (z.B. wenn ein Screenshot gemacht
+					 * wird) wird. Dann werden wird der Hintergrund auf WEISS gesetzt.
+					 * 
+					 * @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons
+					 *         Kr&uuml;ger</a>
+					 */
+					@Override
+					public void print(Graphics g) {
+						final Color orig = getBackground();
+						setBackground(Color.WHITE);
+						// wrap in try/finally so that we always restore the state
+						try {
+							super.print(g);
+						} finally {
+							setBackground(orig);
+						}
+					}
+				};
+
 				/**
 				 * The size of the legend Symbol is dependent on the size of the font.
 				 */

Modified: trunk/src/skrueger/geotools/MapPaneToolBar.java
===================================================================
--- trunk/src/skrueger/geotools/MapPaneToolBar.java	2009-07-02 14:23:36 UTC (rev 179)
+++ trunk/src/skrueger/geotools/MapPaneToolBar.java	2009-07-02 14:44:57 UTC (rev 180)
@@ -1,6 +1,8 @@
 package skrueger.geotools;
 
+import java.awt.Color;
 import java.awt.Dimension;
+import java.awt.Graphics;
 import java.awt.event.ActionEvent;
 import java.util.ArrayList;
 import java.util.Locale;
@@ -795,4 +797,23 @@
 			return id;
 		}
 	}
+	
+	  /**
+	   * Nuetzlich wenn die Componente gedruckt (z.B. wenn ein Screenshot gemacht wird) wird. Dann werden wird der
+	   * Hintergrund auf WEISS gesetzt.
+	   *
+	   * @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons
+	   *         Kr&uuml;ger</a>
+	   */
+	  @Override
+	  public void print(Graphics g) {
+	      Color orig = getBackground();
+	      setBackground(Color.WHITE);
+	      // wrap in try/finally so that we always restore the state
+	      try {
+	          super.print(g);
+	      } finally {
+	          setBackground(orig);
+	      }
+	  }
 }



More information about the Schmitzm-commits mailing list