/[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 512 by mojays, Fri Nov 6 15:00:17 2009 UTC revision 518 by alfonx, Fri Nov 13 18:16:38 2009 UTC
# Line 68  import org.geotools.renderer.GTRenderer; Line 68  import org.geotools.renderer.GTRenderer;
68  import org.geotools.renderer.label.LabelCacheImpl;  import org.geotools.renderer.label.LabelCacheImpl;
69  import org.geotools.renderer.lite.LabelCache;  import org.geotools.renderer.lite.LabelCache;
70  import org.geotools.swing.JMapPane;  import org.geotools.swing.JMapPane;
 //import org.geotools.swing.RenderingExecutor;  // gt2-2.6.1  
 import skrueger.geotools.RenderingExecutor;     // until gt2-2.6.1  
71  import org.geotools.swing.event.MapMouseEvent;  import org.geotools.swing.event.MapMouseEvent;
72  import org.geotools.swing.event.MapPaneEvent;  import org.geotools.swing.event.MapPaneEvent;
73  import org.geotools.swing.event.MapPaneListener;  import org.geotools.swing.event.MapPaneListener;
# Line 86  import schmitzm.geotools.gui.SelectableX Line 84  import schmitzm.geotools.gui.SelectableX
84  import schmitzm.geotools.map.event.JMapPaneListener;  import schmitzm.geotools.map.event.JMapPaneListener;
85  import schmitzm.geotools.map.event.MapLayerAdapter;  import schmitzm.geotools.map.event.MapLayerAdapter;
86  import schmitzm.swing.SwingUtil;  import schmitzm.swing.SwingUtil;
87    import skrueger.geotools.RenderingExecutor;
88    
89  import com.vividsolutions.jts.geom.Coordinate;  import com.vividsolutions.jts.geom.Coordinate;
90  import com.vividsolutions.jts.geom.Envelope;  import com.vividsolutions.jts.geom.Envelope;
# 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          public static final long DEFAULT_REPAINTING_DELAY = 200;  //      /**
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          protected RenderingExecutor bgExecuter;          protected RenderingExecutor bgExecuter;
198    
# 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 1450  public class XMapPane extends JPanel imp Line 1471  public class XMapPane extends JPanel imp
1471    
1472                  Rectangle curPaintArea = getVisibleRect();                  Rectangle curPaintArea = getVisibleRect();
1473    
                 // allow a single pixel margin at the right and bottom edges  
                 curPaintArea.width -= 1;  
                 curPaintArea.height -= 1;  
   
1474                  labelCache.clear();                  labelCache.clear();
1475    
1476                  /**                  /**
# Line 1464  public class XMapPane extends JPanel imp Line 1481  public class XMapPane extends JPanel imp
1481                   */                   */
1482    
1483                  if (getBgContext() != null) {                  if (getBgContext() != null) {
1484                          bgExecuter = new RenderingExecutor(this);                          bgExecuter = new RenderingExecutor(this, 333l);
1485                          LOGGER.debug("starting bg renderer:");                          LOGGER.debug("starting bg renderer:");
1486                          // /* System.out.println("rendering"); */                          // /* System.out.println("rendering"); */
1487                          final GTRenderer createGTRenderer = GTUtil.createGTRenderer(                          final GTRenderer createGTRenderer = GTUtil.createGTRenderer(
# Line 1475  public class XMapPane extends JPanel imp Line 1492  public class XMapPane extends JPanel imp
1492                  }                  }
1493    
1494                  if (getContext() != null) {                  if (getContext() != null) {
1495                          localExecuter = new RenderingExecutor(this);                          localExecuter = new RenderingExecutor(this, 150l);
1496                          LOGGER.debug("starting local renderer:");                          LOGGER.debug("starting local renderer:");
1497                          final GTRenderer createGTRenderer = GTUtil.createGTRenderer(                          final GTRenderer createGTRenderer = GTUtil.createGTRenderer(
1498                                          localContext, getRendererHints());                                          localContext, getRendererHints());
# Line 1485  public class XMapPane extends JPanel imp Line 1502  public class XMapPane extends JPanel imp
1502                                          createGTRenderer);                                          createGTRenderer);
1503                  }                  }
1504    
1505                  updateCursorAndRepaintTimer();                  updateCursor();
1506    //
1507                  // start regular repaints until all renderers are done.  //              // start regular repaints until all renderers are done.
1508                  repainterTimer.setRepeats(true);  //              repainterTimer.setRepeats(true);
1509                  repainterTimer.restart();  //              repainterTimer.restart();
1510    
1511          }          }
1512    
# Line 1499  public class XMapPane extends JPanel imp Line 1516  public class XMapPane extends JPanel imp
1516          private BufferedImage getBgImage() {          private BufferedImage getBgImage() {
1517    
1518                  if (bgImage == null) {                  if (bgImage == null) {
1519                          LOGGER.debug("creating a new background image");  //                      LOGGER.debug("creating a new background image");
1520    
1521                          Rectangle curPaintArea = getVisibleRect();                          Rectangle curPaintArea = getVisibleRect();
                         // allow a single pixel margin at the right and bottom edges  
                         curPaintArea.width -= 1;  
                         curPaintArea.height -= 1;  
1522    
1523                          bgImage = new BufferedImage(curPaintArea.width + 1,                          bgImage = new BufferedImage(curPaintArea.width + 1,
1524                                          curPaintArea.height + 1, BufferedImage.TYPE_INT_ARGB);                                          curPaintArea.height + 1, BufferedImage.TYPE_INT_ARGB);
# Line 1536  public class XMapPane extends JPanel imp Line 1550  public class XMapPane extends JPanel imp
1550           */           */
1551          public void setMapImage(BufferedImage mapImage) {          public void setMapImage(BufferedImage mapImage) {
1552                  this.mapImage = mapImage;                  this.mapImage = mapImage;
1553  //              gadgetsImage = null;                  // gadgetsImage = null;
1554          }          }
1555    
1556          /**          /**
# Line 1545  public class XMapPane extends JPanel imp Line 1559  public class XMapPane extends JPanel imp
1559          private BufferedImage getLocalImage() {          private BufferedImage getLocalImage() {
1560    
1561                  if (localImage == null) {                  if (localImage == null) {
1562                          LOGGER.debug("creating a new local image");  
1563    //                      LOGGER.debug("creating a new local image");
1564    
1565                          Rectangle curPaintArea = getVisibleRect();                          Rectangle curPaintArea = getVisibleRect();
                         // allow a single pixel margin at the right and bottom edges  
                         curPaintArea.width -= 1;  
                         curPaintArea.height -= 1;  
1566    
1567                          localImage = new BufferedImage(curPaintArea.width + 1,                          localImage = new BufferedImage(curPaintArea.width + 1,
1568                                          curPaintArea.height + 1, BufferedImage.TYPE_INT_ARGB);                                          curPaintArea.height + 1, BufferedImage.TYPE_INT_ARGB);
# Line 1558  public class XMapPane extends JPanel imp Line 1570  public class XMapPane extends JPanel imp
1570    
1571                  return localImage;                  return localImage;
1572          }          }
1573  //  
1574  //      /**          //
1575  //       * Lazyly initializes a {@link BufferedImage} for the background renderer.          // /**
1576  //       */          // * Lazyly initializes a {@link BufferedImage} for the background renderer.
1577  //      private BufferedImage getGadgetsImage() {          // */
1578  //          // private BufferedImage getGadgetsImage() {
1579  //              if (gadgetsImage == null) {          //
1580  //                      LOGGER.debug("creating a new gadgets image");          // if (gadgetsImage == null) {
1581  //          // LOGGER.debug("creating a new gadgets image");
1582  //                      Rectangle curPaintArea = getVisibleRect();          //
1583  //                      // allow a single pixel margin at the right and bottom edges          // Rectangle curPaintArea = getVisibleRect();
1584  //                      curPaintArea.width -= 1;          // // allow a single pixel margin at the right and bottom edges
1585  //                      curPaintArea.height -= 1;          // curPaintArea.width -= 1;
1586  //          // curPaintArea.height -= 1;
1587  //                      gadgetsImage = new BufferedImage(curPaintArea.width + 1,          //
1588  //                                      curPaintArea.height + 1, BufferedImage.TYPE_INT_ARGB);          // gadgetsImage = new BufferedImage(curPaintArea.width + 1,
1589  //          // curPaintArea.height + 1, BufferedImage.TYPE_INT_ARGB);
1590  //                      if (mapImage != null)          //
1591  //                              gadgetsImage.getGraphics().drawImage(mapImage,          // if (mapImage != null)
1592  //                                              curPaintArea.width - mapImage.getWidth() - 10,          // gadgetsImage.getGraphics().drawImage(mapImage,
1593  //                                              curPaintArea.height - mapImage.getHeight() - 10, this);          // curPaintArea.width - mapImage.getWidth() - 10,
1594  //                                // curPaintArea.height - mapImage.getHeight() - 10, this);
1595  //              }          //                      
1596  //          // }
1597  //              return gadgetsImage;          //
1598  //      }          // return gadgetsImage;
1599            // }
1600    
1601          /**          /**
1602           * 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 1606  public class XMapPane extends JPanel imp
1606           * @see MapPaneListener#onRenderingStopped(org.geotools.swing.event.MapPaneEvent)           * @see MapPaneListener#onRenderingStopped(org.geotools.swing.event.MapPaneEvent)
1607           */           */
1608          public void onRenderingCompleted() {          public void onRenderingCompleted() {
                 System.out.println("onRenderingCompleted");  
   
1609                  updateFinalImage();                  updateFinalImage();
   
1610                  repaint();                  repaint();
   
1611          }          }
1612    
1613          /**          /**
# Line 2009  public class XMapPane extends JPanel imp Line 2018  public class XMapPane extends JPanel imp
2018          public void dispose() {          public void dispose() {
2019                  if (isDisposed())                  if (isDisposed())
2020                          return;                          return;
2021                    
2022                    setPainting(false);
2023    
2024                  disposed = true;                  disposed = true;
2025    
# Line 2021  public class XMapPane extends JPanel imp Line 2032  public class XMapPane extends JPanel imp
2032                  }                  }
2033    
2034                  startRenderThreadsTimer.stop();                  startRenderThreadsTimer.stop();
2035                  repainterTimer.stop();  //              repainterTimer.stop();
2036    
2037                  if (bgImage != null)                  if (bgImage != null)
2038                          bgImage.flush();                          bgImage.flush();
2039                  if (localImage != null)                  if (localImage != null)
2040                          localImage.flush();                          localImage.flush();
2041  //              if (gadgetsImage != null)                  // if (gadgetsImage != null)
2042  //                      gadgetsImage.flush();                  // gadgetsImage.flush();
2043                  if (finalImage != null)                  if (finalImage != null)
2044                          finalImage.flush();                          finalImage.flush();
2045                  if (preFinalImage != null)                  if (preFinalImage != null)
# Line 2088  public class XMapPane extends JPanel imp Line 2099  public class XMapPane extends JPanel imp
2099    
2100                  Point2D gcenter = getScreenToWorld().transform(center, null);                  Point2D gcenter = getScreenToWorld().transform(center, null);
2101                  center = null;                  center = null;
2102                    
2103                  if (                  if (Double.isNaN(gcenter.getX()) || Double.isNaN(gcenter.getY())
2104                                  Double.isNaN(gcenter.getX()) || Double.isNaN(gcenter.getY())                                  || Double.isInfinite(gcenter.getX())
2105                                  ||                                  || Double.isInfinite(gcenter.getY())
2106                                  Double.isInfinite(gcenter.getX()) || Double.isInfinite(gcenter.getY())  
                                   
2107                  ) {                  ) {
2108                          // Not inside valid CRS area! cancel                          // Not inside valid CRS area! cancel
2109                          return;                          return;
2110                  }                  }
2111    
2112                  final Envelope mapArea = getMapArea();                  final Envelope mapArea = getMapArea();
2113                    
2114                  Envelope newMapArea = new Envelope(mapArea);                  Envelope newMapArea = new Envelope(mapArea);
2115                  newMapArea                  newMapArea.expandBy((mapArea.getWidth() * zoomFaktor - mapArea
2116                                  .expandBy((mapArea.getWidth() * zoomFaktor - mapArea                                  .getWidth()) / 2., (mapArea.getHeight() * zoomFaktor - mapArea
2117                                                  .getWidth()) / 2., (mapArea.getHeight()                                  .getHeight()) / 2.);
                                                 * zoomFaktor - mapArea.getHeight()) / 2.);  
2118    
2119                  // Move the newMapArea above the new center                  // Move the newMapArea above the new center
2120                  newMapArea.translate(gcenter.getX() - mapArea.centre().x, gcenter.getY()                  newMapArea.translate(gcenter.getX() - mapArea.centre().x, gcenter
2121                                    .getY()
2122                                  - mapArea.centre().y);                                  - mapArea.centre().y);
2123    
2124                  setMapArea(newMapArea);                  setMapArea(newMapArea);
# Line 2233  public class XMapPane extends JPanel imp Line 2243  public class XMapPane extends JPanel imp
2243                  imageOrigin.x = 0;                  imageOrigin.x = 0;
2244                  imageOrigin.y = 0;                  imageOrigin.y = 0;
2245    
2246                  if (!setMapArea(newMapArea)){                  if (!setMapArea(newMapArea)) {
2247                          updateFinalImage();                          updateFinalImage();
2248                          repaint();                          repaint();
2249                  }                  }
# Line 2242  public class XMapPane extends JPanel imp Line 2252  public class XMapPane extends JPanel imp
2252                          setCursor(SwingUtil.PAN_CURSOR);                          setCursor(SwingUtil.PAN_CURSOR);
2253          }          }
2254    
2255            public void onRenderingPending() {
2256                    LOGGER.debug("Pending rendering updates the preview...");
2257                    updateFinalImage();
2258                    XMapPane.this.repaint();
2259            }
2260    
2261  }  }

Legend:
Removed from v.512  
changed lines
  Added in v.518

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26