/[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 648 by alfonx, Thu Jan 28 16:51:55 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                    xMapPaneMouseListener.actions.put(MouseInputType.LClick, XMapPaneAction.ZOOM_OUT);
635                    xMapPaneMouseListener.actions.put(MouseInputType.LDrag, XMapPaneAction.ZOOM_OUT);
636                    
637    
638                  /*                  /*
639                   * 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 649  public class XMapPane extends JPanel {
649                                                  if (!isWellDefined())                                                  if (!isWellDefined())
650                                                          return;                                                          return;
651    
652                                                  LOGGER.debug("resizeTimer performed");                                                  // LOGGER.debug("resizeTimer performed");
653    
654                                                  final Rectangle bounds = getVisibleRect();                                                  // final Rectangle bounds = getVisibleRect();
655                                                  //                                                  //
656                                                  // System.out.println("\n\ntimer performs with bounds = "                                                  // System.out.println("\n\ntimer performs with bounds = "
657                                                  // + bounds);                                                  // + bounds);
658    
659                                                  final Envelope geoMapArea = tranformWindowToGeo(                                                  // final Envelope geoMapArea = tranformWindowToGeo(
660                                                                  bounds.x, bounds.y, bounds.x + bounds.width,                                                  // bounds.x, bounds.y, bounds.x + bounds.width,
661                                                                  bounds.y + bounds.height);                                                  // bounds.y + bounds.height);
662    
663                                                  if (setMapArea(geoMapArea)) {                                                  paneResized = true;
664                                                          LOGGER.debug("  maparea changed");                                                  if (!setMapArea(getMapArea())) {
665                                                          paneResized = true;                                                          // It's important to request new rendering here.
666                                                  } else                                                          // setMapArea only returns true and only calls
667                                                          LOGGER.debug("  maparea NOT changed");                                                          // requestStartRendering if the maparea has changed.
668                                                            // But if the component is resized, the maparea
669                                                            // doesn't have to change.
670                                                            requestStartRendering();
671                                                    }
672    
673                                          }                                          }
674                                  });                                  });
675                  resizeTimer.setRepeats(false);                  resizeTimer.setRepeats(false);
# Line 648  public class XMapPane extends JPanel { Line 684  public class XMapPane extends JPanel {
684                                  // Seems to be called twice with the same size..                                  // Seems to be called twice with the same size..
685                                  if (oldVisibleRect != null                                  if (oldVisibleRect != null
686                                                  && oldVisibleRect.equals(getVisibleRect())) {                                                  && oldVisibleRect.equals(getVisibleRect())) {
687                                          LOGGER.debug("skipping resize.");                                          // LOGGER.debug("skipping resize.");
688                                          return;                                          return;
689                                  }                                  }
690    
691                                  LOGGER.debug("resized: " + getVisibleRect());                                  // LOGGER.debug("resized: " + getVisibleRect());
692                                  resizeTimer.restart();                                  resizeTimer.restart();
693                                  oldVisibleRect = getVisibleRect();                                  oldVisibleRect = getVisibleRect();
694                          }                          }
# Line 952  public class XMapPane extends JPanel { Line 988  public class XMapPane extends JPanel {
988                  // Remove all mapPaneListeners that have registered with us                  // Remove all mapPaneListeners that have registered with us
989                  mapPaneListeners.clear();                  mapPaneListeners.clear();
990    
991                  removeMouseMotionListener(zoomMapPaneMouseListener);                  removeMouseMotionListener(xMapPaneMouseListener);
992                  removeMouseListener(zoomMapPaneMouseListener);                  removeMouseListener(xMapPaneMouseListener);
993    
994                  if (localContext != null)                  if (localContext != null)
995                          getMapContext().clearLayerList();                          getMapContext().clearLayerList();
# Line 962  public class XMapPane extends JPanel { Line 998  public class XMapPane extends JPanel {
998    
999                  removeAll();                  removeAll();
1000          }          }
1001            
1002          /**          /**
1003           * 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
1004           * given point. All in screen coordinates.           * given point. All in screen coordinates.
1005           */           */
1006          protected void drawRectangle(final Graphics graphics, final Point startPos,          protected void drawRectangle(final Graphics graphics, final Point startPos,
1007                          final Point e) {                          final Point e) {
1008                    drawRectangle(graphics, startPos, e, Color.WHITE);
1009            }
1010    
1011            /**
1012             * Draws a rectangle in XOR mode from the origin at {@link #startPos} to the
1013             * given point. All in screen coordinates.
1014             */
1015            protected void drawRectangle(final Graphics graphics, final Point startPos,
1016                            final Point e, Color color) {
1017    
1018                  if (!isWellDefined())                  if (!isWellDefined())
1019                          return;                          return;
# Line 984  public class XMapPane extends JPanel { Line 1029  public class XMapPane extends JPanel {
1029                  if (width == 0 && height == 0)                  if (width == 0 && height == 0)
1030                          return;                          return;
1031    
1032                  graphics.setXORMode(Color.WHITE);                  graphics.setXORMode(color);
1033                  graphics.drawRect(left, bottom, width, height);                  graphics.drawRect(left, bottom, width, height);
1034          }          }
1035    
# Line 996  public class XMapPane extends JPanel { Line 1041  public class XMapPane extends JPanel {
1041           *           *
1042           * @param g           * @param g
1043           *            Graphics2D to paint the preview into           *            Graphics2D to paint the preview into
          *  
          * @param state  
          *            Max be {@link #ZOOM_IN} or {@link #ZOOM_OUT}  
1044           */           */
1045          protected boolean drawScaledPreviewImage_Zoom(final Graphics2D graphics) {          protected boolean drawScaledPreviewImage_Zoom(final Graphics2D graphics) {
1046    
1047                  // if (1 == 1)return false;                  // if (1 == 1)return false;
1048                    // if (quickPreviewHint == 0)
1049                    // return false;
1050    
1051                  if (quickPreviewHint == 0)                  if (oldMapArea == null)
1052                          return false;                          return false;
1053    
1054                  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)  
1055                          return false;                          return false;
1056    
1057                  final Rectangle visibleArea = getVisibleRect();                  final Rectangle visibleArea = getVisibleRect();
# Line 1029  public class XMapPane extends JPanel { Line 1066  public class XMapPane extends JPanel {
1066                  final int xx2 = (int) Math.round(oldMapWindow.getMaxX());                  final int xx2 = (int) Math.round(oldMapWindow.getMaxX());
1067                  final int yy2 = (int) Math.round(oldMapWindow.getMaxY());                  final int yy2 = (int) Math.round(oldMapWindow.getMaxY());
1068    
1069                    graphics.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
1070                                    RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR);
1071                    graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
1072                                    RenderingHints.VALUE_ANTIALIAS_OFF);
1073                    graphics.setRenderingHint(RenderingHints.KEY_RENDERING,
1074                                    RenderingHints.VALUE_RENDER_SPEED);
1075    
1076                  graphics.drawImage(getPreFinalImage(), xx1, yy1, xx2, yy2,                  graphics.drawImage(getPreFinalImage(), xx1, yy1, xx2, yy2,
1077                                  (int) visibleArea.getMinX(), (int) visibleArea.getMinY(),                                  (int) visibleArea.getMinX(), (int) visibleArea.getMinY(),
1078                                  (int) visibleArea.getMaxX(), (int) visibleArea.getMaxY(),                                  (int) visibleArea.getMaxX(), (int) visibleArea.getMaxY(),
# Line 1037  public class XMapPane extends JPanel { Line 1081  public class XMapPane extends JPanel {
1081                  final Rectangle painedArea = new Rectangle(xx1, yy1, xx2 - xx1, yy2                  final Rectangle painedArea = new Rectangle(xx1, yy1, xx2 - xx1, yy2
1082                                  - yy1);                                  - yy1);
1083    
1084                  SwingUtil.clearAround(graphics, painedArea, visibleArea);                  SwingUtil.clearAround(graphics, painedArea, visibleArea,
1085                                    getMapBackgroundColor());
1086    
1087                  addGadgets(graphics, true);                  addGadgets(graphics, true);
1088    
1089                  quickPreviewHint = 0;                  // quickPreviewHint = 0;
1090    
1091                  repaintTimer.restart();                  repaintTimer.restart();
1092    
                 graphics.dispose();  
   
1093                  // Something has been drawn                  // Something has been drawn
1094                  return true;                  return true;
1095          }          }
# Line 1059  public class XMapPane extends JPanel { Line 1102  public class XMapPane extends JPanel {
1102           * Lazyly initializes a {@link BufferedImage} for the background renderer.           * Lazyly initializes a {@link BufferedImage} for the background renderer.
1103           */           */
1104          private Image getBgImage() {          private Image getBgImage() {
1105                  //                  if (bgImage == null) {
1106                  // if (bgImage == null) {                          bgImage = new BufferedImage(getVisibleRect().width,
1107                  // bgImage = createImage(getBounds().width, getBounds().height);                                          getVisibleRect().height, IMAGETYPE);
1108                  // }                          SwingUtil.clearImage(finalImage, getMapBackgroundColor());
1109                    }
1110    
1111                  return bgImage;                  return bgImage;
1112          }          }
# Line 1080  public class XMapPane extends JPanel { Line 1124  public class XMapPane extends JPanel {
1124                          // Rectangle curPaintArea = getVisibleRect();                          // Rectangle curPaintArea = getVisibleRect();
1125                          finalImage = new BufferedImage(getVisibleRect().width,                          finalImage = new BufferedImage(getVisibleRect().width,
1126                                          getVisibleRect().height, IMAGETYPE);                                          getVisibleRect().height, IMAGETYPE);
1127                            SwingUtil.clearImage(finalImage, getMapBackgroundColor());
1128    
1129                          requestStartRendering();                          // requestStartRendering();
1130                  }                  }
1131                  return finalImage;                  return finalImage;
1132          }          }
1133    
         public RenderingHints getJava2dHints() {  
                 return java2dHints;  
         }  
   
1134          /**          /**
1135           * Lazyly initializes a {@link BufferedImage} for the background renderer.           * Lazyly initializes a {@link BufferedImage} for the background renderer.
1136           */           */
# Line 1098  public class XMapPane extends JPanel { Line 1139  public class XMapPane extends JPanel {
1139                  if (localImage == null) {                  if (localImage == null) {
1140                          localImage = new BufferedImage(getVisibleRect().width,                          localImage = new BufferedImage(getVisibleRect().width,
1141                                          getVisibleRect().height, IMAGETYPE_withAlpha);                                          getVisibleRect().height, IMAGETYPE_withAlpha);
1142                            SwingUtil.clearImage(localImage, getMapBackgroundColor());
1143                  }                  }
1144    
1145                  return localImage;                  return localImage;
# Line 1113  public class XMapPane extends JPanel { Line 1155  public class XMapPane extends JPanel {
1155                          ReferencedEnvelope mapArea_ = null;                          ReferencedEnvelope mapArea_ = null;
1156                          try {                          try {
1157                                  mapArea_ = localContext.getLayerBounds();                                  mapArea_ = localContext.getLayerBounds();
1158                          } catch (final IOException e) {                          } catch (final Exception e) {
1159                                  LOGGER.warn("localContext.getLayerBounds()", e);                                  LOGGER.warn("localContext.getLayerBounds()", e);
1160                          }                          }
1161    
# Line 1139  public class XMapPane extends JPanel { Line 1181  public class XMapPane extends JPanel {
1181                          try {                          try {
1182                                  localContext.setCoordinateReferenceSystem(GeoImportUtil                                  localContext.setCoordinateReferenceSystem(GeoImportUtil
1183                                                  .getDefaultCRS());                                                  .getDefaultCRS());
1184                          } catch (Exception e) {                          } catch (final Exception e) {
1185                                  throw new RuntimeException("setting context CRS:", e);                                  throw new RuntimeException("setting context CRS:", e);
1186                          }                          }
1187    
# Line 1185  public class XMapPane extends JPanel { Line 1227  public class XMapPane extends JPanel {
1227    
1228          public Envelope getMaxExtend() {          public Envelope getMaxExtend() {
1229                  if (maxExtend == null) {                  if (maxExtend == null) {
1230                          // Commented-out because it takes soo much time!  
1231                          //                          // The next command may take long time!
1232                          // long start = System.currentTimeMillis();                          // long start = System.currentTimeMillis();
1233                          // final ReferencedEnvelope layerBounds = GTUtil                          final ReferencedEnvelope layerBounds = GTUtil
1234                          // .getVisibleLayoutBounds(localContext);                                          .getVisibleLayoutBounds(localContext);
1235                          //                                                //                      
1236                          // LOGGER.info(                          // LOGGER.info(
1237                          // (System.currentTimeMillis()-start)+"m to get maxExtend");                          // (System.currentTimeMillis()-start)+"m to get maxExtend");
1238                          //                                                //                      
1239                          // if (layerBounds == null) {                          if (layerBounds == null) {
1240                          // // TODO Last fallback could be the CRS valid area                                  // // TODO Last fallback could be the CRS valid area
1241                          // return null;                                  return null;
1242                          // }                          }
1243                          //  
1244                          // // Kartenbereich um 10% vergroessern                          // Vergrößerung um 10% nochmal rausgenommen
1245                            // // // Kartenbereich um 10% vergroessern
1246                          // return JTSUtil.fixAspectRatio(getVisibleRect(), JTSUtil                          // return JTSUtil.fixAspectRatio(getVisibleRect(), JTSUtil
1247                          // .expandEnvelope(layerBounds, 0.1), true);                          // .expandEnvelope(layerBounds, 0.1), true);
1248    
1249                            return JTSUtil.fixAspectRatio(getVisibleRect(), layerBounds, true);
1250                  }                  }
1251                  return maxExtend;                  return maxExtend;
1252          }          }
# Line 1229  public class XMapPane extends JPanel { Line 1274  public class XMapPane extends JPanel {
1274          }          }
1275    
1276          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();  
                 // }  
1277                  return preFinalImage;                  return preFinalImage;
1278          }          }
1279    
# Line 1407  public class XMapPane extends JPanel { Line 1442  public class XMapPane extends JPanel {
1442                                  || (getState() == XMapPane.SELECT_TOP)) {                                  || (getState() == XMapPane.SELECT_TOP)) {
1443    
1444                          // Draws a rectangle                          // Draws a rectangle
1445                          final Graphics graphics = getGraphics();                          final Graphics2D graphics = (Graphics2D) getGraphics();
1446                          drawRectangle(graphics, startPos, event.getPoint());                          drawRectangle(graphics, startPos, event.getPoint());
1447                          if ((lastPos.x > 0) && (lastPos.y > 0))                          if ((lastPos.x > 0) && (lastPos.y > 0))
1448                                  drawRectangle(graphics, startPos, lastPos);                                  drawRectangle(graphics, startPos, lastPos);
# Line 1419  public class XMapPane extends JPanel { Line 1454  public class XMapPane extends JPanel {
1454           * Called by the {@link RenderingExecutor} when rendering was cancelled.           * Called by the {@link RenderingExecutor} when rendering was cancelled.
1455           */           */
1456          public void onRenderingCancelled() {          public void onRenderingCancelled() {
1457                  LOGGER.debug("Rendering cancelled");                  // LOGGER.debug("Rendering cancelled");
1458                  repaintTimer.stop();                  repaintTimer.stop();
1459          }          }
1460    
1461          /**          /**
1462           * Called by the {@link RenderingExecutor} when rendering has been           * Called by the {@link RenderingExecutor} when rendering has been
1463           * completed.           * completed.
1464             *
1465             * @param l
1466             *            long ms the rendering took
1467           */           */
1468          public void onRenderingCompleted() {          public void onRenderingCompleted(final long l) {
1469                  LOGGER.debug("complete");                  lastRenderingDuration = (lastRenderingDuration + l) / 2;
1470                    // LOGGER
1471                    // .debug("complete rendering after " + lastRenderingDuration
1472                    // + "ms");
1473    
1474                  repaintTimer.stop();                  repaintTimer.stop();
1475    
# Line 1480  public class XMapPane extends JPanel { Line 1521  public class XMapPane extends JPanel {
1521    
1522                  if (!isWellDefined())                  if (!isWellDefined())
1523                          return;                          return;
1524                    //
1525                    // if (paneResized) {
1526                    // // ((Graphics2D) g).setBackground(getMapBackgroundColor());
1527                    // // g.clearRect(0, 0, getVisibleRect().width,
1528                    // getVisibleRect().height);
1529                    // return;
1530                    // }
1531    
1532  //               super.paintComponent(g); // candidate for removal                  // super.paintComponent(g); // candidate for removal
1533    
1534                  boolean paintedSomething = false;                  boolean paintedSomething = false;
1535    
# Line 1492  public class XMapPane extends JPanel { Line 1540  public class XMapPane extends JPanel {
1540                          // If the new mapArea and the oldMapArea intersect, we can draw some                          // If the new mapArea and the oldMapArea intersect, we can draw some
1541                          // quick scaled preview to make the user feel that something is                          // quick scaled preview to make the user feel that something is
1542                          // happening.                          // happening.
1543                          if (mapAreaChanged && oldMapArea != null                          if (lastRenderingDuration > PRESCALE_MINTIME && mapAreaChanged
1544                                            && oldMapArea != null
1545                                          && getMapArea().intersects(oldMapArea)                                          && getMapArea().intersects(oldMapArea)
1546                                          & !getMapArea().equals(oldMapArea) && !paneResized) {                                          && !getMapArea().equals(oldMapArea) && !paneResized) {
1547    
1548                                  mapAreaChanged = false;                                  mapAreaChanged = false;
1549    
1550                                  if (getMapArea().covers(oldMapArea)) {                                  // if (getMapArea().covers(oldMapArea)) {
1551                                          quickPreviewHint = ZOOM_OUT;                                  // // quickPreviewHint = ZOOM_OUT;
1552                                          paintedSomething = drawScaledPreviewImage_Zoom((Graphics2D) g);                                  // paintedSomething = drawScaledPreviewImage_Zoom((Graphics2D)
1553                                  } else if (oldMapArea.covers(getMapArea())) {                                  // g);
1554                                          quickPreviewHint = ZOOM_IN;                                  // } else if (oldMapArea.covers(getMapArea())) {
1555                                          paintedSomething = drawScaledPreviewImage_Zoom((Graphics2D) g);                                  // quickPreviewHint = ZOOM_IN;
1556                                  }                                  paintedSomething = drawScaledPreviewImage_Zoom((Graphics2D) g);
1557                                    // }
1558                          }                          }
1559                  }                  }
1560    
# Line 1512  public class XMapPane extends JPanel { Line 1562  public class XMapPane extends JPanel {
1562    
1563                          g.drawImage(getFinalImage(), 0, 0, null);                          g.drawImage(getFinalImage(), 0, 0, null);
1564    
                         g.dispose(); // cand. for removal  
   
1565                          paintedSomething = true; // cand. for removal                          paintedSomething = true; // cand. for removal
1566                  }                  }
1567    
# Line 1569  public class XMapPane extends JPanel { Line 1617  public class XMapPane extends JPanel {
1617           */           */
1618          public void performPan() {          public void performPan() {
1619    
1620                  Rectangle winBounds = getVisibleRect();                  final Rectangle winBounds = getVisibleRect();
1621    
1622                  winBounds.translate(-imageOrigin.x, -imageOrigin.y);                  winBounds.translate(-imageOrigin.x, -imageOrigin.y);
1623                  final Envelope newMapArea = tranformWindowToGeo(winBounds.x,                  final Envelope newMapArea = tranformWindowToGeo(winBounds.x,
# Line 1637  public class XMapPane extends JPanel { Line 1685  public class XMapPane extends JPanel {
1685           *            the current map pane extent (screen units)           *            the current map pane extent (screen units)
1686           */           */
1687          private void resetTransforms() {          private void resetTransforms() {
                 ReferencedEnvelope refMapEnv = new ReferencedEnvelope(mapArea,  
                                 getMapContext().getCoordinateReferenceSystem());  
   
1688                  // System.out                  // System.out
1689                  // .println("paintArea in resetTeansofrms = " + getVisibleRect());                  // .println("paintArea in resetTeansofrms = " + getVisibleRect());
1690                  if (!isWellDefined())                  if (!isWellDefined())
1691                          return;                          return;
1692    
1693                    if (mapArea == null)
1694                            return;
1695                    
1696                    final ReferencedEnvelope refMapEnv = new ReferencedEnvelope(mapArea,
1697                                    getMapContext().getCoordinateReferenceSystem());
1698    
1699                  worldToScreen = RendererUtilities.worldToScreenTransform(refMapEnv,                  worldToScreen = RendererUtilities.worldToScreenTransform(refMapEnv,
1700                                  getVisibleRect());                                  getVisibleRect());
1701    
1702                  try {                  try {
1703                          screenToWorld = worldToScreen.createInverse();                          screenToWorld = worldToScreen.createInverse();
1704    
1705                  } catch (NoninvertibleTransformException ex) {                  } catch (final NoninvertibleTransformException ex) {
1706                          LOGGER                          LOGGER
1707                                          .error("can't invert worldToScreen to get screenToWorld!",                                          .error("can't invert worldToScreen to get screenToWorld!",
1708                                                          ex);                                                          ex);
# Line 1721  public class XMapPane extends JPanel { Line 1772  public class XMapPane extends JPanel {
1772    
1773          }          }
1774    
1775            public void setBorder(final Border b) {
1776                    super.setBorder(b);
1777            }
1778    
1779          /**          /**
1780           * Triggers to repaint (fast) and re-render (slow) the JMapPane.           * Triggers to repaint (fast) and re-render (slow) the JMapPane.
1781           */           */
# Line 1741  public class XMapPane extends JPanel { Line 1796  public class XMapPane extends JPanel {
1796          // repaint();          // repaint();
1797          // }          // }
1798    
1799            /**
1800             * Set the new map area.
1801             *
1802             * @param newMapArea
1803             * @return <code>true</code> if the mapArea has been changed and a repaint
1804             *         has been triggered.
1805             */
1806          public boolean setMapArea(final Envelope newMapArea) {          public boolean setMapArea(final Envelope newMapArea) {
1807                  if (newMapArea == null)                  if (newMapArea == null)
1808                          return false;                          return false;
# Line 1751  public class XMapPane extends JPanel { Line 1813  public class XMapPane extends JPanel {
1813          }          }
1814    
1815          /**          /**
1816             * Set the new map area.
1817             *
1818           * @param newMapArea           * @param newMapArea
1819           * @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
1820           *         has been triggered.           *         has been triggered.
# Line 1825  public class XMapPane extends JPanel { Line 1889  public class XMapPane extends JPanel {
1889           *           *
1890           * @param if <code>null</code>, white is used.           * @param if <code>null</code>, white is used.
1891           */           */
1892          public void setMapBackgroundColor(Color bgColor) {          public void setMapBackgroundColor(final Color bgColor) {
1893                  this.mapBackgroundColor = bgColor;                  this.mapBackgroundColor = bgColor;
1894          }          }
1895    
# Line 1883  public class XMapPane extends JPanel { Line 1947  public class XMapPane extends JPanel {
1947          }          }
1948    
1949          // /** Stored the time used for the last real rendering in ms. **/          // /** Stored the time used for the last real rendering in ms. **/
1950          // private long lastRenderingDuration = Long.MAX_VALUE;          private long lastRenderingDuration = 1000;
1951    
1952          /**          /**
1953           * 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 1985  public class XMapPane extends JPanel {
1985           *           *
1986           * @param state           * @param state
1987           */           */
1988            @Deprecated
1989          public void setState(final int state) {          public void setState(final int state) {
1990                  this.state = state;                  this.state = state;
1991                    
1992    //              throw new RuntimeException("Old concept.. migrate to new concept!");
1993    
1994                  zoomMapPaneMouseListener.setEnabled((state == ZOOM_IN  //              xMapPaneMouseListener.setEnabled((state == ZOOM_IN
1995                                  || state == ZOOM_OUT || state == PAN));  //                              || state == ZOOM_OUT || state == PAN));
1996    
1997                  // Je nach Aktion den Cursor umsetzen                  // Je nach Aktion den Cursor umsetzen
1998                  updateCursor();                  updateCursor();
1999          }          }
2000            
2001            public void configureMouse(MouseInputType type, XMapPaneAction action){
2002                    
2003            }
2004    
2005          /**          /**
2006           * 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 2079  public class XMapPane extends JPanel {
2079                  updateCursor();                  updateCursor();
2080          }          }
2081    
2082            private RenderingHints getJava2dHints() {
2083                    return java2dHints;
2084            }
2085    
2086          /**          /**
2087           * Transformiert einen Geo-Koordinaten-Bereich in Fenster-Koordinaten.           * Transformiert einen Geo-Koordinaten-Bereich in Fenster-Koordinaten.
2088           *           *
# Line 2147  public class XMapPane extends JPanel { Line 2222  public class XMapPane extends JPanel {
2222                  finalG.drawImage(getPreFinalImage(), imageOrigin.x, imageOrigin.y,                  finalG.drawImage(getPreFinalImage(), imageOrigin.x, imageOrigin.y,
2223                                  getMapBackgroundColor(), null);                                  getMapBackgroundColor(), null);
2224    
2225                  final int finalImageHeight = getFinalImage().getHeight(null);                  // When panning, we have to clear the area around the image
                 final int finalImageWidth = getFinalImage().getWidth(null);  
   
2226                  final Rectangle painedArea = new Rectangle(imageOrigin.x,                  final Rectangle painedArea = new Rectangle(imageOrigin.x,
2227                                  imageOrigin.y, finalImageWidth, finalImageHeight);                                  imageOrigin.y, getFinalImage().getWidth(), getFinalImage()
2228                  SwingUtil.clearAround(finalG, painedArea, getVisibleRect());                                                  .getHeight());
2229                    SwingUtil.clearAround(finalG, painedArea, getVisibleRect(),
2230                                    getMapBackgroundColor());
2231    
2232                  addGadgets(finalG, false);                  addGadgets(finalG, false);
2233    
# Line 2171  public class XMapPane extends JPanel { Line 2246  public class XMapPane extends JPanel {
2246           *            <code>false</code>, it will only depend on           *            <code>false</code>, it will only depend on
2247           *            {@link #localExecuter.isRunning} and #bgExecuter.isRunning           *            {@link #localExecuter.isRunning} and #bgExecuter.isRunning
2248           */           */
2249          private void addGadgets(final Graphics2D graphics, boolean forceWait) {          private void addGadgets(final Graphics2D graphics, final boolean forceWait) {
2250    
2251                  // Paint a logo to the bottom right if available                  // Paint a logo to the bottom right if available
2252                  if (mapImage != null) {                  if (mapImage != null) {
2253                          Rectangle visibleRect = getVisibleRect();                          final Rectangle visibleRect = getVisibleRect();
2254                          graphics.drawImage(mapImage, visibleRect.width                          graphics.drawImage(mapImage, visibleRect.width
2255                                          - mapImage.getWidth() - 10, getVisibleRect().height                                          - mapImage.getWidth() - 10, getVisibleRect().height
2256                                          - mapImage.getHeight() - 10, null);                                          - mapImage.getHeight() - 10, null);
# Line 2201  public class XMapPane extends JPanel { Line 2276  public class XMapPane extends JPanel {
2276    
2277                          graphics.setColor(c);                          graphics.setColor(c);
2278    
2279                          y += 24;                          y += 21;
2280                  }                  }
2281    
2282                  if (!renderingErrors.isEmpty() && isShowExceptions()) {                  if (!renderingErrors.isEmpty() && isShowExceptions()) {
# Line 2209  public class XMapPane extends JPanel { Line 2284  public class XMapPane extends JPanel {
2284                          final Color c = graphics.getColor();                          final Color c = graphics.getColor();
2285                          graphics.setFont(errorFont);                          graphics.setFont(errorFont);
2286    
2287                          for (Exception ex : renderingErrors) {                          for (final Exception ex : renderingErrors) {
2288    
2289                                  String errStr = ex.getLocalizedMessage();                                  String errStr = ex.getLocalizedMessage();
2290    
# Line 2246  public class XMapPane extends JPanel { Line 2321  public class XMapPane extends JPanel {
2321                  final CoordinateReferenceSystem mapCRS = getMapContext()                  final CoordinateReferenceSystem mapCRS = getMapContext()
2322                                  .getCoordinateReferenceSystem();                                  .getCoordinateReferenceSystem();
2323                  final CoordinateReferenceSystem fCRS = features.getSchema()                  final CoordinateReferenceSystem fCRS = features.getSchema()
2324                                  .getGeometryDescriptor().getCoordinateReferenceSystem();                                  .getCoordinateReferenceSystem();
2325    
2326                  ReferencedEnvelope _mapArea;                  ReferencedEnvelope _mapArea;
2327                  if (mapArea == null)                  if (mapArea == null)
# Line 2339  public class XMapPane extends JPanel { Line 2414  public class XMapPane extends JPanel {
2414           * @param center           * @param center
2415           *            position in window coordinates           *            position in window coordinates
2416           * @param zoomFaktor           * @param zoomFaktor
2417           *            > 1 for zoom in, < 1 for zoom out. Default is 1.33.           *            > 1 for zoom out, < 1 for zoom in. Default is .5
2418           */           */
2419          public void zoomTo(Point center, Double zoomFaktor) {          public void zoomTo(Point center, Double zoomFaktor) {
2420                  if (zoomFaktor == null || zoomFaktor == 0.)                  if (zoomFaktor == null || zoomFaktor == 0.)
2421                          zoomFaktor = 2.;                          zoomFaktor = .5;
2422    
2423                  final Point2D gcenter = getScreenToWorld().transform(center, null);                  final Point2D gcenter = getScreenToWorld().transform(center, null);
2424                  center = null;                  center = null;
# Line 2364  public class XMapPane extends JPanel { Line 2439  public class XMapPane extends JPanel {
2439                                  .getWidth()) / 2., (mapArea.getHeight() * zoomFaktor - mapArea                                  .getWidth()) / 2., (mapArea.getHeight() * zoomFaktor - mapArea
2440                                  .getHeight()) / 2.);                                  .getHeight()) / 2.);
2441    
2442                  // TODO we actually want that                  // // Move the newMapArea above the new center if we zoom in:
2443                  // // Move the newMapArea above the new center                  newMapArea.translate(gcenter.getX() - mapArea.centre().x, gcenter
2444                  // newMapArea.translate(gcenter.getX() - mapArea.centre().x, gcenter                                  .getY()
2445                  // .getY()                                  - mapArea.centre().y);
                 // - mapArea.centre().y);  
2446    
2447                  setMapArea(newMapArea);                  setMapArea(newMapArea);
2448          }          }
# Line 2377  public class XMapPane extends JPanel { Line 2451  public class XMapPane extends JPanel {
2451           * Shall non-fatal rendering exceptions be reported in the mappane or be           * Shall non-fatal rendering exceptions be reported in the mappane or be
2452           * dropped quitely.           * dropped quitely.
2453           */           */
2454          public void setShowExceptions(boolean showExceptions) {          public void setShowExceptions(final boolean showExceptions) {
2455                  this.showExceptions = showExceptions;                  this.showExceptions = showExceptions;
2456          }          }
2457    
# Line 2392  public class XMapPane extends JPanel { Line 2466  public class XMapPane extends JPanel {
2466                  return localRenderer;                  return localRenderer;
2467          }          }
2468    
2469            /**
2470             * Setzt den Kartenausschnitt auf die Ausdehnung eines bestimmten Layers.
2471             * Macht nichts, wenn {@code null} uebergeben wird.
2472             *
2473             * <br>
2474             *
2475             * @param layer
2476             *            ein Layer
2477             */
2478            public void zoomToLayer(MapLayer layer) {
2479                    if (layer == null)
2480                            return;
2481                    try {
2482    
2483                            // BB umrechnen von Layer-CRS in Map-CRS
2484                            final CoordinateReferenceSystem targetCRS = getMapContext()
2485                                            .getCoordinateReferenceSystem();
2486                            final CoordinateReferenceSystem sourceCRS = layer
2487                                            .getFeatureSource().getSchema()
2488                                            .getCoordinateReferenceSystem();
2489    
2490                            Envelope mapAreaNew;
2491                            if (!CRS.equalsIgnoreMetadata(sourceCRS, targetCRS)) {
2492                                    mapAreaNew = JTSUtil.transformEnvelope(layer.getFeatureSource()
2493                                                    .getBounds(), sourceCRS, targetCRS);
2494                            } else {
2495                                    try {
2496                                            mapAreaNew = layer.getFeatureSource().getBounds();
2497                                    } catch (java.lang.IllegalArgumentException e) {
2498                                            LOGGER.error("Can't calc layers bounds...", e);
2499                                            mapAreaNew = null;
2500    
2501                                            /**
2502                                             *
2503                                             23.10.2009 11:20:50
2504                                             * org.geotools.data.shapefile.shp.PolygonHandler read
2505                                             * WARNUNG: only one hole in this polygon record ERROR
2506                                             * JMapPane zoomToLayer Zoom to layer did not terminate
2507                                             * correctly java.lang.IllegalArgumentException: Points of
2508                                             * LinearRing do not form a closed linestring at
2509                                             * com.vividsolutions
2510                                             * .jts.geom.LinearRing.validateConstruction
2511                                             * (LinearRing.java:105) at
2512                                             * com.vividsolutions.jts.geom.LinearRing
2513                                             * .<init>(LinearRing.java:100) at
2514                                             * com.vividsolutions.jts.geom
2515                                             * .GeometryFactory.createLinearRing
2516                                             * (GeometryFactory.java:339) at
2517                                             * org.geotools.data.shapefile.
2518                                             * shp.PolygonHandler.read(PolygonHandler.java:188) at
2519                                             * org.geotools
2520                                             * .data.shapefile.shp.ShapefileReader$Record.shape
2521                                             * (ShapefileReader.java:106) at
2522                                             * org.geotools.data.shapefile.
2523                                             * ShapefileAttributeReader.next(
2524                                             * ShapefileAttributeReader.java:157) at
2525                                             * org.geotools.data.shapefile
2526                                             * .indexed.IndexedShapefileAttributeReader
2527                                             * .next(IndexedShapefileAttributeReader.java:122) at
2528                                             * org.geotools
2529                                             * .data.FIDFeatureReader.next(FIDFeatureReader.java:96) at
2530                                             * org.geotools.data.FIDFeatureReader.next(FIDFeatureReader.
2531                                             * java:55) at org.geotools.data.MaxFeatureReader.next(
2532                                             * MaxFeatureReader.java:61) at
2533                                             * org.geotools.data.MaxFeatureReader
2534                                             * .next(MaxFeatureReader.java:61)
2535                                             **/
2536                                    }
2537                            }
2538    
2539                            // Kartenbereich um 10% vergroessern, damit z.B. auch ein
2540                            // Punkt-Layer,
2541                            // welches nur aus 2 Punnkten besteht, sichtbar ist (Punkte liegen
2542                            // sonst
2543                            // genau auf dem Rand der angezeigten Flaeche)
2544    
2545                            if (mapAreaNew != null) {
2546                                    mapAreaNew.expandBy(mapAreaNew.getWidth() * 0.1, mapAreaNew
2547                                                    .getHeight() * 0.1);
2548                                    setMapArea(mapAreaNew);
2549                            } else {
2550                                    LOGGER
2551                                                    .warn("Couldn't transformEnvelope when zooming to the layer");
2552                            }
2553                    } catch (Exception err) {
2554                            LOGGER.error("Zoom to layer did not terminate correctly", err);
2555                    }
2556            }
2557    
2558            /**
2559             * Zooms the {@link SelectableXMapPane} to the {@link Envelope} of a layer.
2560             *
2561             * <br>
2562             * A refresh of the map is not done automatically
2563             *
2564             * @param index
2565             *            Index of the {@link MapLayer} in the {@link MapContext} (from
2566             *            back to top)
2567             *
2568             * @author <a href="mailto:[email protected]">Stefan Alfons
2569             *         Kr&uuml;ger</a>
2570             */
2571            public void zoomToLayer(int index) {
2572                    final MapContext context = getMapContext();
2573                    if (context != null)
2574                            zoomToLayer(context.getLayer(index));
2575            }
2576    
2577            /**
2578             * Zooms the {@link SelectableXMapPane} to the {@link Envelope} of the
2579             * selected layer. The layer is selected by the idx, counting from front to
2580             * back, like humans would expect in a {@link JList}
2581             *
2582             * <br>
2583             * A refresh of the map is not done automatically
2584             *
2585             *
2586             *
2587             * @param index
2588             *            Reverse index of the {@link MapLayer} in the
2589             *            {@link MapContext}
2590             *
2591             * @author <a href="mailto:[email protected]">Stefan Alfons
2592             *         Kr&uuml;ger</a>
2593             */
2594            public void zoomToLayerIdxReverse(int index) {
2595                    zoomToLayer(getMapContext().getLayerCount() - 1 - index);
2596            }
2597    
2598            /**
2599             * Aktiviert oder deaktiviert das AntiAliasing for diese
2600             * {@link SelectableXMapPane}. AntiALiasing ist besonders fuer
2601             * Textbeschriftung sehr schoen, verbraucht aber auch mehr Performance.
2602             *
2603             * @author <a href="mailto:[email protected]">Stefan Alfons
2604             *         Kr&uuml;ger</a>
2605             */
2606            public void setAntiAliasing(final boolean aa) {
2607                    // LOGGER.info("Setting AntiAliasing for this JMapPane to " + aa);
2608                    RenderingHints java2DHints = java2dHints;
2609                    if (java2DHints == null) {
2610                            java2DHints = GeoTools.getDefaultHints();
2611                    }
2612    
2613                    java2DHints.put(RenderingHints.KEY_ANTIALIASING,
2614                                    aa ? RenderingHints.VALUE_ANTIALIAS_ON
2615                                                    : RenderingHints.VALUE_ANTIALIAS_OFF);
2616                    java2DHints.put(RenderingHints.KEY_TEXT_ANTIALIASING,
2617                                    aa ? RenderingHints.VALUE_TEXT_ANTIALIAS_ON
2618                                                    : RenderingHints.VALUE_TEXT_ANTIALIAS_OFF);
2619                    java2DHints.put(RenderingHints.KEY_RENDERING,
2620                                    aa ? RenderingHints.VALUE_RENDER_QUALITY
2621                                                    : RenderingHints.VALUE_RENDER_SPEED);
2622    
2623            }
2624    
2625  }  }

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26