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

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Fri Oct 23 14:36:00 CEST 2009


Author: alfonx
Date: 2009-10-23 14:35:59 +0200 (Fri, 23 Oct 2009)
New Revision: 490

Modified:
   branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/JMapPane.java
   branches/1.0-gt2-2.6/src/schmitzm/swing/SwingUtil.java
   branches/1.0-gt2-2.6/src/skrueger/geotools/StyledFeatureCollectionTableModel.java
   branches/1.0-gt2-2.6/src/skrueger/swing/AtlasDialog.java
   branches/1.0-gt2-2.6/src/skrueger/swing/TranslationEditJPanel.java
Log:
setRelWindowPosition auf Component umgestellt


Modified: branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/JMapPane.java
===================================================================
--- branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/JMapPane.java	2009-10-20 20:04:38 UTC (rev 489)
+++ branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/JMapPane.java	2009-10-23 12:35:59 UTC (rev 490)
@@ -523,9 +523,9 @@
 						// verwenden, so dass die erste
 						// Karte komplett angezeigt wird
 						if (getMapArea() == null) {
-//							Envelope newMapArea = new Envelope(e.getLayer()
-//									.getFeatureSource().getBounds());
-						    Envelope newMapArea = getMaxExtend();
+							// Envelope newMapArea = new Envelope(e.getLayer()
+							// .getFeatureSource().getBounds());
+							Envelope newMapArea = getMaxExtend();
 							setMapArea(newMapArea);
 							// in layerAdded(.) der Oberklasse wird
 							// mapArea nochmal neu gesetzt, wenn das
@@ -705,7 +705,48 @@
 				mapAreaNew = JTSUtil.transformEnvelope(layer.getFeatureSource()
 						.getBounds(), sourceCRS, targetCRS);
 			} else {
-				mapAreaNew = layer.getFeatureSource().getBounds();
+				try {
+					mapAreaNew = layer.getFeatureSource().getBounds();
+				} catch (java.lang.IllegalArgumentException e) {
+					LOGGER.error("Can't calc layers bounds...",e);
+					mapAreaNew = null;
+					
+					/**
+					 * 
+					 23.10.2009 11:20:50
+					 * org.geotools.data.shapefile.shp.PolygonHandler read
+					 * WARNUNG: only one hole in this polygon record ERROR
+					 * JMapPane zoomToLayer Zoom to layer did not terminate
+					 * correctly java.lang.IllegalArgumentException: Points of
+					 * LinearRing do not form a closed linestring at
+					 * com.vividsolutions
+					 * .jts.geom.LinearRing.validateConstruction
+					 * (LinearRing.java:105) at
+					 * com.vividsolutions.jts.geom.LinearRing
+					 * .<init>(LinearRing.java:100) at
+					 * com.vividsolutions.jts.geom
+					 * .GeometryFactory.createLinearRing
+					 * (GeometryFactory.java:339) at
+					 * org.geotools.data.shapefile.
+					 * shp.PolygonHandler.read(PolygonHandler.java:188) at
+					 * org.geotools
+					 * .data.shapefile.shp.ShapefileReader$Record.shape
+					 * (ShapefileReader.java:106) at
+					 * org.geotools.data.shapefile.
+					 * ShapefileAttributeReader.next(
+					 * ShapefileAttributeReader.java:157) at
+					 * org.geotools.data.shapefile
+					 * .indexed.IndexedShapefileAttributeReader
+					 * .next(IndexedShapefileAttributeReader.java:122) at
+					 * org.geotools
+					 * .data.FIDFeatureReader.next(FIDFeatureReader.java:96) at
+					 * org.geotools.data.FIDFeatureReader.next(FIDFeatureReader.
+					 * java:55) at org.geotools.data.MaxFeatureReader.next(
+					 * MaxFeatureReader.java:61) at
+					 * org.geotools.data.MaxFeatureReader
+					 * .next(MaxFeatureReader.java:61)
+					 **/
+				}
 			}
 
 			// Kartenbereich um 10% vergroessern, damit z.B. auch ein
@@ -1061,7 +1102,12 @@
 		// vorher double zFactor = units > 0 ? 1/1.2 : 1.2;
 
 		// Fenster-Koordinaten zu Karten-Koordinaten transformieren
-		Point2D mapCoord = getTransform().transform(e.getPoint(), null);
+		final AffineTransform transform2 = getTransform();
+		if (transform2 == null){
+			LOGGER.warn("No transform can be created! Skipping MouseWheel performAction.");
+			return;
+		}
+		Point2D mapCoord = transform2.transform(e.getPoint(), null);
 		// Relative Position des Mauszeigers zum Kartenausschnitt
 		// -> Nach Zoom soll dieselbe Kartenposition unterhalb des Mauszeigers
 		// erscheinen, wie vor dem Zoom
@@ -1280,7 +1326,8 @@
 				// state, envelope);
 
 				final Envelope smallBox = new Envelope(geoCoord.getX() - dist,
-						geoCoord.getY() -dist, geoCoord.getX()+dist, geoCoord.getY()+dist);
+						geoCoord.getY() - dist, geoCoord.getX() + dist,
+						geoCoord.getY() + dist);
 
 				Hashtable<MapLayer, FeatureCollection<SimpleFeatureType, SimpleFeature>> result = findVisibleFeatures(
 						new BoundingBoxFilterGenerator(smallBox, getContext()

Modified: branches/1.0-gt2-2.6/src/schmitzm/swing/SwingUtil.java
===================================================================
--- branches/1.0-gt2-2.6/src/schmitzm/swing/SwingUtil.java	2009-10-20 20:04:38 UTC (rev 489)
+++ branches/1.0-gt2-2.6/src/schmitzm/swing/SwingUtil.java	2009-10-23 12:35:59 UTC (rev 490)
@@ -428,8 +428,8 @@
 	 * @param comp
 	 *            Eine Komponente des zu positionierenden Fensters oder direkt
 	 *            das {@link Window}.
-	 * @param relFrame
-	 *            Fenster zu dem das Fenster in Relation gesetzt wird (wenn
+	 * @param relComp
+	 *            Fenster (parent Fenster der übergebenen Componente) zu dem das Fenster in Relation gesetzt wird (wenn
 	 *            <code>null</code> wird der gesamte Monitor verwendet)
 	 * @param relX
 	 *            Relationsfaktor fuer die horizontale Position (0 <
@@ -439,22 +439,16 @@
 	 *            <code>relY</code> < 1)
 	 */
 	public static void setRelativeFramePosition(Component comp,
-			Window relFrame, double relX, double relY) {
-
+			Component relComp, double relX, double relY) {
+		
 		// Added by SK, 17.4.2009
-		// sk.sc
-		Window window;
-		if (comp instanceof Window) {
-			window = (Window) comp;
-		} else {
-			window = SwingUtil.getParentWindow(comp);
-		}
-		// sk.ec
+		Window window = SwingUtil.getParentWindow(comp);
+		relComp = getParentWindow(comp);
 
 		Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
-		Dimension relSize = (relFrame == null) ? screenSize : relFrame
+		Dimension relSize = (relComp == null) ? screenSize : relComp
 				.getSize();
-		Point relLocation = (relFrame == null) ? new Point(0, 0) : relFrame
+		Point relLocation = (relComp == null) ? new Point(0, 0) : relComp
 				.getLocation();
 
 		// Fenster auf Monitor-Groesse anpassen
@@ -491,8 +485,15 @@
 	 *            Positionierung des Fensters ({@link #NORTH},
 	 *            {@link #NORTHEAST}, ...)
 	 */
-	public static void setRelativeFramePosition(Window window,
-			Window relWindow, int type, int position) {
+	public static void setRelativeFramePosition(Component comp,
+			Component relWindow, int type, int position) {
+		
+		
+		// Added by SK, 23.10.2009
+		Window window = SwingUtil.getParentWindow(comp);
+		
+		relWindow = SwingUtil.getParentWindow(relWindow);
+		
 		if (type == BOUNDS_INNER) {
 			// An den inneren Grenzen des Frames ausrichten
 			double relX = 0;
@@ -553,7 +554,8 @@
 			case NORTH:
 			case NORTHWEST:
 			case NORTHEAST:
-				loc.y = relLocation.y - window.getHeight();
+				loc.y = relLocation.y; // Oben bündig ist schöner, oder?
+//				loc.y = relLocation.y - window.getHeight();
 				break;
 			case SOUTH:
 			case SOUTHWEST:

Modified: branches/1.0-gt2-2.6/src/skrueger/geotools/StyledFeatureCollectionTableModel.java
===================================================================
--- branches/1.0-gt2-2.6/src/skrueger/geotools/StyledFeatureCollectionTableModel.java	2009-10-20 20:04:38 UTC (rev 489)
+++ branches/1.0-gt2-2.6/src/skrueger/geotools/StyledFeatureCollectionTableModel.java	2009-10-23 12:35:59 UTC (rev 490)
@@ -133,8 +133,16 @@
 				LOGGER.debug("Query contains the following attributes: "
 						+ visibleAttrNames);
 
-				query = new DefaultQuery(schema.getTypeName(), filter,
-						properties);
+
+				/**
+				 * I got NPEs when properties contained only [the_geom] ?!??!!??
+				 */
+				if (properties.length > 1) {
+					query = new DefaultQuery(schema.getTypeName(), filter,
+							properties);
+				} else {
+					query = new DefaultQuery(schema.getTypeName(), filter);
+				}
 			}
 			fc = fs.getFeatures(query);
 		}

Modified: branches/1.0-gt2-2.6/src/skrueger/swing/AtlasDialog.java
===================================================================
--- branches/1.0-gt2-2.6/src/skrueger/swing/AtlasDialog.java	2009-10-20 20:04:38 UTC (rev 489)
+++ branches/1.0-gt2-2.6/src/skrueger/swing/AtlasDialog.java	2009-10-23 12:35:59 UTC (rev 490)
@@ -16,13 +16,16 @@
 
 public class AtlasDialog extends JDialog {
 
+	protected final Component parentWindow;
+
 	public AtlasDialog(final Component parentWindow, String title) {
 		super(SwingUtil.getParentWindow(parentWindow), title);
+		this.parentWindow = SwingUtil.getParentWindow(parentWindow);
 		initDialog();
 	}
 
-	public AtlasDialog(final Component parentWindow) {
-		this(parentWindow, null);
+	public AtlasDialog(final Component parentWindowComponent) {
+		this(parentWindowComponent, null);
 	}
 
 	private void initDialog() {

Modified: branches/1.0-gt2-2.6/src/skrueger/swing/TranslationEditJPanel.java
===================================================================
--- branches/1.0-gt2-2.6/src/skrueger/swing/TranslationEditJPanel.java	2009-10-20 20:04:38 UTC (rev 489)
+++ branches/1.0-gt2-2.6/src/skrueger/swing/TranslationEditJPanel.java	2009-10-23 12:35:59 UTC (rev 490)
@@ -49,6 +49,7 @@
 
 import schmitzm.swing.JPanel;
 import schmitzm.swing.SpringUtilities;
+import schmitzm.swing.SwingUtil;
 import skrueger.i8n.Translation;
 
 /**
@@ -91,6 +92,8 @@
 	public TranslationEditJPanel(String question, Translation trans,
 			List<String> languages_) {
 		super(new BorderLayout());
+		
+		SwingUtil.setMinimumWidth(this, 400);
 
 		if (trans == null)
 			trans = new Translation();



More information about the Schmitzm-commits mailing list