230 |
Map<Object, Object> hints = new HashMap<Object, Object>(); |
Map<Object, Object> hints = new HashMap<Object, Object>(); |
231 |
|
|
232 |
this.renderer = renderer; |
this.renderer = renderer; |
233 |
//MS: Apply hint also for ShapeFileRenderer |
// MS: Apply hint also for ShapeFileRenderer |
234 |
// if (renderer instanceof StreamingRenderer) { |
// if (renderer instanceof StreamingRenderer) { |
235 |
hints = renderer.getRendererHints(); |
hints = renderer.getRendererHints(); |
236 |
if (hints == null) { |
if (hints == null) { |
237 |
hints = new HashMap<Object, Object>(); |
hints = new HashMap<Object, Object>(); |
238 |
} |
} |
239 |
if (hints.containsKey(StreamingRenderer.LABEL_CACHE_KEY)) { |
if (hints.containsKey(StreamingRenderer.LABEL_CACHE_KEY)) { |
240 |
labelCache = (LabelCache) hints |
labelCache = (LabelCache) hints |
241 |
.get(StreamingRenderer.LABEL_CACHE_KEY); |
.get(StreamingRenderer.LABEL_CACHE_KEY); |
242 |
} else { |
} else { |
243 |
hints.put(StreamingRenderer.LABEL_CACHE_KEY, labelCache); |
hints.put(StreamingRenderer.LABEL_CACHE_KEY, labelCache); |
244 |
} |
} |
245 |
|
|
246 |
hints.put("memoryPreloadingEnabled", Boolean.TRUE); |
hints.put("memoryPreloadingEnabled", Boolean.TRUE); |
247 |
|
|
248 |
renderer.setRendererHints(hints); |
renderer.setRendererHints(hints); |
249 |
// } |
// } |
250 |
|
|
251 |
if (this.context != null) { |
if (this.context != null) { |
252 |
this.renderer.setContext(this.context); |
this.renderer.setContext(this.context); |
567 |
protected void processDrag(final int x1, final int y1, final int x2, |
protected void processDrag(final int x1, final int y1, final int x2, |
568 |
final int y2, final MouseEvent e) { |
final int y2, final MouseEvent e) { |
569 |
|
|
|
|
|
570 |
/**** |
/**** |
571 |
* If no layers exist, we ignore the drag. |
* If no layers exist, we ignore the drag. |
572 |
*/ |
*/ |
573 |
if (context.getLayerCount() <= 0) { |
if (context.getLayerCount() <= 0) { |
574 |
return; |
return; |
575 |
} |
} |
576 |
|
|
577 |
// System.out.println("processing drag from " + x1 + "," + y1 + " -> " |
// System.out.println("processing drag from " + x1 + "," + y1 + " -> " |
578 |
// + x2 + "," + y2); |
// + x2 + "," + y2); |
579 |
if ((x1 == x2) && (y1 == y2)) { |
if ((x1 == x2) && (y1 == y2)) { |
619 |
final Coordinate ur = new Coordinate(right, top); |
final Coordinate ur = new Coordinate(right, top); |
620 |
// xulu.sc |
// xulu.sc |
621 |
// mapArea = fixAspectRatio(this.getBounds(), new Envelope(ll, ur)); |
// mapArea = fixAspectRatio(this.getBounds(), new Envelope(ll, ur)); |
|
|
|
622 |
|
|
623 |
setMapArea(bestAllowedMapArea(new Envelope(ll, ur))); |
setMapArea(bestAllowedMapArea(new Envelope(ll, ur))); |
624 |
// xulu.ec |
// xulu.ec |
864 |
|
|
865 |
/** |
/** |
866 |
* Correct the aspect Ratio before we check the rest. Otherwise we might |
* Correct the aspect Ratio before we check the rest. Otherwise we might |
867 |
* easily fail. We allow to grow here, because we don't check against the maxExtend |
* easily fail. We allow to grow here, because we don't check against |
868 |
|
* the maxExtend |
869 |
*/ |
*/ |
870 |
env = JTSUtil.fixAspectRatio(this.getBounds(), env, true); |
env = JTSUtil.fixAspectRatio(this.getBounds(), env, true); |
871 |
|
|
904 |
} |
} |
905 |
|
|
906 |
Envelope maxAllowedExtend = getMaxExtend(); |
Envelope maxAllowedExtend = getMaxExtend(); |
907 |
while (maxAllowedExtend != null && !maxAllowedExtend.contains(newArea) && newArea != null && !newArea.isNull() && !Double.isNaN(newArea.getMinX()) && !Double.isNaN(newArea.getMaxX()) && !Double.isNaN(newArea.getMinY()) && !Double.isNaN(newArea.getMaxY()) ) { |
while (maxAllowedExtend != null && !maxAllowedExtend.contains(newArea) |
908 |
|
&& newArea != null && !newArea.isNull() |
909 |
|
&& !Double.isNaN(newArea.getMinX()) |
910 |
|
&& !Double.isNaN(newArea.getMaxX()) |
911 |
|
&& !Double.isNaN(newArea.getMinY()) |
912 |
|
&& !Double.isNaN(newArea.getMaxY())) { |
913 |
/* |
/* |
914 |
* If a maxExtend is set, we have to honour that... |
* If a maxExtend is set, we have to honour that... |
915 |
*/ |
*/ |
917 |
// Exceeds top? Move down and maybe cut |
// Exceeds top? Move down and maybe cut |
918 |
if (newArea.getMaxY() > maxAllowedExtend.getMaxY()) { |
if (newArea.getMaxY() > maxAllowedExtend.getMaxY()) { |
919 |
double divY = newArea.getMaxY() - maxAllowedExtend.getMaxY(); |
double divY = newArea.getMaxY() - maxAllowedExtend.getMaxY(); |
920 |
// LOGGER.debug("Moving area down by " + divY); |
// LOGGER.debug("Moving area down by " + divY); |
921 |
|
|
922 |
newArea = new Envelope(new Coordinate(newArea.getMinX(), |
newArea = new Envelope(new Coordinate(newArea.getMinX(), |
923 |
newArea.getMinY() - divY), new Coordinate(newArea |
newArea.getMinY() - divY), new Coordinate(newArea |
924 |
.getMaxX(), newArea.getMaxY() - divY)); |
.getMaxX(), newArea.getMaxY() - divY)); |
925 |
|
|
926 |
if (newArea.getMinY() < maxAllowedExtend.getMinY()) { |
if (newArea.getMinY() < maxAllowedExtend.getMinY()) { |
927 |
// LOGGER.debug("Now it exeeds the bottom border.. cut!"); |
// LOGGER.debug("Now it exeeds the bottom border.. cut!"); |
928 |
// And cut the bottom if it moved out of the area |
// And cut the bottom if it moved out of the area |
929 |
newArea = new Envelope(new Coordinate(newArea.getMinX(), |
newArea = new Envelope(new Coordinate(newArea.getMinX(), |
930 |
maxAllowedExtend.getMinY()), new Coordinate(newArea |
maxAllowedExtend.getMinY()), new Coordinate(newArea |
931 |
.getMaxX(), newArea.getMaxY())); |
.getMaxX(), newArea.getMaxY())); |
932 |
|
|
933 |
// LOGGER.debug("and fix aspect ratio"); |
// LOGGER.debug("and fix aspect ratio"); |
934 |
|
|
935 |
newArea = JTSUtil.fixAspectRatio(this.getBounds(), newArea, false); |
newArea = JTSUtil.fixAspectRatio(this.getBounds(), newArea, |
936 |
|
false); |
937 |
} |
} |
938 |
} |
} |
939 |
|
|
940 |
// Exceeds bottom? Move up and maybe cut |
// Exceeds bottom? Move up and maybe cut |
941 |
if (newArea.getMinY() < maxAllowedExtend.getMinY()) { |
if (newArea.getMinY() < maxAllowedExtend.getMinY()) { |
942 |
double divY = newArea.getMinY() - maxAllowedExtend.getMinY(); |
double divY = newArea.getMinY() - maxAllowedExtend.getMinY(); |
943 |
// LOGGER.debug("Moving area up by " + divY); |
// LOGGER.debug("Moving area up by " + divY); |
944 |
|
|
945 |
newArea = new Envelope(new Coordinate(newArea.getMinX(), |
newArea = new Envelope(new Coordinate(newArea.getMinX(), |
946 |
newArea.getMinY() - divY), new Coordinate(newArea |
newArea.getMinY() - divY), new Coordinate(newArea |
947 |
.getMaxX(), newArea.getMaxY() - divY)); |
.getMaxX(), newArea.getMaxY() - divY)); |
948 |
|
|
949 |
if (newArea.getMaxY() > maxAllowedExtend.getMaxY()) { |
if (newArea.getMaxY() > maxAllowedExtend.getMaxY()) { |
950 |
// LOGGER.debug("Now it exeeds the top border.. cut!"); |
// LOGGER.debug("Now it exeeds the top border.. cut!"); |
951 |
// And cut the bottom if it moved out of the area |
// And cut the bottom if it moved out of the area |
952 |
newArea = new Envelope(new Coordinate(newArea.getMinX(), |
newArea = new Envelope(new Coordinate(newArea.getMinX(), |
953 |
newArea.getMinY()), new Coordinate(newArea |
newArea.getMinY()), new Coordinate(newArea |
954 |
.getMaxX(), maxAllowedExtend.getMaxY())); |
.getMaxX(), maxAllowedExtend.getMaxY())); |
955 |
|
|
956 |
// LOGGER.debug("and fix aspect ratio"); |
// LOGGER.debug("and fix aspect ratio"); |
957 |
|
|
958 |
newArea = JTSUtil.fixAspectRatio(this.getBounds(), newArea, false); |
newArea = JTSUtil.fixAspectRatio(this.getBounds(), newArea, |
959 |
|
false); |
960 |
} |
} |
961 |
} |
} |
962 |
|
|
965 |
|
|
966 |
// Move left.. |
// Move left.. |
967 |
double divX = newArea.getMaxX() - maxAllowedExtend.getMaxX(); |
double divX = newArea.getMaxX() - maxAllowedExtend.getMaxX(); |
968 |
// LOGGER.debug("Moving area left by " + divX); |
// LOGGER.debug("Moving area left by " + divX); |
969 |
|
|
970 |
newArea = new Envelope(new Coordinate(newArea.getMinX() - divX, |
newArea = new Envelope(new Coordinate(newArea.getMinX() - divX, |
971 |
newArea.getMinY()), new Coordinate(newArea.getMaxX() |
newArea.getMinY()), new Coordinate(newArea.getMaxX() |
972 |
- divX, newArea.getMaxY())); |
- divX, newArea.getMaxY())); |
973 |
|
|
974 |
if (newArea.getMinX() < maxAllowedExtend.getMinX()) { |
if (newArea.getMinX() < maxAllowedExtend.getMinX()) { |
975 |
// LOGGER.debug("Now it exeeds the left border.. cut!"); |
// LOGGER.debug("Now it exeeds the left border.. cut!"); |
976 |
// And cut the left if it moved out of the area |
// And cut the left if it moved out of the area |
977 |
newArea = new Envelope(new Coordinate(maxAllowedExtend.getMinX(), |
newArea = new Envelope(new Coordinate(maxAllowedExtend |
978 |
newArea.getMinY()), new Coordinate(newArea |
.getMinX(), newArea.getMinY()), new Coordinate( |
979 |
.getMaxX(), newArea.getMaxY())); |
newArea.getMaxX(), newArea.getMaxY())); |
980 |
|
|
981 |
// LOGGER.debug("and fix aspect ratio"); |
// LOGGER.debug("and fix aspect ratio"); |
982 |
|
|
983 |
newArea = JTSUtil.fixAspectRatio(this.getBounds(), newArea, false); |
newArea = JTSUtil.fixAspectRatio(this.getBounds(), newArea, |
984 |
|
false); |
985 |
} |
} |
986 |
} |
} |
987 |
|
|
990 |
|
|
991 |
// Move right.. |
// Move right.. |
992 |
double divX = newArea.getMinX() - maxAllowedExtend.getMinX(); |
double divX = newArea.getMinX() - maxAllowedExtend.getMinX(); |
993 |
// LOGGER.debug("Moving area right by " + divX); |
// LOGGER.debug("Moving area right by " + divX); |
994 |
|
|
995 |
newArea = new Envelope(new Coordinate(newArea.getMinX() - divX, |
newArea = new Envelope(new Coordinate(newArea.getMinX() - divX, |
996 |
newArea.getMinY()), new Coordinate(newArea.getMaxX() |
newArea.getMinY()), new Coordinate(newArea.getMaxX() |
997 |
- divX, newArea.getMaxY())); |
- divX, newArea.getMaxY())); |
998 |
|
|
999 |
if (newArea.getMaxX() > maxAllowedExtend.getMaxX()) { |
if (newArea.getMaxX() > maxAllowedExtend.getMaxX()) { |
1000 |
// LOGGER.debug("Now it exeeds the right border.. cut!"); |
// LOGGER.debug("Now it exeeds the right border.. cut!"); |
1001 |
// And cut the left if it moved out of the area |
// And cut the left if it moved out of the area |
1002 |
newArea = new Envelope(new Coordinate(newArea.getMinX(), |
newArea = new Envelope(new Coordinate(newArea.getMinX(), |
1003 |
newArea.getMinY()), new Coordinate(maxAllowedExtend |
newArea.getMinY()), new Coordinate(maxAllowedExtend |
1004 |
.getMaxX(), newArea.getMaxY())); |
.getMaxX(), newArea.getMaxY())); |
1005 |
|
|
1006 |
// LOGGER.debug("and fix aspect ratio"); |
// LOGGER.debug("and fix aspect ratio"); |
1007 |
|
|
1008 |
newArea = JTSUtil.fixAspectRatio(this.getBounds(), newArea, false); |
newArea = JTSUtil.fixAspectRatio(this.getBounds(), newArea, |
1009 |
|
false); |
1010 |
} |
} |
1011 |
} |
} |
1012 |
|
|
1039 |
|
|
1040 |
/** |
/** |
1041 |
* Set the maximum allowed zoom scale. This is the smaller number value of |
* Set the maximum allowed zoom scale. This is the smaller number value of |
1042 |
* the two. |
* the two. If <code>null</code> is passed, Double.MINVALUE are used which |
1043 |
|
* mean there is no restriction. |
1044 |
* |
* |
1045 |
* @author <a href="mailto:[email protected]">Stefan Alfons |
* @author <a href="mailto:[email protected]">Stefan Alfons |
1046 |
* Krüger</a> |
* Krüger</a> |
1047 |
*/ |
*/ |
1048 |
public void setMaxZoomScale(final Double maxZoomScale) { |
public void setMaxZoomScale(final Double maxZoomScale) { |
1049 |
this.maxZoomScale = maxZoomScale; |
this.maxZoomScale = maxZoomScale == null ? Double.MIN_VALUE |
1050 |
|
: maxZoomScale; |
1051 |
} |
} |
1052 |
|
|
1053 |
/** |
/** |
1054 |
* Set the minimum (nearest) allowed zoom scale. This is the bigger number |
* Set the minimum (nearest) allowed zoom scale. This is the bigger number |
1055 |
* value of the two. |
* value of the two. If <code>null</code> is passed, Double.MAXVALUE are |
1056 |
|
* used which mean there is no restriction. |
1057 |
|
* |
1058 |
* |
* |
1059 |
* @author <a href="mailto:[email protected]">Stefan Alfons |
* @author <a href="mailto:[email protected]">Stefan Alfons |
1060 |
* Krüger</a> |
* Krüger</a> |
1061 |
*/ |
*/ |
1062 |
public void setMinZoomScale(final Double minZoomScale) { |
public void setMinZoomScale(final Double minZoomScale) { |
1063 |
this.minZoomScale = minZoomScale; |
this.minZoomScale = minZoomScale == null ? Double.MAX_VALUE |
1064 |
|
: minZoomScale; |
1065 |
} |
} |
1066 |
|
|
1067 |
/** |
/** |
1089 |
public Envelope getMaxExtend() { |
public Envelope getMaxExtend() { |
1090 |
if (maxExtend == null) { |
if (maxExtend == null) { |
1091 |
try { |
try { |
1092 |
return JTSUtil.fixAspectRatio( |
return JTSUtil.fixAspectRatio(this.getBounds(), |
1093 |
this.getBounds(), |
// Kartenbereich um 10% vergroessern |
1094 |
// Kartenbereich um 10% vergroessern |
JTSUtil.expandEnvelope(context.getLayerBounds(), 0.1), |
1095 |
JTSUtil.expandEnvelope(context.getLayerBounds(), 0.1), |
true); |
|
true |
|
|
); |
|
1096 |
} catch (IOException e) { |
} catch (IOException e) { |
1097 |
LOGGER.warn( |
LOGGER |
1098 |
|
.warn( |
1099 |
"maxExtend == null; failed to getLayerBounds of context", |
"maxExtend == null; failed to getLayerBounds of context", |
1100 |
e); |
e); |
1101 |
} |
} |