/[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

revision 536 by alfonx, Fri Nov 20 15:38:34 2009 UTC revision 558 by alfonx, Tue Nov 24 13:01:09 2009 UTC
# Line 30  import javax.swing.Timer; Line 30  import javax.swing.Timer;
30    
31  import org.apache.log4j.Logger;  import org.apache.log4j.Logger;
32  import org.geotools.feature.FeatureCollection;  import org.geotools.feature.FeatureCollection;
 import org.geotools.geometry.Envelope2D;  
33  import org.geotools.geometry.jts.JTS;  import org.geotools.geometry.jts.JTS;
34  import org.geotools.geometry.jts.ReferencedEnvelope;  import org.geotools.geometry.jts.ReferencedEnvelope;
35  import org.geotools.map.DefaultMapContext;  import org.geotools.map.DefaultMapContext;
# Line 44  import org.geotools.referencing.CRS; Line 43  import org.geotools.referencing.CRS;
43  import org.geotools.renderer.GTRenderer;  import org.geotools.renderer.GTRenderer;
44  import org.geotools.renderer.label.LabelCacheImpl;  import org.geotools.renderer.label.LabelCacheImpl;
45  import org.geotools.renderer.lite.LabelCache;  import org.geotools.renderer.lite.LabelCache;
46    import org.geotools.renderer.lite.RendererUtilities;
47  import org.geotools.renderer.lite.StreamingRenderer;  import org.geotools.renderer.lite.StreamingRenderer;
48  import org.geotools.swing.JMapPane;  import org.geotools.swing.JMapPane;
49  import org.geotools.swing.event.MapMouseEvent;  import org.geotools.swing.event.MapMouseEvent;
# Line 98  public class XMapPane extends JPanel { Line 98  public class XMapPane extends JPanel {
98          private static final int IMAGETYPE = BufferedImage.TYPE_INT_RGB;          private static final int IMAGETYPE = BufferedImage.TYPE_INT_RGB;
99          private static final int IMAGETYPE_withAlpha = BufferedImage.TYPE_INT_ARGB;          private static final int IMAGETYPE_withAlpha = BufferedImage.TYPE_INT_ARGB;
100    
101          private static Logger LOGGER = Logger.getLogger(XMapPane.class);          private final static Logger LOGGER = Logger.getLogger(XMapPane.class);
102    
103          private boolean acceptsRepaintCalls = true;          private boolean acceptsRepaintCalls = true;
104    
# Line 124  public class XMapPane extends JPanel { Line 124  public class XMapPane extends JPanel {
124           * regularly and {@link #repaint()}. This {@link Timer} is stopped when all           * regularly and {@link #repaint()}. This {@link Timer} is stopped when all
125           * renderers have finished.           * renderers have finished.
126           *           *
127           * @see #INITIAL_REPAINT_DELAYAL           * @see INITIAL_REPAINT_DELAYAL
128           * @see #REPEATING_REPAINT_DELAY           * @see #REPEATING_REPAINT_DELAY
129           */           */
130          final private Timer repaintTimer;          final private Timer repaintTimer;
# Line 133  public class XMapPane extends JPanel { Line 133  public class XMapPane extends JPanel {
133           * The initial delay in milliseconds until the {@link #finalImage} is           * The initial delay in milliseconds until the {@link #finalImage} is
134           * updated the first time.           * updated the first time.
135           */           */
136          public static final int INITIAL_REPAINT_DELAY = 1000;          public static final int INITIAL_REPAINT_DELAY = 900;
137    
138          /**          /**
139           * While the {@link #bgExecuter} and {@link #localExecuter} are rendering,           * While the {@link #bgExecuter} and {@link #localExecuter} are rendering,
140           * the {@link #repaintTimer} is regularly updating the {@link #finalImage}           * the {@link #repaintTimer} is regularly updating the {@link #finalImage}
141           * with previews.           * with previews.
142           */           */
143          public static final long REPEATING_REPAINT_DELAY = 500;          public static final int REPEATING_REPAINT_DELAY = 600;
144    
145          /**          /**
146           * Default delay (milliseconds) before the map will be redrawn when resizing           * Default delay (milliseconds) before the map will be redrawn when resizing
147           * the pane. This is to avoid flickering while drag-resizing.           * the pane. This is to avoid flickering while drag-resizing.
148             *
149             * @see #resizeTimer
150             */
151            public static final int DEFAULT_RESIZING_PAINT_DELAY = 600;
152    
153            /**
154             * This not-repeating {@link Timer} is re-started whenever the component is
155             * resized. That means => only if the component is not resizing for
156             * {@link #DEFAULT_RESIZING_PAINT_DELAY} milliseconds, does the
157             * {@link XMapPane} react.
158           */           */
159          public static final int DEFAULT_RESIZING_PAINT_DELAY = 500;          private final Timer resizeTimer;
160    
161            /**
162             * Flag for no-tool.
163             */
164          public static final int NONE = -123;          public static final int NONE = -123;
165    
166          /**          /**
# Line 159  public class XMapPane extends JPanel { Line 172  public class XMapPane extends JPanel {
172          public static final int PAN = 1;          public static final int PAN = 1;
173    
174          /**          /**
175             * Flag fuer Modus "Heran zoomen".
176             *
177             * @see #setState(int)
178             * @see #setState(int)
179             */
180            public static final int ZOOM_IN = 2;
181    
182            /**
183             * Flag fuer Modus "Heraus zoomen". Nicht fuer Window-Auswahl moeglich!
184             *
185             * @see #setState(int)
186             */
187            public static final int ZOOM_OUT = 3;
188    
189            /**
190           * Flag fuer Modus "SimpleFeature-Auswahl auf allen (sichtbaren) Layern".           * Flag fuer Modus "SimpleFeature-Auswahl auf allen (sichtbaren) Layern".
191           *           *
192           * @see #setState(int)           * @see #setState(int)
# Line 182  public class XMapPane extends JPanel { Line 210  public class XMapPane extends JPanel {
210           */           */
211          public static final int SELECT_TOP = 4;          public static final int SELECT_TOP = 4;
212    
213          public static final Cursor WAIT_CURSOR = Cursor          /**
214                          .getPredefinedCursor(Cursor.WAIT_CURSOR);           * {@link Font} used to paint the wait messages into the map
215             *
216             * @see #addGadgets(Graphics2D, boolean)
217             */
218          final static Font waitFont = new Font("Arial", Font.BOLD, 30);          final static Font waitFont = new Font("Arial", Font.BOLD, 30);
         final String waitMsg = SwingUtil.R("WaitMess");  
         final static Font errorFont = new Font("Arial", Font.BOLD, 13);  
219    
220          /**          /**
221           * Flag fuer Modus "Heran zoomen".           * {@link Font} used to paint error messages into the map
222           *           *
223           * @see #setState(int)           * @see #addGadgets(Graphics2D, boolean)
          * @see #setState(int)  
224           */           */
225          public static final int ZOOM_IN = 2;          final static Font errorFont = new Font("Arial", Font.BOLD, 13);
226    
227          /**          /**
228           * Flag fuer Modus "Heraus zoomen". Nicht fuer Window-Auswahl moeglich!           * The wait message painted into the map while rendering is going on on
229             * another thread.
230           *           *
231           * @see #setState(int)           * @see #addGadgets(Graphics2D, boolean)
232           */           */
233          public static final int ZOOM_OUT = 3;          final String waitMsg = SwingUtil.R("WaitMess");
234    
235          /**          /**
236           * Konvertiert die Maus-Koordinaten (relativ zum <code>JMapPane</code>) in           * Konvertiert die Maus-Koordinaten (relativ zum <code>JMapPane</code>) in
# Line 248  public class XMapPane extends JPanel { Line 276  public class XMapPane extends JPanel {
276    
277                  @Override                  @Override
278                  public void layerAdded(final MapLayerListEvent event) {                  public void layerAdded(final MapLayerListEvent event) {
   
279                          MapLayer layer = event.getLayer();                          MapLayer layer = event.getLayer();
   
280                          layer.addMapLayerListener(bgMapLayerListener);                          layer.addMapLayerListener(bgMapLayerListener);
   
                         if (localContext.getLayers().length == 0  
                                         && bgContext.getLayers().length == 1) { // the first one and  
                                 // localContext is  
                                 // empty  
                                 if (!setMapArea(localContext.getAreaOfInterest()))  
                                         requestStartRendering();  
                                 return;  
                         }  
   
                         // We need to redraw, even in case that the mapArea didn't change  
                         // mapImageInvalid = true;  
                         // repaint();  
281                          requestStartRendering();                          requestStartRendering();
282    
283                  }                  }
284    
285                  @Override                  @Override
286                  public void layerChanged(final MapLayerListEvent event) {                  public void layerChanged(final MapLayerListEvent event) {
                         // mapImageInvalid = true;  
                         // repaint();  
287                          requestStartRendering();                          requestStartRendering();
288                  }                  }
289    
290                  @Override                  @Override
291                  public void layerMoved(final MapLayerListEvent event) {                  public void layerMoved(final MapLayerListEvent event) {
                         // mapImageInvalid = true;  
                         // repaint();  
292                          requestStartRendering();                          requestStartRendering();
293                  }                  }
294    
# Line 287  public class XMapPane extends JPanel { Line 296  public class XMapPane extends JPanel {
296                  public void layerRemoved(final MapLayerListEvent event) {                  public void layerRemoved(final MapLayerListEvent event) {
297                          if (event.getLayer() != null)                          if (event.getLayer() != null)
298                                  event.getLayer().removeMapLayerListener(bgMapLayerListener);                                  event.getLayer().removeMapLayerListener(bgMapLayerListener);
                         // mapImageInvalid = true;  
                         // repaint();  
299                          requestStartRendering();                          requestStartRendering();
300                  }                  }
301          };          };
302    
303          /**          /**
304           * compass and icon are rendered into this image           * This {@link RenderingExecutor} manages the creation and cancellation of
305             * up to one {@link Thread} for rendering the {@link #localContext}.
306           */           */
307          // protected BufferedImage gadgetsImage;          private final RenderingExecutor localExecuter = new RenderingExecutor(this);
308    
309            /**
310             * This {@link RenderingExecutor} manages the creation and cancellation of
311             * up to one {@link Thread} for rendering the {@link #bgContext}.
312             */
313          protected RenderingExecutor bgExecuter;          protected RenderingExecutor bgExecuter;
314    
315          /**          /**
316           * The Renderer for the LocalLayers uses this Image. When set to null,           * The {@link #localRenderer} for the {@link #localContext} uses this
317           * please dispose this {@link Graphics2D}           * {@link Image}.
318           */           */
319          private BufferedImage localImage;          private BufferedImage localImage;
320    
         private BufferedImage finalImage;  
321          /**          /**
322           * If # {@link #bgExecuter} is using {@link #bgRenderer} for the Background           * The {@link #bgRenderer} for the {@link #bgContext} uses this
323           * uses this Image. When set to null, please dispose the {@link Graphics2D}           * {@link Image}.
324           */           */
325          private BufferedImage bgImage;          private BufferedImage bgImage;
326    
327          /**          /**
328             * This {@link Image} is a merge of the {@link #bgImage},
329             * {@link #localImage} and {@link #addGadgets(Graphics2D, boolean)}. It is
330             * updated with {@link #updateFinalImage()} and used for painting in
331             * {@link #paintComponent(Graphics)}
332             */
333            private BufferedImage finalImage;
334    
335            /**
336           * Optionally a transparent image to paint over the map in the lower right           * Optionally a transparent image to paint over the map in the lower right
337           * corner.           * corner.
338           *           *
# Line 330  public class XMapPane extends JPanel { Line 349  public class XMapPane extends JPanel {
349    
350                  @Override                  @Override
351                  public void layerChanged(final MapLayerEvent event) {                  public void layerChanged(final MapLayerEvent event) {
                         // Change of SLD for example  
                         // mapImageInvalid = true;  
                         // repaint();  
352                          requestStartRendering();                          requestStartRendering();
353                  }                  }
354    
355                  @Override                  @Override
356                  public void layerHidden(final MapLayerEvent event) {                  public void layerHidden(final MapLayerEvent event) {
                         // mapImageInvalid = true;  
                         // repaint();  
357                          requestStartRendering();                          requestStartRendering();
358                  }                  }
359    
360                  @Override                  @Override
361                  public void layerShown(final MapLayerEvent event) {                  public void layerShown(final MapLayerEvent event) {
                         // mapImageInvalid = true;  
                         // repaint();  
362                          requestStartRendering();                          requestStartRendering();
363                  }                  }
364          };          };
# Line 383  public class XMapPane extends JPanel { Line 395  public class XMapPane extends JPanel {
395                  public void layerAdded(final MapLayerListEvent event) {                  public void layerAdded(final MapLayerListEvent event) {
396                          event.getLayer().addMapLayerListener(localMapLayerListener);                          event.getLayer().addMapLayerListener(localMapLayerListener);
397    
398                          localRenderer.setContext(getContext());                          localRenderer.setContext(getMapContext());
   
                         if (localContext.getLayers().length == 1) { // the first one  
                                 // if the Area of Interest is unset, the LayerBounds are used  
                                 if (!setMapArea(localContext.getAreaOfInterest()))  
                                         repaint();  
   
                                 return;  
                         }  
   
                         // We need to redraw, even in case that the mapArea didn't change  
                         // mapImageInvalid = true;  
                         // repaint();  
399                          requestStartRendering();                          requestStartRendering();
400    
401                  }                  }
402    
403                  @Override                  @Override
404                  public void layerChanged(final MapLayerListEvent event) {                  public void layerChanged(final MapLayerListEvent event) {
405                          // mapImageInvalid = true;                          localRenderer.setContext(getMapContext());
                         // repaint();  
                         localRenderer.setContext(getContext());  
406                          requestStartRendering();                          requestStartRendering();
407                  }                  }
408    
409                  @Override                  @Override
410                  public void layerMoved(final MapLayerListEvent event) {                  public void layerMoved(final MapLayerListEvent event) {
411                          // mapImageInvalid = true;                          localRenderer.setContext(getMapContext());
                         // repaint();  
                         localRenderer.setContext(getContext());  
412                          requestStartRendering();                          requestStartRendering();
413                  }                  }
414    
# Line 420  public class XMapPane extends JPanel { Line 416  public class XMapPane extends JPanel {
416                  public void layerRemoved(final MapLayerListEvent event) {                  public void layerRemoved(final MapLayerListEvent event) {
417                          if (event.getLayer() != null)                          if (event.getLayer() != null)
418                                  event.getLayer().removeMapLayerListener(localMapLayerListener);                                  event.getLayer().removeMapLayerListener(localMapLayerListener);
419                          // mapImageInvalid = true;                          localRenderer.setContext(getMapContext());
                         // repaint();  
                         localRenderer.setContext(getContext());  
420                          requestStartRendering();                          requestStartRendering();
421                  }                  }
422          };          };
423    
         private final RenderingExecutor localExecuter = new RenderingExecutor(this);  
   
424          /**          /**
425           * Listens to each layer in the local {@link MapContext} for changes and           * Listens to each layer in the local {@link MapContext} for changes and
426           * triggers repaints.           * triggers repaints.
# Line 437  public class XMapPane extends JPanel { Line 429  public class XMapPane extends JPanel {
429    
430                  @Override                  @Override
431                  public void layerChanged(final MapLayerEvent event) {                  public void layerChanged(final MapLayerEvent event) {
432                          localRenderer.setContext(getContext()); // betters for SLD changes?!                          localRenderer.setContext(getMapContext()); // betters for SLD
433                          // Change of SLD for example                          // changes?!
                         // mapImageInvalid = true;  
                         // repaint();  
434                          requestStartRendering();                          requestStartRendering();
435                  }                  }
436    
437                  @Override                  @Override
438                  public void layerHidden(final MapLayerEvent event) {                  public void layerHidden(final MapLayerEvent event) {
                         // mapImageInvalid = true;  
                         // repaint();  
439                          requestStartRendering();                          requestStartRendering();
440                  }                  }
441    
442                  @Override                  @Override
443                  public void layerShown(final MapLayerEvent event) {                  public void layerShown(final MapLayerEvent event) {
                         // mapImageInvalid = true;  
                         // repaint();  
444                          requestStartRendering();                          requestStartRendering();
445                  }                  }
446          };          };
# Line 480  public class XMapPane extends JPanel { Line 466  public class XMapPane extends JPanel {
466          /**          /**
467           * This color is used as the default background color when painting a map.           * This color is used as the default background color when painting a map.
468           */           */
469          private Color mapBackgroundColor = Color.WHITE;          private Color mapBackgroundColor = null;
470    
471          /**          /**
472           * A flag indicating that the shown image is invalid and needs to be           * A flag indicating that the shown image is invalid and needs to be
# Line 524  public class XMapPane extends JPanel { Line 510  public class XMapPane extends JPanel {
510           * A flag indicating, that the image size has changed and the buffered           * A flag indicating, that the image size has changed and the buffered
511           * images are not big enough any more           * images are not big enough any more
512           **/           **/
513          protected boolean paneResized = false;          protected boolean paneResized = true;
514    
515          private BufferedImage preFinalImage;          private BufferedImage preFinalImage;
516    
517          // if null, no quick preview will be shown          // ** if 0, no quick preview will be shown **/
518          private int quickPreviewHint = 0;          private int quickPreviewHint = 0;
519    
520          private Map<Object, Object> rendererHints = GTUtil          private Map<Object, Object> rendererHints = GTUtil
521                          .getDefaultGTRendererHints(localRenderer);                          .getDefaultGTRendererHints(localRenderer);
522    
523            /**
524             * If set to <code>true</code>, the {@link #startRenderThreadsTimer} will
525             * start rendering {@link Thread}s
526             **/
527          private volatile Boolean requestStartRendering = false;          private volatile Boolean requestStartRendering = false;
528    
         private final Timer resizeTimer;  
   
         private final int resizingPaintDelay;  
   
529          /**          /**
530           * Transformation zwischen Fenster-Koordinaten und Karten-Koordinaten           * Transformation zwischen Fenster-Koordinaten und Karten-Koordinaten
531           * (lat/lon)           * (lat/lon)
# Line 576  public class XMapPane extends JPanel { Line 562  public class XMapPane extends JPanel {
562          /** Is set if a renderer has an error **/          /** Is set if a renderer has an error **/
563          protected ArrayList<Exception> renderingErrors = new ArrayList<Exception>();          protected ArrayList<Exception> renderingErrors = new ArrayList<Exception>();
564    
565          // TODO doku          /**
566             * If <code>true</code>, then rendering exceptions are rendererd into the
567             * map pane
568             **/
569            private boolean showExceptions = false;
570    
571          public XMapPane() {          public XMapPane() {
572                  this(null, null);                  this(null, null);
573          }          }
# Line 585  public class XMapPane extends JPanel { Line 576  public class XMapPane extends JPanel {
576           * full constructor extending JPanel           * full constructor extending JPanel
577           *           *
578           * @param rendererHints           * @param rendererHints
579             *            may be <code>null</code>. Otherwise a {@link Map<Object,
580             *            Object>} of {@link RenderingHints} to override the default
581             *            from {@link GTUtil#getDefaultGTRendererHints(GTRenderer)}
582           *           *
          * @param layout  
          *            - layout (probably shouldn't be set)  
          * @param isDoubleBuffered  
          *            - a Swing thing I don't really understand  
          * @param render  
          *            - what to draw the map with  
583           * @param localContext           * @param localContext
584           *            - {@link MapContext} of layer to render.           *            The main {@link MapContext} to use. If <code>null</code>, an
585             *            empty {@link DefaultMapContext} will be created.
586           */           */
587          public XMapPane(final MapContext localContext_,          public XMapPane(final MapContext localContext_,
588                          final Map<Object, Object> rendererHints) {                          final Map<Object, Object> rendererHints) {
# Line 620  public class XMapPane extends JPanel { Line 609  public class XMapPane extends JPanel {
609                   * Using a ComponentListener doesn't work because, unlike a JFrame, the                   * Using a ComponentListener doesn't work because, unlike a JFrame, the
610                   * pane receives a stream of events during drag-resizing.                   * pane receives a stream of events during drag-resizing.
611                   */                   */
612                  resizingPaintDelay = DEFAULT_RESIZING_PAINT_DELAY;                  resizeTimer = new Timer(DEFAULT_RESIZING_PAINT_DELAY,
613                  resizeTimer = new Timer(resizingPaintDelay, new ActionListener() {                                  new ActionListener() {
   
                         public void actionPerformed(final ActionEvent e) {  
                                 paneResized = true;  
   
                                 if (!isWellDefined())  
                                         return;  
614    
615                                  final Rectangle bounds = getVisibleRect();                                          public void actionPerformed(final ActionEvent e) {
616                                                    if (!isWellDefined())
617                                                            return;
618    
619                                  final Envelope geoMapArea = tranformWindowToGeo(bounds.x,                                                  LOGGER.debug("resizeTimer performed");
                                                 bounds.y, bounds.x + bounds.width, bounds.y  
                                                                 + bounds.height);  
620    
621                                  setMapArea(bestAllowedMapArea(geoMapArea));                                                  final Rectangle bounds = getVisibleRect();
622                          }                                                  //
623                  });                                                  // System.out.println("\n\ntimer performs with bounds = "
624                                                    // + bounds);
625    
626                                                    final Envelope geoMapArea = tranformWindowToGeo(
627                                                                    bounds.x, bounds.y, bounds.x + bounds.width,
628                                                                    bounds.y + bounds.height);
629    
630                                                    if (setMapArea(geoMapArea)) {
631                                                            LOGGER.debug("  maparea changed");
632                                                            paneResized = true;
633                                                    } else
634                                                            LOGGER.debug("  maparea NOT changed");
635                                            }
636                                    });
637                  resizeTimer.setRepeats(false);                  resizeTimer.setRepeats(false);
638    
639                  this.addComponentListener(new ComponentAdapter() {                  this.addComponentListener(new ComponentAdapter() {
640    
641                            private Rectangle oldVisibleRect;
642    
643                          @Override                          @Override
644                          public void componentResized(final ComponentEvent e) {                          public void componentResized(final ComponentEvent e) {
645                                  if (bgExecuter != null)  
646                                          bgExecuter.cancelTask();                                  // Seems to be called twice with the same size..
647                                  if (localExecuter != null)                                  if (oldVisibleRect != null
648                                          localExecuter.cancelTask();                                                  && oldVisibleRect.equals(getVisibleRect())) {
649                                            LOGGER.debug("skipping resize.");
650                                            return;
651                                    }
652    
653                                    LOGGER.debug("resized: " + getVisibleRect());
654                                  resizeTimer.restart();                                  resizeTimer.restart();
655                                    oldVisibleRect = getVisibleRect();
656                          }                          }
657    
658                  });                  });
# Line 655  public class XMapPane extends JPanel { Line 660  public class XMapPane extends JPanel {
660                  /*                  /*
661                   * Setting up the repaintTimer. Not started automatically.                   * Setting up the repaintTimer. Not started automatically.
662                   */                   */
663                  repaintTimer = new Timer((int) REPEATING_REPAINT_DELAY,                  repaintTimer = new Timer(REPEATING_REPAINT_DELAY, new ActionListener() {
664                                  new ActionListener() {  
665                            @Override
666                            public void actionPerformed(final ActionEvent e) {
667                                    if ((!localExecuter.isRunning())
668                                                    && (bgExecuter != null && !bgExecuter.isRunning())) {
669                                            repaintTimer.stop();
670                                    } else {
671                                            updateFinalImage();
672                                            XMapPane.this.repaint(100);
673    
674                                    }
675                            }
676                    });
677    
                                         @Override  
                                         public void actionPerformed(final ActionEvent e) {  
                                                 updateFinalImage();  
                                                 XMapPane.this.repaint();  
                                         }  
                                 });  
678                  repaintTimer.setInitialDelay(INITIAL_REPAINT_DELAY);                  repaintTimer.setInitialDelay(INITIAL_REPAINT_DELAY);
679                  repaintTimer.setRepeats(true);                  repaintTimer.setRepeats(true);
680    
# Line 681  public class XMapPane extends JPanel { Line 692  public class XMapPane extends JPanel {
692                                                  if (localExecuter.isRunning()) {                                                  if (localExecuter.isRunning()) {
693                                                          localExecuter.cancelTask();                                                          localExecuter.cancelTask();
694                                                  } else {                                                  } else {
695                                                            // Stupidly, but we have to recheck the
696                                                            setMapArea(getMapArea());
697                                                          requestStartRendering = false;                                                          requestStartRendering = false;
698                                                          startRendering();                                                          startRendering();
699                                                  }                                                  }
# Line 713  public class XMapPane extends JPanel { Line 726  public class XMapPane extends JPanel {
726           * @author <a href="mailto:[email protected]">Stefan Alfons           * @author <a href="mailto:[email protected]">Stefan Alfons
727           *         Kr&uuml;ger</a>           *         Kr&uuml;ger</a>
728           */           */
729          public Envelope bestAllowedMapArea(Envelope env) {          public ReferencedEnvelope bestAllowedMapArea(ReferencedEnvelope env) {
730    
731                  if (getWidth() == 0)                  if (getWidth() == 0)
732                          return env;                          return env;
733    
734                  if (env == null)                  if (env == null)
735                          return null;                          return null;
736    
# Line 765  public class XMapPane extends JPanel { Line 780  public class XMapPane extends JPanel {
780                  }                  }
781    
782                  final Envelope maxAllowedExtend = getMaxExtend();                  final Envelope maxAllowedExtend = getMaxExtend();
783    
784                  while (maxAllowedExtend != null && !maxAllowedExtend.contains(newArea)                  while (maxAllowedExtend != null && !maxAllowedExtend.contains(newArea)
785                                  && newArea != null && !newArea.isNull()                                  && newArea != null && !newArea.isNull()
786                                  && !Double.isNaN(newArea.getMinX())                                  && !Double.isNaN(newArea.getMinX())
# Line 794  public class XMapPane extends JPanel { Line 810  public class XMapPane extends JPanel {
810    
811                                          // LOGGER.debug("and fix aspect ratio");                                          // LOGGER.debug("and fix aspect ratio");
812    
813                                          newArea = JTSUtil.fixAspectRatio(this.getBounds(), newArea,                                          newArea = JTSUtil.fixAspectRatio(getVisibleRect(),
814                                                          false);                                                          new ReferencedEnvelope(newArea, env
815                                                                            .getCoordinateReferenceSystem()), false);
816                                  }                                  }
817                          }                          }
818    
# Line 818  public class XMapPane extends JPanel { Line 835  public class XMapPane extends JPanel {
835    
836                                          // LOGGER.debug("and fix aspect ratio");                                          // LOGGER.debug("and fix aspect ratio");
837    
838                                          newArea = JTSUtil.fixAspectRatio(this.getBounds(), newArea,                                          newArea = JTSUtil.fixAspectRatio(getVisibleRect(),
839                                                          false);                                                          new ReferencedEnvelope(newArea, env
840                                                                            .getCoordinateReferenceSystem()), false);
841                                  }                                  }
842                          }                          }
843    
# Line 844  public class XMapPane extends JPanel { Line 862  public class XMapPane extends JPanel {
862    
863                                          // LOGGER.debug("and fix aspect ratio");                                          // LOGGER.debug("and fix aspect ratio");
864    
865                                          newArea = JTSUtil.fixAspectRatio(this.getBounds(), newArea,                                          newArea = JTSUtil.fixAspectRatio(getVisibleRect(),
866                                                          false);                                                          new ReferencedEnvelope(newArea, env
867                                                                            .getCoordinateReferenceSystem()), false);
868                                  }                                  }
869                          }                          }
870    
# Line 870  public class XMapPane extends JPanel { Line 889  public class XMapPane extends JPanel {
889    
890                                          // LOGGER.debug("and fix aspect ratio");                                          // LOGGER.debug("and fix aspect ratio");
891    
892                                          newArea = JTSUtil.fixAspectRatio(this.getBounds(), newArea,                                          newArea = JTSUtil.fixAspectRatio(getVisibleRect(),
893                                                          false);                                                          new ReferencedEnvelope(newArea, env
894                                                                            .getCoordinateReferenceSystem()), false);
895                                  }                                  }
896                          }                          }
897                  }                  }
898    
899                  return newArea;                  return new ReferencedEnvelope(newArea, env
900                                    .getCoordinateReferenceSystem());
901          }          }
902    
903          /**          /**
# Line 904  public class XMapPane extends JPanel { Line 925  public class XMapPane extends JPanel {
925                          bgExecuter.dispose();                          bgExecuter.dispose();
926                  }                  }
927    
928                  if (localExecuter != null) {                  if (localExecuter.isRunning()) {
929                          int i = 0;                          int i = 0;
930                          localExecuter.cancelTask();                          localExecuter.cancelTask();
931                          while (i++ < 10 && localExecuter.isRunning()) {                          while (i++ < 10 && localExecuter.isRunning()) {
932                                  try {                                  try {
933                                          Thread.sleep(100);                                          Thread.sleep(200);
934                                  } catch (final InterruptedException e) {                                  } catch (final InterruptedException e) {
935                                          // TODO Auto-generated catch block                                          LOGGER
936                                          e.printStackTrace();                                                          .warn(
937                                                                            "while XMapPane we are waiting for the localExcutor to stop",
938                                                                            e);
939                                  }                                  }
940                          }                          }
941                          if (localExecuter.isRunning()) {                          if (localExecuter.isRunning()) {
942                                  System.out                                  LOGGER
943                                                  .println("BAD BAD BAD... still running the thread....");                                                  .warn("localExecutor Thread still running after 2s! Continuing anyways...");
944                          }                          }
945                          localExecuter.dispose();                          localExecuter.dispose();
946                  }                  }
                 //  
                 // if (bgImage != null) {  
                 // bgImage = dispose(bgImage);  
                 // bgImage = null;  
                 // // LangUtil.gcTotal();  
                 // }  
                 //  
                 // if (localImage != null) {  
                 // localImage = dispose(localImage);  
                 // localImage = null;  
                 // // LangUtil.gcTotal();  
                 // }  
                 //  
                 // if (finalImage != null) {  
                 // finalImage = dispose(finalImage);  
                 // finalImage = null;  
                 // // LangUtil.gcTotal();  
                 // }  
                 //  
                 // if (preFinalImage != null) {  
                 // preFinalImage = dispose(preFinalImage);  
                 // preFinalImage = null;  
                 // }  
                 disposeImages();  
947    
948                  // LangUtil.gcTotal();                  disposeImages();
949    
950                  // Alle mapPaneListener entfernen                  // Remove all mapPaneListeners that have registered with us
951                  mapPaneListeners.clear();                  mapPaneListeners.clear();
952    
953                  removeMouseMotionListener(zoomMapPaneMouseListener);                  removeMouseMotionListener(zoomMapPaneMouseListener);
954                  removeMouseListener(zoomMapPaneMouseListener);                  removeMouseListener(zoomMapPaneMouseListener);
955    
956                  if (localContext != null)                  if (localContext != null)
957                          getContext().clearLayerList();                          getMapContext().clearLayerList();
958                  if (bgContext != null)                  if (bgContext != null)
959                          getBgContext().clearLayerList();                          getBgContext().clearLayerList();
960    
# Line 1001  public class XMapPane extends JPanel { Line 1000  public class XMapPane extends JPanel {
1000           */           */
1001          protected boolean drawScaledPreviewImage_Zoom(final Graphics2D graphics) {          protected boolean drawScaledPreviewImage_Zoom(final Graphics2D graphics) {
1002    
1003                    // if (1 == 1)return false;
1004    
1005                  if (quickPreviewHint == 0)                  if (quickPreviewHint == 0)
1006                          return false;                          return false;
1007    
# Line 1019  public class XMapPane extends JPanel { Line 1020  public class XMapPane extends JPanel {
1020                  // Calculate the oldMapArea in the current WindowCoordinates:                  // Calculate the oldMapArea in the current WindowCoordinates:
1021                  final Envelope oldMapWindow = tranformGeoToWindow(oldMapArea.getMinX(),                  final Envelope oldMapWindow = tranformGeoToWindow(oldMapArea.getMinX(),
1022                                  oldMapArea.getMinY(), oldMapArea.getMaxX(), oldMapArea                                  oldMapArea.getMinY(), oldMapArea.getMaxX(), oldMapArea
1023                                                  .getMaxY(), null);                                                  .getMaxY());
1024    
1025                  final int xx1 = (int) Math.round(oldMapWindow.getMinX());                  final int xx1 = (int) Math.round(oldMapWindow.getMinX());
1026                  final int yy1 = (int) Math.round(oldMapWindow.getMinY());                  final int yy1 = (int) Math.round(oldMapWindow.getMinY());
# Line 1064  public class XMapPane extends JPanel { Line 1065  public class XMapPane extends JPanel {
1065                  return bgImage;                  return bgImage;
1066          }          }
1067    
1068          public MapContext getContext() {          public MapContext getMapContext() {
1069                  if (localContext == null) {                  if (localContext == null) {
1070                          setLocalContext(new DefaultMapContext());                          setLocalContext(new DefaultMapContext());
1071                  }                  }
# Line 1075  public class XMapPane extends JPanel { Line 1076  public class XMapPane extends JPanel {
1076                  //                  //
1077                  if (finalImage == null) {                  if (finalImage == null) {
1078                          // Rectangle curPaintArea = getVisibleRect();                          // Rectangle curPaintArea = getVisibleRect();
1079                          finalImage = new BufferedImage(getBounds().width,                          finalImage = new BufferedImage(getVisibleRect().width,
1080                                          getBounds().height, IMAGETYPE);                                          getVisibleRect().height, IMAGETYPE);
1081    
1082                          requestStartRendering();                          requestStartRendering();
1083                  }                  }
# Line 1093  public class XMapPane extends JPanel { Line 1094  public class XMapPane extends JPanel {
1094          private BufferedImage getLocalImage() {          private BufferedImage getLocalImage() {
1095    
1096                  if (localImage == null) {                  if (localImage == null) {
1097                          localImage = new BufferedImage(getBounds().width,                          localImage = new BufferedImage(getVisibleRect().width,
1098                                          getBounds().height, IMAGETYPE_withAlpha);                                          getVisibleRect().height, IMAGETYPE_withAlpha);
1099                  }                  }
1100    
1101                  return localImage;                  return localImage;
# Line 1111  public class XMapPane extends JPanel { Line 1112  public class XMapPane extends JPanel {
1112                          try {                          try {
1113                                  mapArea_ = localContext.getLayerBounds();                                  mapArea_ = localContext.getLayerBounds();
1114                          } catch (final IOException e) {                          } catch (final IOException e) {
1115                                  LOGGER.warn("context.getLayerBounds()", e);                                  LOGGER.warn("localContext.getLayerBounds()", e);
1116                            }
1117    
1118                            if (mapArea_ == null && bgContext != null) {
1119                                    try {
1120                                            mapArea_ = bgContext.getLayerBounds();
1121                                    } catch (final IOException e) {
1122                                            LOGGER.warn("bgContext.getLayerBounds()", e);
1123                                    }
1124                          }                          }
1125    
1126                          if (mapArea_ != null) {                          if (mapArea_ != null) {
                                 mapImageInvalid = true; /* note we need to redraw */  
                                 // setMapArea(mapArea_); // results in a loop  
1127                                  mapArea = bestAllowedMapArea(mapArea_);                                  mapArea = bestAllowedMapArea(mapArea_);
1128                                    requestStartRendering();
1129                          }                          }
1130                  }                  }
1131    
1132                  if (mapArea == null)                  if (mapArea == null)
1133                          return null;                          return null;
1134    
1135                    // TODO is needed at all, this should go to setMapArea maybe
1136                  if (localContext.getCoordinateReferenceSystem() == null)                  if (localContext.getCoordinateReferenceSystem() == null)
1137                          try {                          try {
1138                                  localContext.setCoordinateReferenceSystem(GeoImportUtil                                  localContext.setCoordinateReferenceSystem(GeoImportUtil
1139                                                  .getDefaultCRS());                                                  .getDefaultCRS());
1140                          } catch (TransformException e) {                          } catch (Exception e) {
1141                                  // TODO Auto-generated catch block                                  throw new RuntimeException("setting context CRS:", e);
                                 e.printStackTrace();  
                         } catch (FactoryException e) {  
                                 // TODO Auto-generated catch block  
                                 e.printStackTrace();  
1142                          }                          }
1143    
1144                  return new ReferencedEnvelope(mapArea, localContext                  return new ReferencedEnvelope(mapArea, localContext
# Line 1141  public class XMapPane extends JPanel { Line 1146  public class XMapPane extends JPanel {
1146          }          }
1147    
1148          /**          /**
1149           * Returns the background {@link Color} of the map pane. Default is white.           * Returns the background {@link Color} of the map pane. If not set, the
1150             * methods looks for a parent component and will use its background color.
1151             * If no parent component is available, WHITE is returned.
1152           **/           **/
1153          public Color getMapBackgroundColor() {          public Color getMapBackgroundColor() {
1154                    if (mapBackgroundColor == null){
1155                            if (getParent() != null) return getParent().getBackground();
1156                            else return Color.WHITE;
1157                    }
1158                  return mapBackgroundColor;                  return mapBackgroundColor;
1159          }          }
1160    
# Line 1170  public class XMapPane extends JPanel { Line 1181  public class XMapPane extends JPanel {
1181    
1182          public Envelope getMaxExtend() {          public Envelope getMaxExtend() {
1183                  if (maxExtend == null) {                  if (maxExtend == null) {
1184                          final ReferencedEnvelope layerBounds = GTUtil                          // Commented-out because it takes soo much time!
1185                                          .getVisibleLayoutBounds(localContext);                          //
1186                          if (layerBounds == null) {                          // long start = System.currentTimeMillis();
1187                                  // TODO Last fallback could be the CRS valid area                          // final ReferencedEnvelope layerBounds = GTUtil
1188                                  return null;                          // .getVisibleLayoutBounds(localContext);
1189                          }                          //                      
1190                            // LOGGER.info(
1191                          // Kartenbereich um 10% vergroessern                          // (System.currentTimeMillis()-start)+"m to get maxExtend");
1192                          return JTSUtil.fixAspectRatio(this.getBounds(), JTSUtil                          //                      
1193                                          .expandEnvelope(layerBounds, 0.1), true);                          // if (layerBounds == null) {
1194                            // // TODO Last fallback could be the CRS valid area
1195                            // return null;
1196                            // }
1197                            //
1198                            // // Kartenbereich um 10% vergroessern
1199                            // return JTSUtil.fixAspectRatio(getVisibleRect(), JTSUtil
1200                            // .expandEnvelope(layerBounds, 0.1), true);
1201                  }                  }
1202                  return maxExtend;                  return maxExtend;
1203          }          }
# Line 1293  public class XMapPane extends JPanel { Line 1311  public class XMapPane extends JPanel {
1311           * {@link XMapPane} is visible and has bounds set.           * {@link XMapPane} is visible and has bounds set.
1312           */           */
1313          public boolean isWellDefined() {          public boolean isWellDefined() {
   
1314                  try {                  try {
1315                            if (getMapContext() == null)
                         if (getContext() == null)  
                                 return false;  
                         if (getContext().getLayerCount() <= 0)  
1316                                  return false;                                  return false;
1317                          if (getMapArea() == null)                          if (getMapContext().getLayerCount() <= 0)
1318                                  return false;                                  return false;
1319                          if (getBounds().getWidth() == 0)                          if (getVisibleRect().getWidth() == 0)
1320                                  return false;                                  return false;
1321                          if (getBounds().getHeight() == 0)                          if (getVisibleRect().getHeight() == 0)
1322                                  return false;                                  return false;
1323                            // if (getMapArea() == null)
1324                            // return false;
1325                  } catch (final Exception e) {                  } catch (final Exception e) {
1326                          return false;                          return false;
1327                  }                  }
1328                  return true;                  return true;
1329          }          }
1330    
1331            /**
1332             * Called from the listeners while the mouse is dragging, this method either
1333             * paints a translated (moved/panned) version of the image, or a rectangle.
1334             *
1335             * @param startPos
1336             *            in screen coordinates
1337             * @param lastPos
1338             *            in screen coordinates
1339             * @param event
1340             *            the {@link MouseEvent} to read the mouse buttons from
1341             */
1342          public void mouseDragged(final Point startPos, final Point lastPos,          public void mouseDragged(final Point startPos, final Point lastPos,
1343                          final MouseEvent event) {                          final MouseEvent event) {
1344    
1345                  if ((getState() == XMapPane.PAN)                  if ((getState() == XMapPane.PAN)
1346                                  || ((event.getModifiersEx() & InputEvent.BUTTON3_DOWN_MASK) != 0)) {                                  || ((event.getModifiersEx() & InputEvent.BUTTON3_DOWN_MASK) != 0)) {
1347    
1348                            // Panning needs a panning coursor
1349                          if (getCursor() != SwingUtil.PANNING_CURSOR) {                          if (getCursor() != SwingUtil.PANNING_CURSOR) {
1350                                  setCursor(SwingUtil.PANNING_CURSOR);                                  setCursor(SwingUtil.PANNING_CURSOR);
1351    
1352                                  // While panning, we deactivate the rendering. So the tasts are                                  // While panning, we deactivate the rendering. So the tasks are
1353                                  // ready to start when the panning os done.                                  // ready to start when the panning is finished.
1354                                  if (bgExecuter != null)                                  if (bgExecuter != null && bgExecuter.isRunning())
1355                                          bgExecuter.cancelTask();                                          bgExecuter.cancelTask();
1356                                  if (localExecuter != null)                                  if (localExecuter.isRunning())
1357                                          localExecuter.cancelTask();                                          localExecuter.cancelTask();
1358                          }                          }
1359    
# Line 1372  public class XMapPane extends JPanel { Line 1400  public class XMapPane extends JPanel {
1400                  } else if ((getState() == XMapPane.ZOOM_IN)                  } else if ((getState() == XMapPane.ZOOM_IN)
1401                                  || (getState() == XMapPane.ZOOM_OUT)                                  || (getState() == XMapPane.ZOOM_OUT)
1402                                  || (getState() == XMapPane.SELECT_ALL)                                  || (getState() == XMapPane.SELECT_ALL)
1403                                  || (getState() == XMapPane.SELECT_TOP)                                  || (getState() == XMapPane.SELECT_TOP)) {
                 // || (getState() == XMapPane.SELECT_ONE_FROM_TOP)  
                 ) {  
                         final Graphics graphics = getGraphics();  
1404    
1405                            // Draws a rectangle
1406                            final Graphics graphics = getGraphics();
1407                          drawRectangle(graphics, startPos, event.getPoint());                          drawRectangle(graphics, startPos, event.getPoint());
1408                            if ((lastPos.x > 0) && (lastPos.y > 0))
                         if ((lastPos.x > 0) && (lastPos.y > 0)) {  
1409                                  drawRectangle(graphics, startPos, lastPos);                                  drawRectangle(graphics, startPos, lastPos);
                         }  
   
1410                          graphics.dispose();                          graphics.dispose();
   
1411                  }                  }
   
1412          }          }
1413    
1414          /**          /**
1415           * Called by the {@link RenderingExecutor} when rendering was cancelled.           * Called by the {@link RenderingExecutor} when rendering was cancelled.
1416           */           */
1417          public void onRenderingCancelled() {          public void onRenderingCancelled() {
                 repaintTimer.stop();  
1418                  LOGGER.debug("Rendering cancelled");                  LOGGER.debug("Rendering cancelled");
1419                    repaintTimer.stop();
1420          }          }
1421    
1422          /**          /**
# Line 1402  public class XMapPane extends JPanel { Line 1424  public class XMapPane extends JPanel {
1424           * completed.           * completed.
1425           */           */
1426          public void onRenderingCompleted() {          public void onRenderingCompleted() {
1427                    LOGGER.debug("complete");
1428    
1429                  repaintTimer.stop();                  repaintTimer.stop();
1430                  updateFinalImage();  
1431                  repaint();                  // We "forget" about an exception every time we complete a rendering
1432                    // thread successfully
1433                  if (renderingErrors.size() > 0)                  if (renderingErrors.size() > 0)
1434                          renderingErrors.remove(0);                          renderingErrors.remove(0);
1435    
1436                    updateFinalImage();
1437                    repaint();
1438          }          }
1439    
1440          /**          /**
# Line 1420  public class XMapPane extends JPanel { Line 1448  public class XMapPane extends JPanel {
1448           * @see MapPaneListener#onRenderingStopped(org.geotools.swing.event.MapPaneEvent)           * @see MapPaneListener#onRenderingStopped(org.geotools.swing.event.MapPaneEvent)
1449           */           */
1450          public void onRenderingFailed(final Exception renderingError) {          public void onRenderingFailed(final Exception renderingError) {
1451                  this.renderingErrors.add(renderingError);  
1452                    // Store the exceptions so we can show it to the user:
1453                    if (!(renderingError instanceof java.lang.IllegalArgumentException && renderingError
1454                                    .getMessage().equals(
1455                                                    "Argument \"sourceCRS\" should not be null.")))
1456                            this.renderingErrors.add(renderingError);
1457                  if (renderingErrors.size() > 3)                  if (renderingErrors.size() > 3)
1458                          renderingErrors.remove(0);                          renderingErrors.remove(0);
1459    
1460                  repaintTimer.stop();                  repaintTimer.stop();
1461    
1462                  LOGGER.warn("Rendering failed", renderingError);                  LOGGER.warn("Rendering failed", renderingError);
1463                  updateFinalImage();                  updateFinalImage();
1464                  repaint();                  repaint();
1465    
1466          }          }
1467    
         public void onRenderingPending() {  
                 // LOGGER.debug("Pending rendering updates the preview...");  
                 updateFinalImage();  
                 repaint();  
         }  
   
1468          @Override          @Override
1469          protected void paintComponent(final Graphics g) {          protected void paintComponent(final Graphics g) {
                 if (!acceptsRepaintCalls)  
                         return;  
1470    
1471                  // Maybe update the cursor and maybe stop the repainting timer                  // Maybe update the cursor and maybe stop the repainting timer
1472                  updateCursor();                  updateCursor();
1473    
1474                    if (!acceptsRepaintCalls)
1475                            return;
1476    
1477                    if (!isWellDefined())
1478                            return;
1479    
1480                  // super.paintComponent(g); // candidate for removal                  // super.paintComponent(g); // candidate for removal
1481    
1482                  boolean paintedSomething = false;                  boolean paintedSomething = false;
# Line 1457  public class XMapPane extends JPanel { Line 1490  public class XMapPane extends JPanel {
1490                          // happening.                          // happening.
1491                          if (mapAreaChanged && oldMapArea != null                          if (mapAreaChanged && oldMapArea != null
1492                                          && getMapArea().intersects(oldMapArea)                                          && getMapArea().intersects(oldMapArea)
1493                                          & !getMapArea().equals(oldMapArea)) {                                          & !getMapArea().equals(oldMapArea) && !paneResized) {
1494    
1495                                  mapAreaChanged = false;                                  mapAreaChanged = false;
1496    
1497                                  if (getMapArea().covers(oldMapArea)) {                                  if (getMapArea().covers(oldMapArea)) {
1498                                          setQuickPreviewHint(ZOOM_OUT);                                          quickPreviewHint = ZOOM_OUT;
1499                                          paintedSomething = drawScaledPreviewImage_Zoom((Graphics2D) g);                                          paintedSomething = drawScaledPreviewImage_Zoom((Graphics2D) g);
1500                                  } else if (oldMapArea.covers(getMapArea())) {                                  } else if (oldMapArea.covers(getMapArea())) {
1501                                          setQuickPreviewHint(ZOOM_IN);                                          quickPreviewHint = ZOOM_IN;
1502                                          paintedSomething = drawScaledPreviewImage_Zoom((Graphics2D) g);                                          paintedSomething = drawScaledPreviewImage_Zoom((Graphics2D) g);
1503                                  }                                  }
   
1504                          }                          }
   
                         if (paneResized) {  
                                 paneResized = false;  
                                 disposeImages();  
                         }  
   
                         // Start the Threads and Timers to render the image  
                         requestStartRendering();  
   
1505                  }                  }
1506    
1507                  if (!paintedSomething) {                  if (!paintedSomething) {
# Line 1542  public class XMapPane extends JPanel { Line 1565  public class XMapPane extends JPanel {
1565           */           */
1566          public void performPan() {          public void performPan() {
1567    
1568                  final Rectangle winBounds = getBounds();                  Rectangle winBounds = getVisibleRect();
1569    
1570                  winBounds.translate(-imageOrigin.x, -imageOrigin.y);                  winBounds.translate(-imageOrigin.x, -imageOrigin.y);
1571                  final Envelope newMapArea = tranformWindowToGeo(winBounds.x,                  final Envelope newMapArea = tranformWindowToGeo(winBounds.x,
1572                                  winBounds.y, winBounds.x + winBounds.width, winBounds.y                                  winBounds.y, winBounds.x + winBounds.width, winBounds.y
# Line 1565  public class XMapPane extends JPanel { Line 1589  public class XMapPane extends JPanel {
1589                          setCursor(SwingUtil.PAN_CURSOR);                          setCursor(SwingUtil.PAN_CURSOR);
1590          }          }
1591    
         //  
         // /**  
         // * Nuetzlich wenn die Componente gedruckt (z.B. wenn ein Screenshot  
         // gemacht  
         // * wird) wird. Dann werden wird der Hintergrund auf WEISS gesetzt.  
         // *  
         // * @author <a href="mailto:[email protected]">Stefan Alfons  
         // * Kr&uuml;ger</a>  
         // */  
         // @Override  
         // public void print(final Graphics g) {  
         // final Color orig = getBackground();  
         // setBackground(Color.WHITE);  
         //  
         // // wrap in try/finally so that we always restore the state  
         // try {  
         // super.print(g);  
         // } finally {  
         // setBackground(orig);  
         // }  
         // }  
   
1592          /**          /**
1593           * Entfernt einen Listener von der Map.           * Entfernt einen Listener von der Map.
1594           *           *
# Line 1605  public class XMapPane extends JPanel { Line 1607  public class XMapPane extends JPanel {
1607          private void requestStartRendering() {          private void requestStartRendering() {
1608                  if (bgExecuter != null)                  if (bgExecuter != null)
1609                          bgExecuter.cancelTask();                          bgExecuter.cancelTask();
1610                  if (localExecuter != null)  
1611                          localExecuter.cancelTask();                  localExecuter.cancelTask();
1612    
1613                    mapImageInvalid = true;
1614                    if (paneResized) {
1615                            paneResized = false;
1616                            disposeImages();
1617                    }
1618                  requestStartRendering = true;                  requestStartRendering = true;
1619    
1620          }          }
1621  //  
1622  //      /**          /**
1623  //       * Berechnet die Transformation zwischen Fenster- und Karten-Koordinaten           * Calculate the affine transforms used to convert between world and pixel
1624  //       * neu.           * coordinates. The calculations here are very basic and assume a cartesian
1625  //       */           * reference system.
1626  //      protected void resetTransforms() {           * <p>
1627  //              if (getMapArea() == null || getWidth() == 0 || getHeight() == 0)           * Tne transform is calculated such that {@code envelope} will be centred in
1628  //                      return;           * the display
1629  //           *
1630  //              // We store the last Transform           * @param envelope
1631  //              oldScreenToWorld = screenToWorld;           *            the current map extent (world coordinates)
1632  //           * @param paintArea
1633  //              this.screenToWorld = new AffineTransform(           *            the current map pane extent (screen units)
1634  //              // Genauso wie die Fenster-Koordinaten, werden die Longitude-Koordinaten           */
1635  //                              // nach rechts (Osten) hin groesser          private void resetTransforms() {
1636  //                              // --> positive Verschiebung                  ReferencedEnvelope refMapEnv = new ReferencedEnvelope(mapArea,
1637  //                              getMapArea().getWidth() / getWidth(),                                  getMapContext().getCoordinateReferenceSystem());
1638  //                              // keine Verzerrung  
1639  //                              0.0, 0.0,                  // System.out
1640  //                              // Waehrend die Fenster-Koordinaten nach unten hin groesser                  // .println("paintArea in resetTeansofrms = " + getVisibleRect());
1641  //                              // werden,                  if (!isWellDefined())
1642  //                              // werden Latitude-Koordinaten nach Sueden hin keiner                          return;
1643  //                              // --> negative Verschiebung  
1644  //                              -getMapArea().getHeight() / getHeight(),                  worldToScreen = RendererUtilities.worldToScreenTransform(refMapEnv,
1645  //                              // Die Longitude-Koordinaten werden nach Osten hin groesser                                  getVisibleRect());
1646  //                              // --> obere linke Ecke des Fensters hat also den Minimalwert  
1647  //                              getMapArea().getMinX(),                  try {
1648  //                              // Die Latitude-Koordinaten werden nach Norden hin groesser                          screenToWorld = worldToScreen.createInverse();
1649  //                              // --> obere linke Ecke des Fensters hat also den Maximalwert  
1650  //                              getMapArea().getMaxY());                  } catch (NoninvertibleTransformException ex) {
1651  //                          LOGGER
1652  //              try {                                          .error("can't invert worldToScreen to get screenToWorld!",
1653  //                      this.worldToScreen = screenToWorld.createInverse();                                                          ex);
1654  //              } catch (final NoninvertibleTransformException e) {                  }
1655  //                      LOGGER.error(e);          }
 //              }  
 //      }  
           
           
   
     /**  
      * Calculate the affine transforms used to convert between  
      * world and pixel coordinates. The calculations here are very  
      * basic and assume a cartesian reference system.  
      * <p>  
      * Tne transform is calculated such that {@code envelope} will  
      * be centred in the display  
      *  
      * @param envelope the current map extent (world coordinates)  
      * @param paintArea the current map pane extent (screen units)  
      */  
     private void resetTransforms() {  
         ReferencedEnvelope refEnv = new ReferencedEnvelope(mapArea, getContext().getCoordinateReferenceSystem());  
   
         Rectangle paintArea = getBounds();  
           
         double xscale = paintArea.getWidth() / refEnv.getWidth();  
         double yscale = paintArea.getHeight() / refEnv.getHeight();  
   
         double scale = Math.min(xscale, yscale);  
   
         double xoff = refEnv.getMedian(0) * scale - paintArea.getCenterX();  
         double yoff = refEnv.getMedian(1) * scale + paintArea.getCenterY();  
   
         worldToScreen = new AffineTransform(scale, 0, 0, -scale, -xoff, yoff);  
         try {  
             screenToWorld = worldToScreen.createInverse();  
   
         } catch (NoninvertibleTransformException ex) {  
             ex.printStackTrace();  
         }  
     }  
           
           
1656    
1657          public void setBgContext(final MapContext context) {          public void setBgContext(final MapContext context) {
1658    
# Line 1700  public class XMapPane extends JPanel { Line 1669  public class XMapPane extends JPanel {
1669                  this.bgContext = context;                  this.bgContext = context;
1670    
1671                  if (context != null) {                  if (context != null) {
1672                          setMapArea(bgContext.getAreaOfInterest());                          // setMapArea(bgContext.getAreaOfInterest());
1673    
1674                          this.bgContext.addMapLayerListListener(bgContextListener);                          this.bgContext.addMapLayerListListener(bgContextListener);
1675    
# Line 1709  public class XMapPane extends JPanel { Line 1678  public class XMapPane extends JPanel {
1678                                  mapLayer.addMapLayerListener(bgMapLayerListener);                                  mapLayer.addMapLayerListener(bgMapLayerListener);
1679                          }                          }
1680                  }                  }
1681                  mapImageInvalid = true;  
1682                  repaint();                  requestStartRendering();
1683          }          }
1684    
1685          public void setJava2dHints(final RenderingHints java2dHints) {          public void setJava2dHints(final RenderingHints java2dHints) {
1686                  this.java2dHints = java2dHints;                  this.java2dHints = java2dHints;
1687          }          }
1688    
         /**  
          *  
          * @param context  
          */  
1689          public void setLocalContext(final MapContext context) {          public void setLocalContext(final MapContext context) {
1690                  // Remove the default listener from the old context                  // Remove the default listener from the old context
1691                  if (this.localContext != null) {                  if (this.localContext != null) {
# Line 1736  public class XMapPane extends JPanel { Line 1701  public class XMapPane extends JPanel {
1701    
1702                  if (context != null) {                  if (context != null) {
1703    
1704                          setMapArea(localContext.getAreaOfInterest());                          // setMapArea(localContext.getAreaOfInterest());
1705    
1706                          localRenderer.setContext(localContext);                          localRenderer.setContext(localContext);
1707    
# Line 1748  public class XMapPane extends JPanel { Line 1713  public class XMapPane extends JPanel {
1713                          }                          }
1714                  }                  }
1715    
1716                  mapImageInvalid = true;                  requestStartRendering();
1717                  repaint();  
1718            }
1719    
1720            public boolean setMapArea(final Envelope newMapArea) {
1721                    if (newMapArea == null)
1722                            return false;
1723                    if (getMapContext()
1724                                    .getCoordinateReferenceSystem() == null) return false;
1725                    return setMapArea(new ReferencedEnvelope(newMapArea, getMapContext()
1726                                    .getCoordinateReferenceSystem()));
1727          }          }
1728    
1729          /**          /**
# Line 1757  public class XMapPane extends JPanel { Line 1731  public class XMapPane extends JPanel {
1731           * @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
1732           *         has been triggered.           *         has been triggered.
1733           */           */
1734          public boolean setMapArea(final Envelope newMapArea) {          public boolean setMapArea(final ReferencedEnvelope newMapArea) {
1735    
1736                  if (newMapArea == null                  if (newMapArea == null
1737                                  || bestAllowedMapArea(newMapArea).equals(mapArea)) {                                  || bestAllowedMapArea(newMapArea).equals(mapArea)) {
# Line 1776  public class XMapPane extends JPanel { Line 1750  public class XMapPane extends JPanel {
1750                          return false;                          return false;
1751                  }                  }
1752    
1753                    final Envelope candNew = bestAllowedMapArea(newMapArea);
1754    
1755                  // Testing, whether the difference if just minimal                  // Testing, whether the difference if just minimal
1756                  if (mapArea != null) {                  if (mapArea != null) {
                         final Envelope candNew = bestAllowedMapArea(newMapArea);  
1757                          final double tolX = mapArea.getWidth() / 1000.;                          final double tolX = mapArea.getWidth() / 1000.;
1758                          final double tolY = mapArea.getHeight() / 1000.;                          final double tolY = mapArea.getHeight() / 1000.;
1759                          if ((candNew.getMinX() - tolX < mapArea.getMinX())                          if ((candNew.getMinX() - tolX < mapArea.getMinX())
# Line 1798  public class XMapPane extends JPanel { Line 1773  public class XMapPane extends JPanel {
1773                          }                          }
1774                  }                  }
1775    
1776                    // New map are is accepted:
1777                  oldMapArea = mapArea;                  oldMapArea = mapArea;
1778                    mapArea = candNew;
1779                  this.mapArea = bestAllowedMapArea(newMapArea);                  resetTransforms();
1780    
1781                  if (localContext != null) {                  if (localContext != null) {
1782                          localContext.setAreaOfInterest(mapArea, localContext                          localContext.setAreaOfInterest(mapArea, localContext
# Line 1810  public class XMapPane extends JPanel { Line 1786  public class XMapPane extends JPanel {
1786                          bgContext.setAreaOfInterest(mapArea, localContext                          bgContext.setAreaOfInterest(mapArea, localContext
1787                                          .getCoordinateReferenceSystem());                                          .getCoordinateReferenceSystem());
1788                  }                  }
1789                  resetTransforms();  
                 mapImageInvalid = true;  
1790                  mapAreaChanged = true;                  mapAreaChanged = true;
                 repaint();  
1791    
1792                  // LOGGER.debug("New maparea = " + mapArea);                  repaint(200); // Do not remove it!
1793    
1794                    requestStartRendering();
1795    
1796                  return true;                  return true;
1797          }          }
1798    
# Line 1825  public class XMapPane extends JPanel { Line 1802  public class XMapPane extends JPanel {
1802           * @param if <code>null</code>, white is used.           * @param if <code>null</code>, white is used.
1803           */           */
1804          public void setMapBackgroundColor(Color bgColor) {          public void setMapBackgroundColor(Color bgColor) {
                 if (bgColor == null)  
                         bgColor = Color.WHITE;  
1805                  this.mapBackgroundColor = bgColor;                  this.mapBackgroundColor = bgColor;
1806          }          }
1807    
# Line 1901  public class XMapPane extends JPanel { Line 1876  public class XMapPane extends JPanel {
1876          }          }
1877    
1878          /**          /**
1879           *           * If <code>true</code>, allow the {@link XMapPane} to process #repaint()
1880           * @param b           * requests. Otherwise the map will not paint anything and not start any
1881             * rendering {@link Thread}s.
1882           */           */
1883          public void setPainting(final boolean b) {          public void setPainting(final boolean b) {
1884                  acceptsRepaintCalls = b;                  acceptsRepaintCalls = b;
1885          }                  if (acceptsRepaintCalls == true)
1886                            repaint();
         // /**  
         // * Returns in milli seconds the time the last rending of the  
         // * {@link SelectableXMapPane} took. #Long.MAX_VALUE if the JMapPane has  
         // not  
         // * been rendered yet.  
         // */  
         // public long getLastRenderingDuration() {  
         // return lastRenderingDuration;  
         // }  
   
         public void setQuickPreviewHint(final int quickPreviewHint) {  
                 this.quickPreviewHint = quickPreviewHint;  
   
1887          }          }
1888    
1889          private void setRendererHints(final Map<Object, Object> rendererHints) {          private void setRendererHints(final Map<Object, Object> rendererHints) {
# Line 1965  public class XMapPane extends JPanel { Line 1928  public class XMapPane extends JPanel {
1928           */           */
1929          private void startRendering() {          private void startRendering() {
1930    
1931                  if (!isWellDefined())                  if (!isWellDefined() || !acceptsRepaintCalls) {
1932                            // if we are not ready to start rendering, try it again the next
1933                            // time the timer is chacking the flag.
1934                            requestStartRendering = true;
1935                          return;                          return;
1936                    }
1937    
1938                  if (bgExecuter != null) {                  if (bgExecuter != null) {
1939                          // Stop all renderers                          // Stop all renderers
1940                          bgExecuter.cancelTask();                          bgExecuter.cancelTask();
1941                  }                  }
1942    
1943                  if (localExecuter != null) {                  localExecuter.cancelTask();
                         localExecuter.cancelTask();  
                 }  
1944    
1945                  final Rectangle curPaintArea = getVisibleRect();                  final Rectangle curPaintArea = getVisibleRect();
1946    
# Line 1998  public class XMapPane extends JPanel { Line 1963  public class XMapPane extends JPanel {
1963                          // (Graphics2D) getBgImage().getGraphics(), createGTRenderer);                          // (Graphics2D) getBgImage().getGraphics(), createGTRenderer);
1964                  }                  }
1965    
1966                  if (getContext() != null) {                  if (getMapContext() != null) {
1967                          // localExecuter = new RenderingExecutor(this, 150l);                          // localExecuter = new RenderingExecutor(this, 150l);
1968                          // LOGGER.debug("starting local renderer:");                          // LOGGER.debug("starting local renderer:");
1969    
1970                          localRenderer.setJava2DHints(getJava2dHints());                          localRenderer.setJava2DHints(getJava2dHints());
1971                          localRenderer.setRendererHints(getRendererHints());                          localRenderer.setRendererHints(getRendererHints());
1972    
1973                          ReferencedEnvelope areaOfInterest = getMapArea();                          final boolean submitted = localExecuter.submit(getMapArea(),
                         final boolean submitted = localExecuter.submit(areaOfInterest,  
1974                                          curPaintArea, (Graphics2D) getLocalImage().getGraphics(),                                          curPaintArea, (Graphics2D) getLocalImage().getGraphics(),
1975                                          localRenderer, getWorldToScreenTransform());                                          localRenderer);
1976                          if (submitted)                          if (submitted)
1977                                  repaintTimer.restart();                                  repaintTimer.restart();
1978                          else                          else
1979                                  requestStartRendering = true; // Try to start rendering again in                                  requestStartRendering = true; // Try to start rendering
1980                            // again in
1981                          // a moment                          // a moment
1982                  }                  }
1983    
# Line 2035  public class XMapPane extends JPanel { Line 2000  public class XMapPane extends JPanel {
2000           *            {@link #getScreenToWorld()} is used.           *            {@link #getScreenToWorld()} is used.
2001           */           */
2002          public Envelope tranformGeoToWindow(final double ox, final double oy,          public Envelope tranformGeoToWindow(final double ox, final double oy,
2003                          final double px, final double py,                          final double px, final double py) {
2004                          final AffineTransform winToGeotransform) {                  final AffineTransform at = getWorldToScreenTransform();
                 final AffineTransform at = winToGeotransform == null ? getScreenToWorld()  
                                 : winToGeotransform;  
2005                  Point2D geoO;                  Point2D geoO;
2006                  try {                  // try {
2007                          geoO = at.inverseTransform(new Point2D.Double(ox, oy), null);                  geoO = at.transform(new Point2D.Double(ox, oy), null);
2008                          final Point2D geoP = at.inverseTransform(                  final Point2D geoP = at.transform(new Point2D.Double(px, py), null);
2009                                          new Point2D.Double(px, py), null);                  return new Envelope(geoO.getX(), geoP.getX(), geoO.getY(), geoP.getY());
2010                          return new Envelope(geoO.getX(), geoP.getX(), geoO.getY(), geoP                  // } catch (final NoninvertibleTransformException e) {
2011                                          .getY());                  // LOGGER.error(e);
2012                  } catch (final NoninvertibleTransformException e) {                  // return new Envelope(ox, oy, px, py);
2013                          LOGGER.error(e);                  // }
                         return new Envelope(ox, oy, px, py);  
                 }  
2014          }          }
2015    
2016          /**          /**
# Line 2069  public class XMapPane extends JPanel { Line 2030  public class XMapPane extends JPanel {
2030                  final AffineTransform at = getScreenToWorld();                  final AffineTransform at = getScreenToWorld();
2031                  final Point2D geoO = at.transform(new Point2D.Double(ox, oy), null);                  final Point2D geoO = at.transform(new Point2D.Double(ox, oy), null);
2032                  final Point2D geoP = at.transform(new Point2D.Double(px, py), null);                  final Point2D geoP = at.transform(new Point2D.Double(px, py), null);
2033                  return new Envelope(geoO.getX(), geoP.getX(), geoO.getY(), geoP.getY());  
2034                    // Mmmmm... don't really understand why its x,x,y,y
2035                    // return new Envelope(geoO.getX(), geoP.getX(), geoO.getY(),
2036                    // geoP.getY());
2037                    return new Envelope(new Coordinate(geoO.getX(), geoO.getY()),
2038                                    new Coordinate(geoP.getX(), geoP.getY()));
2039          }          }
2040    
2041          /**          /**
# Line 2081  public class XMapPane extends JPanel { Line 2047  public class XMapPane extends JPanel {
2047                  // if the renderers have stopped, also stop the timer that is updating                  // if the renderers have stopped, also stop the timer that is updating
2048                  // the final image                  // the final image
2049                  if (bgExecuter != null && bgExecuter.isRunning()                  if (bgExecuter != null && bgExecuter.isRunning()
2050                                  || localExecuter != null && localExecuter.isRunning()) {                                  || localExecuter.isRunning()) {
2051                          setCursor(WAIT_CURSOR);                          setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
2052                          return;                          return;
2053                  } else {                  } else {
2054                          // Allow one last rendering                          // Allow one last rendering
2055                          if (repaintTimer.isRunning()) {                          if (repaintTimer.isRunning()) {
2056                                  System.out.println("one last rendering....");                                  // System.out.println("one last rendering....");
2057                                  repaintTimer.stop();                                  repaintTimer.stop();
2058                                  updateFinalImage();                                  updateFinalImage();
2059                                  repaint();                                  repaint();
# Line 2185  public class XMapPane extends JPanel { Line 2151  public class XMapPane extends JPanel {
2151    
2152                  // Paint a logo to the bottom right if available                  // Paint a logo to the bottom right if available
2153                  if (mapImage != null) {                  if (mapImage != null) {
2154                          graphics.drawImage(mapImage, getBounds().width                          Rectangle visibleRect = getVisibleRect();
2155                                          - mapImage.getWidth() - 10, getBounds().height                          graphics.drawImage(mapImage, visibleRect.width
2156                                            - mapImage.getWidth() - 10, getVisibleRect().height
2157                                          - mapImage.getHeight() - 10, null);                                          - mapImage.getHeight() - 10, null);
2158                  }                  }
2159                    
                   
2160                  int y = 17;                  int y = 17;
2161    
2162                  // If the rendering process is still running, indicate this is the image                  // If the rendering process is still running, indicate this is the image
2163                  if (forceWait || bgExecuter != null && bgExecuter.isRunning()                  if (forceWait || bgExecuter != null && bgExecuter.isRunning()
2164                                  || localExecuter != null && localExecuter.isRunning()) {                                  || localExecuter.isRunning()) {
2165                            
2166                          y+=8;                          y += 8;
2167    
2168                          final Color c = graphics.getColor();                          final Color c = graphics.getColor();
2169                          graphics.setFont(waitFont);                          graphics.setFont(waitFont);
 //                      String waitStr = "Wait..."; // i8n  
2170    
2171                          graphics.setColor(getMapBackgroundColor());                          graphics.setColor(getMapBackgroundColor());
2172                          graphics.drawString(waitMsg, 5, y);                          graphics.drawString(waitMsg, 5, y);
2173                          graphics.setColor(getMapBackgroundColor());                          graphics.setColor(getMapBackgroundColor());
2174                          graphics.drawString(waitMsg, 7, y+2);                          graphics.drawString(waitMsg, 7, y + 2);
2175                          graphics.setColor(Color.BLACK);                          graphics.setColor(Color.BLACK);
2176                          graphics.drawString(waitMsg, 6, y+1);                          graphics.drawString(waitMsg, 6, y + 1);
2177    
2178                          graphics.setColor(c);                          graphics.setColor(c);
2179                            
2180                          y += 24;                          y += 24;
2181                  }                  }
2182    
2183                  if (renderingErrors != null) {                  if (!renderingErrors.isEmpty() && isShowExceptions()) {
2184    
2185                          final Color c = graphics.getColor();                          final Color c = graphics.getColor();
2186                          graphics.setFont(errorFont);                          graphics.setFont(errorFont);
2187    
2188                          for (Exception ex : renderingErrors) {                          for (Exception ex : renderingErrors) {
2189    
                                 if (ex instanceof java.lang.IllegalArgumentException  
                                                 && ex.getMessage().equals(  
                                                                 "Argument \"sourceCRS\" should not be null."))  
                                         continue;  
   
2190                                  String errStr = ex.getLocalizedMessage();                                  String errStr = ex.getLocalizedMessage();
2191    
2192                                    if (errStr == null)
2193                                            errStr = ex.getMessage();
2194                                    if (errStr == null)
2195                                            errStr = "unknown error: " + ex.getClass().getSimpleName();
2196    
2197                                  graphics.setColor(Color.WHITE);                                  graphics.setColor(Color.WHITE);
2198                                  graphics.drawString(errStr, 5, y);                                  graphics.drawString(errStr, 5, y);
2199                                  graphics.setColor(Color.RED);                                  graphics.setColor(Color.RED);
# Line 2252  public class XMapPane extends JPanel { Line 2217  public class XMapPane extends JPanel {
2217          public void zoomTo(          public void zoomTo(
2218                          final FeatureCollection<SimpleFeatureType, SimpleFeature> features) {                          final FeatureCollection<SimpleFeatureType, SimpleFeature> features) {
2219    
2220                  final CoordinateReferenceSystem mapCRS = getContext()                  // if (!isWellDefined()) return;
2221    
2222                    final CoordinateReferenceSystem mapCRS = getMapContext()
2223                                  .getCoordinateReferenceSystem();                                  .getCoordinateReferenceSystem();
2224                  final CoordinateReferenceSystem fCRS = features.getSchema()                  final CoordinateReferenceSystem fCRS = features.getSchema()
2225                                  .getGeometryDescriptor().getCoordinateReferenceSystem();                                  .getGeometryDescriptor().getCoordinateReferenceSystem();
2226    
2227                  double width = mapArea.getWidth();                  ReferencedEnvelope _mapArea;
2228                  double height = mapArea.getHeight();                  if (mapArea == null)
2229                            _mapArea = features.getBounds();
2230                    else
2231                            _mapArea = getMapArea();
2232                    double width = _mapArea.getWidth();
2233                    double height = _mapArea.getHeight();
2234                  final double ratio = height / width;                  final double ratio = height / width;
2235    
2236                  if (features == null || features.size() == 0) {                  if (features == null || features.size() == 0) {
# Line 2310  public class XMapPane extends JPanel { Line 2282  public class XMapPane extends JPanel {
2282                  } else {                  } else {
2283                          final ReferencedEnvelope fBounds = features.getBounds();                          final ReferencedEnvelope fBounds = features.getBounds();
2284    
2285                          Envelope bounds;                          ReferencedEnvelope bounds;
2286                          if (!mapCRS.equals(fCRS)) {                          if (!mapCRS.equals(fCRS)) {
2287                                  bounds = JTSUtil.transformEnvelope(fBounds, fCRS, mapCRS);                                  bounds = JTSUtil.transformEnvelope(fBounds, mapCRS);
2288                          } else {                          } else {
2289                                  bounds = fBounds;                                  bounds = fBounds;
2290                          }                          }
# Line 2368  public class XMapPane extends JPanel { Line 2340  public class XMapPane extends JPanel {
2340                                  .getWidth()) / 2., (mapArea.getHeight() * zoomFaktor - mapArea                                  .getWidth()) / 2., (mapArea.getHeight() * zoomFaktor - mapArea
2341                                  .getHeight()) / 2.);                                  .getHeight()) / 2.);
2342    
2343                  // Move the newMapArea above the new center                  // TODO we actually want that
2344                  newMapArea.translate(gcenter.getX() - mapArea.centre().x, gcenter                  // // Move the newMapArea above the new center
2345                                  .getY()                  // newMapArea.translate(gcenter.getX() - mapArea.centre().x, gcenter
2346                                  - mapArea.centre().y);                  // .getY()
2347                    // - mapArea.centre().y);
2348    
2349                  setMapArea(newMapArea);                  setMapArea(newMapArea);
2350          }          }
2351    
2352            /**
2353             * Shall non-fatal rendering exceptions be reported in the mappane or be
2354             * dropped quitely.
2355             */
2356            public void setShowExceptions(boolean showExceptions) {
2357                    this.showExceptions = showExceptions;
2358            }
2359    
2360            /**
2361             * Shall exceptions be reported in the mappane?
2362             */
2363            public boolean isShowExceptions() {
2364                    return showExceptions;
2365            }
2366    
2367  }  }

Legend:
Removed from v.536  
changed lines
  Added in v.558

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26