68 |
import org.geotools.renderer.label.LabelCacheImpl; |
import org.geotools.renderer.label.LabelCacheImpl; |
69 |
import org.geotools.renderer.lite.LabelCache; |
import org.geotools.renderer.lite.LabelCache; |
70 |
import org.geotools.swing.JMapPane; |
import org.geotools.swing.JMapPane; |
|
//import org.geotools.swing.RenderingExecutor; // gt2-2.6.1 |
|
|
import skrueger.geotools.RenderingExecutor; // until gt2-2.6.1 |
|
71 |
import org.geotools.swing.event.MapMouseEvent; |
import org.geotools.swing.event.MapMouseEvent; |
72 |
import org.geotools.swing.event.MapPaneEvent; |
import org.geotools.swing.event.MapPaneEvent; |
73 |
import org.geotools.swing.event.MapPaneListener; |
import org.geotools.swing.event.MapPaneListener; |
84 |
import schmitzm.geotools.map.event.JMapPaneListener; |
import schmitzm.geotools.map.event.JMapPaneListener; |
85 |
import schmitzm.geotools.map.event.MapLayerAdapter; |
import schmitzm.geotools.map.event.MapLayerAdapter; |
86 |
import schmitzm.swing.SwingUtil; |
import schmitzm.swing.SwingUtil; |
87 |
|
import skrueger.geotools.RenderingExecutor; |
88 |
|
|
89 |
import com.vividsolutions.jts.geom.Coordinate; |
import com.vividsolutions.jts.geom.Coordinate; |
90 |
import com.vividsolutions.jts.geom.Envelope; |
import com.vividsolutions.jts.geom.Envelope; |
174 |
* @see #setState(int) |
* @see #setState(int) |
175 |
*/ |
*/ |
176 |
public static final int SELECT_ONE_FROM_TOP = 104; |
public static final int SELECT_ONE_FROM_TOP = 104; |
177 |
|
// |
178 |
public static final long DEFAULT_REPAINTING_DELAY = 200; |
// /** |
179 |
|
// * While threads are working, we call {@link XMapPane#updateFinalImage()} |
180 |
|
// * regularly and repaint(). This {@link Timer} is stopped when all renderers |
181 |
|
// * have finished. |
182 |
|
// */ |
183 |
|
// final private Timer repainterTimer; |
184 |
|
// |
185 |
|
// /** |
186 |
|
// * While the {@link #bgExecuter} and {@link #localExecuter} are rendering, |
187 |
|
// * the {@link #repainterTimer} is regularly updating the {@link #finalImage} |
188 |
|
// * with previews. |
189 |
|
// */ |
190 |
|
// public static final long REPEATING_REPAINT_DELAY = 500; |
191 |
|
// |
192 |
|
// /** |
193 |
|
// * The initial delay in milliseconds until the {@link #finalImage} is updated the first time. |
194 |
|
// */ |
195 |
|
// public static final long INITIAL_REPAINT_DELAY = 333; |
196 |
|
|
197 |
protected RenderingExecutor bgExecuter; |
protected RenderingExecutor bgExecuter; |
198 |
|
|
235 |
/** |
/** |
236 |
* compass and icon are rendered into this image |
* compass and icon are rendered into this image |
237 |
*/ |
*/ |
238 |
// protected BufferedImage gadgetsImage; |
// protected BufferedImage gadgetsImage; |
239 |
|
|
240 |
/** |
/** |
241 |
* The default state is ZOOM_IN, hence by default the |
* The default state is ZOOM_IN, hence by default the |
264 |
|
|
265 |
// aktuelle Geo-Position ueber Transformation des JMapPane berechnen |
// aktuelle Geo-Position ueber Transformation des JMapPane berechnen |
266 |
if (e != null && e.getSource() instanceof XMapPane) { |
if (e != null && e.getSource() instanceof XMapPane) { |
267 |
|
|
268 |
final XMapPane xMapPane = (XMapPane) e.getSource(); |
final XMapPane xMapPane = (XMapPane) e.getSource(); |
269 |
|
|
270 |
if (!xMapPane.isWellDefined()) return null; |
if (!xMapPane.isWellDefined()) |
271 |
|
return null; |
272 |
|
|
273 |
AffineTransform at = xMapPane.getScreenToWorld(); |
AffineTransform at = xMapPane.getScreenToWorld(); |
274 |
if (at != null) |
if (at != null) |
275 |
return at.transform(e.getPoint(), null); |
return at.transform(e.getPoint(), null); |
314 |
protected boolean paneResized = false; |
protected boolean paneResized = false; |
315 |
|
|
316 |
/** |
/** |
|
* While threads are working, we call {@link XMapPane#updateFinalImage()} |
|
|
* regularly and repaint(). This {@link Timer} is stoppen when all renderers |
|
|
* finished. |
|
|
*/ |
|
|
final private Timer repainterTimer; |
|
|
|
|
|
/** |
|
317 |
* The flag {@link #requestStartRendering} can be set to true by events. |
* The flag {@link #requestStartRendering} can be set to true by events. |
318 |
* This {@link Timer} checks the flag regularly and starts one renderer |
* This {@link Timer} checks the flag regularly and starts one renderer |
319 |
* thread. |
* thread. |
415 |
|
|
416 |
}); |
}); |
417 |
|
|
418 |
repainterTimer = new Timer((int) DEFAULT_REPAINTING_DELAY, |
// repainterTimer = new Timer((int) REPEATING_REPAINT_DELAY, |
419 |
new ActionListener() { |
// new ActionListener() { |
420 |
|
// |
421 |
@Override |
// @Override |
422 |
public void actionPerformed(ActionEvent e) { |
// public void actionPerformed(ActionEvent e) { |
423 |
updateFinalImage(); |
// updateFinalImage(); |
424 |
XMapPane.this.repaint(DEFAULT_REPAINTING_DELAY); |
// XMapPane.this.repaint(); |
425 |
} |
// } |
426 |
}); |
// }); |
427 |
repainterTimer.setInitialDelay(1000); |
// repainterTimer.setInitialDelay(300); |
428 |
repainterTimer.setRepeats(true); |
// repainterTimer.setRepeats(true); |
429 |
|
|
430 |
startRenderThreadsTimer = new Timer(200, new ActionListener() { |
startRenderThreadsTimer = new Timer(200, new ActionListener() { |
431 |
|
|
543 |
* {@link XMapPane} is visible and has bounds set. |
* {@link XMapPane} is visible and has bounds set. |
544 |
*/ |
*/ |
545 |
public boolean isWellDefined() { |
public boolean isWellDefined() { |
546 |
|
|
547 |
try { |
try { |
548 |
|
|
549 |
if (getContext() == null) |
if (getContext() == null) |
550 |
return false; |
return false; |
551 |
if (getContext().getLayerCount() <= 0) |
if (getContext().getLayerCount() <= 0) |
552 |
return false; |
return false; |
553 |
if (getMapArea() == null) |
if (getMapArea() == null) |
554 |
return false; |
return false; |
555 |
if (getBounds().getWidth() == 0) |
if (getBounds().getWidth() == 0) |
556 |
return false; |
return false; |
557 |
if (getBounds().getHeight() == 0) |
if (getBounds().getHeight() == 0) |
558 |
return false; |
return false; |
559 |
} catch (Exception e) { |
} catch (Exception e) { |
560 |
return false; |
return false; |
561 |
} |
} |
613 |
/** |
/** |
614 |
* Abhaengig von selState wird der Cursor gesetzt |
* Abhaengig von selState wird der Cursor gesetzt |
615 |
*/ |
*/ |
616 |
public void updateCursorAndRepaintTimer() { |
public void updateCursor() { |
617 |
|
|
618 |
if (bgExecuter != null && bgExecuter.isRunning() |
if (bgExecuter != null && bgExecuter.isRunning() |
619 |
|| localExecuter != null && localExecuter.isRunning()) { |
|| localExecuter != null && localExecuter.isRunning()) { |
620 |
setCursor(WAIT_CURSOR); |
setCursor(WAIT_CURSOR); |
621 |
return; |
return; |
622 |
} else { |
} else { |
623 |
// Allow one last rendering |
// // Allow one last rendering |
624 |
if (repainterTimer.isRunning()) { |
// if (repainterTimer.isRunning()) { |
625 |
repainterTimer.stop(); |
// repainterTimer.stop(); |
626 |
updateFinalImage(); |
// updateFinalImage(); |
627 |
repaint(); |
// repaint(); |
628 |
} |
// } |
629 |
} |
} |
630 |
|
|
631 |
// wenn manueller Cursor gesetzt ist, dann diesen verwenden (unabhaengig |
// wenn manueller Cursor gesetzt ist, dann diesen verwenden (unabhaengig |
1026 |
return false; |
return false; |
1027 |
} |
} |
1028 |
|
|
1029 |
// Testen, ob der Unterschied nur im minimalen Rundungsfehlerbereich |
// Testing, whether NaN or Infinity are used in the newMapArea |
1030 |
// liegt |
if (newMapArea.isNull() || Double.isInfinite(newMapArea.getMaxX()) |
1031 |
|
|| Double.isInfinite(newMapArea.getMaxY()) |
1032 |
|
|| Double.isInfinite(newMapArea.getMinX()) |
1033 |
|
|| Double.isInfinite(newMapArea.getMinY())) { |
1034 |
|
// No change.. ugly new values |
1035 |
|
LOGGER.warn("setMapArea has been called with newArea = " |
1036 |
|
+ newMapArea); |
1037 |
|
return false; |
1038 |
|
} |
1039 |
|
|
1040 |
|
// Testing, whether the difference if just minimal |
1041 |
if (mapArea != null) { |
if (mapArea != null) { |
1042 |
Envelope candNew = bestAllowedMapArea(newMapArea); |
Envelope candNew = bestAllowedMapArea(newMapArea); |
1043 |
double tolX = mapArea.getWidth() / 1000.; |
double tolX = mapArea.getWidth() / 1000.; |
1061 |
|
|
1062 |
oldMapArea = mapArea; |
oldMapArea = mapArea; |
1063 |
|
|
|
System.out.println("requested setting to \\t" + newMapArea); |
|
1064 |
this.mapArea = bestAllowedMapArea(newMapArea); |
this.mapArea = bestAllowedMapArea(newMapArea); |
|
System.out.println("set to \\t\\ŧ" + newMapArea); |
|
1065 |
|
|
1066 |
if (localContext != null) { |
if (localContext != null) { |
1067 |
localContext.setAreaOfInterest(mapArea, localContext |
localContext.setAreaOfInterest(mapArea, localContext |
1075 |
mapImageInvalid = true; |
mapImageInvalid = true; |
1076 |
mapAreaChanged = true; |
mapAreaChanged = true; |
1077 |
repaint(); |
repaint(); |
1078 |
|
|
1079 |
|
// LOGGER.debug("New maparea = " + mapArea); |
1080 |
return true; |
return true; |
1081 |
} |
} |
1082 |
|
|
1097 |
|| state == ZOOM_OUT || state == PAN)); |
|| state == ZOOM_OUT || state == PAN)); |
1098 |
|
|
1099 |
// Je nach Aktion den Cursor umsetzen |
// Je nach Aktion den Cursor umsetzen |
1100 |
updateCursorAndRepaintTimer(); |
updateCursor(); |
1101 |
} |
} |
1102 |
|
|
1103 |
/** Cursor wenn kein Mausbutton gedrueckt wird. default oder SwingUtil.PAN **/ |
/** Cursor wenn kein Mausbutton gedrueckt wird. default oder SwingUtil.PAN **/ |
1129 |
|
|
1130 |
protected void paintComponent(final Graphics g) { |
protected void paintComponent(final Graphics g) { |
1131 |
// Maybe update the cursor |
// Maybe update the cursor |
1132 |
updateCursorAndRepaintTimer(); |
updateCursor(); |
1133 |
|
|
1134 |
if (!acceptsRepaintCalls) |
if (!acceptsRepaintCalls) |
1135 |
return; |
return; |
1165 |
finalImage = null; |
finalImage = null; |
1166 |
localImage = null; |
localImage = null; |
1167 |
bgImage = null; |
bgImage = null; |
1168 |
// gadgetsImage = null; |
// gadgetsImage = null; |
1169 |
} |
} |
1170 |
|
|
1171 |
// Start the Threads and Timers to render the image |
// Start the Threads and Timers to render the image |
1294 |
(int) visibleArea.getMinX(), (int) visibleArea.getMinY(), |
(int) visibleArea.getMinX(), (int) visibleArea.getMinY(), |
1295 |
(int) visibleArea.getMaxX(), (int) visibleArea.getMaxY(), |
(int) visibleArea.getMaxX(), (int) visibleArea.getMaxY(), |
1296 |
getMapBackgroundColor(), null); |
getMapBackgroundColor(), null); |
|
|
|
1297 |
|
|
1298 |
Rectangle painedArea = new Rectangle(xx1, yy1, xx2 - xx1, yy2 - yy1); |
Rectangle painedArea = new Rectangle(xx1, yy1, xx2 - xx1, yy2 - yy1); |
1299 |
|
|
1300 |
SwingUtil.clearAround(graphics, painedArea, visibleArea); |
SwingUtil.clearAround(graphics, painedArea, visibleArea); |
1301 |
|
|
1302 |
addGadgets(graphics); |
addGadgets(graphics); |
1303 |
// graphics.drawImage(getGadgetsImage(), 0,0, (int) visibleArea.getMaxX(), (int) visibleArea.getMaxY(),null); |
// graphics.drawImage(getGadgetsImage(), 0,0, (int) |
1304 |
|
// visibleArea.getMaxX(), (int) visibleArea.getMaxY(),null); |
1305 |
|
|
1306 |
quickPreviewHint = 0; |
quickPreviewHint = 0; |
1307 |
|
|
1309 |
// Something has been drawn |
// Something has been drawn |
1310 |
return true; |
return true; |
1311 |
} |
} |
1312 |
|
|
1313 |
final static Font waitFont = new Font("Arial", Font.BOLD, 30); |
final static Font waitFont = new Font("Arial", Font.BOLD, 30); |
1314 |
|
|
1315 |
/** |
/** |
1316 |
* Paints some optinal stuff into the given {@link Graphics2D}. Usually called as the last paint on the mapImage. |
* Paints some optinal stuff into the given {@link Graphics2D}. Usually |
1317 |
|
* called as the last paint on the mapImage. |
1318 |
*/ |
*/ |
1319 |
private void addGadgets(Graphics2D graphics) { |
private void addGadgets(Graphics2D graphics) { |
1320 |
|
|
1321 |
if (mapImage != null) |
if (mapImage != null) |
1322 |
graphics.drawImage(mapImage, |
graphics.drawImage(mapImage, getBounds().width |
1323 |
getBounds().width - mapImage.getWidth() - 10, |
- mapImage.getWidth() - 10, getBounds().height |
1324 |
getBounds().height - mapImage.getHeight() - 10, this); |
- mapImage.getHeight() - 10, this); |
1325 |
|
|
1326 |
// If still rendering, paint a gray shadow or so... |
// If still rendering, paint a gray shadow or so... |
1327 |
if (bgExecuter != null && bgExecuter.isRunning() |
if (bgExecuter != null && bgExecuter.isRunning() |
1328 |
|| localExecuter != null && localExecuter.isRunning()) { |
|| localExecuter != null && localExecuter.isRunning()) { |
1329 |
graphics.setColor(Color.BLACK); |
graphics.setColor(Color.BLACK); |
1330 |
|
|
1331 |
graphics.setFont(waitFont); |
graphics.setFont(waitFont); |
1332 |
graphics.drawString("Wait...", 40, 70); |
graphics.drawString("Wait...", 40, 70); |
1333 |
} |
} |
1334 |
|
|
1335 |
} |
} |
1336 |
|
|
1337 |
/** |
/** |
1343 |
|
|
1344 |
final Graphics2D finalG = (Graphics2D) getFinalImage().getGraphics(); |
final Graphics2D finalG = (Graphics2D) getFinalImage().getGraphics(); |
1345 |
finalG.setBackground(getMapBackgroundColor()); |
finalG.setBackground(getMapBackgroundColor()); |
1346 |
|
|
|
|
|
1347 |
// Render the two map images first, into the preFinalImage |
// Render the two map images first, into the preFinalImage |
1348 |
{ |
{ |
1349 |
final Graphics2D preFinalG = (Graphics2D) getPreFinalImage().getGraphics(); |
final Graphics2D preFinalG = (Graphics2D) getPreFinalImage() |
1350 |
|
.getGraphics(); |
1351 |
preFinalG.setBackground(getMapBackgroundColor()); |
preFinalG.setBackground(getMapBackgroundColor()); |
1352 |
|
|
1353 |
preFinalG.drawImage(getBgImage(), 0, 0, |
preFinalG.drawImage(getBgImage(), 0, 0, getMapBackgroundColor(), |
1354 |
getMapBackgroundColor(), null); |
null); |
1355 |
// // Draw the local layers image |
// // Draw the local layers image |
1356 |
preFinalG.drawImage(getLocalImage(), 0, 0, null); |
preFinalG.drawImage(getLocalImage(), 0, 0, null); |
1357 |
preFinalG.dispose(); |
preFinalG.dispose(); |
1358 |
} |
} |
1359 |
|
|
1360 |
finalG.drawImage(getPreFinalImage(), imageOrigin.x, imageOrigin.y, |
finalG.drawImage(getPreFinalImage(), imageOrigin.x, imageOrigin.y, |
1361 |
getMapBackgroundColor(), null); |
getMapBackgroundColor(), null); |
1362 |
|
|
1381 |
SwingUtil.clearAround(finalG, painedArea, getVisibleRect()); |
SwingUtil.clearAround(finalG, painedArea, getVisibleRect()); |
1382 |
|
|
1383 |
addGadgets(finalG); |
addGadgets(finalG); |
1384 |
// finalG.drawImage(getGadgetsImage(), 0, 0, null); |
// finalG.drawImage(getGadgetsImage(), 0, 0, null); |
1385 |
|
|
1386 |
finalG.dispose(); |
finalG.dispose(); |
1387 |
|
|
1409 |
} |
} |
1410 |
return finalImage; |
return finalImage; |
1411 |
} |
} |
1412 |
|
|
1413 |
private Image getPreFinalImage() { |
private Image getPreFinalImage() { |
1414 |
|
|
1415 |
if (preFinalImage == null) { |
if (preFinalImage == null) { |
1416 |
preFinalImage = null; |
preFinalImage = null; |
1417 |
Rectangle curPaintArea = getVisibleRect(); |
Rectangle curPaintArea = getVisibleRect(); |
1418 |
|
|
1419 |
preFinalImage = new BufferedImage(curPaintArea.width, |
preFinalImage = new BufferedImage(curPaintArea.width, |
1420 |
curPaintArea.height, BufferedImage.TYPE_INT_RGB); |
curPaintArea.height, BufferedImage.TYPE_INT_RGB); |
1421 |
|
|
1422 |
requestStartRendering(); |
requestStartRendering(); |
1423 |
} |
} |
1424 |
return preFinalImage; |
return preFinalImage; |
1485 |
*/ |
*/ |
1486 |
|
|
1487 |
if (getBgContext() != null) { |
if (getBgContext() != null) { |
1488 |
bgExecuter = new RenderingExecutor(this); |
bgExecuter = new RenderingExecutor(this, 333l); |
1489 |
LOGGER.debug("starting bg renderer:"); |
LOGGER.debug("starting bg renderer:"); |
1490 |
// /* System.out.println("rendering"); */ |
// /* System.out.println("rendering"); */ |
1491 |
final GTRenderer createGTRenderer = GTUtil.createGTRenderer( |
final GTRenderer createGTRenderer = GTUtil.createGTRenderer( |
1496 |
} |
} |
1497 |
|
|
1498 |
if (getContext() != null) { |
if (getContext() != null) { |
1499 |
localExecuter = new RenderingExecutor(this); |
localExecuter = new RenderingExecutor(this, 150l); |
1500 |
LOGGER.debug("starting local renderer:"); |
LOGGER.debug("starting local renderer:"); |
1501 |
final GTRenderer createGTRenderer = GTUtil.createGTRenderer( |
final GTRenderer createGTRenderer = GTUtil.createGTRenderer( |
1502 |
localContext, getRendererHints()); |
localContext, getRendererHints()); |
1506 |
createGTRenderer); |
createGTRenderer); |
1507 |
} |
} |
1508 |
|
|
1509 |
updateCursorAndRepaintTimer(); |
updateCursor(); |
1510 |
|
// |
1511 |
// start regular repaints until all renderers are done. |
// // start regular repaints until all renderers are done. |
1512 |
repainterTimer.setRepeats(true); |
// repainterTimer.setRepeats(true); |
1513 |
repainterTimer.restart(); |
// repainterTimer.restart(); |
1514 |
|
|
1515 |
} |
} |
1516 |
|
|
1557 |
*/ |
*/ |
1558 |
public void setMapImage(BufferedImage mapImage) { |
public void setMapImage(BufferedImage mapImage) { |
1559 |
this.mapImage = mapImage; |
this.mapImage = mapImage; |
1560 |
// gadgetsImage = null; |
// gadgetsImage = null; |
1561 |
} |
} |
1562 |
|
|
1563 |
/** |
/** |
1579 |
|
|
1580 |
return localImage; |
return localImage; |
1581 |
} |
} |
1582 |
// |
|
1583 |
// /** |
// |
1584 |
// * Lazyly initializes a {@link BufferedImage} for the background renderer. |
// /** |
1585 |
// */ |
// * Lazyly initializes a {@link BufferedImage} for the background renderer. |
1586 |
// private BufferedImage getGadgetsImage() { |
// */ |
1587 |
// |
// private BufferedImage getGadgetsImage() { |
1588 |
// if (gadgetsImage == null) { |
// |
1589 |
// LOGGER.debug("creating a new gadgets image"); |
// if (gadgetsImage == null) { |
1590 |
// |
// LOGGER.debug("creating a new gadgets image"); |
1591 |
// Rectangle curPaintArea = getVisibleRect(); |
// |
1592 |
// // allow a single pixel margin at the right and bottom edges |
// Rectangle curPaintArea = getVisibleRect(); |
1593 |
// curPaintArea.width -= 1; |
// // allow a single pixel margin at the right and bottom edges |
1594 |
// curPaintArea.height -= 1; |
// curPaintArea.width -= 1; |
1595 |
// |
// curPaintArea.height -= 1; |
1596 |
// gadgetsImage = new BufferedImage(curPaintArea.width + 1, |
// |
1597 |
// curPaintArea.height + 1, BufferedImage.TYPE_INT_ARGB); |
// gadgetsImage = new BufferedImage(curPaintArea.width + 1, |
1598 |
// |
// curPaintArea.height + 1, BufferedImage.TYPE_INT_ARGB); |
1599 |
// if (mapImage != null) |
// |
1600 |
// gadgetsImage.getGraphics().drawImage(mapImage, |
// if (mapImage != null) |
1601 |
// curPaintArea.width - mapImage.getWidth() - 10, |
// gadgetsImage.getGraphics().drawImage(mapImage, |
1602 |
// curPaintArea.height - mapImage.getHeight() - 10, this); |
// curPaintArea.width - mapImage.getWidth() - 10, |
1603 |
// |
// curPaintArea.height - mapImage.getHeight() - 10, this); |
1604 |
// } |
// |
1605 |
// |
// } |
1606 |
// return gadgetsImage; |
// |
1607 |
// } |
// return gadgetsImage; |
1608 |
|
// } |
1609 |
|
|
1610 |
/** |
/** |
1611 |
* Called by the {@linkplain XMapPane.RenderingTask} when rendering has been |
* Called by the {@linkplain XMapPane.RenderingTask} when rendering has been |
2043 |
} |
} |
2044 |
|
|
2045 |
startRenderThreadsTimer.stop(); |
startRenderThreadsTimer.stop(); |
2046 |
repainterTimer.stop(); |
// repainterTimer.stop(); |
2047 |
|
|
2048 |
if (bgImage != null) |
if (bgImage != null) |
2049 |
bgImage.flush(); |
bgImage.flush(); |
2050 |
if (localImage != null) |
if (localImage != null) |
2051 |
localImage.flush(); |
localImage.flush(); |
2052 |
// if (gadgetsImage != null) |
// if (gadgetsImage != null) |
2053 |
// gadgetsImage.flush(); |
// gadgetsImage.flush(); |
2054 |
if (finalImage != null) |
if (finalImage != null) |
2055 |
finalImage.flush(); |
finalImage.flush(); |
2056 |
if (preFinalImage != null) |
if (preFinalImage != null) |
2110 |
|
|
2111 |
Point2D gcenter = getScreenToWorld().transform(center, null); |
Point2D gcenter = getScreenToWorld().transform(center, null); |
2112 |
center = null; |
center = null; |
2113 |
|
|
2114 |
if ( |
if (Double.isNaN(gcenter.getX()) || Double.isNaN(gcenter.getY()) |
2115 |
Double.isNaN(gcenter.getX()) || Double.isNaN(gcenter.getY()) |
|| Double.isInfinite(gcenter.getX()) |
2116 |
|| |
|| Double.isInfinite(gcenter.getY()) |
2117 |
Double.isInfinite(gcenter.getX()) || Double.isInfinite(gcenter.getY()) |
|
|
|
|
2118 |
) { |
) { |
2119 |
// Not inside valid CRS area! cancel |
// Not inside valid CRS area! cancel |
2120 |
return; |
return; |
2121 |
} |
} |
2122 |
|
|
2123 |
final Envelope mapArea = getMapArea(); |
final Envelope mapArea = getMapArea(); |
2124 |
|
|
2125 |
Envelope newMapArea = new Envelope(mapArea); |
Envelope newMapArea = new Envelope(mapArea); |
2126 |
newMapArea |
newMapArea.expandBy((mapArea.getWidth() * zoomFaktor - mapArea |
2127 |
.expandBy((mapArea.getWidth() * zoomFaktor - mapArea |
.getWidth()) / 2., (mapArea.getHeight() * zoomFaktor - mapArea |
2128 |
.getWidth()) / 2., (mapArea.getHeight() |
.getHeight()) / 2.); |
|
* zoomFaktor - mapArea.getHeight()) / 2.); |
|
2129 |
|
|
2130 |
// Move the newMapArea above the new center |
// Move the newMapArea above the new center |
2131 |
newMapArea.translate(gcenter.getX() - mapArea.centre().x, gcenter.getY() |
newMapArea.translate(gcenter.getX() - mapArea.centre().x, gcenter |
2132 |
|
.getY() |
2133 |
- mapArea.centre().y); |
- mapArea.centre().y); |
2134 |
|
|
2135 |
setMapArea(newMapArea); |
setMapArea(newMapArea); |
2254 |
imageOrigin.x = 0; |
imageOrigin.x = 0; |
2255 |
imageOrigin.y = 0; |
imageOrigin.y = 0; |
2256 |
|
|
2257 |
if (!setMapArea(newMapArea)){ |
if (!setMapArea(newMapArea)) { |
2258 |
updateFinalImage(); |
updateFinalImage(); |
2259 |
repaint(); |
repaint(); |
2260 |
} |
} |
2263 |
setCursor(SwingUtil.PAN_CURSOR); |
setCursor(SwingUtil.PAN_CURSOR); |
2264 |
} |
} |
2265 |
|
|
2266 |
|
public void onRenderingPending() { |
2267 |
|
LOGGER.debug("Pending rendering updates the preview..."); |
2268 |
|
updateFinalImage(); |
2269 |
|
XMapPane.this.repaint(); |
2270 |
|
} |
2271 |
|
|
2272 |
} |
} |