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

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

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

revision 509 by alfonx, Thu Nov 5 08:51:33 2009 UTC revision 516 by alfonx, Wed Nov 11 21:17:33 2009 UTC
# Line 22  package gtmig.org.geotools.swing; Line 22  package gtmig.org.geotools.swing;
22    
23  import java.awt.AlphaComposite;  import java.awt.AlphaComposite;
24  import java.awt.Color;  import java.awt.Color;
 import java.awt.Composite;  
25  import java.awt.Cursor;  import java.awt.Cursor;
26  import java.awt.Font;  import java.awt.Font;
27  import java.awt.Graphics;  import java.awt.Graphics;
# Line 175  public class XMapPane extends JPanel imp Line 174  public class XMapPane extends JPanel imp
174           * @see #setState(int)           * @see #setState(int)
175           */           */
176          public static final int SELECT_ONE_FROM_TOP = 104;          public static final int SELECT_ONE_FROM_TOP = 104;
177    //
178    //      /**
179    //       * While threads are working, we call {@link XMapPane#updateFinalImage()}
180    //       * regularly and repaint(). This {@link Timer} is stopped when all renderers
181    //       * have finished.
182    //       */
183    //      final private Timer repainterTimer;
184    //
185    //      /**
186    //       * While the {@link #bgExecuter} and {@link #localExecuter} are rendering,
187    //       * the {@link #repainterTimer} is regularly updating the {@link #finalImage}
188    //       * with previews.
189    //       */
190    //      public static final long REPEATING_REPAINT_DELAY = 500;
191    //      
192    //      /**
193    //       * The initial delay in milliseconds until the {@link #finalImage} is updated the first time.  
194    //       */
195    //      public static final long INITIAL_REPAINT_DELAY = 333;
196    
197          public static final long DEFAULT_REPAINTING_DELAY = 200;          protected RenderingExecutor bgExecuter;
   
         protected skrueger.geotools.RenderingExecutor bgExecuter;  
198    
199          /**          /**
200           * the map context to render           * the map context to render
# Line 219  public class XMapPane extends JPanel imp Line 235  public class XMapPane extends JPanel imp
235          /**          /**
236           * compass and icon are rendered into this image           * compass and icon are rendered into this image
237           */           */
238  //      protected BufferedImage gadgetsImage;          // protected BufferedImage gadgetsImage;
239    
240          /**          /**
241           * The default state is ZOOM_IN, hence by default the           * The default state is ZOOM_IN, hence by default the
# Line 248  public class XMapPane extends JPanel imp Line 264  public class XMapPane extends JPanel imp
264    
265                  // aktuelle Geo-Position ueber Transformation des JMapPane berechnen                  // aktuelle Geo-Position ueber Transformation des JMapPane berechnen
266                  if (e != null && e.getSource() instanceof XMapPane) {                  if (e != null && e.getSource() instanceof XMapPane) {
267                            
268                          final XMapPane xMapPane = (XMapPane) e.getSource();                          final XMapPane xMapPane = (XMapPane) e.getSource();
269                            
270                          if (!xMapPane.isWellDefined()) return null;                          if (!xMapPane.isWellDefined())
271                                                            return null;
272    
273                          AffineTransform at = xMapPane.getScreenToWorld();                          AffineTransform at = xMapPane.getScreenToWorld();
274                          if (at != null)                          if (at != null)
275                                  return at.transform(e.getPoint(), null);                                  return at.transform(e.getPoint(), null);
# Line 297  public class XMapPane extends JPanel imp Line 314  public class XMapPane extends JPanel imp
314          protected boolean paneResized = false;          protected boolean paneResized = false;
315    
316          /**          /**
          * While threads are working, we call {@link XMapPane#updateFinalImage()}  
          * regularly and repaint(). This {@link Timer} is stoppen when all renderers  
          * finished.  
          */  
         final private Timer repainterTimer;  
   
         /**  
317           * The flag {@link #requestStartRendering} can be set to true by events.           * The flag {@link #requestStartRendering} can be set to true by events.
318           * This {@link Timer} checks the flag regularly and starts one renderer           * This {@link Timer} checks the flag regularly and starts one renderer
319           * thread.           * thread.
# Line 405  public class XMapPane extends JPanel imp Line 415  public class XMapPane extends JPanel imp
415    
416                  });                  });
417    
418                  repainterTimer = new Timer((int) DEFAULT_REPAINTING_DELAY,  //              repainterTimer = new Timer((int) REPEATING_REPAINT_DELAY,
419                                  new ActionListener() {  //                              new ActionListener() {
420    //
421                                          @Override  //                                      @Override
422                                          public void actionPerformed(ActionEvent e) {  //                                      public void actionPerformed(ActionEvent e) {
423                                                  updateFinalImage();  //                                              updateFinalImage();
424                                                  XMapPane.this.repaint(DEFAULT_REPAINTING_DELAY);  //                                              XMapPane.this.repaint();
425                                          }  //                                      }
426                                  });  //                              });
427                  repainterTimer.setInitialDelay(1000);  //              repainterTimer.setInitialDelay(300);
428                  repainterTimer.setRepeats(true);  //              repainterTimer.setRepeats(true);
429    
430                  startRenderThreadsTimer = new Timer(200, new ActionListener() {                  startRenderThreadsTimer = new Timer(200, new ActionListener() {
431    
# Line 533  public class XMapPane extends JPanel imp Line 543  public class XMapPane extends JPanel imp
543           * {@link XMapPane} is visible and has bounds set.           * {@link XMapPane} is visible and has bounds set.
544           */           */
545          public boolean isWellDefined() {          public boolean isWellDefined() {
546                    
547                  try {                  try {
548                            
549                  if (getContext() == null)                          if (getContext() == null)
550                          return false;                                  return false;
551                  if (getContext().getLayerCount() <= 0)                          if (getContext().getLayerCount() <= 0)
552                          return false;                                  return false;
553                  if (getMapArea() == null)                          if (getMapArea() == null)
554                          return false;                                  return false;
555                  if (getBounds().getWidth() == 0)                          if (getBounds().getWidth() == 0)
556                          return false;                                  return false;
557                  if (getBounds().getHeight() == 0)                          if (getBounds().getHeight() == 0)
558                          return false;                                  return false;
559                  } catch (Exception e) {                  } catch (Exception e) {
560                          return false;                          return false;
561                  }                  }
# Line 603  public class XMapPane extends JPanel imp Line 613  public class XMapPane extends JPanel imp
613          /**          /**
614           * Abhaengig von selState wird der Cursor gesetzt           * Abhaengig von selState wird der Cursor gesetzt
615           */           */
616          public void updateCursorAndRepaintTimer() {          public void updateCursor() {
617    
618                  if (bgExecuter != null && bgExecuter.isRunning()                  if (bgExecuter != null && bgExecuter.isRunning()
619                                  || localExecuter != null && localExecuter.isRunning()) {                                  || localExecuter != null && localExecuter.isRunning()) {
620                          setCursor(WAIT_CURSOR);                          setCursor(WAIT_CURSOR);
621                          return;                          return;
622                  } else {                  } else {
623                          // Allow one last rendering  //                      // Allow one last rendering
624                          if (repainterTimer.isRunning()) {  //                      if (repainterTimer.isRunning()) {
625                                  repainterTimer.stop();  //                              repainterTimer.stop();
626                                  updateFinalImage();  //                              updateFinalImage();
627                                  repaint();  //                              repaint();
628                          }  //                      }
629                  }                  }
630    
631                  // wenn manueller Cursor gesetzt ist, dann diesen verwenden (unabhaengig                  // wenn manueller Cursor gesetzt ist, dann diesen verwenden (unabhaengig
# Line 1016  public class XMapPane extends JPanel imp Line 1026  public class XMapPane extends JPanel imp
1026                          return false;                          return false;
1027                  }                  }
1028    
1029                  // Testen, ob der Unterschied nur im minimalen Rundungsfehlerbereich                  // Testing, whether NaN or Infinity are used in the newMapArea
1030                  // liegt                  if (newMapArea.isNull() || Double.isInfinite(newMapArea.getMaxX())
1031                                    || Double.isInfinite(newMapArea.getMaxY())
1032                                    || Double.isInfinite(newMapArea.getMinX())
1033                                    || Double.isInfinite(newMapArea.getMinY())) {
1034                            // No change.. ugly new values
1035                            LOGGER.warn("setMapArea has been called with newArea = "
1036                                            + newMapArea);
1037                            return false;
1038                    }
1039    
1040                    // Testing, whether the difference if just minimal
1041                  if (mapArea != null) {                  if (mapArea != null) {
1042                          Envelope candNew = bestAllowedMapArea(newMapArea);                          Envelope candNew = bestAllowedMapArea(newMapArea);
1043                          double tolX = mapArea.getWidth() / 1000.;                          double tolX = mapArea.getWidth() / 1000.;
# Line 1041  public class XMapPane extends JPanel imp Line 1061  public class XMapPane extends JPanel imp
1061    
1062                  oldMapArea = mapArea;                  oldMapArea = mapArea;
1063    
                 System.out.println("requested setting to \\t" + newMapArea);  
1064                  this.mapArea = bestAllowedMapArea(newMapArea);                  this.mapArea = bestAllowedMapArea(newMapArea);
                 System.out.println("set to \\t\\ŧ" + newMapArea);  
1065    
1066                  if (localContext != null) {                  if (localContext != null) {
1067                          localContext.setAreaOfInterest(mapArea, localContext                          localContext.setAreaOfInterest(mapArea, localContext
# Line 1057  public class XMapPane extends JPanel imp Line 1075  public class XMapPane extends JPanel imp
1075                  mapImageInvalid = true;                  mapImageInvalid = true;
1076                  mapAreaChanged = true;                  mapAreaChanged = true;
1077                  repaint();                  repaint();
1078    
1079    //              LOGGER.debug("New maparea = " + mapArea);
1080                  return true;                  return true;
1081          }          }
1082    
# Line 1077  public class XMapPane extends JPanel imp Line 1097  public class XMapPane extends JPanel imp
1097                                  || state == ZOOM_OUT || state == PAN));                                  || state == ZOOM_OUT || state == PAN));
1098    
1099                  // Je nach Aktion den Cursor umsetzen                  // Je nach Aktion den Cursor umsetzen
1100                  updateCursorAndRepaintTimer();                  updateCursor();
1101          }          }
1102    
1103          /** Cursor wenn kein Mausbutton gedrueckt wird. default oder SwingUtil.PAN **/          /** Cursor wenn kein Mausbutton gedrueckt wird. default oder SwingUtil.PAN **/
# Line 1109  public class XMapPane extends JPanel imp Line 1129  public class XMapPane extends JPanel imp
1129    
1130          protected void paintComponent(final Graphics g) {          protected void paintComponent(final Graphics g) {
1131                  // Maybe update the cursor                  // Maybe update the cursor
1132                  updateCursorAndRepaintTimer();                  updateCursor();
1133    
1134                  if (!acceptsRepaintCalls)                  if (!acceptsRepaintCalls)
1135                          return;                          return;
# Line 1145  public class XMapPane extends JPanel imp Line 1165  public class XMapPane extends JPanel imp
1165                                  finalImage = null;                                  finalImage = null;
1166                                  localImage = null;                                  localImage = null;
1167                                  bgImage = null;                                  bgImage = null;
1168  //                              gadgetsImage = null;                                  // gadgetsImage = null;
1169                          }                          }
1170    
1171                          // Start the Threads and Timers to render the image                          // Start the Threads and Timers to render the image
# Line 1274  public class XMapPane extends JPanel imp Line 1294  public class XMapPane extends JPanel imp
1294                                  (int) visibleArea.getMinX(), (int) visibleArea.getMinY(),                                  (int) visibleArea.getMinX(), (int) visibleArea.getMinY(),
1295                                  (int) visibleArea.getMaxX(), (int) visibleArea.getMaxY(),                                  (int) visibleArea.getMaxX(), (int) visibleArea.getMaxY(),
1296                                  getMapBackgroundColor(), null);                                  getMapBackgroundColor(), null);
                   
1297    
1298                  Rectangle painedArea = new Rectangle(xx1, yy1, xx2 - xx1, yy2 - yy1);                  Rectangle painedArea = new Rectangle(xx1, yy1, xx2 - xx1, yy2 - yy1);
1299    
1300                  SwingUtil.clearAround(graphics, painedArea, visibleArea);                  SwingUtil.clearAround(graphics, painedArea, visibleArea);
1301                    
1302                  addGadgets(graphics);                  addGadgets(graphics);
1303  //              graphics.drawImage(getGadgetsImage(), 0,0, (int) visibleArea.getMaxX(), (int) visibleArea.getMaxY(),null);                  // graphics.drawImage(getGadgetsImage(), 0,0, (int)
1304                    // visibleArea.getMaxX(), (int) visibleArea.getMaxY(),null);
1305    
1306                  quickPreviewHint = 0;                  quickPreviewHint = 0;
1307    
# Line 1289  public class XMapPane extends JPanel imp Line 1309  public class XMapPane extends JPanel imp
1309                  // Something has been drawn                  // Something has been drawn
1310                  return true;                  return true;
1311          }          }
1312            
1313          final static Font waitFont = new Font("Arial", Font.BOLD, 30);          final static Font waitFont = new Font("Arial", Font.BOLD, 30);
1314    
1315          /**          /**
1316           * Paints some optinal stuff into the given {@link Graphics2D}. Usually called as the last paint on the mapImage.           * Paints some optinal stuff into the given {@link Graphics2D}. Usually
1317             * called as the last paint on the mapImage.
1318           */           */
1319          private void addGadgets(Graphics2D graphics) {          private void addGadgets(Graphics2D graphics) {
1320    
1321                  if (mapImage != null)                  if (mapImage != null)
1322                          graphics.drawImage(mapImage,                          graphics.drawImage(mapImage, getBounds().width
1323                                          getBounds().width - mapImage.getWidth() - 10,                                          - mapImage.getWidth() - 10, getBounds().height
1324                                          getBounds().height - mapImage.getHeight() - 10, this);                                          - mapImage.getHeight() - 10, this);
1325    
1326                  // If still rendering, paint a gray shadow or so...                  // If still rendering, paint a gray shadow or so...
1327                  if (bgExecuter != null && bgExecuter.isRunning()                  if (bgExecuter != null && bgExecuter.isRunning()
1328                                  || localExecuter != null && localExecuter.isRunning()) {                                  || localExecuter != null && localExecuter.isRunning()) {
1329                          graphics.setColor(Color.BLACK);                          graphics.setColor(Color.BLACK);
1330                            
1331                          graphics.setFont(waitFont);                          graphics.setFont(waitFont);
1332                          graphics.drawString("Wait...", 40, 70);                          graphics.drawString("Wait...", 40, 70);
1333                  }                  }
1334                    
1335          }          }
1336    
1337          /**          /**
# Line 1322  public class XMapPane extends JPanel imp Line 1343  public class XMapPane extends JPanel imp
1343    
1344                  final Graphics2D finalG = (Graphics2D) getFinalImage().getGraphics();                  final Graphics2D finalG = (Graphics2D) getFinalImage().getGraphics();
1345                  finalG.setBackground(getMapBackgroundColor());                  finalG.setBackground(getMapBackgroundColor());
1346                    
                   
1347                  // Render the two map images first, into the preFinalImage                  // Render the two map images first, into the preFinalImage
1348                  {                  {
1349                          final Graphics2D preFinalG = (Graphics2D) getPreFinalImage().getGraphics();                          final Graphics2D preFinalG = (Graphics2D) getPreFinalImage()
1350                                            .getGraphics();
1351                          preFinalG.setBackground(getMapBackgroundColor());                          preFinalG.setBackground(getMapBackgroundColor());
1352                            
1353                          preFinalG.drawImage(getBgImage(), 0, 0,                          preFinalG.drawImage(getBgImage(), 0, 0, getMapBackgroundColor(),
1354                                          getMapBackgroundColor(), null);                                          null);
1355                          // // Draw the local layers image                          // // Draw the local layers image
1356                          preFinalG.drawImage(getLocalImage(), 0, 0, null);                          preFinalG.drawImage(getLocalImage(), 0, 0, null);
1357                          preFinalG.dispose();                          preFinalG.dispose();
1358                  }                  }
1359                    
1360                  finalG.drawImage(getPreFinalImage(), imageOrigin.x, imageOrigin.y,                  finalG.drawImage(getPreFinalImage(), imageOrigin.x, imageOrigin.y,
1361                                  getMapBackgroundColor(), null);                                  getMapBackgroundColor(), null);
1362    
# Line 1360  public class XMapPane extends JPanel imp Line 1381  public class XMapPane extends JPanel imp
1381                  SwingUtil.clearAround(finalG, painedArea, getVisibleRect());                  SwingUtil.clearAround(finalG, painedArea, getVisibleRect());
1382    
1383                  addGadgets(finalG);                  addGadgets(finalG);
1384  //              finalG.drawImage(getGadgetsImage(), 0, 0, null);                  // finalG.drawImage(getGadgetsImage(), 0, 0, null);
1385    
1386                  finalG.dispose();                  finalG.dispose();
1387    
# Line 1388  public class XMapPane extends JPanel imp Line 1409  public class XMapPane extends JPanel imp
1409                  }                  }
1410                  return finalImage;                  return finalImage;
1411          }          }
1412            
1413          private Image getPreFinalImage() {          private Image getPreFinalImage() {
1414                    
1415                  if (preFinalImage == null) {                  if (preFinalImage == null) {
1416                          preFinalImage = null;                          preFinalImage = null;
1417                          Rectangle curPaintArea = getVisibleRect();                          Rectangle curPaintArea = getVisibleRect();
1418    
1419                          preFinalImage = new BufferedImage(curPaintArea.width,                          preFinalImage = new BufferedImage(curPaintArea.width,
1420                                          curPaintArea.height, BufferedImage.TYPE_INT_RGB);                                          curPaintArea.height, BufferedImage.TYPE_INT_RGB);
1421                            
1422                          requestStartRendering();                          requestStartRendering();
1423                  }                  }
1424                  return preFinalImage;                  return preFinalImage;
# Line 1464  public class XMapPane extends JPanel imp Line 1485  public class XMapPane extends JPanel imp
1485                   */                   */
1486    
1487                  if (getBgContext() != null) {                  if (getBgContext() != null) {
1488                          bgExecuter = new RenderingExecutor(this);                          bgExecuter = new RenderingExecutor(this, 333l);
1489                          LOGGER.debug("starting bg renderer:");                          LOGGER.debug("starting bg renderer:");
1490                          // /* System.out.println("rendering"); */                          // /* System.out.println("rendering"); */
1491                          final GTRenderer createGTRenderer = GTUtil.createGTRenderer(                          final GTRenderer createGTRenderer = GTUtil.createGTRenderer(
# Line 1475  public class XMapPane extends JPanel imp Line 1496  public class XMapPane extends JPanel imp
1496                  }                  }
1497    
1498                  if (getContext() != null) {                  if (getContext() != null) {
1499                          localExecuter = new RenderingExecutor(this);                          localExecuter = new RenderingExecutor(this, 150l);
1500                          LOGGER.debug("starting local renderer:");                          LOGGER.debug("starting local renderer:");
1501                          final GTRenderer createGTRenderer = GTUtil.createGTRenderer(                          final GTRenderer createGTRenderer = GTUtil.createGTRenderer(
1502                                          localContext, getRendererHints());                                          localContext, getRendererHints());
# Line 1485  public class XMapPane extends JPanel imp Line 1506  public class XMapPane extends JPanel imp
1506                                          createGTRenderer);                                          createGTRenderer);
1507                  }                  }
1508    
1509                  updateCursorAndRepaintTimer();                  updateCursor();
1510    //
1511                  // start regular repaints until all renderers are done.  //              // start regular repaints until all renderers are done.
1512                  repainterTimer.setRepeats(true);  //              repainterTimer.setRepeats(true);
1513                  repainterTimer.restart();  //              repainterTimer.restart();
1514    
1515          }          }
1516    
# Line 1499  public class XMapPane extends JPanel imp Line 1520  public class XMapPane extends JPanel imp
1520          private BufferedImage getBgImage() {          private BufferedImage getBgImage() {
1521    
1522                  if (bgImage == null) {                  if (bgImage == null) {
1523                          LOGGER.debug("creating a new background image");  //                      LOGGER.debug("creating a new background image");
1524    
1525                          Rectangle curPaintArea = getVisibleRect();                          Rectangle curPaintArea = getVisibleRect();
1526                          // allow a single pixel margin at the right and bottom edges                          // allow a single pixel margin at the right and bottom edges
# Line 1536  public class XMapPane extends JPanel imp Line 1557  public class XMapPane extends JPanel imp
1557           */           */
1558          public void setMapImage(BufferedImage mapImage) {          public void setMapImage(BufferedImage mapImage) {
1559                  this.mapImage = mapImage;                  this.mapImage = mapImage;
1560  //              gadgetsImage = null;                  // gadgetsImage = null;
1561          }          }
1562    
1563          /**          /**
# Line 1545  public class XMapPane extends JPanel imp Line 1566  public class XMapPane extends JPanel imp
1566          private BufferedImage getLocalImage() {          private BufferedImage getLocalImage() {
1567    
1568                  if (localImage == null) {                  if (localImage == null) {
1569                          LOGGER.debug("creating a new local image");  //                      LOGGER.debug("creating a new local image");
1570    
1571                          Rectangle curPaintArea = getVisibleRect();                          Rectangle curPaintArea = getVisibleRect();
1572                          // allow a single pixel margin at the right and bottom edges                          // allow a single pixel margin at the right and bottom edges
# Line 1558  public class XMapPane extends JPanel imp Line 1579  public class XMapPane extends JPanel imp
1579    
1580                  return localImage;                  return localImage;
1581          }          }
1582  //  
1583  //      /**          //
1584  //       * Lazyly initializes a {@link BufferedImage} for the background renderer.          // /**
1585  //       */          // * Lazyly initializes a {@link BufferedImage} for the background renderer.
1586  //      private BufferedImage getGadgetsImage() {          // */
1587  //          // private BufferedImage getGadgetsImage() {
1588  //              if (gadgetsImage == null) {          //
1589  //                      LOGGER.debug("creating a new gadgets image");          // if (gadgetsImage == null) {
1590  //          // LOGGER.debug("creating a new gadgets image");
1591  //                      Rectangle curPaintArea = getVisibleRect();          //
1592  //                      // allow a single pixel margin at the right and bottom edges          // Rectangle curPaintArea = getVisibleRect();
1593  //                      curPaintArea.width -= 1;          // // allow a single pixel margin at the right and bottom edges
1594  //                      curPaintArea.height -= 1;          // curPaintArea.width -= 1;
1595  //          // curPaintArea.height -= 1;
1596  //                      gadgetsImage = new BufferedImage(curPaintArea.width + 1,          //
1597  //                                      curPaintArea.height + 1, BufferedImage.TYPE_INT_ARGB);          // gadgetsImage = new BufferedImage(curPaintArea.width + 1,
1598  //          // curPaintArea.height + 1, BufferedImage.TYPE_INT_ARGB);
1599  //                      if (mapImage != null)          //
1600  //                              gadgetsImage.getGraphics().drawImage(mapImage,          // if (mapImage != null)
1601  //                                              curPaintArea.width - mapImage.getWidth() - 10,          // gadgetsImage.getGraphics().drawImage(mapImage,
1602  //                                              curPaintArea.height - mapImage.getHeight() - 10, this);          // curPaintArea.width - mapImage.getWidth() - 10,
1603  //                                // curPaintArea.height - mapImage.getHeight() - 10, this);
1604  //              }          //                      
1605  //          // }
1606  //              return gadgetsImage;          //
1607  //      }          // return gadgetsImage;
1608            // }
1609    
1610          /**          /**
1611           * Called by the {@linkplain XMapPane.RenderingTask} when rendering has been           * Called by the {@linkplain XMapPane.RenderingTask} when rendering has been
# Line 1593  public class XMapPane extends JPanel imp Line 1615  public class XMapPane extends JPanel imp
1615           * @see MapPaneListener#onRenderingStopped(org.geotools.swing.event.MapPaneEvent)           * @see MapPaneListener#onRenderingStopped(org.geotools.swing.event.MapPaneEvent)
1616           */           */
1617          public void onRenderingCompleted() {          public void onRenderingCompleted() {
                 System.out.println("onRenderingCompleted");  
   
1618                  updateFinalImage();                  updateFinalImage();
   
1619                  repaint();                  repaint();
   
1620          }          }
1621    
1622          /**          /**
# Line 2009  public class XMapPane extends JPanel imp Line 2027  public class XMapPane extends JPanel imp
2027          public void dispose() {          public void dispose() {
2028                  if (isDisposed())                  if (isDisposed())
2029                          return;                          return;
2030                    
2031                    setPainting(false);
2032    
2033                  disposed = true;                  disposed = true;
2034    
# Line 2021  public class XMapPane extends JPanel imp Line 2041  public class XMapPane extends JPanel imp
2041                  }                  }
2042    
2043                  startRenderThreadsTimer.stop();                  startRenderThreadsTimer.stop();
2044                  repainterTimer.stop();  //              repainterTimer.stop();
2045    
2046                  if (bgImage != null)                  if (bgImage != null)
2047                          bgImage.flush();                          bgImage.flush();
2048                  if (localImage != null)                  if (localImage != null)
2049                          localImage.flush();                          localImage.flush();
2050  //              if (gadgetsImage != null)                  // if (gadgetsImage != null)
2051  //                      gadgetsImage.flush();                  // gadgetsImage.flush();
2052                  if (finalImage != null)                  if (finalImage != null)
2053                          finalImage.flush();                          finalImage.flush();
2054                  if (preFinalImage != null)                  if (preFinalImage != null)
# Line 2088  public class XMapPane extends JPanel imp Line 2108  public class XMapPane extends JPanel imp
2108    
2109                  Point2D gcenter = getScreenToWorld().transform(center, null);                  Point2D gcenter = getScreenToWorld().transform(center, null);
2110                  center = null;                  center = null;
2111                    
2112                  if (                  if (Double.isNaN(gcenter.getX()) || Double.isNaN(gcenter.getY())
2113                                  Double.isNaN(gcenter.getX()) || Double.isNaN(gcenter.getY())                                  || Double.isInfinite(gcenter.getX())
2114                                  ||                                  || Double.isInfinite(gcenter.getY())
2115                                  Double.isInfinite(gcenter.getX()) || Double.isInfinite(gcenter.getY())  
                                   
2116                  ) {                  ) {
2117                          // Not inside valid CRS area! cancel                          // Not inside valid CRS area! cancel
2118                          return;                          return;
2119                  }                  }
2120    
2121                  final Envelope mapArea = getMapArea();                  final Envelope mapArea = getMapArea();
2122                    
2123                  Envelope newMapArea = new Envelope(mapArea);                  Envelope newMapArea = new Envelope(mapArea);
2124                  newMapArea                  newMapArea.expandBy((mapArea.getWidth() * zoomFaktor - mapArea
2125                                  .expandBy((mapArea.getWidth() * zoomFaktor - mapArea                                  .getWidth()) / 2., (mapArea.getHeight() * zoomFaktor - mapArea
2126                                                  .getWidth()) / 2., (mapArea.getHeight()                                  .getHeight()) / 2.);
                                                 * zoomFaktor - mapArea.getHeight()) / 2.);  
2127    
2128                  // Move the newMapArea above the new center                  // Move the newMapArea above the new center
2129                  newMapArea.translate(gcenter.getX() - mapArea.centre().x, gcenter.getY()                  newMapArea.translate(gcenter.getX() - mapArea.centre().x, gcenter
2130                                    .getY()
2131                                  - mapArea.centre().y);                                  - mapArea.centre().y);
2132    
2133                  setMapArea(newMapArea);                  setMapArea(newMapArea);
# Line 2233  public class XMapPane extends JPanel imp Line 2252  public class XMapPane extends JPanel imp
2252                  imageOrigin.x = 0;                  imageOrigin.x = 0;
2253                  imageOrigin.y = 0;                  imageOrigin.y = 0;
2254    
2255                  if (!setMapArea(newMapArea)){                  if (!setMapArea(newMapArea)) {
2256                          updateFinalImage();                          updateFinalImage();
2257                          repaint();                          repaint();
2258                  }                  }
# Line 2242  public class XMapPane extends JPanel imp Line 2261  public class XMapPane extends JPanel imp
2261                          setCursor(SwingUtil.PAN_CURSOR);                          setCursor(SwingUtil.PAN_CURSOR);
2262          }          }
2263    
2264            public void onRenderingPending() {
2265                    LOGGER.debug("Pending rendering updates the preview...");
2266                    updateFinalImage();
2267                    XMapPane.this.repaint();
2268            }
2269    
2270  }  }

Legend:
Removed from v.509  
changed lines
  Added in v.516

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26