[Schmitzm-commits] r1269 - in trunk/src/schmitzm/geotools: . gui

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Sat Nov 13 23:34:29 CET 2010


Author: alfonx
Date: 2010-11-13 23:34:29 +0100 (Sat, 13 Nov 2010)
New Revision: 1269

Modified:
   trunk/src/schmitzm/geotools/FilterUtil.java
   trunk/src/schmitzm/geotools/gui/XMapPane.java
Log:
All RuleListTypes can be en- and disabled individually now. New AS GUI making progress

Modified: trunk/src/schmitzm/geotools/FilterUtil.java
===================================================================
--- trunk/src/schmitzm/geotools/FilterUtil.java	2010-11-13 17:12:29 UTC (rev 1268)
+++ trunk/src/schmitzm/geotools/FilterUtil.java	2010-11-13 22:34:29 UTC (rev 1269)
@@ -67,7 +67,7 @@
 			FILTER_FAC2.literal("NEVER"), FILTER_FAC2.literal("TRUE"));
 
 	/**
-	 * Problem: If <or><boolena expression></or> is used, the filter works fine
+	 * Problem: If <or><boolean expression></or> is used, the filter works fine
 	 * in Geotools, BUT it is not validated: <br/>
 	 * <code>org.xml.sax.SAXParseException: cvc-complex-type.2.4.b: The content of element 'ogc:Or' is not
 	 * complete. One of '{"http://www.opengis.net/ogc":comparisonOps,
@@ -76,15 +76,26 @@
 	 * Hence, to comply with SLD validity, if there is only one element in the
 	 * <code>ors</code> list, we remove the or around it.
 	 */
-	public static Filter correctOrForValidation(Or or) {
+	public static Or correctOrForValidation(Or or) {
 
 		List<Filter> ors = or.getChildren();
 
 		if (ors.size() == 0)
-			return NEVER_TRUE_FILTER;
-		if (ors.size() == 1)
-			return ors.get(0);
+			return FILTER_FAC2.or(NEVER_TRUE_FILTER, NEVER_TRUE_FILTER);
+		if (ors.size() == 1) {
+			/**
+			 * Return a an or, with the only element doubled. Hope this does not
+			 * produce horrible long XML. This must "play nice" with the parsing
+			 * logic: addFilter... and parseFilter.... Other options would be to
+			 * return the onyl child or an allwaysTrueFilter.
+			 */
+			// return ors.get(0);
 
+			ors.add(ors.get(0));
+			FILTER_FAC2.or(ors);
+			return or;
+		}
+
 		return or;
 	}
 

Modified: trunk/src/schmitzm/geotools/gui/XMapPane.java
===================================================================
--- trunk/src/schmitzm/geotools/gui/XMapPane.java	2010-11-13 17:12:29 UTC (rev 1268)
+++ trunk/src/schmitzm/geotools/gui/XMapPane.java	2010-11-13 22:34:29 UTC (rev 1269)
@@ -646,6 +646,7 @@
 		this(null, null);
 	}
 
+	@Override
 	protected void finalize() throws Throwable {
 		dispose();
 	};
@@ -1678,7 +1679,7 @@
 
 	@Override
 	protected void paintComponent(final Graphics g) {
-		
+
 		setBackground(Color.blue);
 
 		// Maybe update the cursor and maybe stop the repainting timer
@@ -1956,6 +1957,7 @@
 
 	}
 
+	@Override
 	public void setBorder(final Border b) {
 		super.setBorder(b);
 	}
@@ -2605,25 +2607,42 @@
 	 * at the same positino in screen coordinates.
 	 * 
 	 * @param point
-	 *            fixed {@link Point} that will be at the same screen poistion
-	 *            after zoom.
+	 *            fixed {@link Point} in screen coordinates that will be at the
+	 *            same screen position after zoom.
 	 */
 	public boolean zoomTowards(Point point, Double zFactor) {
-		// int units = wheelEvt.getUnitsToScroll();
+		final Point2D mapCoord = getScreenToWorld().transform(point, null);
+
+		return zoomTowards(mapCoord, zFactor);
 		//
-		// Negativer Wert --> Zoom out --> Faktir > 1
+		// 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));
+	}
 
-		// SK: 9.9.2007 zoom jetzt wie bei GoogleEarth
-		// double zFactor = units > 0 ? 1.3 : 1 / 1.3;
-		// vorher double zFactor = units > 0 ? 1/1.2 : 1.2;
+	/**
+	 * Zooms in or out in a way, that the given {@link Point} on the map stays
+	 * at the same positino in screen coordinates.
+	 * 
+	 * @param point
+	 *            fixed {@link Point2D} in map CRS coordinates that will be at
+	 *            the same screen position after zoom.
+	 */
+	public boolean zoomTowards(Point2D coordinate, Double zFactor) {
+		final Point2D mapCoord = coordinate;
 
-		// Fenster-Koordinaten zu Karten-Koordinaten transformieren
-		// Point2D mapCoord = XMapPane.getMapCoordinatesFromEvent(wheelEvt);
-		// Relative Position des Mauszeigers zum Kartenausschnitt
-		// -> Nach Zoom soll dieselbe Kartenposition unterhalb des Mauszeigers
-		// erscheinen, wie vor dem Zoom
-		final Point2D mapCoord = getScreenToWorld().transform(point, null);
-
 		double relX = (mapCoord.getX() - getMapArea().getMinX())
 				/ getMapArea().getWidth();
 		double relY = (mapCoord.getY() - getMapArea().getMinY())
@@ -2960,4 +2979,8 @@
 		return renderLanguage;
 	}
 
+	public void zoomTowards(Coordinate centre, double zFactor) {
+		zoomTowards(new Point2D.Double(centre.x, centre.y), zFactor);
+	}
+
 }



More information about the Schmitzm-commits mailing list