/[schmitzm]/trunk/src/skrueger/geotools/XMapPane.java
ViewVC logotype

Diff of /trunk/src/skrueger/geotools/XMapPane.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

branches/1.0-gt2-2.6/src/skrueger/geotools/XMapPane.java revision 560 by alfonx, Tue Nov 24 14:57:05 2009 UTC branches/2.0-RC2/src/skrueger/geotools/XMapPane.java revision 644 by alfonx, Thu Jan 28 16:28:36 2010 UTC
# Line 26  import java.util.HashMap; Line 26  import java.util.HashMap;
26  import java.util.Map;  import java.util.Map;
27  import java.util.Vector;  import java.util.Vector;
28    
29  import javax.jws.soap.SOAPBinding.Style;  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;
# Line 66  import schmitzm.geotools.map.event.MapLa Line 69  import schmitzm.geotools.map.event.MapLa
69  import schmitzm.lang.LangUtil;  import schmitzm.lang.LangUtil;
70  import schmitzm.swing.JPanel;  import schmitzm.swing.JPanel;
71  import schmitzm.swing.SwingUtil;  import schmitzm.swing.SwingUtil;
72    import schmitzm.swing.event.MouseInputType;
73    
74  import com.vividsolutions.jts.geom.Coordinate;  import com.vividsolutions.jts.geom.Coordinate;
75  import com.vividsolutions.jts.geom.Envelope;  import com.vividsolutions.jts.geom.Envelope;
# Line 96  import com.vividsolutions.jts.geom.Geome Line 100  import com.vividsolutions.jts.geom.Geome
100   */   */
101  public class XMapPane extends JPanel {  public class XMapPane extends JPanel {
102    
103          private static final int IMAGETYPE = BufferedImage.TYPE_INT_RGB;          // private static final int IMAGETYPE = BufferedImage.TYPE_INT_RGB;
104          private static final int IMAGETYPE_withAlpha = BufferedImage.TYPE_INT_ARGB;          // private static final int IMAGETYPE_withAlpha =
105            // BufferedImage.TYPE_INT_ARGB;
106            private static final int IMAGETYPE = BufferedImage.TYPE_3BYTE_BGR;
107            private static final int IMAGETYPE_withAlpha = BufferedImage.TYPE_4BYTE_ABGR;
108    
109          private final static Logger LOGGER = Logger.getLogger(XMapPane.class);          private final static Logger LOGGER = Logger.getLogger(XMapPane.class);
110    
111            /** A flag indicating whether the {@link XMapPane} is accepting repaints from the EDT. @see {@link XMapPane#setPainting(boolean)) **/
112          private boolean acceptsRepaintCalls = true;          private boolean acceptsRepaintCalls = true;
113    
114          /**          /**
# Line 216  public class XMapPane extends JPanel { Line 224  public class XMapPane extends JPanel {
224           *           *
225           * @see #addGadgets(Graphics2D, boolean)           * @see #addGadgets(Graphics2D, boolean)
226           */           */
227          final static Font waitFont = new Font("Arial", Font.BOLD, 30);          final static Font waitFont = new Font("Arial", Font.BOLD, 28);
228    
229          /**          /**
230           * {@link Font} used to paint error messages into the map           * {@link Font} used to paint error messages into the map
# Line 226  public class XMapPane extends JPanel { Line 234  public class XMapPane extends JPanel {
234          final static Font errorFont = new Font("Arial", Font.BOLD, 13);          final static Font errorFont = new Font("Arial", Font.BOLD, 13);
235    
236          /**          /**
237             * If last average last two renderings took more than that many ms, show the
238             * user a scaled preview
239             **/
240            private static final long PRESCALE_MINTIME = 230;
241    
242            /**
243           * 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
244           * another thread.           * another thread.
245           *           *
# Line 240  public class XMapPane extends JPanel { Line 254  public class XMapPane extends JPanel {
254           * @param e           * @param e
255           *            Maus-Ereignis           *            Maus-Ereignis
256           */           */
257          public static Point2D getMapCoordinatesFromEvent(final MouseEvent e) {          public static DirectPosition2D getMapCoordinatesFromEvent(final MouseEvent e) {
258                  // aktuelle Geo-Position aus GeoMouseEvent ermitteln                  // aktuelle Geo-Position aus GeoMouseEvent ermitteln
259                  if (e != null && e instanceof MapMouseEvent)                  if (e != null && e instanceof MapMouseEvent)
260                          try {                          try {
261                                  return ((MapMouseEvent) e).getMapPosition().toPoint2D();                                  return ((MapMouseEvent) e).getMapPosition();
262                          } catch (final Exception err) {                          } catch (final Exception err) {
263                                  LOGGER                                  LOGGER
264                                                  .error(                                                  .error(
# Line 261  public class XMapPane extends JPanel { Line 275  public class XMapPane extends JPanel {
275                                  return null;                                  return null;
276    
277                          final AffineTransform at = xMapPane.getScreenToWorld();                          final AffineTransform at = xMapPane.getScreenToWorld();
278                          if (at != null)                          if (at != null) {
279                                  return at.transform(e.getPoint(), null);                                  Point2D transformed = at.transform(e.getPoint(), null);
280                                    return new DirectPosition2D(xMapPane.getMapContext()
281                                                    .getCoordinateReferenceSystem(), transformed.getX(),
282                                                    transformed.getY());
283                            }
284                          return null;                          return null;
285                  }                  }
286                  throw new IllegalArgumentException(                  throw new IllegalArgumentException(
# Line 277  public class XMapPane extends JPanel { Line 295  public class XMapPane extends JPanel {
295    
296                  @Override                  @Override
297                  public void layerAdded(final MapLayerListEvent event) {                  public void layerAdded(final MapLayerListEvent event) {
298                          MapLayer layer = event.getLayer();                          final MapLayer layer = event.getLayer();
299                          layer.addMapLayerListener(bgMapLayerListener);                          layer.addMapLayerListener(bgMapLayerListener);
300                          requestStartRendering();                          requestStartRendering();
301    
# Line 403  public class XMapPane extends JPanel { Line 421  public class XMapPane extends JPanel {
421    
422                  @Override                  @Override
423                  public void layerChanged(final MapLayerListEvent event) {                  public void layerChanged(final MapLayerListEvent event) {
424  //                      localRenderer = GTUtil.createGTRenderer();                          // getLocalRenderer().setContext(getMapContext()); geht doch auch
425                          getLocalRenderer().setContext(getMapContext());                          // ohne?!?!? wow...
426                          requestStartRendering();                          requestStartRendering();
427                  }                  }
428    
# Line 425  public class XMapPane extends JPanel { Line 443  public class XMapPane extends JPanel {
443    
444          /**          /**
445           * Listens to each layer in the local {@link MapContext} for changes and           * Listens to each layer in the local {@link MapContext} for changes and
446           * triggers repaints.           * triggers repaints. We don't have to listen layerChanged, because that is
447             * already done in {@link #localContextListener}
448           */           */
449          protected MapLayerListener localMapLayerListener = new MapLayerAdapter() {          protected MapLayerListener localMapLayerListener = new MapLayerAdapter() {
450    
451                  @Override                  // @Override
452                  public void layerChanged(final MapLayerEvent event) {                  // public void layerChanged(final MapLayerEvent event) {
453                          getLocalRenderer().setContext(getMapContext()); // betters for SLD                  // // getLocalRenderer().setContext(getMapContext()); // betters for SLD
454                          // changes?!                  // // // changes?!
455                          requestStartRendering();                  // // requestStartRendering();
456                  }                  // }
457    
458                  @Override                  @Override
459                  public void layerHidden(final MapLayerEvent event) {                  public void layerHidden(final MapLayerEvent event) {
# Line 517  public class XMapPane extends JPanel { Line 536  public class XMapPane extends JPanel {
536          private BufferedImage preFinalImage;          private BufferedImage preFinalImage;
537    
538          // ** if 0, no quick preview will be shown **/          // ** if 0, no quick preview will be shown **/
539          private int quickPreviewHint = 0;          // private int quickPreviewHint = 0;
540    
541          private Map<Object, Object> rendererHints = GTUtil          private Map<Object, Object> rendererHints = GTUtil
542                          .getDefaultGTRendererHints(getLocalRenderer());                          .getDefaultGTRendererHints(getLocalRenderer());
# Line 543  public class XMapPane extends JPanel { Line 562  public class XMapPane extends JPanel {
562    
563          /**          /**
564           * The default state is ZOOM_IN, hence by default the           * The default state is ZOOM_IN, hence by default the
565           * {@link #zoomMapPaneMouseListener} is also enabled.           * {@link #xMapPaneMouseListener} is also enabled.
566           **/           **/
567          private int state = ZOOM_IN;          private int state = ZOOM_IN;
568    
# Line 555  public class XMapPane extends JPanel { Line 574  public class XMapPane extends JPanel {
574    
575          private AffineTransform worldToScreen;          private AffineTransform worldToScreen;
576    
577    //      /**
578    //       * This {@link MouseListener} is managing all zoom related tasks
579    //       */
580    //      private final ZoomXMapPaneMouseListener zoomMapPaneMouseListener = new ZoomXMapPaneMouseListener(
581    //                      this);
582            
583          /**          /**
584           * This {@link MouseListener} is managing all zoom related tasks           * This {@link MouseListener} is managing all zoom related tasks
585           */           */
586          public final ZoomXMapPaneMouseListener zoomMapPaneMouseListener = new ZoomXMapPaneMouseListener(          private final XMapPaneMouseListener xMapPaneMouseListener = new XMapPaneMouseListener(this);
587                          this);          
588    
589          /** Is set if a renderer has an error **/          /** Is set if a renderer has an error **/
590          protected ArrayList<Exception> renderingErrors = new ArrayList<Exception>();          protected ArrayList<Exception> renderingErrors = new ArrayList<Exception>();
# Line 600  public class XMapPane extends JPanel { Line 625  public class XMapPane extends JPanel {
625                  /**                  /**
626                   * Adding the #zoomMapPaneMouseListener                   * Adding the #zoomMapPaneMouseListener
627                   */                   */
628                  this.addMouseListener(zoomMapPaneMouseListener);                  this.addMouseListener(xMapPaneMouseListener);
629                  this.addMouseMotionListener(zoomMapPaneMouseListener);                  this.addMouseMotionListener(xMapPaneMouseListener);
630                  this.addMouseWheelListener(zoomMapPaneMouseListener);                  this.addMouseWheelListener(xMapPaneMouseListener);
631                    xMapPaneMouseListener.actions.put(MouseInputType.RClick, XMapPaneAction.ZOOM_IN);
632                    xMapPaneMouseListener.actions.put(MouseInputType.RDrag, XMapPaneAction.ZOOM_IN);
633    
634                  /*                  /*
635                   * We use a Timer object to avoid rendering delays and flickering when                   * We use a Timer object to avoid rendering delays and flickering when
# Line 618  public class XMapPane extends JPanel { Line 645  public class XMapPane extends JPanel {
645                                                  if (!isWellDefined())                                                  if (!isWellDefined())
646                                                          return;                                                          return;
647    
648                                                  LOGGER.debug("resizeTimer performed");                                                  // LOGGER.debug("resizeTimer performed");
649    
650                                                  final Rectangle bounds = getVisibleRect();                                                  // final Rectangle bounds = getVisibleRect();
651                                                  //                                                  //
652                                                  // System.out.println("\n\ntimer performs with bounds = "                                                  // System.out.println("\n\ntimer performs with bounds = "
653                                                  // + bounds);                                                  // + bounds);
654    
655                                                  final Envelope geoMapArea = tranformWindowToGeo(                                                  // final Envelope geoMapArea = tranformWindowToGeo(
656                                                                  bounds.x, bounds.y, bounds.x + bounds.width,                                                  // bounds.x, bounds.y, bounds.x + bounds.width,
657                                                                  bounds.y + bounds.height);                                                  // bounds.y + bounds.height);
658    
659                                                  if (setMapArea(geoMapArea)) {                                                  paneResized = true;
660                                                          LOGGER.debug("  maparea changed");                                                  if (!setMapArea(getMapArea())) {
661                                                          paneResized = true;                                                          // It's important to request new rendering here.
662                                                  } else                                                          // setMapArea only returns true and only calls
663                                                          LOGGER.debug("  maparea NOT changed");                                                          // requestStartRendering if the maparea has changed.
664                                                            // But if the component is resized, the maparea
665                                                            // doesn't have to change.
666                                                            requestStartRendering();
667                                                    }
668    
669                                          }                                          }
670                                  });                                  });
671                  resizeTimer.setRepeats(false);                  resizeTimer.setRepeats(false);
# Line 648  public class XMapPane extends JPanel { Line 680  public class XMapPane extends JPanel {
680                                  // Seems to be called twice with the same size..                                  // Seems to be called twice with the same size..
681                                  if (oldVisibleRect != null                                  if (oldVisibleRect != null
682                                                  && oldVisibleRect.equals(getVisibleRect())) {                                                  && oldVisibleRect.equals(getVisibleRect())) {
683                                          LOGGER.debug("skipping resize.");                                          // LOGGER.debug("skipping resize.");
684                                          return;                                          return;
685                                  }                                  }
686    
687                                  LOGGER.debug("resized: " + getVisibleRect());                                  // LOGGER.debug("resized: " + getVisibleRect());
688                                  resizeTimer.restart();                                  resizeTimer.restart();
689                                  oldVisibleRect = getVisibleRect();                                  oldVisibleRect = getVisibleRect();
690                          }                          }
# Line 952  public class XMapPane extends JPanel { Line 984  public class XMapPane extends JPanel {
984                  // Remove all mapPaneListeners that have registered with us                  // Remove all mapPaneListeners that have registered with us
985                  mapPaneListeners.clear();                  mapPaneListeners.clear();
986    
987                  removeMouseMotionListener(zoomMapPaneMouseListener);                  removeMouseMotionListener(xMapPaneMouseListener);
988                  removeMouseListener(zoomMapPaneMouseListener);                  removeMouseListener(xMapPaneMouseListener);
989    
990                  if (localContext != null)                  if (localContext != null)
991                          getMapContext().clearLayerList();                          getMapContext().clearLayerList();
# Line 962  public class XMapPane extends JPanel { Line 994  public class XMapPane extends JPanel {
994    
995                  removeAll();                  removeAll();
996          }          }
997            
998          /**          /**
999           * Draws a rectangle in XOR mode from the origin at {@link #startPos} to the           * Draws a rectangle in XOR mode from the origin at {@link #startPos} to the
1000           * given point. All in screen coordinates.           * given point. All in screen coordinates.
1001           */           */
1002          protected void drawRectangle(final Graphics graphics, final Point startPos,          protected void drawRectangle(final Graphics graphics, final Point startPos,
1003                          final Point e) {                          final Point e) {
1004                    drawRectangle(graphics, startPos, e, Color.WHITE);
1005            }
1006    
1007            /**
1008             * Draws a rectangle in XOR mode from the origin at {@link #startPos} to the
1009             * given point. All in screen coordinates.
1010             */
1011            protected void drawRectangle(final Graphics graphics, final Point startPos,
1012                            final Point e, Color color) {
1013    
1014                  if (!isWellDefined())                  if (!isWellDefined())
1015                          return;                          return;
# Line 984  public class XMapPane extends JPanel { Line 1025  public class XMapPane extends JPanel {
1025                  if (width == 0 && height == 0)                  if (width == 0 && height == 0)
1026                          return;                          return;
1027    
1028                  graphics.setXORMode(Color.WHITE);                  graphics.setXORMode(color);
1029                  graphics.drawRect(left, bottom, width, height);                  graphics.drawRect(left, bottom, width, height);
1030          }          }
1031    
# Line 996  public class XMapPane extends JPanel { Line 1037  public class XMapPane extends JPanel {
1037           *           *
1038           * @param g           * @param g
1039           *            Graphics2D to paint the preview into           *            Graphics2D to paint the preview into
          *  
          * @param state  
          *            Max be {@link #ZOOM_IN} or {@link #ZOOM_OUT}  
1040           */           */
1041          protected boolean drawScaledPreviewImage_Zoom(final Graphics2D graphics) {          protected boolean drawScaledPreviewImage_Zoom(final Graphics2D graphics) {
1042    
1043                  // if (1 == 1)return false;                  // if (1 == 1)return false;
1044                    // if (quickPreviewHint == 0)
1045                    // return false;
1046    
1047                  if (quickPreviewHint == 0)                  if (oldMapArea == null)
1048                          return false;                          return false;
1049    
1050                  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)  
1051                          return false;                          return false;
1052    
1053                  final Rectangle visibleArea = getVisibleRect();                  final Rectangle visibleArea = getVisibleRect();
# Line 1029  public class XMapPane extends JPanel { Line 1062  public class XMapPane extends JPanel {
1062                  final int xx2 = (int) Math.round(oldMapWindow.getMaxX());                  final int xx2 = (int) Math.round(oldMapWindow.getMaxX());
1063                  final int yy2 = (int) Math.round(oldMapWindow.getMaxY());                  final int yy2 = (int) Math.round(oldMapWindow.getMaxY());
1064    
1065                    graphics.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
1066                                    RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR);
1067                    graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
1068                                    RenderingHints.VALUE_ANTIALIAS_OFF);
1069                    graphics.setRenderingHint(RenderingHints.KEY_RENDERING,
1070                                    RenderingHints.VALUE_RENDER_SPEED);
1071    
1072                  graphics.drawImage(getPreFinalImage(), xx1, yy1, xx2, yy2,                  graphics.drawImage(getPreFinalImage(), xx1, yy1, xx2, yy2,
1073                                  (int) visibleArea.getMinX(), (int) visibleArea.getMinY(),                                  (int) visibleArea.getMinX(), (int) visibleArea.getMinY(),
1074                                  (int) visibleArea.getMaxX(), (int) visibleArea.getMaxY(),                                  (int) visibleArea.getMaxX(), (int) visibleArea.getMaxY(),
# Line 1037  public class XMapPane extends JPanel { Line 1077  public class XMapPane extends JPanel {
1077                  final Rectangle painedArea = new Rectangle(xx1, yy1, xx2 - xx1, yy2                  final Rectangle painedArea = new Rectangle(xx1, yy1, xx2 - xx1, yy2
1078                                  - yy1);                                  - yy1);
1079    
1080                  SwingUtil.clearAround(graphics, painedArea, visibleArea);                  SwingUtil.clearAround(graphics, painedArea, visibleArea,
1081                                    getMapBackgroundColor());
1082    
1083                  addGadgets(graphics, true);                  addGadgets(graphics, true);
1084    
1085                  quickPreviewHint = 0;                  // quickPreviewHint = 0;
1086    
1087                  repaintTimer.restart();                  repaintTimer.restart();
1088    
                 graphics.dispose();  
   
1089                  // Something has been drawn                  // Something has been drawn
1090                  return true;                  return true;
1091          }          }
# Line 1059  public class XMapPane extends JPanel { Line 1098  public class XMapPane extends JPanel {
1098           * Lazyly initializes a {@link BufferedImage} for the background renderer.           * Lazyly initializes a {@link BufferedImage} for the background renderer.
1099           */           */
1100          private Image getBgImage() {          private Image getBgImage() {
1101                  //                  if (bgImage == null) {
1102                  // if (bgImage == null) {                          bgImage = new BufferedImage(getVisibleRect().width,
1103                  // bgImage = createImage(getBounds().width, getBounds().height);                                          getVisibleRect().height, IMAGETYPE);
1104                  // }                          SwingUtil.clearImage(finalImage, getMapBackgroundColor());
1105                    }
1106    
1107                  return bgImage;                  return bgImage;
1108          }          }
# Line 1080  public class XMapPane extends JPanel { Line 1120  public class XMapPane extends JPanel {
1120                          // Rectangle curPaintArea = getVisibleRect();                          // Rectangle curPaintArea = getVisibleRect();
1121                          finalImage = new BufferedImage(getVisibleRect().width,                          finalImage = new BufferedImage(getVisibleRect().width,
1122                                          getVisibleRect().height, IMAGETYPE);                                          getVisibleRect().height, IMAGETYPE);
1123                            SwingUtil.clearImage(finalImage, getMapBackgroundColor());
1124    
1125                          requestStartRendering();                          // requestStartRendering();
1126                  }                  }
1127                  return finalImage;                  return finalImage;
1128          }          }
1129    
         public RenderingHints getJava2dHints() {  
                 return java2dHints;  
         }  
   
1130          /**          /**
1131           * Lazyly initializes a {@link BufferedImage} for the background renderer.           * Lazyly initializes a {@link BufferedImage} for the background renderer.
1132           */           */
# Line 1098  public class XMapPane extends JPanel { Line 1135  public class XMapPane extends JPanel {
1135                  if (localImage == null) {                  if (localImage == null) {
1136                          localImage = new BufferedImage(getVisibleRect().width,                          localImage = new BufferedImage(getVisibleRect().width,
1137                                          getVisibleRect().height, IMAGETYPE_withAlpha);                                          getVisibleRect().height, IMAGETYPE_withAlpha);
1138                            SwingUtil.clearImage(localImage, getMapBackgroundColor());
1139                  }                  }
1140    
1141                  return localImage;                  return localImage;
# Line 1113  public class XMapPane extends JPanel { Line 1151  public class XMapPane extends JPanel {
1151                          ReferencedEnvelope mapArea_ = null;                          ReferencedEnvelope mapArea_ = null;
1152                          try {                          try {
1153                                  mapArea_ = localContext.getLayerBounds();                                  mapArea_ = localContext.getLayerBounds();
1154                          } catch (final IOException e) {                          } catch (final Exception e) {
1155                                  LOGGER.warn("localContext.getLayerBounds()", e);                                  LOGGER.warn("localContext.getLayerBounds()", e);
1156                          }                          }
1157    
# Line 1139  public class XMapPane extends JPanel { Line 1177  public class XMapPane extends JPanel {
1177                          try {                          try {
1178                                  localContext.setCoordinateReferenceSystem(GeoImportUtil                                  localContext.setCoordinateReferenceSystem(GeoImportUtil
1179                                                  .getDefaultCRS());                                                  .getDefaultCRS());
1180                          } catch (Exception e) {                          } catch (final Exception e) {
1181                                  throw new RuntimeException("setting context CRS:", e);                                  throw new RuntimeException("setting context CRS:", e);
1182                          }                          }
1183    
# Line 1185  public class XMapPane extends JPanel { Line 1223  public class XMapPane extends JPanel {
1223    
1224          public Envelope getMaxExtend() {          public Envelope getMaxExtend() {
1225                  if (maxExtend == null) {                  if (maxExtend == null) {
1226                          // Commented-out because it takes soo much time!  
1227                          //                          // The next command may take long time!
1228                          // long start = System.currentTimeMillis();                          // long start = System.currentTimeMillis();
1229                          // final ReferencedEnvelope layerBounds = GTUtil                          final ReferencedEnvelope layerBounds = GTUtil
1230                          // .getVisibleLayoutBounds(localContext);                                          .getVisibleLayoutBounds(localContext);
1231                          //                                                //                      
1232                          // LOGGER.info(                          // LOGGER.info(
1233                          // (System.currentTimeMillis()-start)+"m to get maxExtend");                          // (System.currentTimeMillis()-start)+"m to get maxExtend");
1234                          //                                                //                      
1235                          // if (layerBounds == null) {                          if (layerBounds == null) {
1236                          // // TODO Last fallback could be the CRS valid area                                  // // TODO Last fallback could be the CRS valid area
1237                          // return null;                                  return null;
1238                          // }                          }
1239                          //  
1240                          // // Kartenbereich um 10% vergroessern                          // Vergrößerung um 10% nochmal rausgenommen
1241                            // // // Kartenbereich um 10% vergroessern
1242                          // return JTSUtil.fixAspectRatio(getVisibleRect(), JTSUtil                          // return JTSUtil.fixAspectRatio(getVisibleRect(), JTSUtil
1243                          // .expandEnvelope(layerBounds, 0.1), true);                          // .expandEnvelope(layerBounds, 0.1), true);
1244    
1245                            return JTSUtil.fixAspectRatio(getVisibleRect(), layerBounds, true);
1246                  }                  }
1247                  return maxExtend;                  return maxExtend;
1248          }          }
# Line 1229  public class XMapPane extends JPanel { Line 1270  public class XMapPane extends JPanel {
1270          }          }
1271    
1272          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();  
                 // }  
1273                  return preFinalImage;                  return preFinalImage;
1274          }          }
1275    
# Line 1407  public class XMapPane extends JPanel { Line 1438  public class XMapPane extends JPanel {
1438                                  || (getState() == XMapPane.SELECT_TOP)) {                                  || (getState() == XMapPane.SELECT_TOP)) {
1439    
1440                          // Draws a rectangle                          // Draws a rectangle
1441                          final Graphics graphics = getGraphics();                          final Graphics2D graphics = (Graphics2D) getGraphics();
1442                          drawRectangle(graphics, startPos, event.getPoint());                          drawRectangle(graphics, startPos, event.getPoint());
1443                          if ((lastPos.x > 0) && (lastPos.y > 0))                          if ((lastPos.x > 0) && (lastPos.y > 0))
1444                                  drawRectangle(graphics, startPos, lastPos);                                  drawRectangle(graphics, startPos, lastPos);
# Line 1419  public class XMapPane extends JPanel { Line 1450  public class XMapPane extends JPanel {
1450           * Called by the {@link RenderingExecutor} when rendering was cancelled.           * Called by the {@link RenderingExecutor} when rendering was cancelled.
1451           */           */
1452          public void onRenderingCancelled() {          public void onRenderingCancelled() {
1453                  LOGGER.debug("Rendering cancelled");                  // LOGGER.debug("Rendering cancelled");
1454                  repaintTimer.stop();                  repaintTimer.stop();
1455          }          }
1456    
1457          /**          /**
1458           * Called by the {@link RenderingExecutor} when rendering has been           * Called by the {@link RenderingExecutor} when rendering has been
1459           * completed.           * completed.
1460             *
1461             * @param l
1462             *            long ms the rendering took
1463           */           */
1464          public void onRenderingCompleted() {          public void onRenderingCompleted(final long l) {
1465                  LOGGER.debug("complete");                  lastRenderingDuration = (lastRenderingDuration + l) / 2;
1466                    // LOGGER
1467                    // .debug("complete rendering after " + lastRenderingDuration
1468                    // + "ms");
1469    
1470                  repaintTimer.stop();                  repaintTimer.stop();
1471    
# Line 1480  public class XMapPane extends JPanel { Line 1517  public class XMapPane extends JPanel {
1517    
1518                  if (!isWellDefined())                  if (!isWellDefined())
1519                          return;                          return;
1520                    //
1521                    // if (paneResized) {
1522                    // // ((Graphics2D) g).setBackground(getMapBackgroundColor());
1523                    // // g.clearRect(0, 0, getVisibleRect().width,
1524                    // getVisibleRect().height);
1525                    // return;
1526                    // }
1527    
1528  //               super.paintComponent(g); // candidate for removal                  // super.paintComponent(g); // candidate for removal
1529    
1530                  boolean paintedSomething = false;                  boolean paintedSomething = false;
1531    
# Line 1492  public class XMapPane extends JPanel { Line 1536  public class XMapPane extends JPanel {
1536                          // If the new mapArea and the oldMapArea intersect, we can draw some                          // If the new mapArea and the oldMapArea intersect, we can draw some
1537                          // quick scaled preview to make the user feel that something is                          // quick scaled preview to make the user feel that something is
1538                          // happening.                          // happening.
1539                          if (mapAreaChanged && oldMapArea != null                          if (lastRenderingDuration > PRESCALE_MINTIME && mapAreaChanged
1540                                            && oldMapArea != null
1541                                          && getMapArea().intersects(oldMapArea)                                          && getMapArea().intersects(oldMapArea)
1542                                          & !getMapArea().equals(oldMapArea) && !paneResized) {                                          && !getMapArea().equals(oldMapArea) && !paneResized) {
1543    
1544                                  mapAreaChanged = false;                                  mapAreaChanged = false;
1545    
1546                                  if (getMapArea().covers(oldMapArea)) {                                  // if (getMapArea().covers(oldMapArea)) {
1547                                          quickPreviewHint = ZOOM_OUT;                                  // // quickPreviewHint = ZOOM_OUT;
1548                                          paintedSomething = drawScaledPreviewImage_Zoom((Graphics2D) g);                                  // paintedSomething = drawScaledPreviewImage_Zoom((Graphics2D)
1549                                  } else if (oldMapArea.covers(getMapArea())) {                                  // g);
1550                                          quickPreviewHint = ZOOM_IN;                                  // } else if (oldMapArea.covers(getMapArea())) {
1551                                          paintedSomething = drawScaledPreviewImage_Zoom((Graphics2D) g);                                  // quickPreviewHint = ZOOM_IN;
1552                                  }                                  paintedSomething = drawScaledPreviewImage_Zoom((Graphics2D) g);
1553                                    // }
1554                          }                          }
1555                  }                  }
1556    
# Line 1512  public class XMapPane extends JPanel { Line 1558  public class XMapPane extends JPanel {
1558    
1559                          g.drawImage(getFinalImage(), 0, 0, null);                          g.drawImage(getFinalImage(), 0, 0, null);
1560    
                         g.dispose(); // cand. for removal  
   
1561                          paintedSomething = true; // cand. for removal                          paintedSomething = true; // cand. for removal
1562                  }                  }
1563    
# Line 1569  public class XMapPane extends JPanel { Line 1613  public class XMapPane extends JPanel {
1613           */           */
1614          public void performPan() {          public void performPan() {
1615    
1616                  Rectangle winBounds = getVisibleRect();                  final Rectangle winBounds = getVisibleRect();
1617    
1618                  winBounds.translate(-imageOrigin.x, -imageOrigin.y);                  winBounds.translate(-imageOrigin.x, -imageOrigin.y);
1619                  final Envelope newMapArea = tranformWindowToGeo(winBounds.x,                  final Envelope newMapArea = tranformWindowToGeo(winBounds.x,
# Line 1637  public class XMapPane extends JPanel { Line 1681  public class XMapPane extends JPanel {
1681           *            the current map pane extent (screen units)           *            the current map pane extent (screen units)
1682           */           */
1683          private void resetTransforms() {          private void resetTransforms() {
                 ReferencedEnvelope refMapEnv = new ReferencedEnvelope(mapArea,  
                                 getMapContext().getCoordinateReferenceSystem());  
   
1684                  // System.out                  // System.out
1685                  // .println("paintArea in resetTeansofrms = " + getVisibleRect());                  // .println("paintArea in resetTeansofrms = " + getVisibleRect());
1686                  if (!isWellDefined())                  if (!isWellDefined())
1687                          return;                          return;
1688    
1689                    if (mapArea == null)
1690                            return;
1691                    
1692                    final ReferencedEnvelope refMapEnv = new ReferencedEnvelope(mapArea,
1693                                    getMapContext().getCoordinateReferenceSystem());
1694    
1695                  worldToScreen = RendererUtilities.worldToScreenTransform(refMapEnv,                  worldToScreen = RendererUtilities.worldToScreenTransform(refMapEnv,
1696                                  getVisibleRect());                                  getVisibleRect());
1697    
1698                  try {                  try {
1699                          screenToWorld = worldToScreen.createInverse();                          screenToWorld = worldToScreen.createInverse();
1700    
1701                  } catch (NoninvertibleTransformException ex) {                  } catch (final NoninvertibleTransformException ex) {
1702                          LOGGER                          LOGGER
1703                                          .error("can't invert worldToScreen to get screenToWorld!",                                          .error("can't invert worldToScreen to get screenToWorld!",
1704                                                          ex);                                                          ex);
# Line 1721  public class XMapPane extends JPanel { Line 1768  public class XMapPane extends JPanel {
1768    
1769          }          }
1770    
1771            public void setBorder(final Border b) {
1772                    super.setBorder(b);
1773            }
1774    
1775          /**          /**
1776           * Triggers to repaint (fast) and re-render (slow) the JMapPane.           * Triggers to repaint (fast) and re-render (slow) the JMapPane.
1777           */           */
# Line 1741  public class XMapPane extends JPanel { Line 1792  public class XMapPane extends JPanel {
1792          // repaint();          // repaint();
1793          // }          // }
1794    
1795            /**
1796             * Set the new map area.
1797             *
1798             * @param newMapArea
1799             * @return <code>true</code> if the mapArea has been changed and a repaint
1800             *         has been triggered.
1801             */
1802          public boolean setMapArea(final Envelope newMapArea) {          public boolean setMapArea(final Envelope newMapArea) {
1803                  if (newMapArea == null)                  if (newMapArea == null)
1804                          return false;                          return false;
# Line 1751  public class XMapPane extends JPanel { Line 1809  public class XMapPane extends JPanel {
1809          }          }
1810    
1811          /**          /**
1812             * Set the new map area.
1813             *
1814           * @param newMapArea           * @param newMapArea
1815           * @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
1816           *         has been triggered.           *         has been triggered.
# Line 1825  public class XMapPane extends JPanel { Line 1885  public class XMapPane extends JPanel {
1885           *           *
1886           * @param if <code>null</code>, white is used.           * @param if <code>null</code>, white is used.
1887           */           */
1888          public void setMapBackgroundColor(Color bgColor) {          public void setMapBackgroundColor(final Color bgColor) {
1889                  this.mapBackgroundColor = bgColor;                  this.mapBackgroundColor = bgColor;
1890          }          }
1891    
# Line 1883  public class XMapPane extends JPanel { Line 1943  public class XMapPane extends JPanel {
1943          }          }
1944    
1945          // /** Stored the time used for the last real rendering in ms. **/          // /** Stored the time used for the last real rendering in ms. **/
1946          // private long lastRenderingDuration = Long.MAX_VALUE;          private long lastRenderingDuration = 1000;
1947    
1948          /**          /**
1949           * Set the minimum (nearest) allowed zoom scale. This is the bigger number           * Set the minimum (nearest) allowed zoom scale. This is the bigger number
# Line 1921  public class XMapPane extends JPanel { Line 1981  public class XMapPane extends JPanel {
1981           *           *
1982           * @param state           * @param state
1983           */           */
1984            @Deprecated
1985          public void setState(final int state) {          public void setState(final int state) {
1986                  this.state = state;                  this.state = state;
1987                    
1988    //              throw new RuntimeException("Old concept.. migrate to new concept!");
1989    
1990                  zoomMapPaneMouseListener.setEnabled((state == ZOOM_IN  //              xMapPaneMouseListener.setEnabled((state == ZOOM_IN
1991                                  || state == ZOOM_OUT || state == PAN));  //                              || state == ZOOM_OUT || state == PAN));
1992    
1993                  // Je nach Aktion den Cursor umsetzen                  // Je nach Aktion den Cursor umsetzen
1994                  updateCursor();                  updateCursor();
1995          }          }
1996            
1997            public void configureMouse(MouseInputType type, XMapPaneAction action){
1998                    
1999            }
2000    
2001          /**          /**
2002           * Standardmaessig wird der Cursor automatisch je nach MapPane-Aktion (Zoom,           * Standardmaessig wird der Cursor automatisch je nach MapPane-Aktion (Zoom,
# Line 2008  public class XMapPane extends JPanel { Line 2075  public class XMapPane extends JPanel {
2075                  updateCursor();                  updateCursor();
2076          }          }
2077    
2078            private RenderingHints getJava2dHints() {
2079                    return java2dHints;
2080            }
2081    
2082          /**          /**
2083           * Transformiert einen Geo-Koordinaten-Bereich in Fenster-Koordinaten.           * Transformiert einen Geo-Koordinaten-Bereich in Fenster-Koordinaten.
2084           *           *
# Line 2147  public class XMapPane extends JPanel { Line 2218  public class XMapPane extends JPanel {
2218                  finalG.drawImage(getPreFinalImage(), imageOrigin.x, imageOrigin.y,                  finalG.drawImage(getPreFinalImage(), imageOrigin.x, imageOrigin.y,
2219                                  getMapBackgroundColor(), null);                                  getMapBackgroundColor(), null);
2220    
2221                  final int finalImageHeight = getFinalImage().getHeight(null);                  // When panning, we have to clear the area around the image
                 final int finalImageWidth = getFinalImage().getWidth(null);  
   
2222                  final Rectangle painedArea = new Rectangle(imageOrigin.x,                  final Rectangle painedArea = new Rectangle(imageOrigin.x,
2223                                  imageOrigin.y, finalImageWidth, finalImageHeight);                                  imageOrigin.y, getFinalImage().getWidth(), getFinalImage()
2224                  SwingUtil.clearAround(finalG, painedArea, getVisibleRect());                                                  .getHeight());
2225                    SwingUtil.clearAround(finalG, painedArea, getVisibleRect(),
2226                                    getMapBackgroundColor());
2227    
2228                  addGadgets(finalG, false);                  addGadgets(finalG, false);
2229    
# Line 2171  public class XMapPane extends JPanel { Line 2242  public class XMapPane extends JPanel {
2242           *            <code>false</code>, it will only depend on           *            <code>false</code>, it will only depend on
2243           *            {@link #localExecuter.isRunning} and #bgExecuter.isRunning           *            {@link #localExecuter.isRunning} and #bgExecuter.isRunning
2244           */           */
2245          private void addGadgets(final Graphics2D graphics, boolean forceWait) {          private void addGadgets(final Graphics2D graphics, final boolean forceWait) {
2246    
2247                  // Paint a logo to the bottom right if available                  // Paint a logo to the bottom right if available
2248                  if (mapImage != null) {                  if (mapImage != null) {
2249                          Rectangle visibleRect = getVisibleRect();                          final Rectangle visibleRect = getVisibleRect();
2250                          graphics.drawImage(mapImage, visibleRect.width                          graphics.drawImage(mapImage, visibleRect.width
2251                                          - mapImage.getWidth() - 10, getVisibleRect().height                                          - mapImage.getWidth() - 10, getVisibleRect().height
2252                                          - mapImage.getHeight() - 10, null);                                          - mapImage.getHeight() - 10, null);
# Line 2201  public class XMapPane extends JPanel { Line 2272  public class XMapPane extends JPanel {
2272    
2273                          graphics.setColor(c);                          graphics.setColor(c);
2274    
2275                          y += 24;                          y += 21;
2276                  }                  }
2277    
2278                  if (!renderingErrors.isEmpty() && isShowExceptions()) {                  if (!renderingErrors.isEmpty() && isShowExceptions()) {
# Line 2209  public class XMapPane extends JPanel { Line 2280  public class XMapPane extends JPanel {
2280                          final Color c = graphics.getColor();                          final Color c = graphics.getColor();
2281                          graphics.setFont(errorFont);                          graphics.setFont(errorFont);
2282    
2283                          for (Exception ex : renderingErrors) {                          for (final Exception ex : renderingErrors) {
2284    
2285                                  String errStr = ex.getLocalizedMessage();                                  String errStr = ex.getLocalizedMessage();
2286    
# Line 2246  public class XMapPane extends JPanel { Line 2317  public class XMapPane extends JPanel {
2317                  final CoordinateReferenceSystem mapCRS = getMapContext()                  final CoordinateReferenceSystem mapCRS = getMapContext()
2318                                  .getCoordinateReferenceSystem();                                  .getCoordinateReferenceSystem();
2319                  final CoordinateReferenceSystem fCRS = features.getSchema()                  final CoordinateReferenceSystem fCRS = features.getSchema()
2320                                  .getGeometryDescriptor().getCoordinateReferenceSystem();                                  .getCoordinateReferenceSystem();
2321    
2322                  ReferencedEnvelope _mapArea;                  ReferencedEnvelope _mapArea;
2323                  if (mapArea == null)                  if (mapArea == null)
# Line 2339  public class XMapPane extends JPanel { Line 2410  public class XMapPane extends JPanel {
2410           * @param center           * @param center
2411           *            position in window coordinates           *            position in window coordinates
2412           * @param zoomFaktor           * @param zoomFaktor
2413           *            > 1 for zoom in, < 1 for zoom out. Default is 1.33.           *            > 1 for zoom out, < 1 for zoom in. Default is .5
2414           */           */
2415          public void zoomTo(Point center, Double zoomFaktor) {          public void zoomTo(Point center, Double zoomFaktor) {
2416                  if (zoomFaktor == null || zoomFaktor == 0.)                  if (zoomFaktor == null || zoomFaktor == 0.)
2417                          zoomFaktor = 2.;                          zoomFaktor = .5;
2418    
2419                  final Point2D gcenter = getScreenToWorld().transform(center, null);                  final Point2D gcenter = getScreenToWorld().transform(center, null);
2420                  center = null;                  center = null;
# Line 2364  public class XMapPane extends JPanel { Line 2435  public class XMapPane extends JPanel {
2435                                  .getWidth()) / 2., (mapArea.getHeight() * zoomFaktor - mapArea                                  .getWidth()) / 2., (mapArea.getHeight() * zoomFaktor - mapArea
2436                                  .getHeight()) / 2.);                                  .getHeight()) / 2.);
2437    
2438                  // TODO we actually want that                  // // Move the newMapArea above the new center if we zoom in:
2439                  // // Move the newMapArea above the new center                  newMapArea.translate(gcenter.getX() - mapArea.centre().x, gcenter
2440                  // newMapArea.translate(gcenter.getX() - mapArea.centre().x, gcenter                                  .getY()
2441                  // .getY()                                  - mapArea.centre().y);
                 // - mapArea.centre().y);  
2442    
2443                  setMapArea(newMapArea);                  setMapArea(newMapArea);
2444          }          }
# Line 2377  public class XMapPane extends JPanel { Line 2447  public class XMapPane extends JPanel {
2447           * Shall non-fatal rendering exceptions be reported in the mappane or be           * Shall non-fatal rendering exceptions be reported in the mappane or be
2448           * dropped quitely.           * dropped quitely.
2449           */           */
2450          public void setShowExceptions(boolean showExceptions) {          public void setShowExceptions(final boolean showExceptions) {
2451                  this.showExceptions = showExceptions;                  this.showExceptions = showExceptions;
2452          }          }
2453    
# Line 2392  public class XMapPane extends JPanel { Line 2462  public class XMapPane extends JPanel {
2462                  return localRenderer;                  return localRenderer;
2463          }          }
2464    
2465            /**
2466             * Setzt den Kartenausschnitt auf die Ausdehnung eines bestimmten Layers.
2467             * Macht nichts, wenn {@code null} uebergeben wird.
2468             *
2469             * <br>
2470             *
2471             * @param layer
2472             *            ein Layer
2473             */
2474            public void zoomToLayer(MapLayer layer) {
2475                    if (layer == null)
2476                            return;
2477                    try {
2478    
2479                            // BB umrechnen von Layer-CRS in Map-CRS
2480                            final CoordinateReferenceSystem targetCRS = getMapContext()
2481                                            .getCoordinateReferenceSystem();
2482                            final CoordinateReferenceSystem sourceCRS = layer
2483                                            .getFeatureSource().getSchema()
2484                                            .getCoordinateReferenceSystem();
2485    
2486                            Envelope mapAreaNew;
2487                            if (!CRS.equalsIgnoreMetadata(sourceCRS, targetCRS)) {
2488                                    mapAreaNew = JTSUtil.transformEnvelope(layer.getFeatureSource()
2489                                                    .getBounds(), sourceCRS, targetCRS);
2490                            } else {
2491                                    try {
2492                                            mapAreaNew = layer.getFeatureSource().getBounds();
2493                                    } catch (java.lang.IllegalArgumentException e) {
2494                                            LOGGER.error("Can't calc layers bounds...", e);
2495                                            mapAreaNew = null;
2496    
2497                                            /**
2498                                             *
2499                                             23.10.2009 11:20:50
2500                                             * org.geotools.data.shapefile.shp.PolygonHandler read
2501                                             * WARNUNG: only one hole in this polygon record ERROR
2502                                             * JMapPane zoomToLayer Zoom to layer did not terminate
2503                                             * correctly java.lang.IllegalArgumentException: Points of
2504                                             * LinearRing do not form a closed linestring at
2505                                             * com.vividsolutions
2506                                             * .jts.geom.LinearRing.validateConstruction
2507                                             * (LinearRing.java:105) at
2508                                             * com.vividsolutions.jts.geom.LinearRing
2509                                             * .<init>(LinearRing.java:100) at
2510                                             * com.vividsolutions.jts.geom
2511                                             * .GeometryFactory.createLinearRing
2512                                             * (GeometryFactory.java:339) at
2513                                             * org.geotools.data.shapefile.
2514                                             * shp.PolygonHandler.read(PolygonHandler.java:188) at
2515                                             * org.geotools
2516                                             * .data.shapefile.shp.ShapefileReader$Record.shape
2517                                             * (ShapefileReader.java:106) at
2518                                             * org.geotools.data.shapefile.
2519                                             * ShapefileAttributeReader.next(
2520                                             * ShapefileAttributeReader.java:157) at
2521                                             * org.geotools.data.shapefile
2522                                             * .indexed.IndexedShapefileAttributeReader
2523                                             * .next(IndexedShapefileAttributeReader.java:122) at
2524                                             * org.geotools
2525                                             * .data.FIDFeatureReader.next(FIDFeatureReader.java:96) at
2526                                             * org.geotools.data.FIDFeatureReader.next(FIDFeatureReader.
2527                                             * java:55) at org.geotools.data.MaxFeatureReader.next(
2528                                             * MaxFeatureReader.java:61) at
2529                                             * org.geotools.data.MaxFeatureReader
2530                                             * .next(MaxFeatureReader.java:61)
2531                                             **/
2532                                    }
2533                            }
2534    
2535                            // Kartenbereich um 10% vergroessern, damit z.B. auch ein
2536                            // Punkt-Layer,
2537                            // welches nur aus 2 Punnkten besteht, sichtbar ist (Punkte liegen
2538                            // sonst
2539                            // genau auf dem Rand der angezeigten Flaeche)
2540    
2541                            if (mapAreaNew != null) {
2542                                    mapAreaNew.expandBy(mapAreaNew.getWidth() * 0.1, mapAreaNew
2543                                                    .getHeight() * 0.1);
2544                                    setMapArea(mapAreaNew);
2545                            } else {
2546                                    LOGGER
2547                                                    .warn("Couldn't transformEnvelope when zooming to the layer");
2548                            }
2549                    } catch (Exception err) {
2550                            LOGGER.error("Zoom to layer did not terminate correctly", err);
2551                    }
2552            }
2553    
2554            /**
2555             * Zooms the {@link SelectableXMapPane} to the {@link Envelope} of a layer.
2556             *
2557             * <br>
2558             * A refresh of the map is not done automatically
2559             *
2560             * @param index
2561             *            Index of the {@link MapLayer} in the {@link MapContext} (from
2562             *            back to top)
2563             *
2564             * @author <a href="mailto:[email protected]">Stefan Alfons
2565             *         Kr&uuml;ger</a>
2566             */
2567            public void zoomToLayer(int index) {
2568                    final MapContext context = getMapContext();
2569                    if (context != null)
2570                            zoomToLayer(context.getLayer(index));
2571            }
2572    
2573            /**
2574             * Zooms the {@link SelectableXMapPane} to the {@link Envelope} of the
2575             * selected layer. The layer is selected by the idx, counting from front to
2576             * back, like humans would expect in a {@link JList}
2577             *
2578             * <br>
2579             * A refresh of the map is not done automatically
2580             *
2581             *
2582             *
2583             * @param index
2584             *            Reverse index of the {@link MapLayer} in the
2585             *            {@link MapContext}
2586             *
2587             * @author <a href="mailto:[email protected]">Stefan Alfons
2588             *         Kr&uuml;ger</a>
2589             */
2590            public void zoomToLayerIdxReverse(int index) {
2591                    zoomToLayer(getMapContext().getLayerCount() - 1 - index);
2592            }
2593    
2594            /**
2595             * Aktiviert oder deaktiviert das AntiAliasing for diese
2596             * {@link SelectableXMapPane}. AntiALiasing ist besonders fuer
2597             * Textbeschriftung sehr schoen, verbraucht aber auch mehr Performance.
2598             *
2599             * @author <a href="mailto:[email protected]">Stefan Alfons
2600             *         Kr&uuml;ger</a>
2601             */
2602            public void setAntiAliasing(final boolean aa) {
2603                    // LOGGER.info("Setting AntiAliasing for this JMapPane to " + aa);
2604                    RenderingHints java2DHints = java2dHints;
2605                    if (java2DHints == null) {
2606                            java2DHints = GeoTools.getDefaultHints();
2607                    }
2608    
2609                    java2DHints.put(RenderingHints.KEY_ANTIALIASING,
2610                                    aa ? RenderingHints.VALUE_ANTIALIAS_ON
2611                                                    : RenderingHints.VALUE_ANTIALIAS_OFF);
2612                    java2DHints.put(RenderingHints.KEY_TEXT_ANTIALIASING,
2613                                    aa ? RenderingHints.VALUE_TEXT_ANTIALIAS_ON
2614                                                    : RenderingHints.VALUE_TEXT_ANTIALIAS_OFF);
2615                    java2DHints.put(RenderingHints.KEY_RENDERING,
2616                                    aa ? RenderingHints.VALUE_RENDER_QUALITY
2617                                                    : RenderingHints.VALUE_RENDER_SPEED);
2618    
2619            }
2620    
2621  }  }

Legend:
Removed from v.560  
changed lines
  Added in v.644

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26