[Schmitzm-commits] r1533 - in trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools: gui map/event styling

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Sun Mar 20 20:45:02 CET 2011


Author: alfonx
Date: 2011-03-20 20:45:02 +0100 (Sun, 20 Mar 2011)
New Revision: 1533

Modified:
   trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/gui/SelectableXMapPane.java
   trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/map/event/ScaleChangedEvent.java
   trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/styling/StyledLayerUtil.java
Log:
Legends are now rendered scale dependent

Modified: trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/gui/SelectableXMapPane.java
===================================================================
--- trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/gui/SelectableXMapPane.java	2011-03-20 18:36:33 UTC (rev 1532)
+++ trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/gui/SelectableXMapPane.java	2011-03-20 19:45:02 UTC (rev 1533)
@@ -908,6 +908,7 @@
 	@Override
 	public boolean setMapArea(ReferencedEnvelope newMapArea) {
 		double oldScale = getScale();
+		double oldScaleDenom = getScaleDenominator();
 
 		boolean b = super.setMapArea(newMapArea);
 
@@ -917,7 +918,7 @@
 				// no scale
 				// if (oldScale != getScale())
 				fireMapPaneEvent(new ScaleChangedEvent(this, oldScale,
-						getScale()));
+						oldScaleDenom, getScale()));
 			}
 			fireMapPaneEvent(new MapAreaChangedEvent(this, oldMapArea,
 					getMapArea()));

Modified: trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/map/event/ScaleChangedEvent.java
===================================================================
--- trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/map/event/ScaleChangedEvent.java	2011-03-20 18:36:33 UTC (rev 1532)
+++ trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/map/event/ScaleChangedEvent.java	2011-03-20 19:45:02 UTC (rev 1533)
@@ -44,6 +44,7 @@
 	private double oldScale = 0;
 	private double newScale = 0;
 	private final double newScaleDenominator;
+	private final double oldScaleDenominator;
 
 	/**
 	 * Erzeugt ein neues Ereignis.
@@ -52,11 +53,13 @@
 	 *            vormalige Aufloesung
 	 * @param newScale
 	 *            neue Aufloesung
+	 * @param d
 	 */
 	public ScaleChangedEvent(SelectableXMapPane source, double oldScale,
-			double newScale) {
+			double oldScaleDenominator, double newScale) {
 		super(source);
 		this.oldScale = oldScale;
+		this.oldScaleDenominator = oldScaleDenominator;
 		this.newScale = newScale;
 		this.newScaleDenominator = source.getScaleDenominator();
 	}
@@ -81,4 +84,11 @@
 	public double getNewScaleDenominator() {
 		return newScaleDenominator;
 	}
+
+	/**
+	 * Liefert die alte Aufloesung als OGC ScaleDenominator.
+	 */
+	public double getOldScaleDenominator() {
+		return oldScaleDenominator;
+	}
 }

Modified: trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/styling/StyledLayerUtil.java
===================================================================
--- trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/styling/StyledLayerUtil.java	2011-03-20 18:36:33 UTC (rev 1532)
+++ trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/styling/StyledLayerUtil.java	2011-03-20 19:45:02 UTC (rev 1533)
@@ -1030,10 +1030,10 @@
 				 * inclusive and the maximum scale is exclusive. So, for
 				 * example, the following scale range:
 				 */
-				if (scaleDenominator != null
+				if (scaleDenominator != null && scaleDenominator != 0.0
 						&& scaleDenominator < rule.getMinScaleDenominator())
 					continue;
-				if (scaleDenominator != null
+				if (scaleDenominator != null && scaleDenominator != 0.0
 						&& scaleDenominator >= rule.getMaxScaleDenominator())
 					continue;
 
@@ -1629,4 +1629,36 @@
 		}
 		return attMap;
 	}
+
+	/**
+	 * Returns <code>true</code> is changing the zoom from oldScaleDenominator
+	 * to newScaleDenominator would result in a another styling.
+	 * 
+	 * TODO This is not evaluating the AtlasStlyer diabled classes Filters yet!
+	 */
+	public static boolean hasScalechangeAnyEffect(Style style,
+			double oldScaleDenominator, double newScaleDenominator) {
+
+		for (FeatureTypeStyle fts : style.featureTypeStyles()) {
+			for (Rule r : fts.rules()) {
+				double minScale = r.getMinScaleDenominator();
+				double maxScale = r.getMaxScaleDenominator();
+				if (oldScaleDenominator < minScale
+						&& newScaleDenominator >= minScale)
+					return true;
+				if (oldScaleDenominator >= minScale
+						&& newScaleDenominator < minScale)
+					return true;
+
+				if (oldScaleDenominator < maxScale
+						&& newScaleDenominator >= maxScale)
+					return true;
+				if (oldScaleDenominator >= maxScale
+						&& newScaleDenominator < maxScale)
+					return true;
+			}
+		}
+
+		return false;
+	}
 }



More information about the Schmitzm-commits mailing list