[Schmitzm-commits] r436 - in branches/1.0-gt2-2.6/src: gtmig/org/geotools/swing schmitzm/geotools schmitzm/geotools/gui
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Mon Oct 5 13:54:13 CEST 2009
Author: mojays
Date: 2009-10-05 13:54:12 +0200 (Mon, 05 Oct 2009)
New Revision: 436
Modified:
branches/1.0-gt2-2.6/src/gtmig/org/geotools/swing/JMapPane.java
branches/1.0-gt2-2.6/src/schmitzm/geotools/GTUtil.java
branches/1.0-gt2-2.6/src/schmitzm/geotools/JTSUtil.java
branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/JMapPane.java
Log:
Removed some annoying debug messages in GT-JMapPane
New util method JTSUtil.expandEnvelope(..)
JMapPane.getMaxExtend(..) creates a 10% expanded envelope to show the complete map with "some" surrounding
Modified: branches/1.0-gt2-2.6/src/gtmig/org/geotools/swing/JMapPane.java
===================================================================
--- branches/1.0-gt2-2.6/src/gtmig/org/geotools/swing/JMapPane.java 2009-10-04 23:33:30 UTC (rev 435)
+++ branches/1.0-gt2-2.6/src/gtmig/org/geotools/swing/JMapPane.java 2009-10-05 11:54:12 UTC (rev 436)
@@ -58,6 +58,7 @@
import javax.swing.JPanel;
import org.apache.log4j.Logger;
+import org.geotools.geometry.jts.ReferencedEnvelope;
import org.geotools.map.MapContext;
import org.geotools.map.event.MapLayerListEvent;
import org.geotools.map.event.MapLayerListListener;
@@ -69,6 +70,7 @@
import org.opengis.filter.FilterFactory2;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
+import schmitzm.geotools.JTSUtil;
import schmitzm.swing.SwingUtil;
import com.vividsolutions.jts.geom.Coordinate;
@@ -971,20 +973,20 @@
// Exceeds top? Move down and maybe cut
if (newArea.getMaxY() > maxAllowedExtend.getMaxY()) {
double divY = newArea.getMaxY() - maxAllowedExtend.getMaxY();
- LOGGER.debug("Moving area down by " + divY);
+// LOGGER.debug("Moving area down by " + divY);
newArea = new Envelope(new Coordinate(newArea.getMinX(),
newArea.getMinY() - divY), new Coordinate(newArea
.getMaxX(), newArea.getMaxY() - divY));
if (newArea.getMinY() < maxAllowedExtend.getMinY()) {
- LOGGER.debug("Now it exeeds the bottom border.. cut!");
+// LOGGER.debug("Now it exeeds the bottom border.. cut!");
// And cut the bottom if it moved out of the area
newArea = new Envelope(new Coordinate(newArea.getMinX(),
maxAllowedExtend.getMinY()), new Coordinate(newArea
.getMaxX(), newArea.getMaxY()));
- LOGGER.debug("and fix aspect ratio");
+// LOGGER.debug("and fix aspect ratio");
newArea = fixAspectRatio(this.getBounds(), newArea, false);
}
@@ -993,7 +995,7 @@
// Exceeds bottom? Move up and maybe cut
if (newArea.getMinY() < maxAllowedExtend.getMinY()) {
double divY = newArea.getMinY() - maxAllowedExtend.getMinY();
- LOGGER.debug("Moving area up by " + divY);
+// LOGGER.debug("Moving area up by " + divY);
newArea = new Envelope(new Coordinate(newArea.getMinX(),
newArea.getMinY() - divY), new Coordinate(newArea
@@ -1017,7 +1019,7 @@
// Move left..
double divX = newArea.getMaxX() - maxAllowedExtend.getMaxX();
- LOGGER.debug("Moving area left by " + divX);
+// LOGGER.debug("Moving area left by " + divX);
newArea = new Envelope(new Coordinate(newArea.getMinX() - divX,
newArea.getMinY()), new Coordinate(newArea.getMaxX()
@@ -1041,7 +1043,7 @@
// Move right..
double divX = newArea.getMinX() - maxAllowedExtend.getMinX();
- LOGGER.debug("Moving area right by " + divX);
+// LOGGER.debug("Moving area right by " + divX);
newArea = new Envelope(new Coordinate(newArea.getMinX() - divX,
newArea.getMinY()), new Coordinate(newArea.getMaxX()
@@ -1134,10 +1136,14 @@
public Envelope getMaxExtend() {
if (maxExtend == null) {
try {
- return fixAspectRatio(this.getBounds(), context.getLayerBounds(), true);
+ return fixAspectRatio(
+ this.getBounds(),
+ // Kartenbereich um 10% vergroessern
+ JTSUtil.expandEnvelope(context.getLayerBounds(), 0.1),
+ true
+ );
} catch (IOException e) {
- LOGGER
- .warn(
+ LOGGER.warn(
"maxExtend == null; faild to getLayerBounds of context",
e);
}
Modified: branches/1.0-gt2-2.6/src/schmitzm/geotools/GTUtil.java
===================================================================
--- branches/1.0-gt2-2.6/src/schmitzm/geotools/GTUtil.java 2009-10-04 23:33:30 UTC (rev 435)
+++ branches/1.0-gt2-2.6/src/schmitzm/geotools/GTUtil.java 2009-10-05 11:54:12 UTC (rev 436)
@@ -182,5 +182,4 @@
// Subset nur bzgl. des Bereichs in dem auch das Raster liegt
return JTS.getEnvelope2D(intersetionEnvJTS,crs);
}
-
}
Modified: branches/1.0-gt2-2.6/src/schmitzm/geotools/JTSUtil.java
===================================================================
--- branches/1.0-gt2-2.6/src/schmitzm/geotools/JTSUtil.java 2009-10-04 23:33:30 UTC (rev 435)
+++ branches/1.0-gt2-2.6/src/schmitzm/geotools/JTSUtil.java 2009-10-05 11:54:12 UTC (rev 436)
@@ -66,6 +66,20 @@
}
/**
+ * Expands an {@link Envelope} by percentage.
+ * @param env the {@link Envelope}
+ * @param pct percentage (e.g. 0.1 = 10%) to expands the envelope by
+ */
+ public static Envelope expandEnvelope(Envelope env, double pct) {
+ final Envelope expandedEnv = new Envelope(env);
+ expandedEnv.expandBy(
+ env.getWidth() * pct,
+ env.getHeight() * pct
+ );
+ return expandedEnv;
+ }
+
+ /**
* Transformiert einen JTS-Envelope von einem CRS in ein anderes. Wenn Bursa-Wolf parameter fehlen, wird lenient gerechnet.
* @param sourceEnv JTS-Envelope
* @param sourceCRS CRS von {@code sourceEnv}
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-04 23:33:30 UTC (rev 435)
+++ branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/JMapPane.java 2009-10-05 11:54:12 UTC (rev 436)
@@ -520,17 +520,7 @@
Envelope newMapArea = new Envelope(e
.getLayer().getFeatureSource()
.getBounds());
- // Kartenbereich um 10% vergroessern, damit
- // z.B. auch ein Punkt-Layer, welches nur
- // aus 2 Punnkten
- // besteht, sichtbar ist (Punkte liegen
- // sonst
- // genau auf dem Rand der angezeigten
- // Flaeche)
- newMapArea.expandBy(
- newMapArea.getWidth() * 0.1,
- newMapArea.getHeight() * 0.1);
- setMapArea(newMapArea);
+ setMapArea( getMaxExtend() );
// in layerAdded(.) der Oberklasse wird
// mapArea nochmal neu gesetzt, wenn das
// erste Layer
More information about the Schmitzm-commits
mailing list