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.geometry.jts.ReferencedEnvelope; |
62 |
import org.geotools.map.MapContext; |
import org.geotools.map.MapContext; |
63 |
import org.geotools.map.event.MapLayerListEvent; |
import org.geotools.map.event.MapLayerListEvent; |
64 |
import org.geotools.map.event.MapLayerListListener; |
import org.geotools.map.event.MapLayerListListener; |
70 |
import org.opengis.filter.FilterFactory2; |
import org.opengis.filter.FilterFactory2; |
71 |
import org.opengis.referencing.crs.CoordinateReferenceSystem; |
import org.opengis.referencing.crs.CoordinateReferenceSystem; |
72 |
|
|
73 |
|
import schmitzm.geotools.JTSUtil; |
74 |
import schmitzm.swing.SwingUtil; |
import schmitzm.swing.SwingUtil; |
75 |
|
|
76 |
import com.vividsolutions.jts.geom.Coordinate; |
import com.vividsolutions.jts.geom.Coordinate; |
973 |
// Exceeds top? Move down and maybe cut |
// Exceeds top? Move down and maybe cut |
974 |
if (newArea.getMaxY() > maxAllowedExtend.getMaxY()) { |
if (newArea.getMaxY() > maxAllowedExtend.getMaxY()) { |
975 |
double divY = newArea.getMaxY() - maxAllowedExtend.getMaxY(); |
double divY = newArea.getMaxY() - maxAllowedExtend.getMaxY(); |
976 |
LOGGER.debug("Moving area down by " + divY); |
// LOGGER.debug("Moving area down by " + divY); |
977 |
|
|
978 |
newArea = new Envelope(new Coordinate(newArea.getMinX(), |
newArea = new Envelope(new Coordinate(newArea.getMinX(), |
979 |
newArea.getMinY() - divY), new Coordinate(newArea |
newArea.getMinY() - divY), new Coordinate(newArea |
980 |
.getMaxX(), newArea.getMaxY() - divY)); |
.getMaxX(), newArea.getMaxY() - divY)); |
981 |
|
|
982 |
if (newArea.getMinY() < maxAllowedExtend.getMinY()) { |
if (newArea.getMinY() < maxAllowedExtend.getMinY()) { |
983 |
LOGGER.debug("Now it exeeds the bottom border.. cut!"); |
// LOGGER.debug("Now it exeeds the bottom border.. cut!"); |
984 |
// And cut the bottom if it moved out of the area |
// And cut the bottom if it moved out of the area |
985 |
newArea = new Envelope(new Coordinate(newArea.getMinX(), |
newArea = new Envelope(new Coordinate(newArea.getMinX(), |
986 |
maxAllowedExtend.getMinY()), new Coordinate(newArea |
maxAllowedExtend.getMinY()), new Coordinate(newArea |
987 |
.getMaxX(), newArea.getMaxY())); |
.getMaxX(), newArea.getMaxY())); |
988 |
|
|
989 |
LOGGER.debug("and fix aspect ratio"); |
// LOGGER.debug("and fix aspect ratio"); |
990 |
|
|
991 |
newArea = fixAspectRatio(this.getBounds(), newArea, false); |
newArea = fixAspectRatio(this.getBounds(), newArea, false); |
992 |
} |
} |
995 |
// Exceeds bottom? Move up and maybe cut |
// Exceeds bottom? Move up and maybe cut |
996 |
if (newArea.getMinY() < maxAllowedExtend.getMinY()) { |
if (newArea.getMinY() < maxAllowedExtend.getMinY()) { |
997 |
double divY = newArea.getMinY() - maxAllowedExtend.getMinY(); |
double divY = newArea.getMinY() - maxAllowedExtend.getMinY(); |
998 |
LOGGER.debug("Moving area up by " + divY); |
// LOGGER.debug("Moving area up by " + divY); |
999 |
|
|
1000 |
newArea = new Envelope(new Coordinate(newArea.getMinX(), |
newArea = new Envelope(new Coordinate(newArea.getMinX(), |
1001 |
newArea.getMinY() - divY), new Coordinate(newArea |
newArea.getMinY() - divY), new Coordinate(newArea |
1019 |
|
|
1020 |
// Move left.. |
// Move left.. |
1021 |
double divX = newArea.getMaxX() - maxAllowedExtend.getMaxX(); |
double divX = newArea.getMaxX() - maxAllowedExtend.getMaxX(); |
1022 |
LOGGER.debug("Moving area left by " + divX); |
// LOGGER.debug("Moving area left by " + divX); |
1023 |
|
|
1024 |
newArea = new Envelope(new Coordinate(newArea.getMinX() - divX, |
newArea = new Envelope(new Coordinate(newArea.getMinX() - divX, |
1025 |
newArea.getMinY()), new Coordinate(newArea.getMaxX() |
newArea.getMinY()), new Coordinate(newArea.getMaxX() |
1043 |
|
|
1044 |
// Move right.. |
// Move right.. |
1045 |
double divX = newArea.getMinX() - maxAllowedExtend.getMinX(); |
double divX = newArea.getMinX() - maxAllowedExtend.getMinX(); |
1046 |
LOGGER.debug("Moving area right by " + divX); |
// LOGGER.debug("Moving area right by " + divX); |
1047 |
|
|
1048 |
newArea = new Envelope(new Coordinate(newArea.getMinX() - divX, |
newArea = new Envelope(new Coordinate(newArea.getMinX() - divX, |
1049 |
newArea.getMinY()), new Coordinate(newArea.getMaxX() |
newArea.getMinY()), new Coordinate(newArea.getMaxX() |
1136 |
public Envelope getMaxExtend() { |
public Envelope getMaxExtend() { |
1137 |
if (maxExtend == null) { |
if (maxExtend == null) { |
1138 |
try { |
try { |
1139 |
return fixAspectRatio(this.getBounds(), context.getLayerBounds(), true); |
return fixAspectRatio( |
1140 |
|
this.getBounds(), |
1141 |
|
// Kartenbereich um 10% vergroessern |
1142 |
|
JTSUtil.expandEnvelope(context.getLayerBounds(), 0.1), |
1143 |
|
true |
1144 |
|
); |
1145 |
} catch (IOException e) { |
} catch (IOException e) { |
1146 |
LOGGER |
LOGGER.warn( |
|
.warn( |
|
1147 |
"maxExtend == null; faild to getLayerBounds of context", |
"maxExtend == null; faild to getLayerBounds of context", |
1148 |
e); |
e); |
1149 |
} |
} |