26 |
import java.util.Map; |
import java.util.Map; |
27 |
import java.util.Vector; |
import java.util.Vector; |
28 |
|
|
29 |
|
import javax.swing.JList; |
30 |
import javax.swing.Timer; |
import javax.swing.Timer; |
31 |
|
import javax.swing.border.Border; |
32 |
|
|
33 |
import org.apache.log4j.Logger; |
import org.apache.log4j.Logger; |
34 |
|
import org.geotools.factory.GeoTools; |
35 |
import org.geotools.feature.FeatureCollection; |
import org.geotools.feature.FeatureCollection; |
36 |
|
import org.geotools.geometry.DirectPosition2D; |
37 |
import org.geotools.geometry.jts.JTS; |
import org.geotools.geometry.jts.JTS; |
38 |
import org.geotools.geometry.jts.ReferencedEnvelope; |
import org.geotools.geometry.jts.ReferencedEnvelope; |
39 |
import org.geotools.map.DefaultMapContext; |
import org.geotools.map.DefaultMapContext; |
99 |
*/ |
*/ |
100 |
public class XMapPane extends JPanel { |
public class XMapPane extends JPanel { |
101 |
|
|
102 |
private static final int IMAGETYPE = BufferedImage.TYPE_INT_RGB; |
// private static final int IMAGETYPE = BufferedImage.TYPE_INT_RGB; |
103 |
private static final int IMAGETYPE_withAlpha = BufferedImage.TYPE_INT_ARGB; |
// private static final int IMAGETYPE_withAlpha = |
104 |
|
// BufferedImage.TYPE_INT_ARGB; |
105 |
|
private static final int IMAGETYPE = BufferedImage.TYPE_3BYTE_BGR; |
106 |
|
private static final int IMAGETYPE_withAlpha = BufferedImage.TYPE_4BYTE_ABGR; |
107 |
|
|
108 |
private final static Logger LOGGER = Logger.getLogger(XMapPane.class); |
private final static Logger LOGGER = Logger.getLogger(XMapPane.class); |
109 |
|
|
147 |
* the {@link #repaintTimer} is regularly updating the {@link #finalImage} |
* the {@link #repaintTimer} is regularly updating the {@link #finalImage} |
148 |
* with previews. |
* with previews. |
149 |
*/ |
*/ |
150 |
public static final int REPEATING_REPAINT_DELAY = 600; |
public static final int REPEATING_REPAINT_DELAY = 500; |
151 |
|
|
152 |
/** |
/** |
153 |
* Default delay (milliseconds) before the map will be redrawn when resizing |
* Default delay (milliseconds) before the map will be redrawn when resizing |
222 |
* |
* |
223 |
* @see #addGadgets(Graphics2D, boolean) |
* @see #addGadgets(Graphics2D, boolean) |
224 |
*/ |
*/ |
225 |
final static Font waitFont = new Font("Arial", Font.BOLD, 30); |
final static Font waitFont = new Font("Arial", Font.BOLD, 28); |
226 |
|
|
227 |
/** |
/** |
228 |
* {@link Font} used to paint error messages into the map |
* {@link Font} used to paint error messages into the map |
232 |
final static Font errorFont = new Font("Arial", Font.BOLD, 13); |
final static Font errorFont = new Font("Arial", Font.BOLD, 13); |
233 |
|
|
234 |
/** |
/** |
235 |
|
* If last average last two renderings took more than that many ms, show the |
236 |
|
* user a scaled preview |
237 |
|
**/ |
238 |
|
private static final long PRESCALE_MINTIME = 230; |
239 |
|
|
240 |
|
/** |
241 |
* The wait message painted into the map while rendering is going on on |
* The wait message painted into the map while rendering is going on on |
242 |
* another thread. |
* another thread. |
243 |
* |
* |
252 |
* @param e |
* @param e |
253 |
* Maus-Ereignis |
* Maus-Ereignis |
254 |
*/ |
*/ |
255 |
public static Point2D getMapCoordinatesFromEvent(final MouseEvent e) { |
public static DirectPosition2D getMapCoordinatesFromEvent(final MouseEvent e) { |
256 |
// aktuelle Geo-Position aus GeoMouseEvent ermitteln |
// aktuelle Geo-Position aus GeoMouseEvent ermitteln |
257 |
if (e != null && e instanceof MapMouseEvent) |
if (e != null && e instanceof MapMouseEvent) |
258 |
try { |
try { |
259 |
return ((MapMouseEvent) e).getMapPosition().toPoint2D(); |
return ((MapMouseEvent) e).getMapPosition(); |
260 |
} catch (final Exception err) { |
} catch (final Exception err) { |
261 |
LOGGER |
LOGGER |
262 |
.error( |
.error( |
273 |
return null; |
return null; |
274 |
|
|
275 |
final AffineTransform at = xMapPane.getScreenToWorld(); |
final AffineTransform at = xMapPane.getScreenToWorld(); |
276 |
if (at != null) |
if (at != null) { |
277 |
return at.transform(e.getPoint(), null); |
Point2D transformed = at.transform(e.getPoint(), null); |
278 |
|
return new DirectPosition2D(xMapPane.getMapContext().getCoordinateReferenceSystem(), transformed.getX(), transformed.getY()); |
279 |
|
} |
280 |
return null; |
return null; |
281 |
} |
} |
282 |
throw new IllegalArgumentException( |
throw new IllegalArgumentException( |
283 |
"MouseEvent has to be of instance MapMouseEvent or come from an XMapPane"); |
"MouseEvent has to be of instance MapMouseEvent or come from an XMapPane"); |
284 |
} |
} |
285 |
|
|
286 |
|
|
287 |
|
|
288 |
/** |
/** |
289 |
* Listens to changes of the "background" {@link MapContext} and triggers |
* Listens to changes of the "background" {@link MapContext} and triggers |
293 |
|
|
294 |
@Override |
@Override |
295 |
public void layerAdded(final MapLayerListEvent event) { |
public void layerAdded(final MapLayerListEvent event) { |
296 |
MapLayer layer = event.getLayer(); |
final MapLayer layer = event.getLayer(); |
297 |
layer.addMapLayerListener(bgMapLayerListener); |
layer.addMapLayerListener(bgMapLayerListener); |
298 |
requestStartRendering(); |
requestStartRendering(); |
299 |
|
|
412 |
public void layerAdded(final MapLayerListEvent event) { |
public void layerAdded(final MapLayerListEvent event) { |
413 |
event.getLayer().addMapLayerListener(localMapLayerListener); |
event.getLayer().addMapLayerListener(localMapLayerListener); |
414 |
|
|
415 |
localRenderer.setContext(getMapContext()); |
getLocalRenderer().setContext(getMapContext()); |
416 |
requestStartRendering(); |
requestStartRendering(); |
417 |
|
|
418 |
} |
} |
419 |
|
|
420 |
@Override |
@Override |
421 |
public void layerChanged(final MapLayerListEvent event) { |
public void layerChanged(final MapLayerListEvent event) { |
422 |
localRenderer.setContext(getMapContext()); |
// getLocalRenderer().setContext(getMapContext()); geht doch auch ohne?!?!? wow... |
423 |
requestStartRendering(); |
requestStartRendering(); |
424 |
} |
} |
425 |
|
|
426 |
@Override |
@Override |
427 |
public void layerMoved(final MapLayerListEvent event) { |
public void layerMoved(final MapLayerListEvent event) { |
428 |
localRenderer.setContext(getMapContext()); |
getLocalRenderer().setContext(getMapContext()); |
429 |
requestStartRendering(); |
requestStartRendering(); |
430 |
} |
} |
431 |
|
|
433 |
public void layerRemoved(final MapLayerListEvent event) { |
public void layerRemoved(final MapLayerListEvent event) { |
434 |
if (event.getLayer() != null) |
if (event.getLayer() != null) |
435 |
event.getLayer().removeMapLayerListener(localMapLayerListener); |
event.getLayer().removeMapLayerListener(localMapLayerListener); |
436 |
localRenderer.setContext(getMapContext()); |
getLocalRenderer().setContext(getMapContext()); |
437 |
requestStartRendering(); |
requestStartRendering(); |
438 |
} |
} |
439 |
}; |
}; |
440 |
|
|
441 |
/** |
/** |
442 |
* Listens to each layer in the local {@link MapContext} for changes and |
* Listens to each layer in the local {@link MapContext} for changes and |
443 |
* triggers repaints. |
* triggers repaints. We don't have to listen layerChanged, because that is |
444 |
|
* already done in {@link #localContextListener} |
445 |
*/ |
*/ |
446 |
protected MapLayerListener localMapLayerListener = new MapLayerAdapter() { |
protected MapLayerListener localMapLayerListener = new MapLayerAdapter() { |
447 |
|
|
448 |
@Override |
// @Override |
449 |
public void layerChanged(final MapLayerEvent event) { |
// public void layerChanged(final MapLayerEvent event) { |
450 |
localRenderer.setContext(getMapContext()); // betters for SLD |
// // getLocalRenderer().setContext(getMapContext()); // betters for SLD |
451 |
// changes?! |
// // // changes?! |
452 |
requestStartRendering(); |
// // requestStartRendering(); |
453 |
} |
// } |
454 |
|
|
455 |
@Override |
@Override |
456 |
public void layerHidden(final MapLayerEvent event) { |
public void layerHidden(final MapLayerEvent event) { |
463 |
} |
} |
464 |
}; |
}; |
465 |
|
|
466 |
private final GTRenderer localRenderer = GTUtil.createGTRenderer(); |
final private GTRenderer localRenderer = GTUtil.createGTRenderer(); |
467 |
|
|
468 |
private final GTRenderer bgRenderer = GTUtil.createGTRenderer(); |
private final GTRenderer bgRenderer = GTUtil.createGTRenderer(); |
469 |
|
|
484 |
/** |
/** |
485 |
* This color is used as the default background color when painting a map. |
* This color is used as the default background color when painting a map. |
486 |
*/ |
*/ |
487 |
private Color mapBackgroundColor = Color.WHITE; |
private Color mapBackgroundColor = null; |
488 |
|
|
489 |
/** |
/** |
490 |
* A flag indicating that the shown image is invalid and needs to be |
* A flag indicating that the shown image is invalid and needs to be |
533 |
private BufferedImage preFinalImage; |
private BufferedImage preFinalImage; |
534 |
|
|
535 |
// ** if 0, no quick preview will be shown **/ |
// ** if 0, no quick preview will be shown **/ |
536 |
private int quickPreviewHint = 0; |
// private int quickPreviewHint = 0; |
537 |
|
|
538 |
private Map<Object, Object> rendererHints = GTUtil |
private Map<Object, Object> rendererHints = GTUtil |
539 |
.getDefaultGTRendererHints(localRenderer); |
.getDefaultGTRendererHints(getLocalRenderer()); |
540 |
|
|
541 |
/** |
/** |
542 |
* If set to <code>true</code>, the {@link #startRenderThreadsTimer} will |
* If set to <code>true</code>, the {@link #startRenderThreadsTimer} will |
634 |
if (!isWellDefined()) |
if (!isWellDefined()) |
635 |
return; |
return; |
636 |
|
|
637 |
LOGGER.debug("resizeTimer performed"); |
// LOGGER.debug("resizeTimer performed"); |
638 |
|
|
639 |
final Rectangle bounds = getVisibleRect(); |
// final Rectangle bounds = getVisibleRect(); |
640 |
// |
// |
641 |
// System.out.println("\n\ntimer performs with bounds = " |
// System.out.println("\n\ntimer performs with bounds = " |
642 |
// + bounds); |
// + bounds); |
643 |
|
|
644 |
final Envelope geoMapArea = tranformWindowToGeo( |
// final Envelope geoMapArea = tranformWindowToGeo( |
645 |
bounds.x, bounds.y, bounds.x + bounds.width, |
// bounds.x, bounds.y, bounds.x + bounds.width, |
646 |
bounds.y + bounds.height); |
// bounds.y + bounds.height); |
647 |
|
|
648 |
if (setMapArea(geoMapArea)) { |
paneResized = true; |
649 |
LOGGER.debug(" maparea changed"); |
if (!setMapArea(getMapArea())) { |
650 |
paneResized = true; |
// It's important to request new rendering here. |
651 |
} else |
// setMapArea only returns true and only calls |
652 |
LOGGER.debug(" maparea NOT changed"); |
// requestStartRendering if the maparea has changed. |
653 |
|
// But if the component is resized, the maparea |
654 |
|
// doesn't have to change. |
655 |
|
requestStartRendering(); |
656 |
|
} |
657 |
|
|
658 |
} |
} |
659 |
}); |
}); |
660 |
resizeTimer.setRepeats(false); |
resizeTimer.setRepeats(false); |
669 |
// Seems to be called twice with the same size.. |
// Seems to be called twice with the same size.. |
670 |
if (oldVisibleRect != null |
if (oldVisibleRect != null |
671 |
&& oldVisibleRect.equals(getVisibleRect())) { |
&& oldVisibleRect.equals(getVisibleRect())) { |
672 |
LOGGER.debug("skipping resize."); |
// LOGGER.debug("skipping resize."); |
673 |
return; |
return; |
674 |
} |
} |
675 |
|
|
676 |
LOGGER.debug("resized: " + getVisibleRect()); |
// LOGGER.debug("resized: " + getVisibleRect()); |
677 |
resizeTimer.restart(); |
resizeTimer.restart(); |
678 |
oldVisibleRect = getVisibleRect(); |
oldVisibleRect = getVisibleRect(); |
679 |
} |
} |
1017 |
* |
* |
1018 |
* @param g |
* @param g |
1019 |
* Graphics2D to paint the preview into |
* Graphics2D to paint the preview into |
|
* |
|
|
* @param state |
|
|
* Max be {@link #ZOOM_IN} or {@link #ZOOM_OUT} |
|
1020 |
*/ |
*/ |
1021 |
protected boolean drawScaledPreviewImage_Zoom(final Graphics2D graphics) { |
protected boolean drawScaledPreviewImage_Zoom(final Graphics2D graphics) { |
1022 |
|
|
1023 |
// if (1 == 1)return false; |
// if (1 == 1)return false; |
1024 |
|
// if (quickPreviewHint == 0) |
1025 |
|
// return false; |
1026 |
|
|
1027 |
if (quickPreviewHint == 0) |
if (oldMapArea == null) |
1028 |
return false; |
return false; |
1029 |
|
|
1030 |
graphics.setRenderingHint(RenderingHints.KEY_INTERPOLATION, |
if (getPreFinalImage() == null) |
|
RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR); |
|
|
graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, |
|
|
RenderingHints.VALUE_ANTIALIAS_OFF); |
|
|
graphics.setRenderingHint(RenderingHints.KEY_RENDERING, |
|
|
RenderingHints.VALUE_RENDER_SPEED); |
|
|
|
|
|
if (oldMapArea == null) |
|
1031 |
return false; |
return false; |
1032 |
|
|
1033 |
final Rectangle visibleArea = getVisibleRect(); |
final Rectangle visibleArea = getVisibleRect(); |
1042 |
final int xx2 = (int) Math.round(oldMapWindow.getMaxX()); |
final int xx2 = (int) Math.round(oldMapWindow.getMaxX()); |
1043 |
final int yy2 = (int) Math.round(oldMapWindow.getMaxY()); |
final int yy2 = (int) Math.round(oldMapWindow.getMaxY()); |
1044 |
|
|
1045 |
|
graphics.setRenderingHint(RenderingHints.KEY_INTERPOLATION, |
1046 |
|
RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR); |
1047 |
|
graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, |
1048 |
|
RenderingHints.VALUE_ANTIALIAS_OFF); |
1049 |
|
graphics.setRenderingHint(RenderingHints.KEY_RENDERING, |
1050 |
|
RenderingHints.VALUE_RENDER_SPEED); |
1051 |
|
|
1052 |
graphics.drawImage(getPreFinalImage(), xx1, yy1, xx2, yy2, |
graphics.drawImage(getPreFinalImage(), xx1, yy1, xx2, yy2, |
1053 |
(int) visibleArea.getMinX(), (int) visibleArea.getMinY(), |
(int) visibleArea.getMinX(), (int) visibleArea.getMinY(), |
1054 |
(int) visibleArea.getMaxX(), (int) visibleArea.getMaxY(), |
(int) visibleArea.getMaxX(), (int) visibleArea.getMaxY(), |
1057 |
final Rectangle painedArea = new Rectangle(xx1, yy1, xx2 - xx1, yy2 |
final Rectangle painedArea = new Rectangle(xx1, yy1, xx2 - xx1, yy2 |
1058 |
- yy1); |
- yy1); |
1059 |
|
|
1060 |
SwingUtil.clearAround(graphics, painedArea, visibleArea); |
SwingUtil.clearAround(graphics, painedArea, visibleArea, |
1061 |
|
getMapBackgroundColor()); |
1062 |
|
|
1063 |
addGadgets(graphics, true); |
addGadgets(graphics, true); |
1064 |
|
|
1065 |
quickPreviewHint = 0; |
// quickPreviewHint = 0; |
1066 |
|
|
1067 |
repaintTimer.restart(); |
repaintTimer.restart(); |
1068 |
|
|
|
graphics.dispose(); |
|
|
|
|
1069 |
// Something has been drawn |
// Something has been drawn |
1070 |
return true; |
return true; |
1071 |
} |
} |
1078 |
* Lazyly initializes a {@link BufferedImage} for the background renderer. |
* Lazyly initializes a {@link BufferedImage} for the background renderer. |
1079 |
*/ |
*/ |
1080 |
private Image getBgImage() { |
private Image getBgImage() { |
1081 |
// |
if (bgImage == null) { |
1082 |
// if (bgImage == null) { |
bgImage = new BufferedImage(getVisibleRect().width, |
1083 |
// bgImage = createImage(getBounds().width, getBounds().height); |
getVisibleRect().height, IMAGETYPE); |
1084 |
// } |
SwingUtil.clearImage(finalImage, getMapBackgroundColor()); |
1085 |
|
} |
1086 |
|
|
1087 |
return bgImage; |
return bgImage; |
1088 |
} |
} |
1100 |
// Rectangle curPaintArea = getVisibleRect(); |
// Rectangle curPaintArea = getVisibleRect(); |
1101 |
finalImage = new BufferedImage(getVisibleRect().width, |
finalImage = new BufferedImage(getVisibleRect().width, |
1102 |
getVisibleRect().height, IMAGETYPE); |
getVisibleRect().height, IMAGETYPE); |
1103 |
|
SwingUtil.clearImage(finalImage, getMapBackgroundColor()); |
1104 |
|
|
1105 |
requestStartRendering(); |
// requestStartRendering(); |
1106 |
} |
} |
1107 |
return finalImage; |
return finalImage; |
1108 |
} |
} |
1109 |
|
|
|
public RenderingHints getJava2dHints() { |
|
|
return java2dHints; |
|
|
} |
|
|
|
|
1110 |
/** |
/** |
1111 |
* Lazyly initializes a {@link BufferedImage} for the background renderer. |
* Lazyly initializes a {@link BufferedImage} for the background renderer. |
1112 |
*/ |
*/ |
1115 |
if (localImage == null) { |
if (localImage == null) { |
1116 |
localImage = new BufferedImage(getVisibleRect().width, |
localImage = new BufferedImage(getVisibleRect().width, |
1117 |
getVisibleRect().height, IMAGETYPE_withAlpha); |
getVisibleRect().height, IMAGETYPE_withAlpha); |
1118 |
|
SwingUtil.clearImage(localImage, getMapBackgroundColor()); |
1119 |
} |
} |
1120 |
|
|
1121 |
return localImage; |
return localImage; |
1157 |
try { |
try { |
1158 |
localContext.setCoordinateReferenceSystem(GeoImportUtil |
localContext.setCoordinateReferenceSystem(GeoImportUtil |
1159 |
.getDefaultCRS()); |
.getDefaultCRS()); |
1160 |
} catch (Exception e) { |
} catch (final Exception e) { |
1161 |
throw new RuntimeException("setting context CRS:", e); |
throw new RuntimeException("setting context CRS:", e); |
1162 |
} |
} |
1163 |
|
|
1171 |
* If no parent component is available, WHITE is returned. |
* If no parent component is available, WHITE is returned. |
1172 |
**/ |
**/ |
1173 |
public Color getMapBackgroundColor() { |
public Color getMapBackgroundColor() { |
1174 |
if (mapBackgroundColor == null){ |
if (mapBackgroundColor == null) { |
1175 |
if (getParent() != null) return getParent().getBackground(); |
if (getParent() != null) |
1176 |
else return Color.WHITE; |
return getParent().getBackground(); |
1177 |
|
else |
1178 |
|
return Color.WHITE; |
1179 |
} |
} |
1180 |
return mapBackgroundColor; |
return mapBackgroundColor; |
1181 |
} |
} |
1203 |
|
|
1204 |
public Envelope getMaxExtend() { |
public Envelope getMaxExtend() { |
1205 |
if (maxExtend == null) { |
if (maxExtend == null) { |
1206 |
// Commented-out because it takes soo much time! |
|
1207 |
// |
// The next command may take long time! |
1208 |
// long start = System.currentTimeMillis(); |
// long start = System.currentTimeMillis(); |
1209 |
// final ReferencedEnvelope layerBounds = GTUtil |
final ReferencedEnvelope layerBounds = GTUtil |
1210 |
// .getVisibleLayoutBounds(localContext); |
.getVisibleLayoutBounds(localContext); |
1211 |
// |
// |
1212 |
// LOGGER.info( |
// LOGGER.info( |
1213 |
// (System.currentTimeMillis()-start)+"m to get maxExtend"); |
// (System.currentTimeMillis()-start)+"m to get maxExtend"); |
1214 |
// |
// |
1215 |
// if (layerBounds == null) { |
if (layerBounds == null) { |
1216 |
// // TODO Last fallback could be the CRS valid area |
// // TODO Last fallback could be the CRS valid area |
1217 |
// return null; |
return null; |
1218 |
// } |
} |
1219 |
// |
|
1220 |
// // Kartenbereich um 10% vergroessern |
// Vergrößerung um 10% nochmal rausgenommen |
1221 |
|
// // // Kartenbereich um 10% vergroessern |
1222 |
// return JTSUtil.fixAspectRatio(getVisibleRect(), JTSUtil |
// return JTSUtil.fixAspectRatio(getVisibleRect(), JTSUtil |
1223 |
// .expandEnvelope(layerBounds, 0.1), true); |
// .expandEnvelope(layerBounds, 0.1), true); |
1224 |
|
|
1225 |
|
return JTSUtil.fixAspectRatio(getVisibleRect(), layerBounds, true); |
1226 |
} |
} |
1227 |
return maxExtend; |
return maxExtend; |
1228 |
} |
} |
1250 |
} |
} |
1251 |
|
|
1252 |
private Image getPreFinalImage() { |
private Image getPreFinalImage() { |
|
// if (preFinalImage == null) { |
|
|
// |
|
|
// // Rectangle curPaintArea = getVisibleRect(); |
|
|
// // preFinalImage = new BufferedImage(curPaintArea.width, |
|
|
// // curPaintArea.height, BufferedImage.TYPE_INT_RGB); |
|
|
// |
|
|
// preFinalImage = createImage(getBounds().width, getBounds().height); |
|
|
// |
|
|
// requestStartRendering(); |
|
|
// } |
|
1253 |
return preFinalImage; |
return preFinalImage; |
1254 |
} |
} |
1255 |
|
|
1418 |
|| (getState() == XMapPane.SELECT_TOP)) { |
|| (getState() == XMapPane.SELECT_TOP)) { |
1419 |
|
|
1420 |
// Draws a rectangle |
// Draws a rectangle |
1421 |
final Graphics graphics = getGraphics(); |
final Graphics2D graphics = (Graphics2D) getGraphics(); |
1422 |
drawRectangle(graphics, startPos, event.getPoint()); |
drawRectangle(graphics, startPos, event.getPoint()); |
1423 |
if ((lastPos.x > 0) && (lastPos.y > 0)) |
if ((lastPos.x > 0) && (lastPos.y > 0)) |
1424 |
drawRectangle(graphics, startPos, lastPos); |
drawRectangle(graphics, startPos, lastPos); |
1430 |
* Called by the {@link RenderingExecutor} when rendering was cancelled. |
* Called by the {@link RenderingExecutor} when rendering was cancelled. |
1431 |
*/ |
*/ |
1432 |
public void onRenderingCancelled() { |
public void onRenderingCancelled() { |
1433 |
LOGGER.debug("Rendering cancelled"); |
// LOGGER.debug("Rendering cancelled"); |
1434 |
repaintTimer.stop(); |
repaintTimer.stop(); |
1435 |
} |
} |
1436 |
|
|
1437 |
/** |
/** |
1438 |
* Called by the {@link RenderingExecutor} when rendering has been |
* Called by the {@link RenderingExecutor} when rendering has been |
1439 |
* completed. |
* completed. |
1440 |
|
* |
1441 |
|
* @param l |
1442 |
|
* long ms the rendering took |
1443 |
*/ |
*/ |
1444 |
public void onRenderingCompleted() { |
public void onRenderingCompleted(final long l) { |
1445 |
LOGGER.debug("complete"); |
lastRenderingDuration = (lastRenderingDuration + l) / 2; |
1446 |
|
// LOGGER |
1447 |
|
// .debug("complete rendering after " + lastRenderingDuration |
1448 |
|
// + "ms"); |
1449 |
|
|
1450 |
repaintTimer.stop(); |
repaintTimer.stop(); |
1451 |
|
|
1497 |
|
|
1498 |
if (!isWellDefined()) |
if (!isWellDefined()) |
1499 |
return; |
return; |
1500 |
|
// |
1501 |
|
// if (paneResized) { |
1502 |
|
// // ((Graphics2D) g).setBackground(getMapBackgroundColor()); |
1503 |
|
// // g.clearRect(0, 0, getVisibleRect().width, |
1504 |
|
// getVisibleRect().height); |
1505 |
|
// return; |
1506 |
|
// } |
1507 |
|
|
1508 |
// super.paintComponent(g); // candidate for removal |
// super.paintComponent(g); // candidate for removal |
1509 |
|
|
1516 |
// If the new mapArea and the oldMapArea intersect, we can draw some |
// If the new mapArea and the oldMapArea intersect, we can draw some |
1517 |
// quick scaled preview to make the user feel that something is |
// quick scaled preview to make the user feel that something is |
1518 |
// happening. |
// happening. |
1519 |
if (mapAreaChanged && oldMapArea != null |
if (lastRenderingDuration > PRESCALE_MINTIME && mapAreaChanged |
1520 |
|
&& oldMapArea != null |
1521 |
&& getMapArea().intersects(oldMapArea) |
&& getMapArea().intersects(oldMapArea) |
1522 |
& !getMapArea().equals(oldMapArea) && !paneResized) { |
&& !getMapArea().equals(oldMapArea) && !paneResized) { |
1523 |
|
|
1524 |
mapAreaChanged = false; |
mapAreaChanged = false; |
1525 |
|
|
1526 |
if (getMapArea().covers(oldMapArea)) { |
// if (getMapArea().covers(oldMapArea)) { |
1527 |
quickPreviewHint = ZOOM_OUT; |
// // quickPreviewHint = ZOOM_OUT; |
1528 |
paintedSomething = drawScaledPreviewImage_Zoom((Graphics2D) g); |
// paintedSomething = drawScaledPreviewImage_Zoom((Graphics2D) |
1529 |
} else if (oldMapArea.covers(getMapArea())) { |
// g); |
1530 |
quickPreviewHint = ZOOM_IN; |
// } else if (oldMapArea.covers(getMapArea())) { |
1531 |
paintedSomething = drawScaledPreviewImage_Zoom((Graphics2D) g); |
// quickPreviewHint = ZOOM_IN; |
1532 |
} |
paintedSomething = drawScaledPreviewImage_Zoom((Graphics2D) g); |
1533 |
|
// } |
1534 |
} |
} |
1535 |
} |
} |
1536 |
|
|
1538 |
|
|
1539 |
g.drawImage(getFinalImage(), 0, 0, null); |
g.drawImage(getFinalImage(), 0, 0, null); |
1540 |
|
|
|
g.dispose(); // cand. for removal |
|
|
|
|
1541 |
paintedSomething = true; // cand. for removal |
paintedSomething = true; // cand. for removal |
1542 |
} |
} |
1543 |
|
|
1593 |
*/ |
*/ |
1594 |
public void performPan() { |
public void performPan() { |
1595 |
|
|
1596 |
Rectangle winBounds = getVisibleRect(); |
final Rectangle winBounds = getVisibleRect(); |
1597 |
|
|
1598 |
winBounds.translate(-imageOrigin.x, -imageOrigin.y); |
winBounds.translate(-imageOrigin.x, -imageOrigin.y); |
1599 |
final Envelope newMapArea = tranformWindowToGeo(winBounds.x, |
final Envelope newMapArea = tranformWindowToGeo(winBounds.x, |
1661 |
* the current map pane extent (screen units) |
* the current map pane extent (screen units) |
1662 |
*/ |
*/ |
1663 |
private void resetTransforms() { |
private void resetTransforms() { |
1664 |
ReferencedEnvelope refMapEnv = new ReferencedEnvelope(mapArea, |
final ReferencedEnvelope refMapEnv = new ReferencedEnvelope(mapArea, |
1665 |
getMapContext().getCoordinateReferenceSystem()); |
getMapContext().getCoordinateReferenceSystem()); |
1666 |
|
|
1667 |
// System.out |
// System.out |
1675 |
try { |
try { |
1676 |
screenToWorld = worldToScreen.createInverse(); |
screenToWorld = worldToScreen.createInverse(); |
1677 |
|
|
1678 |
} catch (NoninvertibleTransformException ex) { |
} catch (final NoninvertibleTransformException ex) { |
1679 |
LOGGER |
LOGGER |
1680 |
.error("can't invert worldToScreen to get screenToWorld!", |
.error("can't invert worldToScreen to get screenToWorld!", |
1681 |
ex); |
ex); |
1731 |
|
|
1732 |
// setMapArea(localContext.getAreaOfInterest()); |
// setMapArea(localContext.getAreaOfInterest()); |
1733 |
|
|
1734 |
localRenderer.setContext(localContext); |
getLocalRenderer().setContext(localContext); |
1735 |
|
|
1736 |
this.localContext.addMapLayerListListener(localContextListener); |
this.localContext.addMapLayerListListener(localContextListener); |
1737 |
|
|
1745 |
|
|
1746 |
} |
} |
1747 |
|
|
1748 |
|
public void setBorder(final Border b) { |
1749 |
|
super.setBorder(b); |
1750 |
|
} |
1751 |
|
|
1752 |
|
/** |
1753 |
|
* Triggers to repaint (fast) and re-render (slow) the JMapPane. |
1754 |
|
*/ |
1755 |
|
public void refresh() { |
1756 |
|
mapImageInvalid = true; |
1757 |
|
repaint(); |
1758 |
|
} |
1759 |
|
|
1760 |
|
// /** |
1761 |
|
// * Triggers to use new {@link GTRenderer} and refresh the map. Should be |
1762 |
|
// * called after {@link Style}s have been changed because GTRenderer is |
1763 |
|
// * otherwise not working well. |
1764 |
|
// */ |
1765 |
|
// public void refreshRenderers() { |
1766 |
|
// localRenderer = GTUtil.createGTRenderer(); |
1767 |
|
// setLocalContext(getMapContext()); |
1768 |
|
// mapImageInvalid = true; |
1769 |
|
// repaint(); |
1770 |
|
// } |
1771 |
|
|
1772 |
|
/** |
1773 |
|
* Set the new map area. |
1774 |
|
* |
1775 |
|
* @param newMapArea |
1776 |
|
* @return <code>true</code> if the mapArea has been changed and a repaint |
1777 |
|
* has been triggered. |
1778 |
|
*/ |
1779 |
public boolean setMapArea(final Envelope newMapArea) { |
public boolean setMapArea(final Envelope newMapArea) { |
1780 |
if (newMapArea == null) |
if (newMapArea == null) |
1781 |
return false; |
return false; |
1782 |
if (getMapContext() |
if (getMapContext().getCoordinateReferenceSystem() == null) |
1783 |
.getCoordinateReferenceSystem() == null) return false; |
return false; |
1784 |
return setMapArea(new ReferencedEnvelope(newMapArea, getMapContext() |
return setMapArea(new ReferencedEnvelope(newMapArea, getMapContext() |
1785 |
.getCoordinateReferenceSystem())); |
.getCoordinateReferenceSystem())); |
1786 |
} |
} |
1787 |
|
|
1788 |
/** |
/** |
1789 |
|
* Set the new map area. |
1790 |
|
* |
1791 |
* @param newMapArea |
* @param newMapArea |
1792 |
* @return <code>true</code> if the mapArea has been changed and a repaint |
* @return <code>true</code> if the mapArea has been changed and a repaint |
1793 |
* has been triggered. |
* has been triggered. |
1862 |
* |
* |
1863 |
* @param if <code>null</code>, white is used. |
* @param if <code>null</code>, white is used. |
1864 |
*/ |
*/ |
1865 |
public void setMapBackgroundColor(Color bgColor) { |
public void setMapBackgroundColor(final Color bgColor) { |
1866 |
this.mapBackgroundColor = bgColor; |
this.mapBackgroundColor = bgColor; |
1867 |
} |
} |
1868 |
|
|
1920 |
} |
} |
1921 |
|
|
1922 |
// /** Stored the time used for the last real rendering in ms. **/ |
// /** Stored the time used for the last real rendering in ms. **/ |
1923 |
// private long lastRenderingDuration = Long.MAX_VALUE; |
private long lastRenderingDuration = 1000; |
1924 |
|
|
1925 |
/** |
/** |
1926 |
* Set the minimum (nearest) allowed zoom scale. This is the bigger number |
* Set the minimum (nearest) allowed zoom scale. This is the bigger number |
2028 |
// localExecuter = new RenderingExecutor(this, 150l); |
// localExecuter = new RenderingExecutor(this, 150l); |
2029 |
// LOGGER.debug("starting local renderer:"); |
// LOGGER.debug("starting local renderer:"); |
2030 |
|
|
2031 |
localRenderer.setJava2DHints(getJava2dHints()); |
getLocalRenderer().setJava2DHints(getJava2dHints()); |
2032 |
localRenderer.setRendererHints(getRendererHints()); |
getLocalRenderer().setRendererHints(getRendererHints()); |
2033 |
|
|
2034 |
final boolean submitted = localExecuter.submit(getMapArea(), |
final boolean submitted = localExecuter.submit(getMapArea(), |
2035 |
curPaintArea, (Graphics2D) getLocalImage().getGraphics(), |
curPaintArea, (Graphics2D) getLocalImage().getGraphics(), |
2036 |
localRenderer); |
getLocalRenderer()); |
2037 |
if (submitted) |
if (submitted) |
2038 |
repaintTimer.restart(); |
repaintTimer.restart(); |
2039 |
else |
else |
2045 |
updateCursor(); |
updateCursor(); |
2046 |
} |
} |
2047 |
|
|
2048 |
|
private RenderingHints getJava2dHints() { |
2049 |
|
return java2dHints; |
2050 |
|
} |
2051 |
|
|
2052 |
/** |
/** |
2053 |
* Transformiert einen Geo-Koordinaten-Bereich in Fenster-Koordinaten. |
* Transformiert einen Geo-Koordinaten-Bereich in Fenster-Koordinaten. |
2054 |
* |
* |
2188 |
finalG.drawImage(getPreFinalImage(), imageOrigin.x, imageOrigin.y, |
finalG.drawImage(getPreFinalImage(), imageOrigin.x, imageOrigin.y, |
2189 |
getMapBackgroundColor(), null); |
getMapBackgroundColor(), null); |
2190 |
|
|
2191 |
final int finalImageHeight = getFinalImage().getHeight(null); |
// When panning, we have to clear the area around the image |
|
final int finalImageWidth = getFinalImage().getWidth(null); |
|
|
|
|
2192 |
final Rectangle painedArea = new Rectangle(imageOrigin.x, |
final Rectangle painedArea = new Rectangle(imageOrigin.x, |
2193 |
imageOrigin.y, finalImageWidth, finalImageHeight); |
imageOrigin.y, getFinalImage().getWidth(), getFinalImage() |
2194 |
SwingUtil.clearAround(finalG, painedArea, getVisibleRect()); |
.getHeight()); |
2195 |
|
SwingUtil.clearAround(finalG, painedArea, getVisibleRect(), |
2196 |
|
getMapBackgroundColor()); |
2197 |
|
|
2198 |
addGadgets(finalG, false); |
addGadgets(finalG, false); |
2199 |
|
|
2212 |
* <code>false</code>, it will only depend on |
* <code>false</code>, it will only depend on |
2213 |
* {@link #localExecuter.isRunning} and #bgExecuter.isRunning |
* {@link #localExecuter.isRunning} and #bgExecuter.isRunning |
2214 |
*/ |
*/ |
2215 |
private void addGadgets(final Graphics2D graphics, boolean forceWait) { |
private void addGadgets(final Graphics2D graphics, final boolean forceWait) { |
2216 |
|
|
2217 |
// Paint a logo to the bottom right if available |
// Paint a logo to the bottom right if available |
2218 |
if (mapImage != null) { |
if (mapImage != null) { |
2219 |
Rectangle visibleRect = getVisibleRect(); |
final Rectangle visibleRect = getVisibleRect(); |
2220 |
graphics.drawImage(mapImage, visibleRect.width |
graphics.drawImage(mapImage, visibleRect.width |
2221 |
- mapImage.getWidth() - 10, getVisibleRect().height |
- mapImage.getWidth() - 10, getVisibleRect().height |
2222 |
- mapImage.getHeight() - 10, null); |
- mapImage.getHeight() - 10, null); |
2242 |
|
|
2243 |
graphics.setColor(c); |
graphics.setColor(c); |
2244 |
|
|
2245 |
y += 24; |
y += 21; |
2246 |
} |
} |
2247 |
|
|
2248 |
if (!renderingErrors.isEmpty() && isShowExceptions()) { |
if (!renderingErrors.isEmpty() && isShowExceptions()) { |
2250 |
final Color c = graphics.getColor(); |
final Color c = graphics.getColor(); |
2251 |
graphics.setFont(errorFont); |
graphics.setFont(errorFont); |
2252 |
|
|
2253 |
for (Exception ex : renderingErrors) { |
for (final Exception ex : renderingErrors) { |
2254 |
|
|
2255 |
String errStr = ex.getLocalizedMessage(); |
String errStr = ex.getLocalizedMessage(); |
2256 |
|
|
2259 |
if (errStr == null) |
if (errStr == null) |
2260 |
errStr = "unknown error: " + ex.getClass().getSimpleName(); |
errStr = "unknown error: " + ex.getClass().getSimpleName(); |
2261 |
|
|
2262 |
graphics.setColor(Color.WHITE); |
graphics.setColor(getMapBackgroundColor()); |
2263 |
graphics.drawString(errStr, 5, y); |
graphics.drawString(errStr, 5, y); |
2264 |
graphics.setColor(Color.RED); |
graphics.setColor(Color.RED); |
2265 |
graphics.drawString(errStr, 6, y + 1); |
graphics.drawString(errStr, 6, y + 1); |
2287 |
final CoordinateReferenceSystem mapCRS = getMapContext() |
final CoordinateReferenceSystem mapCRS = getMapContext() |
2288 |
.getCoordinateReferenceSystem(); |
.getCoordinateReferenceSystem(); |
2289 |
final CoordinateReferenceSystem fCRS = features.getSchema() |
final CoordinateReferenceSystem fCRS = features.getSchema() |
2290 |
.getGeometryDescriptor().getCoordinateReferenceSystem(); |
.getCoordinateReferenceSystem(); |
2291 |
|
|
2292 |
ReferencedEnvelope _mapArea; |
ReferencedEnvelope _mapArea; |
2293 |
if (mapArea == null) |
if (mapArea == null) |
2380 |
* @param center |
* @param center |
2381 |
* position in window coordinates |
* position in window coordinates |
2382 |
* @param zoomFaktor |
* @param zoomFaktor |
2383 |
* > 1 for zoom in, < 1 for zoom out. Default is 1.33. |
* > 1 for zoom out, < 1 for zoom in. Default is .5 |
2384 |
*/ |
*/ |
2385 |
public void zoomTo(Point center, Double zoomFaktor) { |
public void zoomTo(Point center, Double zoomFaktor) { |
2386 |
if (zoomFaktor == null || zoomFaktor == 0.) |
if (zoomFaktor == null || zoomFaktor == 0.) |
2387 |
zoomFaktor = 2.; |
zoomFaktor = .5; |
2388 |
|
|
2389 |
final Point2D gcenter = getScreenToWorld().transform(center, null); |
final Point2D gcenter = getScreenToWorld().transform(center, null); |
2390 |
center = null; |
center = null; |
2405 |
.getWidth()) / 2., (mapArea.getHeight() * zoomFaktor - mapArea |
.getWidth()) / 2., (mapArea.getHeight() * zoomFaktor - mapArea |
2406 |
.getHeight()) / 2.); |
.getHeight()) / 2.); |
2407 |
|
|
2408 |
// TODO we actually want that |
// // Move the newMapArea above the new center if we zoom in: |
2409 |
// // Move the newMapArea above the new center |
newMapArea.translate(gcenter.getX() - mapArea.centre().x, gcenter |
2410 |
// newMapArea.translate(gcenter.getX() - mapArea.centre().x, gcenter |
.getY() |
2411 |
// .getY() |
- mapArea.centre().y); |
|
// - mapArea.centre().y); |
|
2412 |
|
|
2413 |
setMapArea(newMapArea); |
setMapArea(newMapArea); |
2414 |
} |
} |
2417 |
* Shall non-fatal rendering exceptions be reported in the mappane or be |
* Shall non-fatal rendering exceptions be reported in the mappane or be |
2418 |
* dropped quitely. |
* dropped quitely. |
2419 |
*/ |
*/ |
2420 |
public void setShowExceptions(boolean showExceptions) { |
public void setShowExceptions(final boolean showExceptions) { |
2421 |
this.showExceptions = showExceptions; |
this.showExceptions = showExceptions; |
2422 |
} |
} |
2423 |
|
|
2428 |
return showExceptions; |
return showExceptions; |
2429 |
} |
} |
2430 |
|
|
2431 |
|
public GTRenderer getLocalRenderer() { |
2432 |
|
return localRenderer; |
2433 |
|
} |
2434 |
|
|
2435 |
|
|
2436 |
|
|
2437 |
|
/** |
2438 |
|
* Setzt den Kartenausschnitt auf die Ausdehnung eines bestimmten Layers. |
2439 |
|
* Macht nichts, wenn {@code null} uebergeben wird. |
2440 |
|
* |
2441 |
|
* <br> |
2442 |
|
* |
2443 |
|
* @param layer |
2444 |
|
* ein Layer |
2445 |
|
*/ |
2446 |
|
public void zoomToLayer(MapLayer layer) { |
2447 |
|
if (layer == null) |
2448 |
|
return; |
2449 |
|
try { |
2450 |
|
|
2451 |
|
// BB umrechnen von Layer-CRS in Map-CRS |
2452 |
|
final CoordinateReferenceSystem targetCRS = getMapContext() |
2453 |
|
.getCoordinateReferenceSystem(); |
2454 |
|
final CoordinateReferenceSystem sourceCRS = layer |
2455 |
|
.getFeatureSource().getSchema() |
2456 |
|
.getCoordinateReferenceSystem(); |
2457 |
|
|
2458 |
|
Envelope mapAreaNew; |
2459 |
|
if (!CRS.equalsIgnoreMetadata(sourceCRS, targetCRS)) { |
2460 |
|
mapAreaNew = JTSUtil.transformEnvelope(layer.getFeatureSource() |
2461 |
|
.getBounds(), sourceCRS, targetCRS); |
2462 |
|
} else { |
2463 |
|
try { |
2464 |
|
mapAreaNew = layer.getFeatureSource().getBounds(); |
2465 |
|
} catch (java.lang.IllegalArgumentException e) { |
2466 |
|
LOGGER.error("Can't calc layers bounds...", e); |
2467 |
|
mapAreaNew = null; |
2468 |
|
|
2469 |
|
/** |
2470 |
|
* |
2471 |
|
23.10.2009 11:20:50 |
2472 |
|
* org.geotools.data.shapefile.shp.PolygonHandler read |
2473 |
|
* WARNUNG: only one hole in this polygon record ERROR |
2474 |
|
* JMapPane zoomToLayer Zoom to layer did not terminate |
2475 |
|
* correctly java.lang.IllegalArgumentException: Points of |
2476 |
|
* LinearRing do not form a closed linestring at |
2477 |
|
* com.vividsolutions |
2478 |
|
* .jts.geom.LinearRing.validateConstruction |
2479 |
|
* (LinearRing.java:105) at |
2480 |
|
* com.vividsolutions.jts.geom.LinearRing |
2481 |
|
* .<init>(LinearRing.java:100) at |
2482 |
|
* com.vividsolutions.jts.geom |
2483 |
|
* .GeometryFactory.createLinearRing |
2484 |
|
* (GeometryFactory.java:339) at |
2485 |
|
* org.geotools.data.shapefile. |
2486 |
|
* shp.PolygonHandler.read(PolygonHandler.java:188) at |
2487 |
|
* org.geotools |
2488 |
|
* .data.shapefile.shp.ShapefileReader$Record.shape |
2489 |
|
* (ShapefileReader.java:106) at |
2490 |
|
* org.geotools.data.shapefile. |
2491 |
|
* ShapefileAttributeReader.next( |
2492 |
|
* ShapefileAttributeReader.java:157) at |
2493 |
|
* org.geotools.data.shapefile |
2494 |
|
* .indexed.IndexedShapefileAttributeReader |
2495 |
|
* .next(IndexedShapefileAttributeReader.java:122) at |
2496 |
|
* org.geotools |
2497 |
|
* .data.FIDFeatureReader.next(FIDFeatureReader.java:96) at |
2498 |
|
* org.geotools.data.FIDFeatureReader.next(FIDFeatureReader. |
2499 |
|
* java:55) at org.geotools.data.MaxFeatureReader.next( |
2500 |
|
* MaxFeatureReader.java:61) at |
2501 |
|
* org.geotools.data.MaxFeatureReader |
2502 |
|
* .next(MaxFeatureReader.java:61) |
2503 |
|
**/ |
2504 |
|
} |
2505 |
|
} |
2506 |
|
|
2507 |
|
// Kartenbereich um 10% vergroessern, damit z.B. auch ein |
2508 |
|
// Punkt-Layer, |
2509 |
|
// welches nur aus 2 Punnkten besteht, sichtbar ist (Punkte liegen |
2510 |
|
// sonst |
2511 |
|
// genau auf dem Rand der angezeigten Flaeche) |
2512 |
|
|
2513 |
|
if (mapAreaNew != null) { |
2514 |
|
mapAreaNew.expandBy(mapAreaNew.getWidth() * 0.1, mapAreaNew |
2515 |
|
.getHeight() * 0.1); |
2516 |
|
setMapArea(mapAreaNew); |
2517 |
|
} else { |
2518 |
|
LOGGER |
2519 |
|
.warn("Couldn't transformEnvelope when zooming to the layer"); |
2520 |
|
} |
2521 |
|
} catch (Exception err) { |
2522 |
|
LOGGER.error("Zoom to layer did not terminate correctly", err); |
2523 |
|
} |
2524 |
|
} |
2525 |
|
|
2526 |
|
/** |
2527 |
|
* Zooms the {@link SelectableXMapPane} to the {@link Envelope} of a layer. |
2528 |
|
* |
2529 |
|
* <br> |
2530 |
|
* A refresh of the map is not done automatically |
2531 |
|
* |
2532 |
|
* @param index |
2533 |
|
* Index of the {@link MapLayer} in the {@link MapContext} (from |
2534 |
|
* back to top) |
2535 |
|
* |
2536 |
|
* @author <a href="mailto:[email protected]">Stefan Alfons |
2537 |
|
* Krüger</a> |
2538 |
|
*/ |
2539 |
|
public void zoomToLayer(int index) { |
2540 |
|
final MapContext context = getMapContext(); |
2541 |
|
if (context != null) |
2542 |
|
zoomToLayer(context.getLayer(index)); |
2543 |
|
} |
2544 |
|
|
2545 |
|
/** |
2546 |
|
* Zooms the {@link SelectableXMapPane} to the {@link Envelope} of the |
2547 |
|
* selected layer. The layer is selected by the idx, counting from front to |
2548 |
|
* back, like humans would expect in a {@link JList} |
2549 |
|
* |
2550 |
|
* <br> |
2551 |
|
* A refresh of the map is not done automatically |
2552 |
|
* |
2553 |
|
* |
2554 |
|
* |
2555 |
|
* @param index |
2556 |
|
* Reverse index of the {@link MapLayer} in the |
2557 |
|
* {@link MapContext} |
2558 |
|
* |
2559 |
|
* @author <a href="mailto:[email protected]">Stefan Alfons |
2560 |
|
* Krüger</a> |
2561 |
|
*/ |
2562 |
|
public void zoomToLayerIdxReverse(int index) { |
2563 |
|
zoomToLayer(getMapContext().getLayerCount() - 1 - index); |
2564 |
|
} |
2565 |
|
|
2566 |
|
|
2567 |
|
|
2568 |
|
|
2569 |
|
|
2570 |
|
/** |
2571 |
|
* Aktiviert oder deaktiviert das AntiAliasing for diese |
2572 |
|
* {@link SelectableXMapPane}. AntiALiasing ist besonders fuer |
2573 |
|
* Textbeschriftung sehr schoen, verbraucht aber auch mehr Performance. |
2574 |
|
* |
2575 |
|
* @author <a href="mailto:[email protected]">Stefan Alfons |
2576 |
|
* Krüger</a> |
2577 |
|
*/ |
2578 |
|
public void setAntiAliasing(final boolean aa) { |
2579 |
|
// LOGGER.info("Setting AntiAliasing for this JMapPane to " + aa); |
2580 |
|
RenderingHints java2DHints = java2dHints; |
2581 |
|
if (java2DHints == null) { |
2582 |
|
java2DHints = GeoTools.getDefaultHints(); |
2583 |
|
} |
2584 |
|
|
2585 |
|
java2DHints.put(RenderingHints.KEY_ANTIALIASING, |
2586 |
|
aa ? RenderingHints.VALUE_ANTIALIAS_ON |
2587 |
|
: RenderingHints.VALUE_ANTIALIAS_OFF); |
2588 |
|
java2DHints.put(RenderingHints.KEY_TEXT_ANTIALIASING, |
2589 |
|
aa ? RenderingHints.VALUE_TEXT_ANTIALIAS_ON |
2590 |
|
: RenderingHints.VALUE_TEXT_ANTIALIAS_OFF); |
2591 |
|
java2DHints.put(RenderingHints.KEY_RENDERING, |
2592 |
|
aa ? RenderingHints.VALUE_RENDER_QUALITY |
2593 |
|
: RenderingHints.VALUE_RENDER_SPEED); |
2594 |
|
|
2595 |
|
} |
2596 |
|
|
2597 |
} |
} |