/[schmitzm]/branches/1.0-gt2-2.6/src/skrueger/geotools/XMapPane.java
ViewVC logotype

Annotation of /branches/1.0-gt2-2.6/src/skrueger/geotools/XMapPane.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 560 - (hide annotations)
Tue Nov 24 14:57:05 2009 UTC (15 years, 3 months ago) by alfonx
File size: 71233 byte(s)
* Selection mit Click funktioniert wieder
1 alfonx 531 package skrueger.geotools;
2 mojays 2
3     import java.awt.Color;
4     import java.awt.Cursor;
5 alfonx 509 import java.awt.Font;
6 mojays 2 import java.awt.Graphics;
7     import java.awt.Graphics2D;
8 alfonx 509 import java.awt.Image;
9     import java.awt.Point;
10 mojays 2 import java.awt.Rectangle;
11 alfonx 505 import java.awt.RenderingHints;
12 alfonx 509 import java.awt.event.ActionEvent;
13     import java.awt.event.ActionListener;
14     import java.awt.event.ComponentAdapter;
15     import java.awt.event.ComponentEvent;
16 mojays 2 import java.awt.event.InputEvent;
17     import java.awt.event.MouseEvent;
18     import java.awt.event.MouseListener;
19 alfonx 505 import java.awt.geom.AffineTransform;
20 alfonx 509 import java.awt.geom.NoninvertibleTransformException;
21     import java.awt.geom.Point2D;
22 mojays 2 import java.awt.image.BufferedImage;
23     import java.io.IOException;
24 alfonx 533 import java.util.ArrayList;
25 mojays 2 import java.util.HashMap;
26     import java.util.Map;
27 alfonx 509 import java.util.Vector;
28 mojays 2
29 alfonx 560 import javax.jws.soap.SOAPBinding.Style;
30 alfonx 509 import javax.swing.Timer;
31 mojays 2
32     import org.apache.log4j.Logger;
33 alfonx 509 import org.geotools.feature.FeatureCollection;
34     import org.geotools.geometry.jts.JTS;
35     import org.geotools.geometry.jts.ReferencedEnvelope;
36     import org.geotools.map.DefaultMapContext;
37 mojays 2 import org.geotools.map.MapContext;
38 alfonx 509 import org.geotools.map.MapLayer;
39     import org.geotools.map.event.MapLayerEvent;
40 mojays 2 import org.geotools.map.event.MapLayerListEvent;
41     import org.geotools.map.event.MapLayerListListener;
42 alfonx 509 import org.geotools.map.event.MapLayerListener;
43     import org.geotools.referencing.CRS;
44 mojays 2 import org.geotools.renderer.GTRenderer;
45 alfonx 336 import org.geotools.renderer.label.LabelCacheImpl;
46 mojays 2 import org.geotools.renderer.lite.LabelCache;
47 alfonx 539 import org.geotools.renderer.lite.RendererUtilities;
48 alfonx 529 import org.geotools.renderer.lite.StreamingRenderer;
49 alfonx 509 import org.geotools.swing.JMapPane;
50     import org.geotools.swing.event.MapMouseEvent;
51     import org.geotools.swing.event.MapPaneEvent;
52     import org.geotools.swing.event.MapPaneListener;
53     import org.opengis.feature.simple.SimpleFeature;
54     import org.opengis.feature.simple.SimpleFeatureType;
55     import org.opengis.referencing.FactoryException;
56 mojays 2 import org.opengis.referencing.crs.CoordinateReferenceSystem;
57 alfonx 509 import org.opengis.referencing.operation.MathTransform;
58     import org.opengis.referencing.operation.TransformException;
59 mojays 2
60 alfonx 509 import schmitzm.geotools.GTUtil;
61 mojays 436 import schmitzm.geotools.JTSUtil;
62 alfonx 509 import schmitzm.geotools.gui.SelectableXMapPane;
63 alfonx 533 import schmitzm.geotools.io.GeoImportUtil;
64 alfonx 509 import schmitzm.geotools.map.event.JMapPaneListener;
65     import schmitzm.geotools.map.event.MapLayerAdapter;
66 alfonx 529 import schmitzm.lang.LangUtil;
67 alfonx 530 import schmitzm.swing.JPanel;
68 mojays 2 import schmitzm.swing.SwingUtil;
69    
70     import com.vividsolutions.jts.geom.Coordinate;
71     import com.vividsolutions.jts.geom.Envelope;
72 alfonx 509 import com.vividsolutions.jts.geom.Geometry;
73 mojays 2
74 alfonx 530 /**
75     * The {@link XMapPane} class uses a Geotools {@link GTRenderer} to paint up to
76     * two {@link MapContext}s: a "local" {@link MapContext} and a "background"
77     * {@link MapContext}. The idea is, that rendering a background layer made up of
78     * e.g. OSM data, may take much longer than rendering local data.<br>
79     * Every {@link MapContext} is rendered on a {@link Thread} of it's own.
80     * Starting/ cancelling these threads is done by the {@link RenderingExecutor}.<br>
81     * <br>
82     * While the renderers are rending the map, a <br>
83     * The {@link XMapPane} is based on schmitzm {@link JPanel}, so
84     * {@link #print(Graphics)} will automatically set the background of components
85     * to pure white.
86     *
87     * The XMapPane has a {@link MouseListener} that manages zooming.<br>
88     * A logo/icon to float in the lower left corner may be set with
89     * {@link #setMapImage(BufferedImage)}<br>
90     *
91     * @see SelectableXMapPane - an extension of {@link XMapPane} that supports
92     * selecting features.
93     *
94     * @author stefan
95     *
96     */
97 alfonx 529 public class XMapPane extends JPanel {
98 alfonx 530
99     private static final int IMAGETYPE = BufferedImage.TYPE_INT_RGB;
100     private static final int IMAGETYPE_withAlpha = BufferedImage.TYPE_INT_ARGB;
101    
102 alfonx 555 private final static Logger LOGGER = Logger.getLogger(XMapPane.class);
103 alfonx 153
104 alfonx 530 private boolean acceptsRepaintCalls = true;
105    
106 alfonx 509 /**
107 alfonx 530 * Main {@link MapContext} that holds all layers that are rendered into the
108     * {@link #localImage} by the {@link #localRenderer}
109 alfonx 509 */
110 alfonx 530 MapContext localContext;
111 mojays 2
112 alfonx 509 /**
113 alfonx 530 * {@link MapContext} holding the background layers. Use it for layers that
114     * CAN take very long for rendering, like layer from the Internet: WMS, WFS,
115     * OSM...<br>
116     * <code>null</code> by default.
117     *
118     * @see #setBgContext(MapContext)
119     * @see #getBgContext()
120 alfonx 509 */
121 alfonx 530 MapContext bgContext;
122 mojays 2
123 alfonx 509 /**
124 alfonx 530 * While threads are working, calls {@link XMapPane#updateFinalImage()}
125     * regularly and {@link #repaint()}. This {@link Timer} is stopped when all
126     * renderers have finished.
127 alfonx 509 *
128 alfonx 544 * @see INITIAL_REPAINT_DELAYAL
129 alfonx 530 * @see #REPEATING_REPAINT_DELAY
130 alfonx 509 */
131 alfonx 530 final private Timer repaintTimer;
132 mojays 2
133 alfonx 509 /**
134 alfonx 530 * The initial delay in milliseconds until the {@link #finalImage} is
135     * updated the first time.
136 alfonx 509 */
137 alfonx 555 public static final int INITIAL_REPAINT_DELAY = 900;
138 alfonx 530
139 alfonx 509 /**
140 alfonx 530 * While the {@link #bgExecuter} and {@link #localExecuter} are rendering,
141     * the {@link #repaintTimer} is regularly updating the {@link #finalImage}
142     * with previews.
143 alfonx 509 */
144 alfonx 560 public static final int REPEATING_REPAINT_DELAY = 500;
145 alfonx 530
146 alfonx 509 /**
147 alfonx 530 * Default delay (milliseconds) before the map will be redrawn when resizing
148     * the pane. This is to avoid flickering while drag-resizing.
149 alfonx 544 *
150     * @see #resizeTimer
151 alfonx 509 */
152 alfonx 539 public static final int DEFAULT_RESIZING_PAINT_DELAY = 600;
153 alfonx 530
154 alfonx 555 /**
155     * This not-repeating {@link Timer} is re-started whenever the component is
156     * resized. That means => only if the component is not resizing for
157     * {@link #DEFAULT_RESIZING_PAINT_DELAY} milliseconds, does the
158     * {@link XMapPane} react.
159     */
160 alfonx 544 private final Timer resizeTimer;
161    
162 alfonx 555 /**
163     * Flag for no-tool.
164     */
165 alfonx 530 public static final int NONE = -123;
166    
167 alfonx 509 /**
168 alfonx 530 * Flag fuer Modus "Kartenausschnitt bewegen". Nicht fuer Window-Auswahl
169     * moeglich!
170 alfonx 509 *
171     * @see #setState(int)
172     */
173 alfonx 530 public static final int PAN = 1;
174    
175 alfonx 509 /**
176 alfonx 555 * Flag fuer Modus "Heran zoomen".
177     *
178     * @see #setState(int)
179     * @see #setState(int)
180     */
181     public static final int ZOOM_IN = 2;
182    
183     /**
184     * Flag fuer Modus "Heraus zoomen". Nicht fuer Window-Auswahl moeglich!
185     *
186     * @see #setState(int)
187     */
188     public static final int ZOOM_OUT = 3;
189    
190     /**
191 alfonx 509 * Flag fuer Modus "SimpleFeature-Auswahl auf allen (sichtbaren) Layern".
192     *
193     * @see #setState(int)
194     * @see #setState(int)
195     */
196     public static final int SELECT_ALL = 103;
197     /**
198     * Flag fuer Modus
199     * "Auswahl nur eines Features, das erste sichtbare von Oben".
200     *
201     * @see #setState(int)
202     * @see #setState(int)
203     */
204     public static final int SELECT_ONE_FROM_TOP = 104;
205 alfonx 524 /**
206 alfonx 530 * Flag fuer Modus
207     * "SimpleFeature-Auswahl auf dem obersten (sichtbaren) Layer".
208     *
209     * @see #setState(int)
210     * @see #setState(int)
211 alfonx 524 */
212 alfonx 530 public static final int SELECT_TOP = 4;
213 alfonx 524
214 alfonx 544 /**
215     * {@link Font} used to paint the wait messages into the map
216     *
217     * @see #addGadgets(Graphics2D, boolean)
218     */
219 alfonx 530 final static Font waitFont = new Font("Arial", Font.BOLD, 30);
220 alfonx 544
221     /**
222     * {@link Font} used to paint error messages into the map
223     *
224     * @see #addGadgets(Graphics2D, boolean)
225     */
226 alfonx 533 final static Font errorFont = new Font("Arial", Font.BOLD, 13);
227 alfonx 524
228 alfonx 144 /**
229 alfonx 544 * The wait message painted into the map while rendering is going on on
230     * another thread.
231     *
232     * @see #addGadgets(Graphics2D, boolean)
233     */
234     final String waitMsg = SwingUtil.R("WaitMess");
235    
236     /**
237 alfonx 509 * Konvertiert die Maus-Koordinaten (relativ zum <code>JMapPane</code>) in
238     * Karten-Koordinaten.
239     *
240     * @param e
241     * Maus-Ereignis
242 alfonx 144 */
243 alfonx 530 public static Point2D getMapCoordinatesFromEvent(final MouseEvent e) {
244 alfonx 509 // aktuelle Geo-Position aus GeoMouseEvent ermitteln
245     if (e != null && e instanceof MapMouseEvent)
246     try {
247     return ((MapMouseEvent) e).getMapPosition().toPoint2D();
248 alfonx 530 } catch (final Exception err) {
249 alfonx 509 LOGGER
250     .error(
251     "return ((GeoMouseEvent) e).getMapCoordinate(null).toPoint2D();",
252     err);
253     }
254 mojays 2
255 alfonx 509 // aktuelle Geo-Position ueber Transformation des JMapPane berechnen
256     if (e != null && e.getSource() instanceof XMapPane) {
257 alfonx 513
258 alfonx 509 final XMapPane xMapPane = (XMapPane) e.getSource();
259 alfonx 513
260     if (!xMapPane.isWellDefined())
261     return null;
262    
263 alfonx 530 final AffineTransform at = xMapPane.getScreenToWorld();
264 alfonx 509 if (at != null)
265     return at.transform(e.getPoint(), null);
266     return null;
267     }
268     throw new IllegalArgumentException(
269     "MouseEvent has to be of instance MapMouseEvent or come from an XMapPane");
270     }
271 mojays 2
272 alfonx 509 /**
273 alfonx 530 * Listens to changes of the "background" {@link MapContext} and triggers
274     * repaints where needed.
275     */
276     private final MapLayerListListener bgContextListener = new MapLayerListListener() {
277    
278     @Override
279     public void layerAdded(final MapLayerListEvent event) {
280 alfonx 533 MapLayer layer = event.getLayer();
281     layer.addMapLayerListener(bgMapLayerListener);
282 alfonx 530 requestStartRendering();
283    
284     }
285    
286     @Override
287     public void layerChanged(final MapLayerListEvent event) {
288     requestStartRendering();
289     }
290    
291     @Override
292     public void layerMoved(final MapLayerListEvent event) {
293     requestStartRendering();
294     }
295    
296     @Override
297     public void layerRemoved(final MapLayerListEvent event) {
298     if (event.getLayer() != null)
299     event.getLayer().removeMapLayerListener(bgMapLayerListener);
300     requestStartRendering();
301     }
302     };
303    
304     /**
305 alfonx 543 * This {@link RenderingExecutor} manages the creation and cancellation of
306     * up to one {@link Thread} for rendering the {@link #localContext}.
307 alfonx 530 */
308 alfonx 543 private final RenderingExecutor localExecuter = new RenderingExecutor(this);
309 alfonx 530
310 alfonx 543 /**
311     * This {@link RenderingExecutor} manages the creation and cancellation of
312     * up to one {@link Thread} for rendering the {@link #bgContext}.
313     */
314 alfonx 530 protected RenderingExecutor bgExecuter;
315    
316     /**
317 alfonx 543 * The {@link #localRenderer} for the {@link #localContext} uses this
318     * {@link Image}.
319 alfonx 530 */
320     private BufferedImage localImage;
321    
322     /**
323 alfonx 543 * The {@link #bgRenderer} for the {@link #bgContext} uses this
324     * {@link Image}.
325 alfonx 530 */
326     private BufferedImage bgImage;
327 alfonx 544
328 alfonx 543 /**
329     * This {@link Image} is a merge of the {@link #bgImage},
330     * {@link #localImage} and {@link #addGadgets(Graphics2D, boolean)}. It is
331     * updated with {@link #updateFinalImage()} and used for painting in
332     * {@link #paintComponent(Graphics)}
333     */
334     private BufferedImage finalImage;
335 alfonx 530
336     /**
337     * Optionally a transparent image to paint over the map in the lower right
338     * corner.
339     *
340     * @see #addGadgets(Graphics2D)
341     * @see #setMapImage(BufferedImage)
342     **/
343     private BufferedImage mapImage = null;
344    
345     /**
346     * Listens to each layer in the local {@link MapContext} for changes and
347     * triggers repaints.
348     */
349     protected MapLayerListener bgMapLayerListener = new MapLayerAdapter() {
350    
351     @Override
352     public void layerChanged(final MapLayerEvent event) {
353     requestStartRendering();
354     }
355    
356     @Override
357     public void layerHidden(final MapLayerEvent event) {
358     requestStartRendering();
359     }
360    
361     @Override
362     public void layerShown(final MapLayerEvent event) {
363     requestStartRendering();
364     }
365     };
366    
367     /**
368     * A flag indicating if dispose() was already called. If true, then further
369     * use of this {@link SelectableXMapPane} is undefined.
370     */
371     private boolean disposed = false;
372    
373     /**
374     * While dragging, the {@link #updateFinalImage()} method is translating the
375     * cached images while setting it together.
376     **/
377     Point imageOrigin = new Point(0, 0);
378     /**
379     * For every rendering thread started,
380     * {@link GTUtil#createGTRenderer(MapContext)} is called to create a new
381     * renderer. These Java2D rendering hints are passed to the
382     * {@link GTRenderer}. The java2dHints are the same for all renderers (bg
383     * and local).
384     */
385     private RenderingHints java2dHints;
386    
387     protected LabelCache labelCache = new LabelCacheImpl();
388    
389     /**
390     * Listens to changes of the "local" {@link MapContext} and triggers
391     * repaints where needed.
392     */
393     private final MapLayerListListener localContextListener = new MapLayerListListener() {
394    
395     @Override
396     public void layerAdded(final MapLayerListEvent event) {
397     event.getLayer().addMapLayerListener(localMapLayerListener);
398    
399 alfonx 560 getLocalRenderer().setContext(getMapContext());
400 alfonx 530 requestStartRendering();
401    
402     }
403    
404     @Override
405     public void layerChanged(final MapLayerListEvent event) {
406 alfonx 560 // localRenderer = GTUtil.createGTRenderer();
407     getLocalRenderer().setContext(getMapContext());
408 alfonx 530 requestStartRendering();
409     }
410    
411     @Override
412     public void layerMoved(final MapLayerListEvent event) {
413 alfonx 560 getLocalRenderer().setContext(getMapContext());
414 alfonx 530 requestStartRendering();
415     }
416    
417     @Override
418     public void layerRemoved(final MapLayerListEvent event) {
419     if (event.getLayer() != null)
420     event.getLayer().removeMapLayerListener(localMapLayerListener);
421 alfonx 560 getLocalRenderer().setContext(getMapContext());
422 alfonx 530 requestStartRendering();
423     }
424     };
425    
426     /**
427     * Listens to each layer in the local {@link MapContext} for changes and
428     * triggers repaints.
429     */
430     protected MapLayerListener localMapLayerListener = new MapLayerAdapter() {
431    
432     @Override
433     public void layerChanged(final MapLayerEvent event) {
434 alfonx 560 getLocalRenderer().setContext(getMapContext()); // betters for SLD
435 alfonx 555 // changes?!
436 alfonx 530 requestStartRendering();
437     }
438    
439     @Override
440     public void layerHidden(final MapLayerEvent event) {
441     requestStartRendering();
442     }
443    
444     @Override
445     public void layerShown(final MapLayerEvent event) {
446     requestStartRendering();
447     }
448     };
449    
450 alfonx 560 final private GTRenderer localRenderer = GTUtil.createGTRenderer();
451 alfonx 533
452 alfonx 530 private final GTRenderer bgRenderer = GTUtil.createGTRenderer();
453    
454     /**
455     * the area of the map to draw
456     */
457     protected Envelope mapArea = null;
458    
459     /**
460     * A flag set it {@link #setMapArea(Envelope)} to indicated the
461     * {@link #paintComponent(Graphics)} method, that the image on-screen is
462     * associated with {@link #oldMapArea} and may hence be scaled for a quick
463     * preview.<br>
464     * The flag is reset
465     **/
466     private boolean mapAreaChanged = false;
467    
468     /**
469     * This color is used as the default background color when painting a map.
470     */
471 alfonx 558 private Color mapBackgroundColor = null;
472 alfonx 530
473     /**
474 alfonx 509 * A flag indicating that the shown image is invalid and needs to be
475     * re-rendered.
476     */
477     protected boolean mapImageInvalid = true;
478 mojays 2
479 alfonx 530 /**
480     * Holds a flag for each layer, whether it is regarded or ignored on
481     * {@link #SELECT_TOP}, {@link #SELECT_ALL} and {@link #SELECT_ONE_FROM_TOP}
482     * actions.
483     */
484     final protected HashMap<MapLayer, Boolean> mapLayerSelectable = new HashMap<MapLayer, Boolean>();
485 mojays 2
486 alfonx 414 /**
487 alfonx 530 * List of listeners of this {@link XMapPane}
488     */
489     protected Vector<JMapPaneListener> mapPaneListeners = new Vector<JMapPaneListener>();
490     /**
491 alfonx 509 * If not <code>null</code>, the {@link XMapPane} will not allow to zoom/pan
492 alfonx 414 * out of that area
493     **/
494     private Envelope maxExtend = null;
495 alfonx 530 private Double maxZoomScale = Double.MIN_VALUE;
496 alfonx 414
497 alfonx 509 private Double minZoomScale = Double.MAX_VALUE;
498 alfonx 414
499 alfonx 509 /**
500 alfonx 530 * We store the old mapArea for a moment to use it for the
501     * "quick scaled preview" in case of ZoomOut
502     **/
503     protected Envelope oldMapArea = null;
504 mojays 2
505 alfonx 509 /**
506 alfonx 530 * We store the old transform for a moment to use it for the
507     * "quick scaled preview" in case of ZoomIn
508     **/
509     protected AffineTransform oldScreenToWorld = null;
510 mojays 2
511 alfonx 509 /**
512     * A flag indicating, that the image size has changed and the buffered
513     * images are not big enough any more
514     **/
515 alfonx 555 protected boolean paneResized = true;
516 mojays 2
517 alfonx 530 private BufferedImage preFinalImage;
518    
519 alfonx 555 // ** if 0, no quick preview will be shown **/
520 alfonx 530 private int quickPreviewHint = 0;
521    
522 alfonx 533 private Map<Object, Object> rendererHints = GTUtil
523 alfonx 560 .getDefaultGTRendererHints(getLocalRenderer());
524 alfonx 530
525 alfonx 544 /**
526     * If set to <code>true</code>, the {@link #startRenderThreadsTimer} will
527     * start rendering {@link Thread}s
528     **/
529     private volatile Boolean requestStartRendering = false;
530 alfonx 530
531 alfonx 144 /**
532 alfonx 530 * Transformation zwischen Fenster-Koordinaten und Karten-Koordinaten
533     * (lat/lon)
534     */
535     protected AffineTransform screenToWorld = null;
536    
537     /**
538 alfonx 544 * The flag {@link #requestStartRendering} can be set to true by events.
539 alfonx 509 * This {@link Timer} checks the flag regularly and starts one renderer
540     * thread.
541 alfonx 505 */
542 alfonx 509 final private Timer startRenderThreadsTimer;
543 alfonx 505
544 alfonx 530 /**
545     * The default state is ZOOM_IN, hence by default the
546     * {@link #zoomMapPaneMouseListener} is also enabled.
547     **/
548     private int state = ZOOM_IN;
549 alfonx 509
550 alfonx 530 /**
551     * Manuell gesetzter statischer Cursor, unabhaengig von der aktuellen
552     * MapPane-Funktion
553     */
554     protected Cursor staticCursor = null;
555 mojays 2
556 alfonx 530 private AffineTransform worldToScreen;
557    
558 alfonx 144 /**
559 alfonx 530 * This {@link MouseListener} is managing all zoom related tasks
560 alfonx 144 */
561 alfonx 530 public final ZoomXMapPaneMouseListener zoomMapPaneMouseListener = new ZoomXMapPaneMouseListener(
562     this);
563 alfonx 509
564 alfonx 533 /** Is set if a renderer has an error **/
565     protected ArrayList<Exception> renderingErrors = new ArrayList<Exception>();
566    
567 alfonx 555 /**
568     * If <code>true</code>, then rendering exceptions are rendererd into the
569     * map pane
570     **/
571     private boolean showExceptions = false;
572 alfonx 544
573 alfonx 530 public XMapPane() {
574     this(null, null);
575 alfonx 144 }
576 mojays 2
577 alfonx 144 /**
578     * full constructor extending JPanel
579     *
580 alfonx 509 * @param rendererHints
581 alfonx 543 * may be <code>null</code>. Otherwise a {@link Map<Object,
582     * Object>} of {@link RenderingHints} to override the default
583     * from {@link GTUtil#getDefaultGTRendererHints(GTRenderer)}
584 alfonx 509 *
585     * @param localContext
586 alfonx 543 * The main {@link MapContext} to use. If <code>null</code>, an
587     * empty {@link DefaultMapContext} will be created.
588 alfonx 144 */
589 alfonx 529 public XMapPane(final MapContext localContext_,
590 alfonx 530 final Map<Object, Object> rendererHints) {
591 alfonx 509 super(true);
592 mojays 2
593 alfonx 509 setRendererHints(rendererHints);
594 mojays 2
595 alfonx 509 setOpaque(true);
596 mojays 2
597 alfonx 529 if (localContext_ != null)
598     setLocalContext(localContext_);
599    
600 alfonx 509 /**
601     * Adding the #zoomMapPaneMouseListener
602     */
603     this.addMouseListener(zoomMapPaneMouseListener);
604     this.addMouseMotionListener(zoomMapPaneMouseListener);
605     this.addMouseWheelListener(zoomMapPaneMouseListener);
606    
607     /*
608     * We use a Timer object to avoid rendering delays and flickering when
609     * the user is drag-resizing the parent container of this map pane.
610     *
611     * Using a ComponentListener doesn't work because, unlike a JFrame, the
612     * pane receives a stream of events during drag-resizing.
613     */
614 alfonx 543 resizeTimer = new Timer(DEFAULT_RESIZING_PAINT_DELAY,
615     new ActionListener() {
616 alfonx 509
617 alfonx 543 public void actionPerformed(final ActionEvent e) {
618     if (!isWellDefined())
619     return;
620 alfonx 509
621 alfonx 557 LOGGER.debug("resizeTimer performed");
622 alfonx 555
623 alfonx 543 final Rectangle bounds = getVisibleRect();
624 alfonx 544 //
625     // System.out.println("\n\ntimer performs with bounds = "
626     // + bounds);
627 alfonx 509
628 alfonx 543 final Envelope geoMapArea = tranformWindowToGeo(
629     bounds.x, bounds.y, bounds.x + bounds.width,
630     bounds.y + bounds.height);
631 alfonx 509
632 alfonx 555 if (setMapArea(geoMapArea)) {
633 alfonx 557 LOGGER.debug(" maparea changed");
634 alfonx 544 paneResized = true;
635 alfonx 555 } else
636 alfonx 557 LOGGER.debug(" maparea NOT changed");
637 alfonx 543 }
638     });
639 alfonx 509 resizeTimer.setRepeats(false);
640    
641 alfonx 544 this.addComponentListener(new ComponentAdapter() {
642    
643 alfonx 555 private Rectangle oldVisibleRect;
644    
645 alfonx 544 @Override
646     public void componentResized(final ComponentEvent e) {
647    
648 alfonx 556 // Seems to be called twice with the same size..
649 alfonx 555 if (oldVisibleRect != null
650 alfonx 556 && oldVisibleRect.equals(getVisibleRect())) {
651 alfonx 557 LOGGER.debug("skipping resize.");
652 alfonx 555 return;
653     }
654 alfonx 544
655 alfonx 557 LOGGER.debug("resized: " + getVisibleRect());
656 alfonx 544 resizeTimer.restart();
657 alfonx 555 oldVisibleRect = getVisibleRect();
658 alfonx 544 }
659    
660     });
661    
662 alfonx 530 /*
663     * Setting up the repaintTimer. Not started automatically.
664     */
665 alfonx 544 repaintTimer = new Timer(REPEATING_REPAINT_DELAY, new ActionListener() {
666 alfonx 509
667 alfonx 544 @Override
668     public void actionPerformed(final ActionEvent e) {
669 alfonx 555 if ((!localExecuter.isRunning())
670 alfonx 544 && (bgExecuter != null && !bgExecuter.isRunning())) {
671     repaintTimer.stop();
672     } else {
673     updateFinalImage();
674     XMapPane.this.repaint(100);
675 alfonx 555
676 alfonx 544 }
677     }
678     });
679 alfonx 555
680 alfonx 530 repaintTimer.setInitialDelay(INITIAL_REPAINT_DELAY);
681     repaintTimer.setRepeats(true);
682 alfonx 509
683 alfonx 530 /*
684     * Setting up the startRenderThreadsTimer. This Timer starts
685     * automatically.
686     */
687 alfonx 524 startRenderThreadsTimer = new Timer(100, new ActionListener() {
688    
689 alfonx 509 @Override
690 alfonx 530 public void actionPerformed(final ActionEvent e) {
691 alfonx 544 synchronized (requestStartRendering) {
692     if (requestStartRendering && isWellDefined()) {
693 alfonx 529
694     if (localExecuter.isRunning()) {
695 alfonx 524 localExecuter.cancelTask();
696     } else {
697 alfonx 544 // Stupidly, but we have to recheck the
698     setMapArea(getMapArea());
699     requestStartRendering = false;
700 alfonx 524 startRendering();
701     }
702     }
703 alfonx 509 }
704     }
705     });
706     startRenderThreadsTimer.start();
707    
708 alfonx 144 }
709 mojays 2
710 alfonx 530 /**
711     * Fuegt der Map einen Listener hinzu.
712     *
713     * @param l
714     * neuer Listener
715     */
716     public void addMapPaneListener(final JMapPaneListener l) {
717     mapPaneListeners.add(l);
718 alfonx 509 }
719    
720 alfonx 144 /**
721 alfonx 530 * Korrigiert den {@link Envelope} aka {@code mapArea} auf die beste
722     * erlaubte Flaeche damit die Massstabsbeschaenkungen noch eingehalten
723     * werden, FALLS der uebergeben Envelope nicht schon gueltig sein sollte.<br>
724     * Since 21. April 09: Before thecalculation starts, the aspect ratio is
725     * corrected. This change implies, that setMapArea() will most of the time
726     * not allow setting to a wrong aspectRatio.
727 alfonx 509 *
728 alfonx 530 * @author <a href="mailto:[email protected]">Stefan Alfons
729     * Kr&uuml;ger</a>
730 alfonx 144 */
731 alfonx 544 public ReferencedEnvelope bestAllowedMapArea(ReferencedEnvelope env) {
732    
733 alfonx 530 if (getWidth() == 0)
734     return env;
735 alfonx 544
736 alfonx 530 if (env == null)
737     return null;
738 alfonx 509
739 alfonx 530 Envelope newArea = null;
740 alfonx 509
741 alfonx 530 /**
742     * Correct the aspect Ratio before we check the rest. Otherwise we might
743     * easily fail. We allow to grow here, because we don't check against
744     * the maxExtend
745     */
746     final Rectangle curPaintArea = getVisibleRect();
747 alfonx 509
748 alfonx 530 env = JTSUtil.fixAspectRatio(curPaintArea, env, true);
749 alfonx 509
750 alfonx 530 final double scale = env.getWidth() / getWidth();
751     final double centerX = env.getMinX() + env.getWidth() / 2.;
752     final double centerY = env.getMinY() + env.getHeight() / 2.;
753     double newWidth2 = 0;
754     double newHeight2 = 0;
755     if (scale < getMaxZoomScale()) {
756     // ****************************************************************************
757     // Wir zoomen weiter rein als erlaubt => Anpassen des envelope
758     // ****************************************************************************
759     newWidth2 = getMaxZoomScale() * getWidth() / 2.;
760     newHeight2 = getMaxZoomScale() * getHeight() / 2.;
761     } else if (scale > getMinZoomScale()) {
762     // ****************************************************************************
763     // Wir zoomen weiter raus als erlaubt => Anpassen des envelope
764     // ****************************************************************************
765     newWidth2 = getMinZoomScale() * getWidth() / 2.;
766     newHeight2 = getMinZoomScale() * getHeight() / 2.;
767     } else {
768     // ****************************************************************************
769     // Die mapArea / der Envelope ist ist gueltig! Keine Aenderungen
770     // ****************************************************************************
771     newArea = env;
772     }
773 alfonx 509
774 alfonx 530 if (newArea == null) {
775    
776     final Coordinate ll = new Coordinate(centerX - newWidth2, centerY
777     - newHeight2);
778     final Coordinate ur = new Coordinate(centerX + newWidth2, centerY
779     + newHeight2);
780    
781     newArea = new Envelope(ll, ur);
782     }
783    
784     final Envelope maxAllowedExtend = getMaxExtend();
785 alfonx 555
786 alfonx 530 while (maxAllowedExtend != null && !maxAllowedExtend.contains(newArea)
787     && newArea != null && !newArea.isNull()
788     && !Double.isNaN(newArea.getMinX())
789     && !Double.isNaN(newArea.getMaxX())
790     && !Double.isNaN(newArea.getMinY())
791     && !Double.isNaN(newArea.getMaxY())) {
792     /*
793     * If a maxExtend is set, we have to honour that...
794     */
795    
796     // Exceeds top? Move down and maybe cut
797     if (newArea.getMaxY() > maxAllowedExtend.getMaxY()) {
798     final double divY = newArea.getMaxY()
799     - maxAllowedExtend.getMaxY();
800     // LOGGER.debug("Moving area down by " + divY);
801    
802     newArea = new Envelope(new Coordinate(newArea.getMinX(),
803     newArea.getMinY() - divY), new Coordinate(newArea
804     .getMaxX(), newArea.getMaxY() - divY));
805    
806     if (newArea.getMinY() < maxAllowedExtend.getMinY()) {
807     // LOGGER.debug("Now it exeeds the bottom border.. cut!");
808     // And cut the bottom if it moved out of the area
809     newArea = new Envelope(new Coordinate(newArea.getMinX(),
810     maxAllowedExtend.getMinY()), new Coordinate(newArea
811     .getMaxX(), newArea.getMaxY()));
812    
813     // LOGGER.debug("and fix aspect ratio");
814    
815 alfonx 544 newArea = JTSUtil.fixAspectRatio(getVisibleRect(),
816     new ReferencedEnvelope(newArea, env
817     .getCoordinateReferenceSystem()), false);
818 alfonx 530 }
819 alfonx 509 }
820    
821 alfonx 530 // Exceeds bottom? Move up and maybe cut
822     if (newArea.getMinY() < maxAllowedExtend.getMinY()) {
823     final double divY = newArea.getMinY()
824     - maxAllowedExtend.getMinY();
825     // LOGGER.debug("Moving area up by " + divY);
826    
827     newArea = new Envelope(new Coordinate(newArea.getMinX(),
828     newArea.getMinY() - divY), new Coordinate(newArea
829     .getMaxX(), newArea.getMaxY() - divY));
830    
831     if (newArea.getMaxY() > maxAllowedExtend.getMaxY()) {
832     // LOGGER.debug("Now it exeeds the top border.. cut!");
833     // And cut the bottom if it moved out of the area
834     newArea = new Envelope(new Coordinate(newArea.getMinX(),
835     newArea.getMinY()), new Coordinate(newArea
836     .getMaxX(), maxAllowedExtend.getMaxY()));
837    
838     // LOGGER.debug("and fix aspect ratio");
839    
840 alfonx 544 newArea = JTSUtil.fixAspectRatio(getVisibleRect(),
841     new ReferencedEnvelope(newArea, env
842     .getCoordinateReferenceSystem()), false);
843 alfonx 509 }
844     }
845    
846 alfonx 530 // Exceeds to the right? move and maybe cut
847     if (newArea.getMaxX() > maxAllowedExtend.getMaxX()) {
848 alfonx 509
849 alfonx 530 // Move left..
850     final double divX = newArea.getMaxX()
851     - maxAllowedExtend.getMaxX();
852     // LOGGER.debug("Moving area left by " + divX);
853 alfonx 509
854 alfonx 530 newArea = new Envelope(new Coordinate(newArea.getMinX() - divX,
855     newArea.getMinY()), new Coordinate(newArea.getMaxX()
856     - divX, newArea.getMaxY()));
857 alfonx 509
858 alfonx 530 if (newArea.getMinX() < maxAllowedExtend.getMinX()) {
859     // LOGGER.debug("Now it exeeds the left border.. cut!");
860     // And cut the left if it moved out of the area
861     newArea = new Envelope(new Coordinate(maxAllowedExtend
862     .getMinX(), newArea.getMinY()), new Coordinate(
863     newArea.getMaxX(), newArea.getMaxY()));
864 alfonx 509
865 alfonx 530 // LOGGER.debug("and fix aspect ratio");
866    
867 alfonx 544 newArea = JTSUtil.fixAspectRatio(getVisibleRect(),
868     new ReferencedEnvelope(newArea, env
869     .getCoordinateReferenceSystem()), false);
870 alfonx 530 }
871 alfonx 509 }
872    
873 alfonx 530 // Exceeds to the left? move and maybe cut
874     if (newArea.getMinX() < maxAllowedExtend.getMinX()) {
875 alfonx 509
876 alfonx 530 // Move right..
877     final double divX = newArea.getMinX()
878     - maxAllowedExtend.getMinX();
879     // LOGGER.debug("Moving area right by " + divX);
880    
881     newArea = new Envelope(new Coordinate(newArea.getMinX() - divX,
882     newArea.getMinY()), new Coordinate(newArea.getMaxX()
883     - divX, newArea.getMaxY()));
884    
885     if (newArea.getMaxX() > maxAllowedExtend.getMaxX()) {
886     // LOGGER.debug("Now it exeeds the right border.. cut!");
887     // And cut the left if it moved out of the area
888     newArea = new Envelope(new Coordinate(newArea.getMinX(),
889     newArea.getMinY()), new Coordinate(maxAllowedExtend
890     .getMaxX(), newArea.getMaxY()));
891    
892     // LOGGER.debug("and fix aspect ratio");
893    
894 alfonx 544 newArea = JTSUtil.fixAspectRatio(getVisibleRect(),
895     new ReferencedEnvelope(newArea, env
896     .getCoordinateReferenceSystem()), false);
897 alfonx 530 }
898     }
899 alfonx 509 }
900 mojays 2
901 alfonx 544 return new ReferencedEnvelope(newArea, env
902     .getCoordinateReferenceSystem());
903 alfonx 509 }
904 alfonx 414
905 alfonx 509 /**
906 alfonx 530 * Should be called when the {@link JMapPane} is not needed no more to help
907     * the GarbageCollector
908     *
909     * Removes all {@link JMapPaneListener}s that are registered
910     *
911     * @author <a href="mailto:[email protected]">Stefan Alfons
912     * Kr&uuml;ger</a>
913 alfonx 509 */
914 alfonx 530 public void dispose() {
915     if (isDisposed())
916     return;
917 alfonx 513
918 alfonx 530 setPainting(false);
919 alfonx 513
920 alfonx 530 resizeTimer.stop();
921     startRenderThreadsTimer.stop();
922    
923     disposed = true;
924    
925     if (bgExecuter != null) {
926     bgExecuter.cancelTask();
927     bgExecuter.dispose();
928 alfonx 504 }
929 alfonx 509
930 alfonx 555 if (localExecuter.isRunning()) {
931 alfonx 530 int i = 0;
932     localExecuter.cancelTask();
933     while (i++ < 10 && localExecuter.isRunning()) {
934     try {
935 alfonx 543 Thread.sleep(200);
936 alfonx 530 } catch (final InterruptedException e) {
937 alfonx 543 LOGGER
938     .warn(
939     "while XMapPane we are waiting for the localExcutor to stop",
940     e);
941 alfonx 530 }
942     }
943     if (localExecuter.isRunning()) {
944 alfonx 543 LOGGER
945     .warn("localExecutor Thread still running after 2s! Continuing anyways...");
946 alfonx 530 }
947     localExecuter.dispose();
948     }
949 alfonx 539
950 alfonx 530 disposeImages();
951 alfonx 509
952 alfonx 543 // Remove all mapPaneListeners that have registered with us
953 alfonx 530 mapPaneListeners.clear();
954 alfonx 509
955 alfonx 530 removeMouseMotionListener(zoomMapPaneMouseListener);
956     removeMouseListener(zoomMapPaneMouseListener);
957 alfonx 509
958 alfonx 530 if (localContext != null)
959 alfonx 551 getMapContext().clearLayerList();
960 alfonx 530 if (bgContext != null)
961     getBgContext().clearLayerList();
962    
963     removeAll();
964 alfonx 509 }
965    
966     /**
967 alfonx 530 * Draws a rectangle in XOR mode from the origin at {@link #startPos} to the
968     * given point. All in screen coordinates.
969 alfonx 509 */
970 alfonx 530 protected void drawRectangle(final Graphics graphics, final Point startPos,
971     final Point e) {
972 alfonx 509
973 alfonx 530 if (!isWellDefined())
974 alfonx 509 return;
975 alfonx 307
976 alfonx 530 // undraw last box/draw new box
977     final int left = Math.min(startPos.x, e.x);
978     final int right = Math.max(startPos.x, e.x);
979     final int top = Math.max(startPos.y, e.y);
980     final int bottom = Math.min(startPos.y, e.y);
981     final int width = right - left;
982     final int height = top - bottom;
983    
984     if (width == 0 && height == 0)
985 alfonx 509 return;
986 alfonx 414
987 alfonx 530 graphics.setXORMode(Color.WHITE);
988     graphics.drawRect(left, bottom, width, height);
989 alfonx 144 }
990 mojays 2
991 alfonx 509 /**
992 alfonx 530 * Diretly paints scaled preview into the {@link SelectableXMapPane}. Used
993     * to give the user something to look at while we are rendering. Method
994     * should be called after {@link #setMapArea(Envelope)} has been set to the
995     * new mapArea and transform has been reset.<br>
996     *
997     * @param g
998     * Graphics2D to paint the preview into
999     *
1000     * @param state
1001     * Max be {@link #ZOOM_IN} or {@link #ZOOM_OUT}
1002 alfonx 509 */
1003 alfonx 530 protected boolean drawScaledPreviewImage_Zoom(final Graphics2D graphics) {
1004 alfonx 509
1005 alfonx 543 // if (1 == 1)return false;
1006    
1007 alfonx 530 if (quickPreviewHint == 0)
1008     return false;
1009 alfonx 509
1010 alfonx 530 graphics.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
1011     RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR);
1012     graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
1013     RenderingHints.VALUE_ANTIALIAS_OFF);
1014     graphics.setRenderingHint(RenderingHints.KEY_RENDERING,
1015     RenderingHints.VALUE_RENDER_SPEED);
1016 alfonx 509
1017 alfonx 530 if (oldMapArea == null)
1018     return false;
1019 mojays 2
1020 alfonx 530 final Rectangle visibleArea = getVisibleRect();
1021 alfonx 509
1022 alfonx 530 // Calculate the oldMapArea in the current WindowCoordinates:
1023     final Envelope oldMapWindow = tranformGeoToWindow(oldMapArea.getMinX(),
1024     oldMapArea.getMinY(), oldMapArea.getMaxX(), oldMapArea
1025 alfonx 539 .getMaxY());
1026 alfonx 509
1027 alfonx 530 final int xx1 = (int) Math.round(oldMapWindow.getMinX());
1028     final int yy1 = (int) Math.round(oldMapWindow.getMinY());
1029     final int xx2 = (int) Math.round(oldMapWindow.getMaxX());
1030     final int yy2 = (int) Math.round(oldMapWindow.getMaxY());
1031 alfonx 509
1032 alfonx 530 graphics.drawImage(getPreFinalImage(), xx1, yy1, xx2, yy2,
1033     (int) visibleArea.getMinX(), (int) visibleArea.getMinY(),
1034     (int) visibleArea.getMaxX(), (int) visibleArea.getMaxY(),
1035     getMapBackgroundColor(), null);
1036 alfonx 509
1037 alfonx 530 final Rectangle painedArea = new Rectangle(xx1, yy1, xx2 - xx1, yy2
1038     - yy1);
1039 alfonx 529
1040 alfonx 530 SwingUtil.clearAround(graphics, painedArea, visibleArea);
1041 alfonx 529
1042 alfonx 533 addGadgets(graphics, true);
1043 alfonx 509
1044 alfonx 530 quickPreviewHint = 0;
1045 alfonx 509
1046 alfonx 533 repaintTimer.restart();
1047    
1048 alfonx 530 graphics.dispose();
1049 alfonx 509
1050 alfonx 530 // Something has been drawn
1051     return true;
1052     }
1053 mojays 2
1054 alfonx 530 public MapContext getBgContext() {
1055     return bgContext;
1056     }
1057 mojays 2
1058 alfonx 530 /**
1059     * Lazyly initializes a {@link BufferedImage} for the background renderer.
1060     */
1061     private Image getBgImage() {
1062     //
1063     // if (bgImage == null) {
1064     // bgImage = createImage(getBounds().width, getBounds().height);
1065     // }
1066    
1067     return bgImage;
1068     }
1069    
1070 alfonx 551 public MapContext getMapContext() {
1071 alfonx 530 if (localContext == null) {
1072     setLocalContext(new DefaultMapContext());
1073 alfonx 144 }
1074 alfonx 530 return localContext;
1075     }
1076 mojays 2
1077 alfonx 530 private BufferedImage getFinalImage() {
1078     //
1079     if (finalImage == null) {
1080     // Rectangle curPaintArea = getVisibleRect();
1081 alfonx 540 finalImage = new BufferedImage(getVisibleRect().width,
1082     getVisibleRect().height, IMAGETYPE);
1083 alfonx 530
1084 alfonx 509 requestStartRendering();
1085 alfonx 144 }
1086 alfonx 530 return finalImage;
1087     }
1088 alfonx 509
1089 alfonx 530 public RenderingHints getJava2dHints() {
1090     return java2dHints;
1091     }
1092    
1093 alfonx 509 /**
1094 alfonx 530 * Lazyly initializes a {@link BufferedImage} for the background renderer.
1095 alfonx 509 */
1096 alfonx 530 private BufferedImage getLocalImage() {
1097 alfonx 509
1098 alfonx 530 if (localImage == null) {
1099 alfonx 540 localImage = new BufferedImage(getVisibleRect().width,
1100     getVisibleRect().height, IMAGETYPE_withAlpha);
1101 alfonx 530 }
1102 alfonx 509
1103 alfonx 530 return localImage;
1104     }
1105    
1106     /**
1107     * Returns a copy of the mapArea
1108     *
1109     * @return
1110     */
1111 alfonx 533 public ReferencedEnvelope getMapArea() {
1112 alfonx 530 if (mapArea == null) {
1113     ReferencedEnvelope mapArea_ = null;
1114     try {
1115     mapArea_ = localContext.getLayerBounds();
1116     } catch (final IOException e) {
1117 alfonx 544 LOGGER.warn("localContext.getLayerBounds()", e);
1118 alfonx 509 }
1119    
1120 alfonx 544 if (mapArea_ == null && bgContext != null) {
1121     try {
1122     mapArea_ = bgContext.getLayerBounds();
1123     } catch (final IOException e) {
1124     LOGGER.warn("bgContext.getLayerBounds()", e);
1125     }
1126     }
1127    
1128 alfonx 530 if (mapArea_ != null) {
1129     mapArea = bestAllowedMapArea(mapArea_);
1130 alfonx 544 requestStartRendering();
1131 alfonx 530 }
1132 alfonx 509 }
1133    
1134 alfonx 530 if (mapArea == null)
1135     return null;
1136 alfonx 509
1137 alfonx 539 // TODO is needed at all, this should go to setMapArea maybe
1138 alfonx 533 if (localContext.getCoordinateReferenceSystem() == null)
1139     try {
1140     localContext.setCoordinateReferenceSystem(GeoImportUtil
1141     .getDefaultCRS());
1142 alfonx 539 } catch (Exception e) {
1143     throw new RuntimeException("setting context CRS:", e);
1144 alfonx 533 }
1145    
1146     return new ReferencedEnvelope(mapArea, localContext
1147     .getCoordinateReferenceSystem());
1148 alfonx 530 }
1149 alfonx 509
1150 alfonx 530 /**
1151 alfonx 557 * Returns the background {@link Color} of the map pane. If not set, the
1152     * methods looks for a parent component and will use its background color.
1153     * If no parent component is available, WHITE is returned.
1154 alfonx 530 **/
1155     public Color getMapBackgroundColor() {
1156 alfonx 560 if (mapBackgroundColor == null) {
1157     if (getParent() != null)
1158     return getParent().getBackground();
1159     else
1160     return Color.WHITE;
1161 alfonx 557 }
1162 alfonx 530 return mapBackgroundColor;
1163     }
1164 alfonx 509
1165     /**
1166 alfonx 530 * Get the BufferedImage to use as a flaoting icon in the lower right
1167     * corner.
1168     *
1169     * @return <code>null</code> if the feature is deactivated.
1170 alfonx 509 */
1171 alfonx 530 public BufferedImage getMapImage() {
1172     return mapImage;
1173     }
1174 alfonx 509
1175 alfonx 530 /**
1176     * Returns the evelope of the viewable area. The JMapPane will never show
1177     * anything outside of this extend. If this has been set to
1178     * <code>null</code> via {@link #setMaxExtend(Envelope)}, it tries to return
1179     * quickly the context's bounds. It it takes to long to determine the
1180     * context bounds, <code>null</code> is returned.
1181     *
1182     * @param maxExtend
1183     * <code>null</code> to not have this restriction.
1184     */
1185 alfonx 509
1186 alfonx 530 public Envelope getMaxExtend() {
1187     if (maxExtend == null) {
1188 alfonx 551 // Commented-out because it takes soo much time!
1189 alfonx 555 //
1190     // long start = System.currentTimeMillis();
1191     // final ReferencedEnvelope layerBounds = GTUtil
1192     // .getVisibleLayoutBounds(localContext);
1193     //
1194     // LOGGER.info(
1195     // (System.currentTimeMillis()-start)+"m to get maxExtend");
1196     //
1197     // if (layerBounds == null) {
1198     // // TODO Last fallback could be the CRS valid area
1199     // return null;
1200     // }
1201     //
1202     // // Kartenbereich um 10% vergroessern
1203     // return JTSUtil.fixAspectRatio(getVisibleRect(), JTSUtil
1204     // .expandEnvelope(layerBounds, 0.1), true);
1205 alfonx 509 }
1206 alfonx 530 return maxExtend;
1207     }
1208 alfonx 509
1209     /**
1210 alfonx 530 * Retuns the maximum allowed zoom scale. This is the smaller number value
1211     * of the two. Defaults to {@link Double}.MIN_VALUE
1212     *
1213     * @author <a href="mailto:[email protected]">Stefan Alfons
1214     * Kr&uuml;ger</a>
1215 alfonx 509 */
1216 alfonx 530 public Double getMaxZoomScale() {
1217     return maxZoomScale;
1218     }
1219 alfonx 509
1220 alfonx 530 /**
1221     * Retuns the minimum allowed zoom scale. This is the bigger number value of
1222     * the two. Defaults to {@link Double}.MAX_VALUE
1223     *
1224     * @author <a href="mailto:[email protected]">Stefan Alfons
1225     * Kr&uuml;ger</a>
1226     */
1227     public Double getMinZoomScale() {
1228     return minZoomScale;
1229     }
1230 alfonx 509
1231 alfonx 530 private Image getPreFinalImage() {
1232     // if (preFinalImage == null) {
1233     //
1234     // // Rectangle curPaintArea = getVisibleRect();
1235     // // preFinalImage = new BufferedImage(curPaintArea.width,
1236     // // curPaintArea.height, BufferedImage.TYPE_INT_RGB);
1237     //
1238     // preFinalImage = createImage(getBounds().width, getBounds().height);
1239     //
1240     // requestStartRendering();
1241     // }
1242     return preFinalImage;
1243     }
1244 alfonx 509
1245 alfonx 530 public Map<Object, Object> getRendererHints() {
1246 alfonx 533 // Clear label cache
1247     labelCache.clear();
1248     rendererHints.put(StreamingRenderer.LABEL_CACHE_KEY, labelCache);
1249    
1250 alfonx 530 return rendererHints;
1251     }
1252 alfonx 509
1253     /**
1254     * Liefert eine affine Transformation, um von den Fenster-Koordinaten in die
1255     * Karten-Koordinaten (Lat/Lon) umzurechnen.
1256     *
1257     * @return eine Kopie der aktuellen Transformation; <code>null</code> wenn
1258     * noch keine Karte angezeigt wird
1259     */
1260     public AffineTransform getScreenToWorld() {
1261     if (screenToWorld == null)
1262     resetTransforms();
1263     // nur Kopie der Transformation zurueckgeben!
1264     if (screenToWorld == null)
1265     return null;
1266     return new AffineTransform(screenToWorld);
1267 alfonx 144 }
1268 mojays 2
1269 alfonx 530 public int getState() {
1270     return state;
1271     }
1272    
1273     /**
1274     * Liefert den statisch eingestellten Cursor, der unabhaengig von der
1275     * eingestellten MapPane-Aktion (Zoom, Auswahl, ...) verwendet wird.
1276     *
1277     * @return {@code null}, wenn kein statischer Cursor verwendet, sondern der
1278     * Cursor automatisch je nach MapPane-Aktion eingestellt wird.
1279     */
1280     public Cursor getStaticCursor() {
1281     return this.staticCursor;
1282     }
1283    
1284 alfonx 509 public AffineTransform getWorldToScreenTransform() {
1285     if (worldToScreen == null) {
1286     resetTransforms();
1287     }
1288     // nur Kopie der Transformation zurueckgeben!
1289     return new AffineTransform(worldToScreen);
1290 alfonx 144 }
1291 mojays 2
1292 alfonx 530 /**
1293     * A flag indicating if dispose() has already been called. If true, then
1294     * further use of this {@link SelectableXMapPane} is undefined.
1295     */
1296     private boolean isDisposed() {
1297     return disposed;
1298     }
1299    
1300     /**
1301     * Returns whether a layer is regarded or ignored on {@link #SELECT_TOP},
1302     * {@link #SELECT_ALL} and {@link #SELECT_ONE_FROM_TOP} actions. Returns
1303     * <code>true</code> if the selectability has not been defined.
1304     *
1305     * @param layer
1306     * a layer
1307     */
1308     public boolean isMapLayerSelectable(final MapLayer layer) {
1309     final Boolean selectable = mapLayerSelectable.get(layer);
1310     return selectable == null ? true : selectable;
1311     }
1312    
1313     /**
1314     * Return <code>true</code> if a CRS and a {@link #mapArea} are set and the
1315     * {@link XMapPane} is visible and has bounds set.
1316     */
1317     public boolean isWellDefined() {
1318     try {
1319 alfonx 551 if (getMapContext() == null)
1320 alfonx 530 return false;
1321 alfonx 551 if (getMapContext().getLayerCount() <= 0)
1322 alfonx 530 return false;
1323 alfonx 544 if (getVisibleRect().getWidth() == 0)
1324 alfonx 530 return false;
1325 alfonx 544 if (getVisibleRect().getHeight() == 0)
1326 alfonx 530 return false;
1327 alfonx 544 // if (getMapArea() == null)
1328     // return false;
1329 alfonx 530 } catch (final Exception e) {
1330     return false;
1331 alfonx 509 }
1332 alfonx 530 return true;
1333 alfonx 144 }
1334 mojays 2
1335 alfonx 555 /**
1336     * Called from the listeners while the mouse is dragging, this method either
1337     * paints a translated (moved/panned) version of the image, or a rectangle.
1338     *
1339     * @param startPos
1340     * in screen coordinates
1341     * @param lastPos
1342     * in screen coordinates
1343     * @param event
1344     * the {@link MouseEvent} to read the mouse buttons from
1345     */
1346 alfonx 530 public void mouseDragged(final Point startPos, final Point lastPos,
1347     final MouseEvent event) {
1348    
1349     if ((getState() == XMapPane.PAN)
1350     || ((event.getModifiersEx() & InputEvent.BUTTON3_DOWN_MASK) != 0)) {
1351    
1352 alfonx 555 // Panning needs a panning coursor
1353 alfonx 530 if (getCursor() != SwingUtil.PANNING_CURSOR) {
1354     setCursor(SwingUtil.PANNING_CURSOR);
1355    
1356 alfonx 555 // While panning, we deactivate the rendering. So the tasks are
1357     // ready to start when the panning is finished.
1358     if (bgExecuter != null && bgExecuter.isRunning())
1359 alfonx 530 bgExecuter.cancelTask();
1360 alfonx 555 if (localExecuter.isRunning())
1361 alfonx 530 localExecuter.cancelTask();
1362     }
1363    
1364     if (lastPos.x > 0 && lastPos.y > 0) {
1365     final int dx = event.getX() - lastPos.x;
1366     final int dy = event.getY() - lastPos.y;
1367    
1368     // TODO Stop dragging when the drag would not be valid...
1369     // boolean dragValid = true;
1370     // // check if this panning results in a valid mapArea
1371     // {
1372     // Rectangle winBounds = xMapPane.getBounds();
1373     // winBounds.translate(xMapPane.imageOrigin.x,
1374     // -xMapPane.imageOrigin.y);
1375     // Envelope newMapAreaBefore = xMapPane.tranformWindowToGeo(
1376     // winBounds.x, winBounds.y, winBounds.x
1377     // + winBounds.width, winBounds.y
1378     // + winBounds.height);
1379     //
1380     //
1381     // winBounds = xMapPane.getBounds();
1382     // Point testIng = new Point(xMapPane.imageOrigin);
1383     // testIng.translate(dx, dy);
1384     // winBounds.translate(testIng.x, -testIng.y);
1385     // Envelope newMapAreaAfter = xMapPane.tranformWindowToGeo(
1386     // winBounds.x, winBounds.y, winBounds.x
1387     // + winBounds.width, winBounds.y
1388     // + winBounds.height);
1389     //
1390     // // If the last drag doesn't change the MapArea anymore cancel
1391     // it.
1392     // if (xMapPane.bestAllowedMapArea(newMapAreaAfter).equals(
1393     // xMapPane.bestAllowedMapArea(newMapAreaBefore))){
1394     // dragValid = false;
1395     // return;
1396     // }
1397     // }
1398    
1399     imageOrigin.translate(dx, dy);
1400     updateFinalImage();
1401     repaint();
1402     }
1403    
1404     } else if ((getState() == XMapPane.ZOOM_IN)
1405     || (getState() == XMapPane.ZOOM_OUT)
1406     || (getState() == XMapPane.SELECT_ALL)
1407 alfonx 555 || (getState() == XMapPane.SELECT_TOP)) {
1408    
1409     // Draws a rectangle
1410 alfonx 530 final Graphics graphics = getGraphics();
1411     drawRectangle(graphics, startPos, event.getPoint());
1412 alfonx 555 if ((lastPos.x > 0) && (lastPos.y > 0))
1413 alfonx 530 drawRectangle(graphics, startPos, lastPos);
1414     graphics.dispose();
1415     }
1416 alfonx 144 }
1417 mojays 2
1418 alfonx 509 /**
1419 alfonx 530 * Called by the {@link RenderingExecutor} when rendering was cancelled.
1420     */
1421     public void onRenderingCancelled() {
1422 alfonx 544 LOGGER.debug("Rendering cancelled");
1423 alfonx 530 repaintTimer.stop();
1424     }
1425    
1426     /**
1427     * Called by the {@link RenderingExecutor} when rendering has been
1428     * completed.
1429     */
1430     public void onRenderingCompleted() {
1431 alfonx 557 LOGGER.debug("complete");
1432 alfonx 555
1433 alfonx 530 repaintTimer.stop();
1434 alfonx 555
1435     // We "forget" about an exception every time we complete a rendering
1436     // thread successfully
1437     if (renderingErrors.size() > 0)
1438     renderingErrors.remove(0);
1439    
1440 alfonx 530 updateFinalImage();
1441     repaint();
1442     }
1443    
1444     /**
1445     * Called by the {@linkplain XMapPane.RenderingTask} when rendering failed.
1446     * Publishes a {@linkplain MapPaneEvent} of type {@code
1447     * MapPaneEvent.Type.RENDERING_STOPPED} to listeners.
1448 alfonx 509 *
1449 alfonx 530 * @param renderingError
1450     * The error that occured during rendering
1451     *
1452     * @see MapPaneListener#onRenderingStopped(org.geotools.swing.event.MapPaneEvent)
1453 alfonx 509 */
1454 alfonx 530 public void onRenderingFailed(final Exception renderingError) {
1455 alfonx 553
1456     // Store the exceptions so we can show it to the user:
1457 alfonx 555 if (!(renderingError instanceof java.lang.IllegalArgumentException && renderingError
1458     .getMessage().equals(
1459 alfonx 553 "Argument \"sourceCRS\" should not be null.")))
1460     this.renderingErrors.add(renderingError);
1461 alfonx 533 if (renderingErrors.size() > 3)
1462     renderingErrors.remove(0);
1463 alfonx 555
1464 alfonx 530 repaintTimer.stop();
1465 alfonx 555
1466 alfonx 530 LOGGER.warn("Rendering failed", renderingError);
1467     updateFinalImage();
1468     repaint();
1469 mojays 2
1470 alfonx 530 }
1471    
1472     @Override
1473     protected void paintComponent(final Graphics g) {
1474 alfonx 544
1475 alfonx 555 // Maybe update the cursor and maybe stop the repainting timer
1476     updateCursor();
1477    
1478 alfonx 530 if (!acceptsRepaintCalls)
1479     return;
1480    
1481 alfonx 555 if (!isWellDefined())
1482     return;
1483 alfonx 530
1484 alfonx 560 // super.paintComponent(g); // candidate for removal
1485 alfonx 530
1486     boolean paintedSomething = false;
1487    
1488     if (mapImageInvalid) { /* if the map changed then redraw */
1489    
1490     mapImageInvalid = false; // Reset for next round
1491    
1492     // If the new mapArea and the oldMapArea intersect, we can draw some
1493     // quick scaled preview to make the user feel that something is
1494     // happening.
1495     if (mapAreaChanged && oldMapArea != null
1496     && getMapArea().intersects(oldMapArea)
1497 alfonx 544 & !getMapArea().equals(oldMapArea) && !paneResized) {
1498 alfonx 530
1499     mapAreaChanged = false;
1500    
1501     if (getMapArea().covers(oldMapArea)) {
1502 alfonx 555 quickPreviewHint = ZOOM_OUT;
1503 alfonx 530 paintedSomething = drawScaledPreviewImage_Zoom((Graphics2D) g);
1504     } else if (oldMapArea.covers(getMapArea())) {
1505 alfonx 555 quickPreviewHint = ZOOM_IN;
1506 alfonx 530 paintedSomething = drawScaledPreviewImage_Zoom((Graphics2D) g);
1507     }
1508 alfonx 509 }
1509     }
1510 mojays 2
1511 alfonx 530 if (!paintedSomething) {
1512 mojays 2
1513 alfonx 530 g.drawImage(getFinalImage(), 0, 0, null);
1514 alfonx 529
1515 alfonx 530 g.dispose(); // cand. for removal
1516 alfonx 509
1517 alfonx 530 paintedSomething = true; // cand. for removal
1518     }
1519 alfonx 529
1520 alfonx 530 }
1521 alfonx 509
1522 alfonx 530 /**
1523     * Heavily works on releasing all resources related to the four
1524     * {@link Image}s used to cache the results of the different renderers.<br>
1525     * In November 2009 i had some memory leaking problems with {@link XMapPane}
1526     * . The resources of the buffered images were never released. It seem to be
1527     * important to call the GC right after flushing the images.<br>
1528     * Hence this method may take a while, because it calls the GC up to four
1529     * times.
1530     */
1531     private void disposeImages() {
1532    
1533     // System.out.println("vorher = "
1534     // + new MbDecimalFormatter().format(LangUtil.gcTotal()));
1535     // bi.flush();
1536     // return bi = null;
1537     // System.out.println("nacher = "
1538     // + new MbDecimalFormatter().format(LangUtil.gcTotal()));
1539     //
1540     // System.out.println("\n");
1541    
1542     if (preFinalImage != null) {
1543     preFinalImage.flush();
1544     preFinalImage = null;
1545     LangUtil.gc();
1546 alfonx 509 }
1547 alfonx 530 if (finalImage != null) {
1548     finalImage.flush();
1549     finalImage = null;
1550     LangUtil.gc();
1551     }
1552     if (localImage != null) {
1553     localImage.flush();
1554     localImage = null;
1555     LangUtil.gc();
1556     }
1557     if (bgImage != null) {
1558     bgImage.flush();
1559     bgImage = null;
1560     LangUtil.gc();
1561     }
1562 alfonx 509
1563 alfonx 144 }
1564 mojays 2
1565 alfonx 530 /**
1566     * Performs a {@value #PAN} action. During panning, the displacement is
1567     * stored in {@link #imageOrigin} object. Calling {@link #performPan()} will
1568     * reset the offset and call {@link #setMapArea(Envelope)}.
1569     */
1570     public void performPan() {
1571    
1572 alfonx 540 Rectangle winBounds = getVisibleRect();
1573 alfonx 543
1574 alfonx 530 winBounds.translate(-imageOrigin.x, -imageOrigin.y);
1575     final Envelope newMapArea = tranformWindowToGeo(winBounds.x,
1576     winBounds.y, winBounds.x + winBounds.width, winBounds.y
1577     + winBounds.height);
1578    
1579     imageOrigin.x = 0;
1580     imageOrigin.y = 0;
1581    
1582     if (!setMapArea(newMapArea)) {
1583     /**
1584     * If setMapArea returns true, the finalImage is updated anyways.
1585     * This if-case exists to ensure that we repaint a correct image
1586     * even if the new panning area has been denied.
1587     */
1588     updateFinalImage();
1589     repaint();
1590     }
1591    
1592     if (getCursor() == SwingUtil.PANNING_CURSOR)
1593     setCursor(SwingUtil.PAN_CURSOR);
1594     }
1595    
1596     /**
1597     * Entfernt einen Listener von der Map.
1598     *
1599     * @param l
1600     * zu entfernender Listener
1601     */
1602     public void removeMapPaneListener(final JMapPaneListener l) {
1603     mapPaneListeners.remove(l);
1604     }
1605    
1606     /**
1607     * Cancels all running renderers and sets the flag to start new ones. <br>
1608     *
1609     * @see #startRenderThreadsTimer
1610     */
1611     private void requestStartRendering() {
1612     if (bgExecuter != null)
1613     bgExecuter.cancelTask();
1614    
1615 alfonx 555 localExecuter.cancelTask();
1616    
1617 alfonx 544 mapImageInvalid = true;
1618     if (paneResized) {
1619     paneResized = false;
1620     disposeImages();
1621     }
1622     requestStartRendering = true;
1623    
1624 alfonx 530 }
1625    
1626 alfonx 539 /**
1627     * Calculate the affine transforms used to convert between world and pixel
1628     * coordinates. The calculations here are very basic and assume a cartesian
1629     * reference system.
1630     * <p>
1631     * Tne transform is calculated such that {@code envelope} will be centred in
1632     * the display
1633     *
1634     * @param envelope
1635     * the current map extent (world coordinates)
1636     * @param paintArea
1637     * the current map pane extent (screen units)
1638     */
1639     private void resetTransforms() {
1640     ReferencedEnvelope refMapEnv = new ReferencedEnvelope(mapArea,
1641 alfonx 551 getMapContext().getCoordinateReferenceSystem());
1642 alfonx 540
1643 alfonx 544 // System.out
1644     // .println("paintArea in resetTeansofrms = " + getVisibleRect());
1645     if (!isWellDefined())
1646     return;
1647 alfonx 543
1648 alfonx 539 worldToScreen = RendererUtilities.worldToScreenTransform(refMapEnv,
1649 alfonx 544 getVisibleRect());
1650 alfonx 530
1651 alfonx 539 try {
1652     screenToWorld = worldToScreen.createInverse();
1653 alfonx 530
1654 alfonx 539 } catch (NoninvertibleTransformException ex) {
1655 alfonx 544 LOGGER
1656     .error("can't invert worldToScreen to get screenToWorld!",
1657     ex);
1658 alfonx 539 }
1659     }
1660 alfonx 536
1661 alfonx 509 public void setBgContext(final MapContext context) {
1662 mojays 2
1663 alfonx 509 // Remove the default listener from the old context
1664     if (this.bgContext != null) {
1665     this.bgContext.removeMapLayerListListener(bgContextListener);
1666    
1667     // adding listener to all layers
1668 alfonx 530 for (final MapLayer mapLayer : bgContext.getLayers()) {
1669 alfonx 509 mapLayer.removeMapLayerListener(bgMapLayerListener);
1670     }
1671 alfonx 144 }
1672 mojays 2
1673 alfonx 509 this.bgContext = context;
1674 mojays 2
1675 alfonx 509 if (context != null) {
1676 alfonx 544 // setMapArea(bgContext.getAreaOfInterest());
1677 alfonx 509
1678     this.bgContext.addMapLayerListListener(bgContextListener);
1679    
1680     // adding listener to all layers
1681 alfonx 530 for (final MapLayer mapLayer : bgContext.getLayers()) {
1682 alfonx 509 mapLayer.addMapLayerListener(bgMapLayerListener);
1683 alfonx 144 }
1684 alfonx 509 }
1685 alfonx 544
1686     requestStartRendering();
1687 alfonx 509 }
1688 mojays 2
1689 alfonx 530 public void setJava2dHints(final RenderingHints java2dHints) {
1690     this.java2dHints = java2dHints;
1691     }
1692    
1693     public void setLocalContext(final MapContext context) {
1694     // Remove the default listener from the old context
1695     if (this.localContext != null) {
1696     this.localContext.removeMapLayerListListener(localContextListener);
1697    
1698     // adding listener to all layers
1699     for (final MapLayer mapLayer : localContext.getLayers()) {
1700     mapLayer.removeMapLayerListener(localMapLayerListener);
1701 alfonx 509 }
1702 alfonx 530 }
1703 alfonx 509
1704 alfonx 530 this.localContext = context;
1705    
1706     if (context != null) {
1707    
1708 alfonx 544 // setMapArea(localContext.getAreaOfInterest());
1709 alfonx 530
1710 alfonx 560 getLocalRenderer().setContext(localContext);
1711 alfonx 530
1712     this.localContext.addMapLayerListListener(localContextListener);
1713    
1714     // adding listener to all layers
1715     for (final MapLayer mapLayer : localContext.getLayers()) {
1716     mapLayer.addMapLayerListener(localMapLayerListener);
1717 alfonx 144 }
1718     }
1719 mojays 2
1720 alfonx 544 requestStartRendering();
1721    
1722 alfonx 509 }
1723    
1724 alfonx 560 /**
1725     * Triggers to repaint (fast) and re-render (slow) the JMapPane.
1726     */
1727     public void refresh() {
1728     mapImageInvalid = true;
1729     repaint();
1730     }
1731    
1732     // /**
1733     // * Triggers to use new {@link GTRenderer} and refresh the map. Should be
1734     // * called after {@link Style}s have been changed because GTRenderer is
1735     // * otherwise not working well.
1736     // */
1737     // public void refreshRenderers() {
1738     // localRenderer = GTUtil.createGTRenderer();
1739     // setLocalContext(getMapContext());
1740     // mapImageInvalid = true;
1741     // repaint();
1742     // }
1743    
1744 alfonx 544 public boolean setMapArea(final Envelope newMapArea) {
1745 alfonx 556 if (newMapArea == null)
1746     return false;
1747 alfonx 560 if (getMapContext().getCoordinateReferenceSystem() == null)
1748     return false;
1749 alfonx 551 return setMapArea(new ReferencedEnvelope(newMapArea, getMapContext()
1750 alfonx 544 .getCoordinateReferenceSystem()));
1751     }
1752    
1753 alfonx 509 /**
1754     * @param newMapArea
1755     * @return <code>true</code> if the mapArea has been changed and a repaint
1756     * has been triggered.
1757     */
1758 alfonx 544 public boolean setMapArea(final ReferencedEnvelope newMapArea) {
1759 alfonx 509
1760     if (newMapArea == null
1761     || bestAllowedMapArea(newMapArea).equals(mapArea)) {
1762     // No change.. no need to repaint
1763     return false;
1764 alfonx 144 }
1765 mojays 2
1766 alfonx 513 // Testing, whether NaN or Infinity are used in the newMapArea
1767     if (newMapArea.isNull() || Double.isInfinite(newMapArea.getMaxX())
1768     || Double.isInfinite(newMapArea.getMaxY())
1769     || Double.isInfinite(newMapArea.getMinX())
1770     || Double.isInfinite(newMapArea.getMinY())) {
1771     // No change.. ugly new values
1772     LOGGER.warn("setMapArea has been called with newArea = "
1773     + newMapArea);
1774     return false;
1775     }
1776    
1777 alfonx 539 final Envelope candNew = bestAllowedMapArea(newMapArea);
1778    
1779 alfonx 513 // Testing, whether the difference if just minimal
1780 alfonx 509 if (mapArea != null) {
1781 alfonx 530 final double tolX = mapArea.getWidth() / 1000.;
1782     final double tolY = mapArea.getHeight() / 1000.;
1783 alfonx 509 if ((candNew.getMinX() - tolX < mapArea.getMinX())
1784     && (mapArea.getMinX() < candNew.getMinX() + tolX)
1785     && (candNew.getMaxX() - tolX < mapArea.getMaxX())
1786     && (mapArea.getMaxX() < candNew.getMaxX() + tolX)
1787 mojays 2
1788 alfonx 509 && (candNew.getMinY() - tolY < mapArea.getMinY())
1789     && (mapArea.getMinY() < candNew.getMinY() + tolY)
1790     && (candNew.getMaxY() - tolY < mapArea.getMaxY())
1791     && (mapArea.getMaxY() < candNew.getMaxY() + tolY)
1792 mojays 2
1793 alfonx 509 ) {
1794     // The two mapAreas only differ my 1/1000th.. ignore
1795 alfonx 505
1796 alfonx 509 return false;
1797     }
1798     }
1799 mojays 2
1800 alfonx 539 // New map are is accepted:
1801 alfonx 509 oldMapArea = mapArea;
1802 alfonx 539 mapArea = candNew;
1803     resetTransforms();
1804 mojays 2
1805 alfonx 509 if (localContext != null) {
1806     localContext.setAreaOfInterest(mapArea, localContext
1807     .getCoordinateReferenceSystem());
1808 alfonx 144 }
1809 alfonx 509 if (bgContext != null) {
1810     bgContext.setAreaOfInterest(mapArea, localContext
1811     .getCoordinateReferenceSystem());
1812     }
1813 alfonx 544
1814 alfonx 509 mapAreaChanged = true;
1815 alfonx 513
1816 alfonx 555 repaint(200); // Do not remove it!
1817 alfonx 544
1818     requestStartRendering();
1819    
1820 alfonx 509 return true;
1821     }
1822 mojays 2
1823 alfonx 509 /**
1824 alfonx 530 * Set the background color of the map.
1825 alfonx 509 *
1826 alfonx 530 * @param if <code>null</code>, white is used.
1827 alfonx 509 */
1828 alfonx 530 public void setMapBackgroundColor(Color bgColor) {
1829     this.mapBackgroundColor = bgColor;
1830 alfonx 509 }
1831 mojays 2
1832 alfonx 509 /**
1833 alfonx 530 * Set the BufferedImage to use as a flaoting icon in the lower right corner
1834     *
1835     * @param mapImageIcon
1836     * <code>null</code> is allowed and deactivates this icon.
1837 alfonx 529 */
1838 alfonx 530 public void setMapImage(final BufferedImage mapImage) {
1839     this.mapImage = mapImage;
1840     }
1841 alfonx 529
1842     /**
1843 alfonx 530 * Sets whether a layer is regarded or ignored on {@link #SELECT_TOP},
1844     * {@link #SELECT_ALL} and {@link #SELECT_ONE_FROM_TOP} actions.
1845     *
1846     * @param layer
1847     * a layer
1848     * @param selectable
1849     * if {@code false} the layer is ignored during the upper
1850     * mentioned actions. If <code>null</code>, the default (true)
1851     * will be used.
1852 alfonx 529 */
1853 alfonx 530 public void setMapLayerSelectable(final MapLayer layer,
1854     final Boolean selectable) {
1855     if (selectable == null)
1856     mapLayerSelectable.remove(layer);
1857     else
1858     mapLayerSelectable.put(layer, selectable);
1859 alfonx 144 }
1860 mojays 2
1861 alfonx 509 /**
1862 alfonx 530 * Defines an evelope of the viwable area. The JMapPane will never show
1863     * anything outside of this extend.
1864 alfonx 509 *
1865 alfonx 530 * @param maxExtend
1866     * <code>null</code> to not have this restriction.
1867 alfonx 509 */
1868 alfonx 530 public void setMaxExtend(final Envelope maxExtend) {
1869     this.maxExtend = maxExtend;
1870 alfonx 144 }
1871 mojays 2
1872 alfonx 509 /**
1873 alfonx 530 * Set the maximum allowed zoom scale. This is the smaller number value of
1874     * the two. If <code>null</code> is passed, Double.MINVALUE are used which
1875     * mean there is no restriction.
1876 alfonx 509 *
1877 alfonx 530 * @author <a href="mailto:[email protected]">Stefan Alfons
1878     * Kr&uuml;ger</a>
1879 alfonx 509 */
1880 alfonx 530 public void setMaxZoomScale(final Double maxZoomScale) {
1881     this.maxZoomScale = maxZoomScale == null ? Double.MIN_VALUE
1882     : maxZoomScale;
1883 alfonx 144 }
1884 mojays 2
1885 alfonx 530 // /** Stored the time used for the last real rendering in ms. **/
1886     // private long lastRenderingDuration = Long.MAX_VALUE;
1887    
1888 alfonx 509 /**
1889 alfonx 530 * Set the minimum (nearest) allowed zoom scale. This is the bigger number
1890     * value of the two. If <code>null</code> is passed, Double.MAXVALUE are
1891     * used which mean there is no restriction.
1892 alfonx 509 *
1893 alfonx 530 *
1894     * @author <a href="mailto:[email protected]">Stefan Alfons
1895     * Kr&uuml;ger</a>
1896 alfonx 509 */
1897 alfonx 530 public void setMinZoomScale(final Double minZoomScale) {
1898     this.minZoomScale = minZoomScale == null ? Double.MAX_VALUE
1899     : minZoomScale;
1900 alfonx 144 }
1901 mojays 2
1902 alfonx 509 /**
1903 alfonx 555 * If <code>true</code>, allow the {@link XMapPane} to process #repaint()
1904     * requests. Otherwise the map will not paint anything and not start any
1905     * rendering {@link Thread}s.
1906 alfonx 509 */
1907 alfonx 530 public void setPainting(final boolean b) {
1908     acceptsRepaintCalls = b;
1909 alfonx 555 if (acceptsRepaintCalls == true)
1910     repaint();
1911 alfonx 530 }
1912 mojays 2
1913 alfonx 530 private void setRendererHints(final Map<Object, Object> rendererHints) {
1914 alfonx 533 if (rendererHints != null)
1915     this.rendererHints = rendererHints;
1916 alfonx 144 }
1917 alfonx 513
1918 alfonx 509 /**
1919 alfonx 530 * Enables/Disables the ZOOM Mouse Listener. Upates the Cursor and stops the
1920     * repaint Timer if
1921     *
1922     * @param state
1923 alfonx 509 */
1924 alfonx 530 public void setState(final int state) {
1925     this.state = state;
1926 mojays 2
1927 alfonx 530 zoomMapPaneMouseListener.setEnabled((state == ZOOM_IN
1928     || state == ZOOM_OUT || state == PAN));
1929 alfonx 509
1930 alfonx 530 // Je nach Aktion den Cursor umsetzen
1931     updateCursor();
1932 alfonx 509 }
1933 alfonx 504
1934 alfonx 509 /**
1935 alfonx 530 * Standardmaessig wird der Cursor automatisch je nach MapPane-Aktion (Zoom,
1936     * Auswahl, ...) gesetzt. Mit dieser Methode kann ein statischer Cursor
1937     * gesetzt werden, der unabhaengig von der aktuellen MapPanes-Aktion
1938     * beibehalten wird. Um diesen statischen Cursor wieder zu entfernen, kann
1939     * {@code null} als Parameter uebergeben werden
1940 alfonx 509 *
1941 alfonx 530 * @param cursor
1942     * Cursor
1943 alfonx 509 */
1944 alfonx 530 public void setStaticCursor(final Cursor cursor) {
1945     this.staticCursor = cursor;
1946     if (cursor != null)
1947     super.setCursor(cursor);
1948 alfonx 509 }
1949 alfonx 431
1950 alfonx 509 /**
1951     * Starts rendering on one or two threads
1952     */
1953     private void startRendering() {
1954    
1955 alfonx 544 if (!isWellDefined() || !acceptsRepaintCalls) {
1956 alfonx 555 // if we are not ready to start rendering, try it again the next
1957     // time the timer is chacking the flag.
1958 alfonx 544 requestStartRendering = true;
1959 alfonx 509 return;
1960 alfonx 544 }
1961 alfonx 509
1962 alfonx 529 if (bgExecuter != null) {
1963 alfonx 509 // Stop all renderers
1964     bgExecuter.cancelTask();
1965 alfonx 524 }
1966 alfonx 509
1967 alfonx 555 localExecuter.cancelTask();
1968 alfonx 529
1969 alfonx 530 final Rectangle curPaintArea = getVisibleRect();
1970 mojays 2
1971 alfonx 509 /**
1972     * We have to set new renderer
1973     */
1974    
1975     if (getBgContext() != null) {
1976 alfonx 533 bgRenderer.setJava2DHints(getJava2dHints());
1977     bgRenderer.setRendererHints(getRendererHints());
1978    
1979 alfonx 529 // bgExecuter = new RenderingExecutor();
1980     // LOGGER.debug("starting bg renderer:");
1981     // // /* System.out.println("rendering"); */
1982     // final GTRenderer createGTRenderer = GTUtil.createGTRenderer(
1983     // bgContext, getRendererHints());
1984     // createGTRenderer.setJava2DHints(getJava2dHints());
1985     // bgExecuter.submit(getBgContext().getAreaOfInterest(),
1986     // curPaintArea,
1987     // (Graphics2D) getBgImage().getGraphics(), createGTRenderer);
1988 alfonx 509 }
1989    
1990 alfonx 551 if (getMapContext() != null) {
1991 alfonx 529 // localExecuter = new RenderingExecutor(this, 150l);
1992 alfonx 530 // LOGGER.debug("starting local renderer:");
1993    
1994 alfonx 560 getLocalRenderer().setJava2DHints(getJava2dHints());
1995     getLocalRenderer().setRendererHints(getRendererHints());
1996 alfonx 529
1997 alfonx 544 final boolean submitted = localExecuter.submit(getMapArea(),
1998 alfonx 533 curPaintArea, (Graphics2D) getLocalImage().getGraphics(),
1999 alfonx 560 getLocalRenderer());
2000 alfonx 530 if (submitted)
2001     repaintTimer.restart();
2002     else
2003 alfonx 544 requestStartRendering = true; // Try to start rendering
2004     // again in
2005 alfonx 530 // a moment
2006 alfonx 509 }
2007    
2008 alfonx 514 updateCursor();
2009 alfonx 144 }
2010 mojays 2
2011 alfonx 509 /**
2012 alfonx 530 * Transformiert einen Geo-Koordinaten-Bereich in Fenster-Koordinaten.
2013 alfonx 509 *
2014 alfonx 530 * @param ox
2015     * X-Koordinate der VON-Position
2016     * @param oy
2017     * Y-Koordinate der VON-Position
2018     * @param px
2019     * X-Koordinate der BIS-Position
2020     * @param py
2021     * Y-Koordinate der BIS-Position
2022     * @param winToGeotransform
2023     * Eine Window to Geo transform. If <code>null</code>,
2024     * {@link #getScreenToWorld()} is used.
2025 alfonx 509 */
2026 alfonx 530 public Envelope tranformGeoToWindow(final double ox, final double oy,
2027 alfonx 539 final double px, final double py) {
2028     final AffineTransform at = getWorldToScreenTransform();
2029 alfonx 530 Point2D geoO;
2030 alfonx 539 // try {
2031     geoO = at.transform(new Point2D.Double(ox, oy), null);
2032     final Point2D geoP = at.transform(new Point2D.Double(px, py), null);
2033     return new Envelope(geoO.getX(), geoP.getX(), geoO.getY(), geoP.getY());
2034     // } catch (final NoninvertibleTransformException e) {
2035     // LOGGER.error(e);
2036     // return new Envelope(ox, oy, px, py);
2037     // }
2038 alfonx 144 }
2039 mojays 2
2040 alfonx 509 /**
2041 alfonx 530 * Transformiert einen Fenster-Koordinaten-Bereich in Geo-Koordinaten.
2042 alfonx 509 *
2043 alfonx 530 * @param ox
2044     * X-Koordinate der VON-Position
2045     * @param oy
2046     * Y-Koordinate der VON-Position
2047     * @param px
2048     * X-Koordinate der BIS-Position
2049     * @param py
2050     * Y-Koordinate der BIS-Position
2051 alfonx 509 */
2052 alfonx 530 public Envelope tranformWindowToGeo(final int ox, final int oy,
2053     final int px, final int py) {
2054     final AffineTransform at = getScreenToWorld();
2055     final Point2D geoO = at.transform(new Point2D.Double(ox, oy), null);
2056     final Point2D geoP = at.transform(new Point2D.Double(px, py), null);
2057 alfonx 543
2058 alfonx 539 // Mmmmm... don't really understand why its x,x,y,y
2059 alfonx 543 // return new Envelope(geoO.getX(), geoP.getX(), geoO.getY(),
2060     // geoP.getY());
2061     return new Envelope(new Coordinate(geoO.getX(), geoO.getY()),
2062     new Coordinate(geoP.getX(), geoP.getY()));
2063 alfonx 144 }
2064 mojays 2
2065 alfonx 509 /**
2066 alfonx 530 * Will update the cursor. If all rendering is finished also stops the
2067     * {@link #repaintTimer}
2068 alfonx 509 */
2069 alfonx 530 public void updateCursor() {
2070 mojays 2
2071 alfonx 530 // if the renderers have stopped, also stop the timer that is updating
2072     // the final image
2073     if (bgExecuter != null && bgExecuter.isRunning()
2074 alfonx 555 || localExecuter.isRunning()) {
2075     setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
2076 alfonx 530 return;
2077     } else {
2078     // Allow one last rendering
2079     if (repaintTimer.isRunning()) {
2080 alfonx 544 // System.out.println("one last rendering....");
2081 alfonx 530 repaintTimer.stop();
2082     updateFinalImage();
2083     repaint();
2084     }
2085 alfonx 144 }
2086 mojays 2
2087 alfonx 530 // wenn manueller Cursor gesetzt ist, dann diesen verwenden (unabhaengig
2088     // von der aktuellen Aktion
2089     if (this.staticCursor != null) {
2090     setCursor(staticCursor);
2091     return;
2092     }
2093     if (getCursor() == SwingUtil.PANNING_CURSOR) {
2094     // This cursor will reset itself
2095     return;
2096     }
2097 mojays 2
2098 alfonx 530 // Set the cursor depending on what tool is in use...
2099     switch (state) {
2100     case SELECT_TOP:
2101     case SELECT_ONE_FROM_TOP:
2102     case SELECT_ALL:
2103     setCursor(SwingUtil.CROSSHAIR_CURSOR);
2104     break;
2105     case ZOOM_IN:
2106     setCursor(SwingUtil.ZOOMIN_CURSOR);
2107     break;
2108     case ZOOM_OUT:
2109     setCursor(SwingUtil.ZOOMOUT_CURSOR);
2110     break;
2111     case PAN:
2112     setCursor(SwingUtil.PAN_CURSOR);
2113     break;
2114     default:
2115     setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
2116     break;
2117     }
2118 alfonx 144 }
2119 mojays 2
2120 alfonx 509 /**
2121 alfonx 530 * The renderers are all rendering into their own {@link Image}s. This
2122     * method combines all images to one {@link #finalImage}. The
2123     * {@link #repaintTimer} is calling this method regularely to update the
2124     * {@link #finalImage} even if the renderers are still working.
2125 alfonx 509 */
2126 alfonx 530 synchronized protected Image updateFinalImage() {
2127 mojays 2
2128 alfonx 530 // Render the two map images first, into the preFinalImage
2129     if (bgExecuter != null) {
2130     final Graphics2D preFinalG = (Graphics2D) getPreFinalImage()
2131     .getGraphics();
2132     preFinalG.setBackground(getMapBackgroundColor());
2133 mojays 2
2134 alfonx 530 preFinalG.drawImage(getBgImage(), 0, 0, getMapBackgroundColor(),
2135     null);
2136 mojays 2
2137 alfonx 530 // // Draw the local layers image
2138     preFinalG.drawImage(getLocalImage(), 0, 0, null);
2139     preFinalG.dispose();
2140 mojays 2
2141 alfonx 76 } else {
2142 alfonx 530 preFinalImage = getLocalImage();
2143 alfonx 76 }
2144 mojays 2
2145 alfonx 530 final Graphics2D finalG = getFinalImage().createGraphics();
2146     finalG.setBackground(getMapBackgroundColor());
2147     finalG.drawImage(getPreFinalImage(), imageOrigin.x, imageOrigin.y,
2148     getMapBackgroundColor(), null);
2149 mojays 2
2150 alfonx 530 final int finalImageHeight = getFinalImage().getHeight(null);
2151     final int finalImageWidth = getFinalImage().getWidth(null);
2152 alfonx 414
2153 alfonx 530 final Rectangle painedArea = new Rectangle(imageOrigin.x,
2154     imageOrigin.y, finalImageWidth, finalImageHeight);
2155     SwingUtil.clearAround(finalG, painedArea, getVisibleRect());
2156 alfonx 414
2157 alfonx 533 addGadgets(finalG, false);
2158 alfonx 414
2159 alfonx 530 finalG.dispose();
2160 alfonx 414
2161 alfonx 530 return finalImage;
2162 alfonx 76 }
2163    
2164 alfonx 144 /**
2165 alfonx 530 * Paints some optional stuff into the given {@link Graphics2D}. Usually
2166     * called as the last layer when {@link #updateFinalImage()}
2167 alfonx 533 *
2168     * @param forceWait
2169     * if <code>true</code>, a Wait-message will be painted even
2170     * though the rendering threads may not yet have started. If
2171     * <code>false</code>, it will only depend on
2172     * {@link #localExecuter.isRunning} and #bgExecuter.isRunning
2173 alfonx 144 */
2174 alfonx 533 private void addGadgets(final Graphics2D graphics, boolean forceWait) {
2175 mojays 2
2176 alfonx 530 // Paint a logo to the bottom right if available
2177     if (mapImage != null) {
2178 alfonx 540 Rectangle visibleRect = getVisibleRect();
2179     graphics.drawImage(mapImage, visibleRect.width
2180     - mapImage.getWidth() - 10, getVisibleRect().height
2181 alfonx 530 - mapImage.getHeight() - 10, null);
2182     }
2183 alfonx 539
2184 alfonx 533 int y = 17;
2185 mojays 2
2186 alfonx 530 // If the rendering process is still running, indicate this is the image
2187 alfonx 533 if (forceWait || bgExecuter != null && bgExecuter.isRunning()
2188 alfonx 555 || localExecuter.isRunning()) {
2189 mojays 2
2190 alfonx 539 y += 8;
2191    
2192 alfonx 530 final Color c = graphics.getColor();
2193     graphics.setFont(waitFont);
2194 alfonx 533
2195     graphics.setColor(getMapBackgroundColor());
2196     graphics.drawString(waitMsg, 5, y);
2197     graphics.setColor(getMapBackgroundColor());
2198 alfonx 539 graphics.drawString(waitMsg, 7, y + 2);
2199 alfonx 530 graphics.setColor(Color.BLACK);
2200 alfonx 539 graphics.drawString(waitMsg, 6, y + 1);
2201 mojays 2
2202 alfonx 530 graphics.setColor(c);
2203 alfonx 539
2204 alfonx 533 y += 24;
2205 alfonx 418 }
2206 alfonx 414
2207 alfonx 555 if (!renderingErrors.isEmpty() && isShowExceptions()) {
2208 alfonx 533
2209     final Color c = graphics.getColor();
2210     graphics.setFont(errorFont);
2211    
2212     for (Exception ex : renderingErrors) {
2213    
2214     String errStr = ex.getLocalizedMessage();
2215    
2216 alfonx 544 if (errStr == null)
2217     errStr = ex.getMessage();
2218     if (errStr == null)
2219     errStr = "unknown error: " + ex.getClass().getSimpleName();
2220    
2221 alfonx 560 graphics.setColor(getMapBackgroundColor());
2222 alfonx 533 graphics.drawString(errStr, 5, y);
2223     graphics.setColor(Color.RED);
2224     graphics.drawString(errStr, 6, y + 1);
2225    
2226     y += 19;
2227     }
2228    
2229     graphics.setColor(c);
2230     }
2231    
2232 alfonx 505 }
2233    
2234     /**
2235 alfonx 533 * Sets the {@link #mapArea} to best possibly present the given features. If
2236     * only one single point is given, the window is moved over the point.
2237 alfonx 509 *
2238 alfonx 530 * @param features
2239     * if <code>null</code> or size==0, the function doesn nothing.
2240 alfonx 509 */
2241 alfonx 530 public void zoomTo(
2242     final FeatureCollection<SimpleFeatureType, SimpleFeature> features) {
2243 alfonx 509
2244 alfonx 551 // if (!isWellDefined()) return;
2245    
2246     final CoordinateReferenceSystem mapCRS = getMapContext()
2247 alfonx 530 .getCoordinateReferenceSystem();
2248     final CoordinateReferenceSystem fCRS = features.getSchema()
2249     .getGeometryDescriptor().getCoordinateReferenceSystem();
2250 alfonx 509
2251 alfonx 551 ReferencedEnvelope _mapArea;
2252     if (mapArea == null)
2253     _mapArea = features.getBounds();
2254 alfonx 555 else
2255     _mapArea = getMapArea();
2256 alfonx 551 double width = _mapArea.getWidth();
2257     double height = _mapArea.getHeight();
2258 alfonx 530 final double ratio = height / width;
2259 alfonx 509
2260 alfonx 530 if (features == null || features.size() == 0) {
2261     // feature count == 0 Zoom to the full extend
2262 alfonx 509 return;
2263 alfonx 530 } else if (features.size() == 1) {
2264 alfonx 529
2265 alfonx 530 // feature count == 1 Just move the window to the point and zoom 'a
2266     // bit'
2267     final SimpleFeature singleFeature = features.iterator().next();
2268 alfonx 509
2269 alfonx 530 if (((Geometry) singleFeature.getDefaultGeometry())
2270     .getCoordinates().length > 1) {
2271     // System.out.println("Zoomed to only pne poylgon");
2272     // Poly
2273     // TODO max width vs. height
2274     width = features.getBounds().getWidth() * 3;
2275     height = ratio * width;
2276     } else {
2277     // System.out.println("Zoomed in a bit becasue only one point");
2278     // width *= .9;
2279     // height *= .9;
2280     }
2281 alfonx 509
2282 alfonx 530 Coordinate centre = features.getBounds().centre();
2283     if (!mapCRS.equals(fCRS)) {
2284     // only to calculations if the CRS differ
2285 alfonx 529 try {
2286 alfonx 530 MathTransform fToMap;
2287     fToMap = CRS.findMathTransform(fCRS, mapCRS);
2288     // centre is transformed to the mapCRS
2289     centre = JTS.transform(centre, null, fToMap);
2290     } catch (final FactoryException e) {
2291     LOGGER.error("Looking for a Math transform", e);
2292     } catch (final TransformException e) {
2293     LOGGER.error("Looking for a Math transform", e);
2294 alfonx 529 }
2295     }
2296 alfonx 509
2297 alfonx 530 final Coordinate newLeftBottom = new Coordinate(centre.x - width
2298     / 2., centre.y - height / 2.);
2299     final Coordinate newTopRight = new Coordinate(
2300     centre.x + width / 2., centre.y + height / 2.);
2301 alfonx 509
2302 alfonx 530 final Envelope newMapArea = new Envelope(newLeftBottom, newTopRight);
2303 alfonx 509
2304 alfonx 530 setMapArea(newMapArea);
2305 alfonx 529
2306 alfonx 530 } else {
2307     final ReferencedEnvelope fBounds = features.getBounds();
2308 alfonx 529
2309 alfonx 551 ReferencedEnvelope bounds;
2310 alfonx 530 if (!mapCRS.equals(fCRS)) {
2311 alfonx 551 bounds = JTSUtil.transformEnvelope(fBounds, mapCRS);
2312 alfonx 530 } else {
2313     bounds = fBounds;
2314     }
2315     // BB umrechnen von Layer-CRS in Map-CRS
2316 alfonx 529
2317 alfonx 530 // Expand a bit
2318     bounds.expandBy(bounds.getWidth() / 6., bounds.getHeight() / 6.);
2319 alfonx 509
2320 alfonx 530 setMapArea(bounds);
2321     }
2322 alfonx 509 }
2323    
2324     /**
2325 alfonx 530 * Zooms towards a point.
2326     *
2327     * @param center
2328     * position in window coordinates
2329     * @param zoomFactor
2330     * > 1 for zoom in, < 1 for zoom out. Default is 1.33
2331 alfonx 509 */
2332 alfonx 530 public void zoomTo(final Point center) {
2333     zoomTo(center, null);
2334 alfonx 509 }
2335    
2336     /**
2337     * Zooms towards a point.
2338     *
2339     * @param center
2340     * position in window coordinates
2341     * @param zoomFaktor
2342     * > 1 for zoom in, < 1 for zoom out. Default is 1.33.
2343     */
2344     public void zoomTo(Point center, Double zoomFaktor) {
2345     if (zoomFaktor == null || zoomFaktor == 0.)
2346     zoomFaktor = 2.;
2347    
2348 alfonx 530 final Point2D gcenter = getScreenToWorld().transform(center, null);
2349 alfonx 509 center = null;
2350 alfonx 513
2351     if (Double.isNaN(gcenter.getX()) || Double.isNaN(gcenter.getY())
2352     || Double.isInfinite(gcenter.getX())
2353     || Double.isInfinite(gcenter.getY())
2354    
2355 alfonx 509 ) {
2356     // Not inside valid CRS area! cancel
2357     return;
2358     }
2359    
2360     final Envelope mapArea = getMapArea();
2361 alfonx 513
2362 alfonx 530 final Envelope newMapArea = new Envelope(mapArea);
2363 alfonx 513 newMapArea.expandBy((mapArea.getWidth() * zoomFaktor - mapArea
2364     .getWidth()) / 2., (mapArea.getHeight() * zoomFaktor - mapArea
2365     .getHeight()) / 2.);
2366 alfonx 509
2367 alfonx 543 // TODO we actually want that
2368     // // Move the newMapArea above the new center
2369     // newMapArea.translate(gcenter.getX() - mapArea.centre().x, gcenter
2370     // .getY()
2371     // - mapArea.centre().y);
2372    
2373 alfonx 509 setMapArea(newMapArea);
2374     }
2375    
2376 alfonx 553 /**
2377     * Shall non-fatal rendering exceptions be reported in the mappane or be
2378     * dropped quitely.
2379     */
2380     public void setShowExceptions(boolean showExceptions) {
2381     this.showExceptions = showExceptions;
2382     }
2383    
2384     /**
2385     * Shall exceptions be reported in the mappane?
2386     */
2387     public boolean isShowExceptions() {
2388     return showExceptions;
2389     }
2390    
2391 alfonx 560 public GTRenderer getLocalRenderer() {
2392     return localRenderer;
2393     }
2394    
2395 mojays 2 }

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26