[Schmitzm-commits] r1370 - in trunk/src: schmitzm/geotools/gui schmitzm/geotools/gui/resource/locales skrueger/geotools skrueger/swing

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Mon Jan 17 16:18:05 CET 2011


Author: alfonx
Date: 2011-01-17 16:18:04 +0100 (Mon, 17 Jan 2011)
New Revision: 1370

Added:
   trunk/src/skrueger/geotools/LogoPosition.java
Modified:
   trunk/src/schmitzm/geotools/gui/XMapPane.java
   trunk/src/schmitzm/geotools/gui/resource/locales/GTResourceBundle.properties
   trunk/src/skrueger/swing/CancellableTabbedDialogAdapter.java
Log:
Gp-Feature: The position of the maplogo can now be defined: TOP-LEFT, BOTTOM-RIGHT etc...

Modified: trunk/src/schmitzm/geotools/gui/XMapPane.java
===================================================================
--- trunk/src/schmitzm/geotools/gui/XMapPane.java	2011-01-16 12:34:56 UTC (rev 1369)
+++ trunk/src/schmitzm/geotools/gui/XMapPane.java	2011-01-17 15:18:04 UTC (rev 1370)
@@ -78,6 +78,7 @@
 import schmitzm.swing.JPanel;
 import schmitzm.swing.SwingUtil;
 import schmitzm.swing.event.MouseInputType;
+import skrueger.geotools.LogoPosition;
 import skrueger.geotools.RenderingExecutor;
 import skrueger.i8n.Translation;
 
@@ -405,14 +406,15 @@
 	private BufferedImage finalImage;
 
 	/**
-	 * Optionally a transparent image to paint over the map in the lower right
-	 * corner.
+	 * Optionally a transparent image to paint over the map in a map-corner.
 	 * 
 	 * @see #addGadgets(Graphics2D)
 	 * @see #setMapImage(BufferedImage)
 	 **/
 	private BufferedImage mapImage = null;
 
+	private LogoPosition mapImagePos = LogoPosition.BOTTOMRIGHT;
+
 	/**
 	 * Listens to each layer in the local {@link MapContext} for changes and
 	 * triggers repaints.
@@ -2105,13 +2107,14 @@
 	}
 
 	/**
-	 * Set the BufferedImage to use as a flaoting icon in the lower right corner
+	 * Set the BufferedImage to use as a flaoting icon in a corner of the map.
 	 * 
 	 * @param mapImageIcon
 	 *            <code>null</code> is allowed and deactivates this icon.
 	 */
-	public void setMapImage(final BufferedImage mapImage) {
+	public void setMapImage(final BufferedImage mapImage, LogoPosition pos) {
 		this.mapImage = mapImage;
+		this.mapImagePos = pos;
 	}
 
 	/**
@@ -2429,13 +2432,25 @@
 	private void addGadgets(final Graphics2D graphics, final boolean forceWait) {
 
 		// TODO Position the logo
-		
+
 		// Paint a logo to the bottom right if available
 		if (mapImage != null) {
 			final Rectangle visibleRect = getMapPaneSize();
-			graphics.drawImage(mapImage,
-					visibleRect.width - mapImage.getWidth() - 10,
-					getMapPaneSize().height - mapImage.getHeight() - 10, null);
+
+			int x;
+			int y;
+
+			if (mapImagePos.isBottom())
+				y = getMapPaneSize().height - mapImage.getHeight() - 10;
+			else
+				y = 10;
+
+			if (mapImagePos.isLeft())
+				x = 10;
+			else
+				x = visibleRect.width - mapImage.getWidth() - 10;
+
+			graphics.drawImage(mapImage, x, y, null);
 		}
 
 		int y = 17;
@@ -2655,22 +2670,6 @@
 		final Point2D mapCoord = getScreenToWorld().transform(point, null);
 
 		return zoomTowards(mapCoord, zFactor);
-		//
-		// double relX = (mapCoord.getX() - getMapArea().getMinX())
-		// / getMapArea().getWidth();
-		// double relY = (mapCoord.getY() - getMapArea().getMinY())
-		// / getMapArea().getHeight();
-		//
-		// // Neuen Karten-Ausschnitt berechnen
-		// Coordinate ll = new Coordinate(mapCoord.getX()
-		// - getMapArea().getWidth() * relX * zFactor, mapCoord.getY()
-		// - getMapArea().getHeight() * relY * zFactor);
-		// Coordinate ur = new Coordinate(mapCoord.getX()
-		// + getMapArea().getWidth() * (1 - relX) * zFactor,
-		// mapCoord.getY() + getMapArea().getHeight() * (1 - relY)
-		// * zFactor);
-		//
-		// return setMapArea(new Envelope(ll, ur));
 	}
 
 	/**
@@ -3043,7 +3042,8 @@
 	}
 
 	/**
-	 * Converts an OGC ScaleDenominator to a Scale as retuned by {@link #getScale()}
+	 * Converts an OGC ScaleDenominator to a Scale as retuned by
+	 * {@link #getScale()}
 	 */
 	public Double calculateScaleDenominatortoScale(double scaleDenominator,
 			double width2) {

Modified: trunk/src/schmitzm/geotools/gui/resource/locales/GTResourceBundle.properties
===================================================================
--- trunk/src/schmitzm/geotools/gui/resource/locales/GTResourceBundle.properties	2011-01-16 12:34:56 UTC (rev 1369)
+++ trunk/src/schmitzm/geotools/gui/resource/locales/GTResourceBundle.properties	2011-01-17 15:18:04 UTC (rev 1370)
@@ -193,3 +193,8 @@
 
 ScalePane.OGCScaleDenominator=Scale: 1:${0}
 ScalePane.PixelMetersScale=1 pixel = {0} meters
+
+Logoposition.TOPRIGHT=top-right
+Logoposition.BOTTOMRIGHT=bottom-right
+Logoposition.TOPLEFT=top-left
+Logoposition.BOTTOMLEFT=bottom-left
\ No newline at end of file

Added: trunk/src/skrueger/geotools/LogoPosition.java
===================================================================
--- trunk/src/skrueger/geotools/LogoPosition.java	2011-01-16 12:34:56 UTC (rev 1369)
+++ trunk/src/skrueger/geotools/LogoPosition.java	2011-01-17 15:18:04 UTC (rev 1370)
@@ -0,0 +1,22 @@
+package skrueger.geotools;
+
+import schmitzm.geotools.gui.GeotoolsGUIUtil;
+
+/**
+ * Possible values where to position a maplogo on the map
+ */
+public enum LogoPosition {
+	TOPRIGHT, TOPLEFT, BOTTOMRIGHT, BOTTOMLEFT;
+
+	public String getDescription() {
+		return GeotoolsGUIUtil.R("Logoposition." + this.toString());
+	}
+
+	public boolean isBottom() {
+		return this == BOTTOMLEFT || this == BOTTOMRIGHT;
+	}
+
+	public boolean isLeft() {
+		return this == BOTTOMLEFT || this == TOPLEFT;
+	}
+}


Property changes on: trunk/src/skrueger/geotools/LogoPosition.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Id URL
Name: svn:eol-style
   + native

Modified: trunk/src/skrueger/swing/CancellableTabbedDialogAdapter.java
===================================================================
--- trunk/src/skrueger/swing/CancellableTabbedDialogAdapter.java	2011-01-16 12:34:56 UTC (rev 1369)
+++ trunk/src/skrueger/swing/CancellableTabbedDialogAdapter.java	2011-01-17 15:18:04 UTC (rev 1370)
@@ -16,8 +16,8 @@
 
 	private final JTabbedPane tabbedPane;
 
-	public CancellableTabbedDialogAdapter(Component owner) {
-		super(owner);
+	public CancellableTabbedDialogAdapter(Component owner, String title) {
+		super(owner, title);
 
 		/**
 		 * Prepare buttons
@@ -25,7 +25,7 @@
 		final JPanel buttons = createButtons();
 
 		/*** Build GUI ***/
-		tabbedPane = new JTabbedPane(){
+		tabbedPane = new JTabbedPane() {
 			@Override
 			public void insertTab(String title, Icon icon, Component component,
 					String tip, int index) {
@@ -45,6 +45,10 @@
 
 	}
 
+	public CancellableTabbedDialogAdapter(Component parentWindow) {
+		this(parentWindow, null);
+	}
+
 	/**
 	 * Is only called once! Doesn't use lazy initialization. Use
 	 * <code>super.createButtons.add( newButton )</code> to add buttons.
@@ -66,8 +70,8 @@
 
 				// Set tool tip text
 				putValue(Action.SHORT_DESCRIPTION,
-						"Accept the changes made in this dialog."); // i8n
-
+						"Accept the changes made in this dialog."); // i8n i8n
+																	// i8n
 			}
 
 			//
@@ -93,9 +97,10 @@
 	public JTabbedPane getTabbedPane() {
 		return tabbedPane;
 	}
-	
+
 	/**
-	 * Calling cancel() will call cancel to all {@link Cancellable} children in the tabbedPane.
+	 * Calling cancel() will call cancel to all {@link Cancellable} children in
+	 * the tabbedPane.
 	 */
 	@Override
 	public void cancel() {
@@ -109,7 +114,6 @@
 		}
 	}
 
-
 	@Override
 	public boolean okClose() {
 		// TranslationAskJDialog.this.firePropertyChange(



More information about the Schmitzm-commits mailing list