58 |
import javax.swing.JPanel; |
import javax.swing.JPanel; |
59 |
|
|
60 |
import org.apache.log4j.Logger; |
import org.apache.log4j.Logger; |
61 |
|
import org.geotools.data.memory.MemoryFeatureCollection; |
62 |
|
import org.geotools.feature.Feature; |
63 |
import org.geotools.feature.FeatureCollection; |
import org.geotools.feature.FeatureCollection; |
64 |
import org.geotools.filter.IllegalFilterException; |
import org.geotools.filter.IllegalFilterException; |
65 |
|
import org.geotools.geometry.jts.ReferencedEnvelope; |
66 |
import org.geotools.gui.swing.event.HighlightChangeListener; |
import org.geotools.gui.swing.event.HighlightChangeListener; |
67 |
import org.geotools.gui.swing.event.HighlightChangedEvent; |
import org.geotools.gui.swing.event.HighlightChangedEvent; |
68 |
import org.geotools.gui.swing.event.SelectionChangeListener; |
import org.geotools.gui.swing.event.SelectionChangeListener; |
91 |
|
|
92 |
import schmitzm.swing.SwingUtil; |
import schmitzm.swing.SwingUtil; |
93 |
|
|
94 |
|
import com.sun.corba.se.spi.legacy.connection.GetEndPointInfoAgainException; |
95 |
import com.vividsolutions.jts.geom.Coordinate; |
import com.vividsolutions.jts.geom.Coordinate; |
96 |
import com.vividsolutions.jts.geom.Envelope; |
import com.vividsolutions.jts.geom.Envelope; |
97 |
import com.vividsolutions.jts.geom.Geometry; |
import com.vividsolutions.jts.geom.Geometry; |
1244 |
|
|
1245 |
|
|
1246 |
//xulu.sn |
//xulu.sn |
1247 |
/** |
/** |
1248 |
* Korrigiert den {@link Envelope} aka {@code mapArea} auf die beste erlaubte Flaeche damit |
* Korrigiert den {@link Envelope} aka {@code mapArea} auf die beste |
1249 |
* die Massstabsbeschaenkungen noch eingehalten werden, FALLS der uebergeben Envelope |
* erlaubte Flaeche damit die Massstabsbeschaenkungen noch eingehalten |
1250 |
* nicht schon gueltig sein sollte. |
* werden, FALLS der uebergeben Envelope nicht schon gueltig sein sollte.<br/> |
1251 |
* |
* Since 21. April 09: Before thecalculation starts, the aspect ratio is |
1252 |
* @author <a href="mailto:[email protected]">Stefan Alfons Krüger</a> |
* corrected. This change implies, that setMapArea() will most of the time |
1253 |
*/ |
* not allow setting to a wrong aspectRatio. |
1254 |
public Envelope bestAllowedMapArea(Envelope env) { |
* |
1255 |
if (getWidth() == 0) return env; |
* @author <a href="mailto:[email protected]">Stefan Alfons |
1256 |
if (env == null) return env; |
* Krüger</a> |
1257 |
|
*/ |
1258 |
double scale = env.getWidth() / getWidth(); |
public Envelope bestAllowedMapArea(Envelope env) { |
1259 |
double centerX = env.getMinX() + env.getWidth() / 2.; |
if (getWidth() == 0) |
1260 |
double centerY = env.getMinY() + env.getHeight() / 2.; |
return env; |
1261 |
double newWidth2; |
if (env == null) |
1262 |
double newHeight2; |
return env; |
1263 |
if (scale < getMaxZoomScale()) { |
|
1264 |
//**************************************************************************** |
/** |
1265 |
// Wir zoomen weiter rein als erlaubt => Anpassen des envelope |
* Correct the aspect Ratio before we check the rest. Otherwise we might easily fail. |
1266 |
//**************************************************************************** |
*/ |
1267 |
newWidth2 = getMaxZoomScale() * getWidth() / 2.; |
env = fixAspectRatio(this.getBounds(), env); |
1268 |
newHeight2 = getMaxZoomScale() * getHeight() / 2.; |
|
1269 |
} else if (scale > getMinZoomScale()) { |
double scale = env.getWidth() / getWidth(); |
1270 |
//**************************************************************************** |
double centerX = env.getMinX() + env.getWidth() / 2.; |
1271 |
// Wir zoomen weiter raus als erlaubt => Anpassen des envelope |
double centerY = env.getMinY() + env.getHeight() / 2.; |
1272 |
//**************************************************************************** |
double newWidth2; |
1273 |
newWidth2 = getMinZoomScale() * getWidth() / 2.; |
double newHeight2; |
1274 |
newHeight2 = getMinZoomScale() * getHeight() / 2.; |
if (scale < getMaxZoomScale()) { |
1275 |
} else { |
// **************************************************************************** |
1276 |
//**************************************************************************** |
// Wir zoomen weiter rein als erlaubt => Anpassen des envelope |
1277 |
// Die mapArea / der Envelope ist ist gueltig! Keine Aenderungen |
// **************************************************************************** |
1278 |
//**************************************************************************** |
newWidth2 = getMaxZoomScale() * getWidth() / 2.; |
1279 |
return env; |
newHeight2 = getMaxZoomScale() * getHeight() / 2.; |
1280 |
} |
} else if (scale > getMinZoomScale()) { |
1281 |
|
// **************************************************************************** |
1282 |
Coordinate ll = new Coordinate(centerX - newWidth2, centerY |
// Wir zoomen weiter raus als erlaubt => Anpassen des envelope |
1283 |
- newHeight2); |
// **************************************************************************** |
1284 |
Coordinate ur = new Coordinate(centerX + newWidth2, centerY |
newWidth2 = getMinZoomScale() * getWidth() / 2.; |
1285 |
+ newHeight2); |
newHeight2 = getMinZoomScale() * getHeight() / 2.; |
1286 |
|
} else { |
1287 |
|
// **************************************************************************** |
1288 |
|
// Die mapArea / der Envelope ist ist gueltig! Keine Aenderungen |
1289 |
|
// **************************************************************************** |
1290 |
|
return env; |
1291 |
|
} |
1292 |
|
|
1293 |
|
Coordinate ll = new Coordinate(centerX - newWidth2, centerY |
1294 |
|
- newHeight2); |
1295 |
|
Coordinate ur = new Coordinate(centerX + newWidth2, centerY |
1296 |
|
+ newHeight2); |
1297 |
|
|
1298 |
return new Envelope(ll, ur); |
return new Envelope(ll, ur); |
1299 |
} |
} |
1300 |
|
|
1301 |
/** |
/** |
1302 |
* Retuns the minimum allowed zoom scale. This is the bigger number value of the two. |
* Retuns the minimum allowed zoom scale. This is the bigger number value of the two. |
1338 |
} |
} |
1339 |
//xulu.en |
//xulu.en |
1340 |
|
|
1341 |
|
|
1342 |
} |
} |