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

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

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

branches/1.0-gt2-2.6/src/skrueger/geotools/XMapPane.java revision 551 by alfonx, Mon Nov 23 15:47:04 2009 UTC branches/2.0-RC2/src/skrueger/geotools/XMapPane.java revision 639 by alfonx, Thu Jan 28 16:07:22 2010 UTC
# Line 26  import java.util.HashMap; Line 26  import java.util.HashMap;
26  import java.util.Map;  import java.util.Map;
27  import java.util.Vector;  import java.util.Vector;
28    
29    import javax.swing.JList;
30  import javax.swing.Timer;  import javax.swing.Timer;
31    import javax.swing.border.Border;
32    
33  import org.apache.log4j.Logger;  import org.apache.log4j.Logger;
34    import org.geotools.factory.GeoTools;
35  import org.geotools.feature.FeatureCollection;  import org.geotools.feature.FeatureCollection;
36    import org.geotools.geometry.DirectPosition2D;
37  import org.geotools.geometry.jts.JTS;  import org.geotools.geometry.jts.JTS;
38  import org.geotools.geometry.jts.ReferencedEnvelope;  import org.geotools.geometry.jts.ReferencedEnvelope;
39  import org.geotools.map.DefaultMapContext;  import org.geotools.map.DefaultMapContext;
# Line 65  import schmitzm.geotools.map.event.MapLa Line 69  import schmitzm.geotools.map.event.MapLa
69  import schmitzm.lang.LangUtil;  import schmitzm.lang.LangUtil;
70  import schmitzm.swing.JPanel;  import schmitzm.swing.JPanel;
71  import schmitzm.swing.SwingUtil;  import schmitzm.swing.SwingUtil;
72    import schmitzm.swing.event.MouseInputType;
73    
74  import com.vividsolutions.jts.geom.Coordinate;  import com.vividsolutions.jts.geom.Coordinate;
75  import com.vividsolutions.jts.geom.Envelope;  import com.vividsolutions.jts.geom.Envelope;
# Line 95  import com.vividsolutions.jts.geom.Geome Line 100  import com.vividsolutions.jts.geom.Geome
100   */   */
101  public class XMapPane extends JPanel {  public class XMapPane extends JPanel {
102    
103          private static final int IMAGETYPE = BufferedImage.TYPE_INT_RGB;          // private static final int IMAGETYPE = BufferedImage.TYPE_INT_RGB;
104          private static final int IMAGETYPE_withAlpha = BufferedImage.TYPE_INT_ARGB;          // private static final int IMAGETYPE_withAlpha =
105            // BufferedImage.TYPE_INT_ARGB;
106            private static final int IMAGETYPE = BufferedImage.TYPE_3BYTE_BGR;
107            private static final int IMAGETYPE_withAlpha = BufferedImage.TYPE_4BYTE_ABGR;
108    
109          private static Logger LOGGER = Logger.getLogger(XMapPane.class);          private final static Logger LOGGER = Logger.getLogger(XMapPane.class);
110    
111            /** A flag indicating whether the {@link XMapPane} is accepting repaints from the EDT. @see {@link XMapPane#setPainting(boolean)) **/
112          private boolean acceptsRepaintCalls = true;          private boolean acceptsRepaintCalls = true;
113    
114          /**          /**
# Line 133  public class XMapPane extends JPanel { Line 142  public class XMapPane extends JPanel {
142           * The initial delay in milliseconds until the {@link #finalImage} is           * The initial delay in milliseconds until the {@link #finalImage} is
143           * updated the first time.           * updated the first time.
144           */           */
145          public static final int INITIAL_REPAINT_DELAY = 1000;          public static final int INITIAL_REPAINT_DELAY = 900;
146    
147          /**          /**
148           * While the {@link #bgExecuter} and {@link #localExecuter} are rendering,           * While the {@link #bgExecuter} and {@link #localExecuter} are rendering,
# Line 150  public class XMapPane extends JPanel { Line 159  public class XMapPane extends JPanel {
159           */           */
160          public static final int DEFAULT_RESIZING_PAINT_DELAY = 600;          public static final int DEFAULT_RESIZING_PAINT_DELAY = 600;
161    
162            /**
163             * This not-repeating {@link Timer} is re-started whenever the component is
164             * resized. That means => only if the component is not resizing for
165             * {@link #DEFAULT_RESIZING_PAINT_DELAY} milliseconds, does the
166             * {@link XMapPane} react.
167             */
168          private final Timer resizeTimer;          private final Timer resizeTimer;
169    
170            /**
171             * Flag for no-tool.
172             */
173          public static final int NONE = -123;          public static final int NONE = -123;
174    
175          /**          /**
# Line 163  public class XMapPane extends JPanel { Line 181  public class XMapPane extends JPanel {
181          public static final int PAN = 1;          public static final int PAN = 1;
182    
183          /**          /**
184             * Flag fuer Modus "Heran zoomen".
185             *
186             * @see #setState(int)
187             * @see #setState(int)
188             */
189            public static final int ZOOM_IN = 2;
190    
191            /**
192             * Flag fuer Modus "Heraus zoomen". Nicht fuer Window-Auswahl moeglich!
193             *
194             * @see #setState(int)
195             */
196            public static final int ZOOM_OUT = 3;
197    
198            /**
199           * Flag fuer Modus "SimpleFeature-Auswahl auf allen (sichtbaren) Layern".           * Flag fuer Modus "SimpleFeature-Auswahl auf allen (sichtbaren) Layern".
200           *           *
201           * @see #setState(int)           * @see #setState(int)
# Line 186  public class XMapPane extends JPanel { Line 219  public class XMapPane extends JPanel {
219           */           */
220          public static final int SELECT_TOP = 4;          public static final int SELECT_TOP = 4;
221    
         public static final Cursor WAIT_CURSOR = Cursor  
                         .getPredefinedCursor(Cursor.WAIT_CURSOR);  
   
222          /**          /**
223           * {@link Font} used to paint the wait messages into the map           * {@link Font} used to paint the wait messages into the map
224           *           *
225           * @see #addGadgets(Graphics2D, boolean)           * @see #addGadgets(Graphics2D, boolean)
226           */           */
227          final static Font waitFont = new Font("Arial", Font.BOLD, 30);          final static Font waitFont = new Font("Arial", Font.BOLD, 28);
228    
229          /**          /**
230           * {@link Font} used to paint error messages into the map           * {@link Font} used to paint error messages into the map
# Line 204  public class XMapPane extends JPanel { Line 234  public class XMapPane extends JPanel {
234          final static Font errorFont = new Font("Arial", Font.BOLD, 13);          final static Font errorFont = new Font("Arial", Font.BOLD, 13);
235    
236          /**          /**
237             * If last average last two renderings took more than that many ms, show the
238             * user a scaled preview
239             **/
240            private static final long PRESCALE_MINTIME = 230;
241    
242            /**
243           * The wait message painted into the map while rendering is going on on           * The wait message painted into the map while rendering is going on on
244           * another thread.           * another thread.
245           *           *
# Line 212  public class XMapPane extends JPanel { Line 248  public class XMapPane extends JPanel {
248          final String waitMsg = SwingUtil.R("WaitMess");          final String waitMsg = SwingUtil.R("WaitMess");
249    
250          /**          /**
          * Flag fuer Modus "Heran zoomen".  
          *  
          * @see #setState(int)  
          * @see #setState(int)  
          */  
         public static final int ZOOM_IN = 2;  
   
         /**  
          * Flag fuer Modus "Heraus zoomen". Nicht fuer Window-Auswahl moeglich!  
          *  
          * @see #setState(int)  
          */  
         public static final int ZOOM_OUT = 3;  
   
         /**  
251           * Konvertiert die Maus-Koordinaten (relativ zum <code>JMapPane</code>) in           * Konvertiert die Maus-Koordinaten (relativ zum <code>JMapPane</code>) in
252           * Karten-Koordinaten.           * Karten-Koordinaten.
253           *           *
254           * @param e           * @param e
255           *            Maus-Ereignis           *            Maus-Ereignis
256           */           */
257          public static Point2D getMapCoordinatesFromEvent(final MouseEvent e) {          public static DirectPosition2D getMapCoordinatesFromEvent(final MouseEvent e) {
258                  // aktuelle Geo-Position aus GeoMouseEvent ermitteln                  // aktuelle Geo-Position aus GeoMouseEvent ermitteln
259                  if (e != null && e instanceof MapMouseEvent)                  if (e != null && e instanceof MapMouseEvent)
260                          try {                          try {
261                                  return ((MapMouseEvent) e).getMapPosition().toPoint2D();                                  return ((MapMouseEvent) e).getMapPosition();
262                          } catch (final Exception err) {                          } catch (final Exception err) {
263                                  LOGGER                                  LOGGER
264                                                  .error(                                                  .error(
# Line 254  public class XMapPane extends JPanel { Line 275  public class XMapPane extends JPanel {
275                                  return null;                                  return null;
276    
277                          final AffineTransform at = xMapPane.getScreenToWorld();                          final AffineTransform at = xMapPane.getScreenToWorld();
278                          if (at != null)                          if (at != null) {
279                                  return at.transform(e.getPoint(), null);                                  Point2D transformed = at.transform(e.getPoint(), null);
280                                    return new DirectPosition2D(xMapPane.getMapContext()
281                                                    .getCoordinateReferenceSystem(), transformed.getX(),
282                                                    transformed.getY());
283                            }
284                          return null;                          return null;
285                  }                  }
286                  throw new IllegalArgumentException(                  throw new IllegalArgumentException(
# Line 270  public class XMapPane extends JPanel { Line 295  public class XMapPane extends JPanel {
295    
296                  @Override                  @Override
297                  public void layerAdded(final MapLayerListEvent event) {                  public void layerAdded(final MapLayerListEvent event) {
298                          MapLayer layer = event.getLayer();                          final MapLayer layer = event.getLayer();
299                          layer.addMapLayerListener(bgMapLayerListener);                          layer.addMapLayerListener(bgMapLayerListener);
300                          requestStartRendering();                          requestStartRendering();
301    
# Line 389  public class XMapPane extends JPanel { Line 414  public class XMapPane extends JPanel {
414                  public void layerAdded(final MapLayerListEvent event) {                  public void layerAdded(final MapLayerListEvent event) {
415                          event.getLayer().addMapLayerListener(localMapLayerListener);                          event.getLayer().addMapLayerListener(localMapLayerListener);
416    
417                          localRenderer.setContext(getMapContext());                          getLocalRenderer().setContext(getMapContext());
418                          requestStartRendering();                          requestStartRendering();
419    
420                  }                  }
421    
422                  @Override                  @Override
423                  public void layerChanged(final MapLayerListEvent event) {                  public void layerChanged(final MapLayerListEvent event) {
424                          localRenderer.setContext(getMapContext());                          // getLocalRenderer().setContext(getMapContext()); geht doch auch
425                            // ohne?!?!? wow...
426                          requestStartRendering();                          requestStartRendering();
427                  }                  }
428    
429                  @Override                  @Override
430                  public void layerMoved(final MapLayerListEvent event) {                  public void layerMoved(final MapLayerListEvent event) {
431                          localRenderer.setContext(getMapContext());                          getLocalRenderer().setContext(getMapContext());
432                          requestStartRendering();                          requestStartRendering();
433                  }                  }
434    
# Line 410  public class XMapPane extends JPanel { Line 436  public class XMapPane extends JPanel {
436                  public void layerRemoved(final MapLayerListEvent event) {                  public void layerRemoved(final MapLayerListEvent event) {
437                          if (event.getLayer() != null)                          if (event.getLayer() != null)
438                                  event.getLayer().removeMapLayerListener(localMapLayerListener);                                  event.getLayer().removeMapLayerListener(localMapLayerListener);
439                          localRenderer.setContext(getMapContext());                          getLocalRenderer().setContext(getMapContext());
440                          requestStartRendering();                          requestStartRendering();
441                  }                  }
442          };          };
443    
444          /**          /**
445           * Listens to each layer in the local {@link MapContext} for changes and           * Listens to each layer in the local {@link MapContext} for changes and
446           * triggers repaints.           * triggers repaints. We don't have to listen layerChanged, because that is
447             * already done in {@link #localContextListener}
448           */           */
449          protected MapLayerListener localMapLayerListener = new MapLayerAdapter() {          protected MapLayerListener localMapLayerListener = new MapLayerAdapter() {
450    
451                  @Override                  // @Override
452                  public void layerChanged(final MapLayerEvent event) {                  // public void layerChanged(final MapLayerEvent event) {
453                          localRenderer.setContext(getMapContext()); // betters for SLD changes?!                  // // getLocalRenderer().setContext(getMapContext()); // betters for SLD
454                          requestStartRendering();                  // // // changes?!
455                  }                  // // requestStartRendering();
456                    // }
457    
458                  @Override                  @Override
459                  public void layerHidden(final MapLayerEvent event) {                  public void layerHidden(final MapLayerEvent event) {
# Line 438  public class XMapPane extends JPanel { Line 466  public class XMapPane extends JPanel {
466                  }                  }
467          };          };
468    
469          private final GTRenderer localRenderer = GTUtil.createGTRenderer();          final private GTRenderer localRenderer = GTUtil.createGTRenderer();
470    
471          private final GTRenderer bgRenderer = GTUtil.createGTRenderer();          private final GTRenderer bgRenderer = GTUtil.createGTRenderer();
472    
# Line 459  public class XMapPane extends JPanel { Line 487  public class XMapPane extends JPanel {
487          /**          /**
488           * 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.
489           */           */
490          private Color mapBackgroundColor = Color.WHITE;          private Color mapBackgroundColor = null;
491    
492          /**          /**
493           * 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 503  public class XMapPane extends JPanel { Line 531  public class XMapPane extends JPanel {
531           * A flag indicating, that the image size has changed and the buffered           * A flag indicating, that the image size has changed and the buffered
532           * images are not big enough any more           * images are not big enough any more
533           **/           **/
534          protected boolean paneResized = false;          protected boolean paneResized = true;
535    
536          private BufferedImage preFinalImage;          private BufferedImage preFinalImage;
537    
538          // if null, no quick preview will be shown          // ** if 0, no quick preview will be shown **/
539          private int quickPreviewHint = 0;          // private int quickPreviewHint = 0;
540    
541          private Map<Object, Object> rendererHints = GTUtil          private Map<Object, Object> rendererHints = GTUtil
542                          .getDefaultGTRendererHints(localRenderer);                          .getDefaultGTRendererHints(getLocalRenderer());
543    
544          /**          /**
545           * If set to <code>true</code>, the {@link #startRenderThreadsTimer} will           * If set to <code>true</code>, the {@link #startRenderThreadsTimer} will
# Line 534  public class XMapPane extends JPanel { Line 562  public class XMapPane extends JPanel {
562    
563          /**          /**
564           * The default state is ZOOM_IN, hence by default the           * The default state is ZOOM_IN, hence by default the
565           * {@link #zoomMapPaneMouseListener} is also enabled.           * {@link #xMapPaneMouseListener} is also enabled.
566           **/           **/
567          private int state = ZOOM_IN;          private int state = ZOOM_IN;
568    
# Line 546  public class XMapPane extends JPanel { Line 574  public class XMapPane extends JPanel {
574    
575          private AffineTransform worldToScreen;          private AffineTransform worldToScreen;
576    
577    //      /**
578    //       * This {@link MouseListener} is managing all zoom related tasks
579    //       */
580    //      private final ZoomXMapPaneMouseListener zoomMapPaneMouseListener = new ZoomXMapPaneMouseListener(
581    //                      this);
582            
583          /**          /**
584           * This {@link MouseListener} is managing all zoom related tasks           * This {@link MouseListener} is managing all zoom related tasks
585           */           */
586          public final ZoomXMapPaneMouseListener zoomMapPaneMouseListener = new ZoomXMapPaneMouseListener(          private final XMapPaneMouseListener xMapPaneMouseListener = new XMapPaneMouseListener(this);
587                          this);          
588    
589          /** Is set if a renderer has an error **/          /** Is set if a renderer has an error **/
590          protected ArrayList<Exception> renderingErrors = new ArrayList<Exception>();          protected ArrayList<Exception> renderingErrors = new ArrayList<Exception>();
591    
592          // /** If {@link #getVisibleRect()} of this {@link JPanel} is not yet          /**
593          // defined, but we are **/           * If <code>true</code>, then rendering exceptions are rendererd into the
594          // private Envelope mapAreaCondidate = null;           * map pane
595             **/
596            private boolean showExceptions = false;
597    
598          public XMapPane() {          public XMapPane() {
599                  this(null, null);                  this(null, null);
# Line 589  public class XMapPane extends JPanel { Line 625  public class XMapPane extends JPanel {
625                  /**                  /**
626                   * Adding the #zoomMapPaneMouseListener                   * Adding the #zoomMapPaneMouseListener
627                   */                   */
628                  this.addMouseListener(zoomMapPaneMouseListener);                  this.addMouseListener(xMapPaneMouseListener);
629                  this.addMouseMotionListener(zoomMapPaneMouseListener);                  this.addMouseMotionListener(xMapPaneMouseListener);
630                  this.addMouseWheelListener(zoomMapPaneMouseListener);                  this.addMouseWheelListener(xMapPaneMouseListener);
631    
632                  /*                  /*
633                   * We use a Timer object to avoid rendering delays and flickering when                   * We use a Timer object to avoid rendering delays and flickering when
# Line 607  public class XMapPane extends JPanel { Line 643  public class XMapPane extends JPanel {
643                                                  if (!isWellDefined())                                                  if (!isWellDefined())
644                                                          return;                                                          return;
645    
646                                                  final Rectangle bounds = getVisibleRect();                                                  // LOGGER.debug("resizeTimer performed");
647    
648                                                    // final Rectangle bounds = getVisibleRect();
649                                                  //                                                  //
650                                                  // System.out.println("\n\ntimer performs with bounds = "                                                  // System.out.println("\n\ntimer performs with bounds = "
651                                                  // + bounds);                                                  // + bounds);
652    
653                                                  final Envelope geoMapArea = tranformWindowToGeo(                                                  // final Envelope geoMapArea = tranformWindowToGeo(
654                                                                  bounds.x, bounds.y, bounds.x + bounds.width,                                                  // bounds.x, bounds.y, bounds.x + bounds.width,
655                                                                  bounds.y + bounds.height);                                                  // bounds.y + bounds.height);
656    
657                                                  if (setMapArea(geoMapArea))                                                  paneResized = true;
658                                                          paneResized = true;                                                  if (!setMapArea(getMapArea())) {
659                                                  // else                                                          // It's important to request new rendering here.
660                                                  // syso                                                          // setMapArea only returns true and only calls
661                                                            // requestStartRendering if the maparea has changed.
662                                                            // But if the component is resized, the maparea
663                                                            // doesn't have to change.
664                                                            requestStartRendering();
665                                                    }
666    
667                                          }                                          }
668                                  });                                  });
669                  resizeTimer.setRepeats(false);                  resizeTimer.setRepeats(false);
670    
671                  this.addComponentListener(new ComponentAdapter() {                  this.addComponentListener(new ComponentAdapter() {
672    
673                            private Rectangle oldVisibleRect;
674    
675                          @Override                          @Override
676                          public void componentResized(final ComponentEvent e) {                          public void componentResized(final ComponentEvent e) {
677    
678                                  // Already cancel the tasks...                                  // Seems to be called twice with the same size..
679                                  if (bgExecuter != null)                                  if (oldVisibleRect != null
680                                          bgExecuter.cancelTask();                                                  && oldVisibleRect.equals(getVisibleRect())) {
681                                  if (localExecuter != null)                                          // LOGGER.debug("skipping resize.");
682                                          localExecuter.cancelTask();                                          return;
683                                    }
684    
685                                    // LOGGER.debug("resized: " + getVisibleRect());
686                                  resizeTimer.restart();                                  resizeTimer.restart();
687                                    oldVisibleRect = getVisibleRect();
688                          }                          }
689    
690                  });                  });
# Line 647  public class XMapPane extends JPanel { Line 696  public class XMapPane extends JPanel {
696    
697                          @Override                          @Override
698                          public void actionPerformed(final ActionEvent e) {                          public void actionPerformed(final ActionEvent e) {
699                                  if ((localExecuter != null && !localExecuter.isRunning())                                  if ((!localExecuter.isRunning())
700                                                  && (bgExecuter != null && !bgExecuter.isRunning())) {                                                  && (bgExecuter != null && !bgExecuter.isRunning())) {
701                                          repaintTimer.stop();                                          repaintTimer.stop();
702                                  } else {                                  } else {
703                                          updateFinalImage();                                          updateFinalImage();
704                                          XMapPane.this.repaint(100);                                          XMapPane.this.repaint(100);
705    
706                                  }                                  }
707                          }                          }
708                  });                  });
709    
710                  repaintTimer.setInitialDelay(INITIAL_REPAINT_DELAY);                  repaintTimer.setInitialDelay(INITIAL_REPAINT_DELAY);
711                  repaintTimer.setRepeats(true);                  repaintTimer.setRepeats(true);
712    
# Line 673  public class XMapPane extends JPanel { Line 724  public class XMapPane extends JPanel {
724                                                  if (localExecuter.isRunning()) {                                                  if (localExecuter.isRunning()) {
725                                                          localExecuter.cancelTask();                                                          localExecuter.cancelTask();
726                                                  } else {                                                  } else {
   
727                                                          // Stupidly, but we have to recheck the                                                          // Stupidly, but we have to recheck the
728                                                          setMapArea(getMapArea());                                                          setMapArea(getMapArea());
729                                                          requestStartRendering = false;                                                          requestStartRendering = false;
# Line 762  public class XMapPane extends JPanel { Line 812  public class XMapPane extends JPanel {
812                  }                  }
813    
814                  final Envelope maxAllowedExtend = getMaxExtend();                  final Envelope maxAllowedExtend = getMaxExtend();
815                    
816                  while (maxAllowedExtend != null && !maxAllowedExtend.contains(newArea)                  while (maxAllowedExtend != null && !maxAllowedExtend.contains(newArea)
817                                  && newArea != null && !newArea.isNull()                                  && newArea != null && !newArea.isNull()
818                                  && !Double.isNaN(newArea.getMinX())                                  && !Double.isNaN(newArea.getMinX())
# Line 907  public class XMapPane extends JPanel { Line 957  public class XMapPane extends JPanel {
957                          bgExecuter.dispose();                          bgExecuter.dispose();
958                  }                  }
959    
960                  if (localExecuter != null) {                  if (localExecuter.isRunning()) {
961                          int i = 0;                          int i = 0;
962                          localExecuter.cancelTask();                          localExecuter.cancelTask();
963                          while (i++ < 10 && localExecuter.isRunning()) {                          while (i++ < 10 && localExecuter.isRunning()) {
# Line 932  public class XMapPane extends JPanel { Line 982  public class XMapPane extends JPanel {
982                  // Remove all mapPaneListeners that have registered with us                  // Remove all mapPaneListeners that have registered with us
983                  mapPaneListeners.clear();                  mapPaneListeners.clear();
984    
985                  removeMouseMotionListener(zoomMapPaneMouseListener);                  removeMouseMotionListener(xMapPaneMouseListener);
986                  removeMouseListener(zoomMapPaneMouseListener);                  removeMouseListener(xMapPaneMouseListener);
987    
988                  if (localContext != null)                  if (localContext != null)
989                          getMapContext().clearLayerList();                          getMapContext().clearLayerList();
# Line 942  public class XMapPane extends JPanel { Line 992  public class XMapPane extends JPanel {
992    
993                  removeAll();                  removeAll();
994          }          }
995            
996          /**          /**
997           * Draws a rectangle in XOR mode from the origin at {@link #startPos} to the           * Draws a rectangle in XOR mode from the origin at {@link #startPos} to the
998           * given point. All in screen coordinates.           * given point. All in screen coordinates.
999           */           */
1000          protected void drawRectangle(final Graphics graphics, final Point startPos,          protected void drawRectangle(final Graphics graphics, final Point startPos,
1001                          final Point e) {                          final Point e) {
1002                    drawRectangle(graphics, startPos, e, Color.WHITE);
1003            }
1004    
1005            /**
1006             * Draws a rectangle in XOR mode from the origin at {@link #startPos} to the
1007             * given point. All in screen coordinates.
1008             */
1009            protected void drawRectangle(final Graphics graphics, final Point startPos,
1010                            final Point e, Color color) {
1011    
1012                  if (!isWellDefined())                  if (!isWellDefined())
1013                          return;                          return;
# Line 964  public class XMapPane extends JPanel { Line 1023  public class XMapPane extends JPanel {
1023                  if (width == 0 && height == 0)                  if (width == 0 && height == 0)
1024                          return;                          return;
1025    
1026                  graphics.setXORMode(Color.WHITE);                  graphics.setXORMode(color);
1027                  graphics.drawRect(left, bottom, width, height);                  graphics.drawRect(left, bottom, width, height);
1028          }          }
1029    
# Line 976  public class XMapPane extends JPanel { Line 1035  public class XMapPane extends JPanel {
1035           *           *
1036           * @param g           * @param g
1037           *            Graphics2D to paint the preview into           *            Graphics2D to paint the preview into
          *  
          * @param state  
          *            Max be {@link #ZOOM_IN} or {@link #ZOOM_OUT}  
1038           */           */
1039          protected boolean drawScaledPreviewImage_Zoom(final Graphics2D graphics) {          protected boolean drawScaledPreviewImage_Zoom(final Graphics2D graphics) {
1040    
1041                  // if (1 == 1)return false;                  // if (1 == 1)return false;
1042                    // if (quickPreviewHint == 0)
1043                    // return false;
1044    
1045                  if (quickPreviewHint == 0)                  if (oldMapArea == null)
1046                          return false;                          return false;
1047    
1048                  graphics.setRenderingHint(RenderingHints.KEY_INTERPOLATION,                  if (getPreFinalImage() == null)
                                 RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR);  
                 graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING,  
                                 RenderingHints.VALUE_ANTIALIAS_OFF);  
                 graphics.setRenderingHint(RenderingHints.KEY_RENDERING,  
                                 RenderingHints.VALUE_RENDER_SPEED);  
   
                 if (oldMapArea == null)  
1049                          return false;                          return false;
1050    
1051                  final Rectangle visibleArea = getVisibleRect();                  final Rectangle visibleArea = getVisibleRect();
# Line 1009  public class XMapPane extends JPanel { Line 1060  public class XMapPane extends JPanel {
1060                  final int xx2 = (int) Math.round(oldMapWindow.getMaxX());                  final int xx2 = (int) Math.round(oldMapWindow.getMaxX());
1061                  final int yy2 = (int) Math.round(oldMapWindow.getMaxY());                  final int yy2 = (int) Math.round(oldMapWindow.getMaxY());
1062    
1063                    graphics.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
1064                                    RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR);
1065                    graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
1066                                    RenderingHints.VALUE_ANTIALIAS_OFF);
1067                    graphics.setRenderingHint(RenderingHints.KEY_RENDERING,
1068                                    RenderingHints.VALUE_RENDER_SPEED);
1069    
1070                  graphics.drawImage(getPreFinalImage(), xx1, yy1, xx2, yy2,                  graphics.drawImage(getPreFinalImage(), xx1, yy1, xx2, yy2,
1071                                  (int) visibleArea.getMinX(), (int) visibleArea.getMinY(),                                  (int) visibleArea.getMinX(), (int) visibleArea.getMinY(),
1072                                  (int) visibleArea.getMaxX(), (int) visibleArea.getMaxY(),                                  (int) visibleArea.getMaxX(), (int) visibleArea.getMaxY(),
# Line 1017  public class XMapPane extends JPanel { Line 1075  public class XMapPane extends JPanel {
1075                  final Rectangle painedArea = new Rectangle(xx1, yy1, xx2 - xx1, yy2                  final Rectangle painedArea = new Rectangle(xx1, yy1, xx2 - xx1, yy2
1076                                  - yy1);                                  - yy1);
1077    
1078                  SwingUtil.clearAround(graphics, painedArea, visibleArea);                  SwingUtil.clearAround(graphics, painedArea, visibleArea,
1079                                    getMapBackgroundColor());
1080    
1081                  addGadgets(graphics, true);                  addGadgets(graphics, true);
1082    
1083                  quickPreviewHint = 0;                  // quickPreviewHint = 0;
1084    
1085                  repaintTimer.restart();                  repaintTimer.restart();
1086    
                 graphics.dispose();  
   
1087                  // Something has been drawn                  // Something has been drawn
1088                  return true;                  return true;
1089          }          }
# Line 1039  public class XMapPane extends JPanel { Line 1096  public class XMapPane extends JPanel {
1096           * Lazyly initializes a {@link BufferedImage} for the background renderer.           * Lazyly initializes a {@link BufferedImage} for the background renderer.
1097           */           */
1098          private Image getBgImage() {          private Image getBgImage() {
1099                  //                  if (bgImage == null) {
1100                  // if (bgImage == null) {                          bgImage = new BufferedImage(getVisibleRect().width,
1101                  // bgImage = createImage(getBounds().width, getBounds().height);                                          getVisibleRect().height, IMAGETYPE);
1102                  // }                          SwingUtil.clearImage(finalImage, getMapBackgroundColor());
1103                    }
1104    
1105                  return bgImage;                  return bgImage;
1106          }          }
# Line 1060  public class XMapPane extends JPanel { Line 1118  public class XMapPane extends JPanel {
1118                          // Rectangle curPaintArea = getVisibleRect();                          // Rectangle curPaintArea = getVisibleRect();
1119                          finalImage = new BufferedImage(getVisibleRect().width,                          finalImage = new BufferedImage(getVisibleRect().width,
1120                                          getVisibleRect().height, IMAGETYPE);                                          getVisibleRect().height, IMAGETYPE);
1121                            SwingUtil.clearImage(finalImage, getMapBackgroundColor());
1122    
1123                          requestStartRendering();                          // requestStartRendering();
1124                  }                  }
1125                  return finalImage;                  return finalImage;
1126          }          }
1127    
         public RenderingHints getJava2dHints() {  
                 return java2dHints;  
         }  
   
1128          /**          /**
1129           * Lazyly initializes a {@link BufferedImage} for the background renderer.           * Lazyly initializes a {@link BufferedImage} for the background renderer.
1130           */           */
# Line 1078  public class XMapPane extends JPanel { Line 1133  public class XMapPane extends JPanel {
1133                  if (localImage == null) {                  if (localImage == null) {
1134                          localImage = new BufferedImage(getVisibleRect().width,                          localImage = new BufferedImage(getVisibleRect().width,
1135                                          getVisibleRect().height, IMAGETYPE_withAlpha);                                          getVisibleRect().height, IMAGETYPE_withAlpha);
1136                            SwingUtil.clearImage(localImage, getMapBackgroundColor());
1137                  }                  }
1138    
1139                  return localImage;                  return localImage;
# Line 1093  public class XMapPane extends JPanel { Line 1149  public class XMapPane extends JPanel {
1149                          ReferencedEnvelope mapArea_ = null;                          ReferencedEnvelope mapArea_ = null;
1150                          try {                          try {
1151                                  mapArea_ = localContext.getLayerBounds();                                  mapArea_ = localContext.getLayerBounds();
1152                          } catch (final IOException e) {                          } catch (final Exception e) {
1153                                  LOGGER.warn("localContext.getLayerBounds()", e);                                  LOGGER.warn("localContext.getLayerBounds()", e);
1154                          }                          }
1155    
# Line 1119  public class XMapPane extends JPanel { Line 1175  public class XMapPane extends JPanel {
1175                          try {                          try {
1176                                  localContext.setCoordinateReferenceSystem(GeoImportUtil                                  localContext.setCoordinateReferenceSystem(GeoImportUtil
1177                                                  .getDefaultCRS());                                                  .getDefaultCRS());
1178                          } catch (Exception e) {                          } catch (final Exception e) {
1179                                  throw new RuntimeException("setting context CRS:", e);                                  throw new RuntimeException("setting context CRS:", e);
1180                          }                          }
1181    
# Line 1128  public class XMapPane extends JPanel { Line 1184  public class XMapPane extends JPanel {
1184          }          }
1185    
1186          /**          /**
1187           * 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
1188             * methods looks for a parent component and will use its background color.
1189             * If no parent component is available, WHITE is returned.
1190           **/           **/
1191          public Color getMapBackgroundColor() {          public Color getMapBackgroundColor() {
1192                    if (mapBackgroundColor == null) {
1193                            if (getParent() != null)
1194                                    return getParent().getBackground();
1195                            else
1196                                    return Color.WHITE;
1197                    }
1198                  return mapBackgroundColor;                  return mapBackgroundColor;
1199          }          }
1200    
# Line 1157  public class XMapPane extends JPanel { Line 1221  public class XMapPane extends JPanel {
1221    
1222          public Envelope getMaxExtend() {          public Envelope getMaxExtend() {
1223                  if (maxExtend == null) {                  if (maxExtend == null) {
1224                          // Commented-out because it takes soo much time!  
1225  //                          // The next command may take long time!
1226  //                      long start = System.currentTimeMillis();                          // long start = System.currentTimeMillis();
1227  //                      final ReferencedEnvelope layerBounds = GTUtil                          final ReferencedEnvelope layerBounds = GTUtil
1228  //                                      .getVisibleLayoutBounds(localContext);                                          .getVisibleLayoutBounds(localContext);
1229  //                                                //                      
1230  //                      LOGGER.info( (System.currentTimeMillis()-start)+"m to get maxExtend");                          // LOGGER.info(
1231  //                                                // (System.currentTimeMillis()-start)+"m to get maxExtend");
1232  //                      if (layerBounds == null) {                          //                      
1233  //                              // TODO Last fallback could be the CRS valid area                          if (layerBounds == null) {
1234  //                              return null;                                  // // TODO Last fallback could be the CRS valid area
1235  //                      }                                  return null;
1236  //                          }
1237  //                      // Kartenbereich um 10% vergroessern  
1238  //                      return JTSUtil.fixAspectRatio(getVisibleRect(), JTSUtil                          // Vergrößerung um 10% nochmal rausgenommen
1239  //                                      .expandEnvelope(layerBounds, 0.1), true);                          // // // Kartenbereich um 10% vergroessern
1240                            // return JTSUtil.fixAspectRatio(getVisibleRect(), JTSUtil
1241                            // .expandEnvelope(layerBounds, 0.1), true);
1242    
1243                            return JTSUtil.fixAspectRatio(getVisibleRect(), layerBounds, true);
1244                  }                  }
1245                  return maxExtend;                  return maxExtend;
1246          }          }
# Line 1200  public class XMapPane extends JPanel { Line 1268  public class XMapPane extends JPanel {
1268          }          }
1269    
1270          private Image getPreFinalImage() {          private Image getPreFinalImage() {
                 // if (preFinalImage == null) {  
                 //                        
                 // // Rectangle curPaintArea = getVisibleRect();  
                 // // preFinalImage = new BufferedImage(curPaintArea.width,  
                 // // curPaintArea.height, BufferedImage.TYPE_INT_RGB);  
                 //                        
                 // preFinalImage = createImage(getBounds().width, getBounds().height);  
                 //  
                 // requestStartRendering();  
                 // }  
1271                  return preFinalImage;                  return preFinalImage;
1272          }          }
1273    
# Line 1303  public class XMapPane extends JPanel { Line 1361  public class XMapPane extends JPanel {
1361                  return true;                  return true;
1362          }          }
1363    
1364            /**
1365             * Called from the listeners while the mouse is dragging, this method either
1366             * paints a translated (moved/panned) version of the image, or a rectangle.
1367             *
1368             * @param startPos
1369             *            in screen coordinates
1370             * @param lastPos
1371             *            in screen coordinates
1372             * @param event
1373             *            the {@link MouseEvent} to read the mouse buttons from
1374             */
1375          public void mouseDragged(final Point startPos, final Point lastPos,          public void mouseDragged(final Point startPos, final Point lastPos,
1376                          final MouseEvent event) {                          final MouseEvent event) {
1377    
1378                  if ((getState() == XMapPane.PAN)                  if ((getState() == XMapPane.PAN)
1379                                  || ((event.getModifiersEx() & InputEvent.BUTTON3_DOWN_MASK) != 0)) {                                  || ((event.getModifiersEx() & InputEvent.BUTTON3_DOWN_MASK) != 0)) {
1380    
1381                            // Panning needs a panning coursor
1382                          if (getCursor() != SwingUtil.PANNING_CURSOR) {                          if (getCursor() != SwingUtil.PANNING_CURSOR) {
1383                                  setCursor(SwingUtil.PANNING_CURSOR);                                  setCursor(SwingUtil.PANNING_CURSOR);
1384    
1385                                  // While panning, we deactivate the rendering. So the tasts are                                  // While panning, we deactivate the rendering. So the tasks are
1386                                  // ready to start when the panning os done.                                  // ready to start when the panning is finished.
1387                                  if (bgExecuter != null)                                  if (bgExecuter != null && bgExecuter.isRunning())
1388                                          bgExecuter.cancelTask();                                          bgExecuter.cancelTask();
1389                                  if (localExecuter != null)                                  if (localExecuter.isRunning())
1390                                          localExecuter.cancelTask();                                          localExecuter.cancelTask();
1391                          }                          }
1392    
# Line 1363  public class XMapPane extends JPanel { Line 1433  public class XMapPane extends JPanel {
1433                  } else if ((getState() == XMapPane.ZOOM_IN)                  } else if ((getState() == XMapPane.ZOOM_IN)
1434                                  || (getState() == XMapPane.ZOOM_OUT)                                  || (getState() == XMapPane.ZOOM_OUT)
1435                                  || (getState() == XMapPane.SELECT_ALL)                                  || (getState() == XMapPane.SELECT_ALL)
1436                                  || (getState() == XMapPane.SELECT_TOP)                                  || (getState() == XMapPane.SELECT_TOP)) {
                 // || (getState() == XMapPane.SELECT_ONE_FROM_TOP)  
                 ) {  
                         final Graphics graphics = getGraphics();  
1437    
1438                            // Draws a rectangle
1439                            final Graphics2D graphics = (Graphics2D) getGraphics();
1440                          drawRectangle(graphics, startPos, event.getPoint());                          drawRectangle(graphics, startPos, event.getPoint());
1441                            if ((lastPos.x > 0) && (lastPos.y > 0))
                         if ((lastPos.x > 0) && (lastPos.y > 0)) {  
1442                                  drawRectangle(graphics, startPos, lastPos);                                  drawRectangle(graphics, startPos, lastPos);
                         }  
   
1443                          graphics.dispose();                          graphics.dispose();
   
1444                  }                  }
   
1445          }          }
1446    
1447          /**          /**
1448           * Called by the {@link RenderingExecutor} when rendering was cancelled.           * Called by the {@link RenderingExecutor} when rendering was cancelled.
1449           */           */
1450          public void onRenderingCancelled() {          public void onRenderingCancelled() {
1451                  LOGGER.debug("Rendering cancelled");                  // LOGGER.debug("Rendering cancelled");
1452                  repaintTimer.stop();                  repaintTimer.stop();
1453          }          }
1454    
1455          /**          /**
1456           * Called by the {@link RenderingExecutor} when rendering has been           * Called by the {@link RenderingExecutor} when rendering has been
1457           * completed.           * completed.
1458             *
1459             * @param l
1460             *            long ms the rendering took
1461           */           */
1462          public void onRenderingCompleted() {          public void onRenderingCompleted(final long l) {
1463                    lastRenderingDuration = (lastRenderingDuration + l) / 2;
1464                    // LOGGER
1465                    // .debug("complete rendering after " + lastRenderingDuration
1466                    // + "ms");
1467    
1468                  repaintTimer.stop();                  repaintTimer.stop();
1469                  updateFinalImage();  
1470                  repaint();                  // We "forget" about an exception every time we complete a rendering
1471                    // thread successfully
1472                  if (renderingErrors.size() > 0)                  if (renderingErrors.size() > 0)
1473                          renderingErrors.remove(0);                          renderingErrors.remove(0);
1474    
1475                    updateFinalImage();
1476                    repaint();
1477          }          }
1478    
1479          /**          /**
# Line 1411  public class XMapPane extends JPanel { Line 1487  public class XMapPane extends JPanel {
1487           * @see MapPaneListener#onRenderingStopped(org.geotools.swing.event.MapPaneEvent)           * @see MapPaneListener#onRenderingStopped(org.geotools.swing.event.MapPaneEvent)
1488           */           */
1489          public void onRenderingFailed(final Exception renderingError) {          public void onRenderingFailed(final Exception renderingError) {
1490                  this.renderingErrors.add(renderingError);  
1491                    // Store the exceptions so we can show it to the user:
1492                    if (!(renderingError instanceof java.lang.IllegalArgumentException && renderingError
1493                                    .getMessage().equals(
1494                                                    "Argument \"sourceCRS\" should not be null.")))
1495                            this.renderingErrors.add(renderingError);
1496                  if (renderingErrors.size() > 3)                  if (renderingErrors.size() > 3)
1497                          renderingErrors.remove(0);                          renderingErrors.remove(0);
1498    
1499                  repaintTimer.stop();                  repaintTimer.stop();
1500    
1501                  LOGGER.warn("Rendering failed", renderingError);                  LOGGER.warn("Rendering failed", renderingError);
1502                  updateFinalImage();                  updateFinalImage();
1503                  repaint();                  repaint();
1504    
1505          }          }
1506    
         public void onRenderingPending() {  
                 // LOGGER.debug("Pending rendering updates the preview...");  
                 updateFinalImage();  
                 repaint();  
         }  
   
1507          @Override          @Override
1508          protected void paintComponent(final Graphics g) {          protected void paintComponent(final Graphics g) {
1509    
1510                    // Maybe update the cursor and maybe stop the repainting timer
1511                    updateCursor();
1512    
1513                  if (!acceptsRepaintCalls)                  if (!acceptsRepaintCalls)
1514                          return;                          return;
1515    
1516                  // Maybe update the cursor and maybe stop the repainting timer                  if (!isWellDefined())
1517                  updateCursor();                          return;
1518                    //
1519                    // if (paneResized) {
1520                    // // ((Graphics2D) g).setBackground(getMapBackgroundColor());
1521                    // // g.clearRect(0, 0, getVisibleRect().width,
1522                    // getVisibleRect().height);
1523                    // return;
1524                    // }
1525    
1526                  // super.paintComponent(g); // candidate for removal                  // super.paintComponent(g); // candidate for removal
1527    
# Line 1447  public class XMapPane extends JPanel { Line 1534  public class XMapPane extends JPanel {
1534                          // If the new mapArea and the oldMapArea intersect, we can draw some                          // If the new mapArea and the oldMapArea intersect, we can draw some
1535                          // quick scaled preview to make the user feel that something is                          // quick scaled preview to make the user feel that something is
1536                          // happening.                          // happening.
1537                          if (mapAreaChanged && oldMapArea != null                          if (lastRenderingDuration > PRESCALE_MINTIME && mapAreaChanged
1538                                            && oldMapArea != null
1539                                          && getMapArea().intersects(oldMapArea)                                          && getMapArea().intersects(oldMapArea)
1540                                          & !getMapArea().equals(oldMapArea) && !paneResized) {                                          && !getMapArea().equals(oldMapArea) && !paneResized) {
1541    
1542                                  mapAreaChanged = false;                                  mapAreaChanged = false;
1543    
1544                                  if (getMapArea().covers(oldMapArea)) {                                  // if (getMapArea().covers(oldMapArea)) {
1545                                          setQuickPreviewHint(ZOOM_OUT);                                  // // quickPreviewHint = ZOOM_OUT;
1546                                          paintedSomething = drawScaledPreviewImage_Zoom((Graphics2D) g);                                  // paintedSomething = drawScaledPreviewImage_Zoom((Graphics2D)
1547                                  } else if (oldMapArea.covers(getMapArea())) {                                  // g);
1548                                          setQuickPreviewHint(ZOOM_IN);                                  // } else if (oldMapArea.covers(getMapArea())) {
1549                                          paintedSomething = drawScaledPreviewImage_Zoom((Graphics2D) g);                                  // quickPreviewHint = ZOOM_IN;
1550                                  }                                  paintedSomething = drawScaledPreviewImage_Zoom((Graphics2D) g);
1551                                    // }
1552                          }                          }
   
                         // if (paneResized) {  
                         // paneResized = false;  
                         // disposeImages();  
                         // }  
                         //  
                         // // Start the Threads and Timers to render the image  
                         // requestStartRendering();  
   
1553                  }                  }
1554    
1555                  if (!paintedSomething) {                  if (!paintedSomething) {
1556    
1557                          g.drawImage(getFinalImage(), 0, 0, null);                          g.drawImage(getFinalImage(), 0, 0, null);
1558    
                         g.dispose(); // cand. for removal  
   
1559                          paintedSomething = true; // cand. for removal                          paintedSomething = true; // cand. for removal
1560                  }                  }
1561    
# Line 1534  public class XMapPane extends JPanel { Line 1611  public class XMapPane extends JPanel {
1611           */           */
1612          public void performPan() {          public void performPan() {
1613    
1614                  Rectangle winBounds = getVisibleRect();                  final Rectangle winBounds = getVisibleRect();
1615    
1616                  winBounds.translate(-imageOrigin.x, -imageOrigin.y);                  winBounds.translate(-imageOrigin.x, -imageOrigin.y);
1617                  final Envelope newMapArea = tranformWindowToGeo(winBounds.x,                  final Envelope newMapArea = tranformWindowToGeo(winBounds.x,
# Line 1558  public class XMapPane extends JPanel { Line 1635  public class XMapPane extends JPanel {
1635                          setCursor(SwingUtil.PAN_CURSOR);                          setCursor(SwingUtil.PAN_CURSOR);
1636          }          }
1637    
         //  
         // /**  
         // * 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);  
         // }  
         // }  
   
1638          /**          /**
1639           * Entfernt einen Listener von der Map.           * Entfernt einen Listener von der Map.
1640           *           *
# Line 1598  public class XMapPane extends JPanel { Line 1653  public class XMapPane extends JPanel {
1653          private void requestStartRendering() {          private void requestStartRendering() {
1654                  if (bgExecuter != null)                  if (bgExecuter != null)
1655                          bgExecuter.cancelTask();                          bgExecuter.cancelTask();
1656                  if (localExecuter != null)  
1657                          localExecuter.cancelTask();                  localExecuter.cancelTask();
1658    
1659                  mapImageInvalid = true;                  mapImageInvalid = true;
1660                  if (paneResized) {                  if (paneResized) {
# Line 1624  public class XMapPane extends JPanel { Line 1679  public class XMapPane extends JPanel {
1679           *            the current map pane extent (screen units)           *            the current map pane extent (screen units)
1680           */           */
1681          private void resetTransforms() {          private void resetTransforms() {
                 ReferencedEnvelope refMapEnv = new ReferencedEnvelope(mapArea,  
                                 getMapContext().getCoordinateReferenceSystem());  
   
1682                  // System.out                  // System.out
1683                  // .println("paintArea in resetTeansofrms = " + getVisibleRect());                  // .println("paintArea in resetTeansofrms = " + getVisibleRect());
1684                  if (!isWellDefined())                  if (!isWellDefined())
1685                          return;                          return;
1686    
1687                    if (mapArea == null)
1688                            return;
1689                    
1690                    final ReferencedEnvelope refMapEnv = new ReferencedEnvelope(mapArea,
1691                                    getMapContext().getCoordinateReferenceSystem());
1692    
1693                  worldToScreen = RendererUtilities.worldToScreenTransform(refMapEnv,                  worldToScreen = RendererUtilities.worldToScreenTransform(refMapEnv,
1694                                  getVisibleRect());                                  getVisibleRect());
1695    
1696                  try {                  try {
1697                          screenToWorld = worldToScreen.createInverse();                          screenToWorld = worldToScreen.createInverse();
1698    
1699                  } catch (NoninvertibleTransformException ex) {                  } catch (final NoninvertibleTransformException ex) {
1700                          LOGGER                          LOGGER
1701                                          .error("can't invert worldToScreen to get screenToWorld!",                                          .error("can't invert worldToScreen to get screenToWorld!",
1702                                                          ex);                                                          ex);
# Line 1694  public class XMapPane extends JPanel { Line 1752  public class XMapPane extends JPanel {
1752    
1753                          // setMapArea(localContext.getAreaOfInterest());                          // setMapArea(localContext.getAreaOfInterest());
1754    
1755                          localRenderer.setContext(localContext);                          getLocalRenderer().setContext(localContext);
1756    
1757                          this.localContext.addMapLayerListListener(localContextListener);                          this.localContext.addMapLayerListListener(localContextListener);
1758    
# Line 1708  public class XMapPane extends JPanel { Line 1766  public class XMapPane extends JPanel {
1766    
1767          }          }
1768    
1769            public void setBorder(final Border b) {
1770                    super.setBorder(b);
1771            }
1772    
1773            /**
1774             * Triggers to repaint (fast) and re-render (slow) the JMapPane.
1775             */
1776            public void refresh() {
1777                    mapImageInvalid = true;
1778                    repaint();
1779            }
1780    
1781            // /**
1782            // * Triggers to use new {@link GTRenderer} and refresh the map. Should be
1783            // * called after {@link Style}s have been changed because GTRenderer is
1784            // * otherwise not working well.
1785            // */
1786            // public void refreshRenderers() {
1787            // localRenderer = GTUtil.createGTRenderer();
1788            // setLocalContext(getMapContext());
1789            // mapImageInvalid = true;
1790            // repaint();
1791            // }
1792    
1793            /**
1794             * Set the new map area.
1795             *
1796             * @param newMapArea
1797             * @return <code>true</code> if the mapArea has been changed and a repaint
1798             *         has been triggered.
1799             */
1800          public boolean setMapArea(final Envelope newMapArea) {          public boolean setMapArea(final Envelope newMapArea) {
1801                    if (newMapArea == null)
1802                            return false;
1803                    if (getMapContext().getCoordinateReferenceSystem() == null)
1804                            return false;
1805                  return setMapArea(new ReferencedEnvelope(newMapArea, getMapContext()                  return setMapArea(new ReferencedEnvelope(newMapArea, getMapContext()
1806                                  .getCoordinateReferenceSystem()));                                  .getCoordinateReferenceSystem()));
1807          }          }
1808    
1809          /**          /**
1810             * Set the new map area.
1811             *
1812           * @param newMapArea           * @param newMapArea
1813           * @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
1814           *         has been triggered.           *         has been triggered.
1815           */           */
1816          public boolean setMapArea(final ReferencedEnvelope newMapArea) {          public boolean setMapArea(final ReferencedEnvelope newMapArea) {
                 //                
                 // if (getVisibleRect().getWidth() == 0 || (!isVisible()) ||  
                 // getVisibleRect().getHeight() == 0) {  
                 // // The window is not yet defined.. so we can not really determine the  
                 // asepect ratio for the mapPane. We store this as a candidate mappane  
                 // and handle it when the component resizes or becomes visible)  
                 // mapAreaCondidate = newMapArea;  
                 // }  
1817    
1818                  if (newMapArea == null                  if (newMapArea == null
1819                                  || bestAllowedMapArea(newMapArea).equals(mapArea)) {                                  || bestAllowedMapArea(newMapArea).equals(mapArea)) {
# Line 1784  public class XMapPane extends JPanel { Line 1871  public class XMapPane extends JPanel {
1871    
1872                  mapAreaChanged = true;                  mapAreaChanged = true;
1873    
1874                  repaint(100);                  repaint(200); // Do not remove it!
1875    
1876                  requestStartRendering();                  requestStartRendering();
1877    
# Line 1796  public class XMapPane extends JPanel { Line 1883  public class XMapPane extends JPanel {
1883           *           *
1884           * @param if <code>null</code>, white is used.           * @param if <code>null</code>, white is used.
1885           */           */
1886          public void setMapBackgroundColor(Color bgColor) {          public void setMapBackgroundColor(final Color bgColor) {
                 if (bgColor == null)  
                         bgColor = Color.WHITE;  
1887                  this.mapBackgroundColor = bgColor;                  this.mapBackgroundColor = bgColor;
1888          }          }
1889    
# Line 1856  public class XMapPane extends JPanel { Line 1941  public class XMapPane extends JPanel {
1941          }          }
1942    
1943          // /** Stored the time used for the last real rendering in ms. **/          // /** Stored the time used for the last real rendering in ms. **/
1944          // private long lastRenderingDuration = Long.MAX_VALUE;          private long lastRenderingDuration = 1000;
1945    
1946          /**          /**
1947           * Set the minimum (nearest) allowed zoom scale. This is the bigger number           * Set the minimum (nearest) allowed zoom scale. This is the bigger number
# Line 1873  public class XMapPane extends JPanel { Line 1958  public class XMapPane extends JPanel {
1958          }          }
1959    
1960          /**          /**
1961           *           * If <code>true</code>, allow the {@link XMapPane} to process #repaint()
1962           * @param b           * requests. Otherwise the map will not paint anything and not start any
1963             * rendering {@link Thread}s.
1964           */           */
1965          public void setPainting(final boolean b) {          public void setPainting(final boolean b) {
1966                  acceptsRepaintCalls = b;                  acceptsRepaintCalls = b;
1967          }                  if (acceptsRepaintCalls == true)
1968                            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;  
   
1969          }          }
1970    
1971          private void setRendererHints(final Map<Object, Object> rendererHints) {          private void setRendererHints(final Map<Object, Object> rendererHints) {
# Line 1906  public class XMapPane extends JPanel { Line 1979  public class XMapPane extends JPanel {
1979           *           *
1980           * @param state           * @param state
1981           */           */
1982            @Deprecated
1983          public void setState(final int state) {          public void setState(final int state) {
1984                  this.state = state;                  this.state = state;
1985                    
1986                    throw new RuntimeException("Old concept.. migrate to new concept!");
1987    
1988                  zoomMapPaneMouseListener.setEnabled((state == ZOOM_IN  //              xMapPaneMouseListener.setEnabled((state == ZOOM_IN
1989                                  || state == ZOOM_OUT || state == PAN));  //                              || state == ZOOM_OUT || state == PAN));
1990    
1991                  // Je nach Aktion den Cursor umsetzen                  // Je nach Aktion den Cursor umsetzen
1992                  updateCursor();  //              updateCursor();
1993            }
1994            
1995            public void configureMouse(MouseInputType type, XMapPaneAction action){
1996                    
1997          }          }
1998    
1999          /**          /**
# Line 1938  public class XMapPane extends JPanel { Line 2018  public class XMapPane extends JPanel {
2018          private void startRendering() {          private void startRendering() {
2019    
2020                  if (!isWellDefined() || !acceptsRepaintCalls) {                  if (!isWellDefined() || !acceptsRepaintCalls) {
2021                            // if we are not ready to start rendering, try it again the next
2022                            // time the timer is chacking the flag.
2023                          requestStartRendering = true;                          requestStartRendering = true;
2024                          return;                          return;
2025                  }                  }
# Line 1947  public class XMapPane extends JPanel { Line 2029  public class XMapPane extends JPanel {
2029                          bgExecuter.cancelTask();                          bgExecuter.cancelTask();
2030                  }                  }
2031    
2032                  if (localExecuter != null) {                  localExecuter.cancelTask();
                         localExecuter.cancelTask();  
                 }  
2033    
2034                  final Rectangle curPaintArea = getVisibleRect();                  final Rectangle curPaintArea = getVisibleRect();
2035    
# Line 1976  public class XMapPane extends JPanel { Line 2056  public class XMapPane extends JPanel {
2056                          // localExecuter = new RenderingExecutor(this, 150l);                          // localExecuter = new RenderingExecutor(this, 150l);
2057                          // LOGGER.debug("starting local renderer:");                          // LOGGER.debug("starting local renderer:");
2058    
2059                          localRenderer.setJava2DHints(getJava2dHints());                          getLocalRenderer().setJava2DHints(getJava2dHints());
2060                          localRenderer.setRendererHints(getRendererHints());                          getLocalRenderer().setRendererHints(getRendererHints());
2061    
2062                          final boolean submitted = localExecuter.submit(getMapArea(),                          final boolean submitted = localExecuter.submit(getMapArea(),
2063                                          curPaintArea, (Graphics2D) getLocalImage().getGraphics(),                                          curPaintArea, (Graphics2D) getLocalImage().getGraphics(),
2064                                          localRenderer                                          getLocalRenderer());
                         // , getWorldToScreenTransform()  
                                         );  
2065                          if (submitted)                          if (submitted)
2066                                  repaintTimer.restart();                                  repaintTimer.restart();
2067                          else                          else
# Line 1995  public class XMapPane extends JPanel { Line 2073  public class XMapPane extends JPanel {
2073                  updateCursor();                  updateCursor();
2074          }          }
2075    
2076            private RenderingHints getJava2dHints() {
2077                    return java2dHints;
2078            }
2079    
2080          /**          /**
2081           * Transformiert einen Geo-Koordinaten-Bereich in Fenster-Koordinaten.           * Transformiert einen Geo-Koordinaten-Bereich in Fenster-Koordinaten.
2082           *           *
# Line 2058  public class XMapPane extends JPanel { Line 2140  public class XMapPane extends JPanel {
2140                  // if the renderers have stopped, also stop the timer that is updating                  // if the renderers have stopped, also stop the timer that is updating
2141                  // the final image                  // the final image
2142                  if (bgExecuter != null && bgExecuter.isRunning()                  if (bgExecuter != null && bgExecuter.isRunning()
2143                                  || localExecuter != null && localExecuter.isRunning()) {                                  || localExecuter.isRunning()) {
2144                          setCursor(WAIT_CURSOR);                          setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
2145                          return;                          return;
2146                  } else {                  } else {
2147                          // Allow one last rendering                          // Allow one last rendering
# Line 2134  public class XMapPane extends JPanel { Line 2216  public class XMapPane extends JPanel {
2216                  finalG.drawImage(getPreFinalImage(), imageOrigin.x, imageOrigin.y,                  finalG.drawImage(getPreFinalImage(), imageOrigin.x, imageOrigin.y,
2217                                  getMapBackgroundColor(), null);                                  getMapBackgroundColor(), null);
2218    
2219                  final int finalImageHeight = getFinalImage().getHeight(null);                  // When panning, we have to clear the area around the image
                 final int finalImageWidth = getFinalImage().getWidth(null);  
   
2220                  final Rectangle painedArea = new Rectangle(imageOrigin.x,                  final Rectangle painedArea = new Rectangle(imageOrigin.x,
2221                                  imageOrigin.y, finalImageWidth, finalImageHeight);                                  imageOrigin.y, getFinalImage().getWidth(), getFinalImage()
2222                  SwingUtil.clearAround(finalG, painedArea, getVisibleRect());                                                  .getHeight());
2223                    SwingUtil.clearAround(finalG, painedArea, getVisibleRect(),
2224                                    getMapBackgroundColor());
2225    
2226                  addGadgets(finalG, false);                  addGadgets(finalG, false);
2227    
# Line 2158  public class XMapPane extends JPanel { Line 2240  public class XMapPane extends JPanel {
2240           *            <code>false</code>, it will only depend on           *            <code>false</code>, it will only depend on
2241           *            {@link #localExecuter.isRunning} and #bgExecuter.isRunning           *            {@link #localExecuter.isRunning} and #bgExecuter.isRunning
2242           */           */
2243          private void addGadgets(final Graphics2D graphics, boolean forceWait) {          private void addGadgets(final Graphics2D graphics, final boolean forceWait) {
2244    
2245                  // Paint a logo to the bottom right if available                  // Paint a logo to the bottom right if available
2246                  if (mapImage != null) {                  if (mapImage != null) {
2247                          Rectangle visibleRect = getVisibleRect();                          final Rectangle visibleRect = getVisibleRect();
2248                          graphics.drawImage(mapImage, visibleRect.width                          graphics.drawImage(mapImage, visibleRect.width
2249                                          - mapImage.getWidth() - 10, getVisibleRect().height                                          - mapImage.getWidth() - 10, getVisibleRect().height
2250                                          - mapImage.getHeight() - 10, null);                                          - mapImage.getHeight() - 10, null);
# Line 2172  public class XMapPane extends JPanel { Line 2254  public class XMapPane extends JPanel {
2254    
2255                  // If the rendering process is still running, indicate this is the image                  // If the rendering process is still running, indicate this is the image
2256                  if (forceWait || bgExecuter != null && bgExecuter.isRunning()                  if (forceWait || bgExecuter != null && bgExecuter.isRunning()
2257                                  || localExecuter != null && localExecuter.isRunning()) {                                  || localExecuter.isRunning()) {
2258    
2259                          y += 8;                          y += 8;
2260    
# Line 2188  public class XMapPane extends JPanel { Line 2270  public class XMapPane extends JPanel {
2270    
2271                          graphics.setColor(c);                          graphics.setColor(c);
2272    
2273                          y += 24;                          y += 21;
2274                  }                  }
2275    
2276                  if (renderingErrors != null) {                  if (!renderingErrors.isEmpty() && isShowExceptions()) {
2277    
2278                          final Color c = graphics.getColor();                          final Color c = graphics.getColor();
2279                          graphics.setFont(errorFont);                          graphics.setFont(errorFont);
2280    
2281                          for (Exception ex : renderingErrors) {                          for (final Exception ex : renderingErrors) {
   
                                 if (ex instanceof java.lang.IllegalArgumentException  
                                                 && ex.getMessage().equals(  
                                                                 "Argument \"sourceCRS\" should not be null."))  
                                         continue;  
2282    
2283                                  String errStr = ex.getLocalizedMessage();                                  String errStr = ex.getLocalizedMessage();
2284    
# Line 2210  public class XMapPane extends JPanel { Line 2287  public class XMapPane extends JPanel {
2287                                  if (errStr == null)                                  if (errStr == null)
2288                                          errStr = "unknown error: " + ex.getClass().getSimpleName();                                          errStr = "unknown error: " + ex.getClass().getSimpleName();
2289    
2290                                  graphics.setColor(Color.WHITE);                                  graphics.setColor(getMapBackgroundColor());
2291                                  graphics.drawString(errStr, 5, y);                                  graphics.drawString(errStr, 5, y);
2292                                  graphics.setColor(Color.RED);                                  graphics.setColor(Color.RED);
2293                                  graphics.drawString(errStr, 6, y + 1);                                  graphics.drawString(errStr, 6, y + 1);
# Line 2238  public class XMapPane extends JPanel { Line 2315  public class XMapPane extends JPanel {
2315                  final CoordinateReferenceSystem mapCRS = getMapContext()                  final CoordinateReferenceSystem mapCRS = getMapContext()
2316                                  .getCoordinateReferenceSystem();                                  .getCoordinateReferenceSystem();
2317                  final CoordinateReferenceSystem fCRS = features.getSchema()                  final CoordinateReferenceSystem fCRS = features.getSchema()
2318                                  .getGeometryDescriptor().getCoordinateReferenceSystem();                                  .getCoordinateReferenceSystem();
2319    
2320                  ReferencedEnvelope _mapArea;                  ReferencedEnvelope _mapArea;
2321                  if (mapArea == null)                  if (mapArea == null)
2322                          _mapArea = features.getBounds();                          _mapArea = features.getBounds();
2323                  else _mapArea = getMapArea();                  else
2324                            _mapArea = getMapArea();
2325                  double width = _mapArea.getWidth();                  double width = _mapArea.getWidth();
2326                  double height = _mapArea.getHeight();                  double height = _mapArea.getHeight();
2327                  final double ratio = height / width;                  final double ratio = height / width;
# Line 2330  public class XMapPane extends JPanel { Line 2408  public class XMapPane extends JPanel {
2408           * @param center           * @param center
2409           *            position in window coordinates           *            position in window coordinates
2410           * @param zoomFaktor           * @param zoomFaktor
2411           *            > 1 for zoom in, < 1 for zoom out. Default is 1.33.           *            > 1 for zoom out, < 1 for zoom in. Default is .5
2412           */           */
2413          public void zoomTo(Point center, Double zoomFaktor) {          public void zoomTo(Point center, Double zoomFaktor) {
2414                  if (zoomFaktor == null || zoomFaktor == 0.)                  if (zoomFaktor == null || zoomFaktor == 0.)
2415                          zoomFaktor = 2.;                          zoomFaktor = .5;
2416    
2417                  final Point2D gcenter = getScreenToWorld().transform(center, null);                  final Point2D gcenter = getScreenToWorld().transform(center, null);
2418                  center = null;                  center = null;
# Line 2355  public class XMapPane extends JPanel { Line 2433  public class XMapPane extends JPanel {
2433                                  .getWidth()) / 2., (mapArea.getHeight() * zoomFaktor - mapArea                                  .getWidth()) / 2., (mapArea.getHeight() * zoomFaktor - mapArea
2434                                  .getHeight()) / 2.);                                  .getHeight()) / 2.);
2435    
2436                  // TODO we actually want that                  // // Move the newMapArea above the new center if we zoom in:
2437                  // // Move the newMapArea above the new center                  newMapArea.translate(gcenter.getX() - mapArea.centre().x, gcenter
2438                  // newMapArea.translate(gcenter.getX() - mapArea.centre().x, gcenter                                  .getY()
2439                  // .getY()                                  - mapArea.centre().y);
                 // - mapArea.centre().y);  
2440    
2441                  setMapArea(newMapArea);                  setMapArea(newMapArea);
2442          }          }
2443    
2444            /**
2445             * Shall non-fatal rendering exceptions be reported in the mappane or be
2446             * dropped quitely.
2447             */
2448            public void setShowExceptions(final boolean showExceptions) {
2449                    this.showExceptions = showExceptions;
2450            }
2451    
2452            /**
2453             * Shall exceptions be reported in the mappane?
2454             */
2455            public boolean isShowExceptions() {
2456                    return showExceptions;
2457            }
2458    
2459            public GTRenderer getLocalRenderer() {
2460                    return localRenderer;
2461            }
2462    
2463            /**
2464             * Setzt den Kartenausschnitt auf die Ausdehnung eines bestimmten Layers.
2465             * Macht nichts, wenn {@code null} uebergeben wird.
2466             *
2467             * <br>
2468             *
2469             * @param layer
2470             *            ein Layer
2471             */
2472            public void zoomToLayer(MapLayer layer) {
2473                    if (layer == null)
2474                            return;
2475                    try {
2476    
2477                            // BB umrechnen von Layer-CRS in Map-CRS
2478                            final CoordinateReferenceSystem targetCRS = getMapContext()
2479                                            .getCoordinateReferenceSystem();
2480                            final CoordinateReferenceSystem sourceCRS = layer
2481                                            .getFeatureSource().getSchema()
2482                                            .getCoordinateReferenceSystem();
2483    
2484                            Envelope mapAreaNew;
2485                            if (!CRS.equalsIgnoreMetadata(sourceCRS, targetCRS)) {
2486                                    mapAreaNew = JTSUtil.transformEnvelope(layer.getFeatureSource()
2487                                                    .getBounds(), sourceCRS, targetCRS);
2488                            } else {
2489                                    try {
2490                                            mapAreaNew = layer.getFeatureSource().getBounds();
2491                                    } catch (java.lang.IllegalArgumentException e) {
2492                                            LOGGER.error("Can't calc layers bounds...", e);
2493                                            mapAreaNew = null;
2494    
2495                                            /**
2496                                             *
2497                                             23.10.2009 11:20:50
2498                                             * org.geotools.data.shapefile.shp.PolygonHandler read
2499                                             * WARNUNG: only one hole in this polygon record ERROR
2500                                             * JMapPane zoomToLayer Zoom to layer did not terminate
2501                                             * correctly java.lang.IllegalArgumentException: Points of
2502                                             * LinearRing do not form a closed linestring at
2503                                             * com.vividsolutions
2504                                             * .jts.geom.LinearRing.validateConstruction
2505                                             * (LinearRing.java:105) at
2506                                             * com.vividsolutions.jts.geom.LinearRing
2507                                             * .<init>(LinearRing.java:100) at
2508                                             * com.vividsolutions.jts.geom
2509                                             * .GeometryFactory.createLinearRing
2510                                             * (GeometryFactory.java:339) at
2511                                             * org.geotools.data.shapefile.
2512                                             * shp.PolygonHandler.read(PolygonHandler.java:188) at
2513                                             * org.geotools
2514                                             * .data.shapefile.shp.ShapefileReader$Record.shape
2515                                             * (ShapefileReader.java:106) at
2516                                             * org.geotools.data.shapefile.
2517                                             * ShapefileAttributeReader.next(
2518                                             * ShapefileAttributeReader.java:157) at
2519                                             * org.geotools.data.shapefile
2520                                             * .indexed.IndexedShapefileAttributeReader
2521                                             * .next(IndexedShapefileAttributeReader.java:122) at
2522                                             * org.geotools
2523                                             * .data.FIDFeatureReader.next(FIDFeatureReader.java:96) at
2524                                             * org.geotools.data.FIDFeatureReader.next(FIDFeatureReader.
2525                                             * java:55) at org.geotools.data.MaxFeatureReader.next(
2526                                             * MaxFeatureReader.java:61) at
2527                                             * org.geotools.data.MaxFeatureReader
2528                                             * .next(MaxFeatureReader.java:61)
2529                                             **/
2530                                    }
2531                            }
2532    
2533                            // Kartenbereich um 10% vergroessern, damit z.B. auch ein
2534                            // Punkt-Layer,
2535                            // welches nur aus 2 Punnkten besteht, sichtbar ist (Punkte liegen
2536                            // sonst
2537                            // genau auf dem Rand der angezeigten Flaeche)
2538    
2539                            if (mapAreaNew != null) {
2540                                    mapAreaNew.expandBy(mapAreaNew.getWidth() * 0.1, mapAreaNew
2541                                                    .getHeight() * 0.1);
2542                                    setMapArea(mapAreaNew);
2543                            } else {
2544                                    LOGGER
2545                                                    .warn("Couldn't transformEnvelope when zooming to the layer");
2546                            }
2547                    } catch (Exception err) {
2548                            LOGGER.error("Zoom to layer did not terminate correctly", err);
2549                    }
2550            }
2551    
2552            /**
2553             * Zooms the {@link SelectableXMapPane} to the {@link Envelope} of a layer.
2554             *
2555             * <br>
2556             * A refresh of the map is not done automatically
2557             *
2558             * @param index
2559             *            Index of the {@link MapLayer} in the {@link MapContext} (from
2560             *            back to top)
2561             *
2562             * @author <a href="mailto:[email protected]">Stefan Alfons
2563             *         Kr&uuml;ger</a>
2564             */
2565            public void zoomToLayer(int index) {
2566                    final MapContext context = getMapContext();
2567                    if (context != null)
2568                            zoomToLayer(context.getLayer(index));
2569            }
2570    
2571            /**
2572             * Zooms the {@link SelectableXMapPane} to the {@link Envelope} of the
2573             * selected layer. The layer is selected by the idx, counting from front to
2574             * back, like humans would expect in a {@link JList}
2575             *
2576             * <br>
2577             * A refresh of the map is not done automatically
2578             *
2579             *
2580             *
2581             * @param index
2582             *            Reverse index of the {@link MapLayer} in the
2583             *            {@link MapContext}
2584             *
2585             * @author <a href="mailto:[email protected]">Stefan Alfons
2586             *         Kr&uuml;ger</a>
2587             */
2588            public void zoomToLayerIdxReverse(int index) {
2589                    zoomToLayer(getMapContext().getLayerCount() - 1 - index);
2590            }
2591    
2592            /**
2593             * Aktiviert oder deaktiviert das AntiAliasing for diese
2594             * {@link SelectableXMapPane}. AntiALiasing ist besonders fuer
2595             * Textbeschriftung sehr schoen, verbraucht aber auch mehr Performance.
2596             *
2597             * @author <a href="mailto:[email protected]">Stefan Alfons
2598             *         Kr&uuml;ger</a>
2599             */
2600            public void setAntiAliasing(final boolean aa) {
2601                    // LOGGER.info("Setting AntiAliasing for this JMapPane to " + aa);
2602                    RenderingHints java2DHints = java2dHints;
2603                    if (java2DHints == null) {
2604                            java2DHints = GeoTools.getDefaultHints();
2605                    }
2606    
2607                    java2DHints.put(RenderingHints.KEY_ANTIALIASING,
2608                                    aa ? RenderingHints.VALUE_ANTIALIAS_ON
2609                                                    : RenderingHints.VALUE_ANTIALIAS_OFF);
2610                    java2DHints.put(RenderingHints.KEY_TEXT_ANTIALIASING,
2611                                    aa ? RenderingHints.VALUE_TEXT_ANTIALIAS_ON
2612                                                    : RenderingHints.VALUE_TEXT_ANTIALIAS_OFF);
2613                    java2DHints.put(RenderingHints.KEY_RENDERING,
2614                                    aa ? RenderingHints.VALUE_RENDER_QUALITY
2615                                                    : RenderingHints.VALUE_RENDER_SPEED);
2616    
2617            }
2618    
2619  }  }

Legend:
Removed from v.551  
changed lines
  Added in v.639

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26