/[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 553 by alfonx, Mon Nov 23 21:39:17 2009 UTC revision 555 by alfonx, Tue Nov 24 09:17:22 2009 UTC
# Line 98  public class XMapPane extends JPanel { Line 98  public class XMapPane extends JPanel {
98          private static final int IMAGETYPE = BufferedImage.TYPE_INT_RGB;          private static final int IMAGETYPE = BufferedImage.TYPE_INT_RGB;
99          private static final int IMAGETYPE_withAlpha = BufferedImage.TYPE_INT_ARGB;          private static final int IMAGETYPE_withAlpha = BufferedImage.TYPE_INT_ARGB;
100    
101          private static Logger LOGGER = Logger.getLogger(XMapPane.class);          private final static Logger LOGGER = Logger.getLogger(XMapPane.class);
102    
103          private boolean acceptsRepaintCalls = true;          private boolean acceptsRepaintCalls = true;
104    
# Line 133  public class XMapPane extends JPanel { Line 133  public class XMapPane extends JPanel {
133           * The initial delay in milliseconds until the {@link #finalImage} is           * The initial delay in milliseconds until the {@link #finalImage} is
134           * updated the first time.           * updated the first time.
135           */           */
136          public static final int INITIAL_REPAINT_DELAY = 1000;          public static final int INITIAL_REPAINT_DELAY = 900;
137    
138          /**          /**
139           * While the {@link #bgExecuter} and {@link #localExecuter} are rendering,           * While the {@link #bgExecuter} and {@link #localExecuter} are rendering,
140           * the {@link #repaintTimer} is regularly updating the {@link #finalImage}           * the {@link #repaintTimer} is regularly updating the {@link #finalImage}
141           * with previews.           * with previews.
142           */           */
143          public static final int REPEATING_REPAINT_DELAY = 500;          public static final int REPEATING_REPAINT_DELAY = 600;
144    
145          /**          /**
146           * Default delay (milliseconds) before the map will be redrawn when resizing           * Default delay (milliseconds) before the map will be redrawn when resizing
# Line 150  public class XMapPane extends JPanel { Line 150  public class XMapPane extends JPanel {
150           */           */
151          public static final int DEFAULT_RESIZING_PAINT_DELAY = 600;          public static final int DEFAULT_RESIZING_PAINT_DELAY = 600;
152    
153            /**
154             * This not-repeating {@link Timer} is re-started whenever the component is
155             * resized. That means => only if the component is not resizing for
156             * {@link #DEFAULT_RESIZING_PAINT_DELAY} milliseconds, does the
157             * {@link XMapPane} react.
158             */
159          private final Timer resizeTimer;          private final Timer resizeTimer;
160    
161            /**
162             * Flag for no-tool.
163             */
164          public static final int NONE = -123;          public static final int NONE = -123;
165    
166          /**          /**
# Line 163  public class XMapPane extends JPanel { Line 172  public class XMapPane extends JPanel {
172          public static final int PAN = 1;          public static final int PAN = 1;
173    
174          /**          /**
175             * Flag fuer Modus "Heran zoomen".
176             *
177             * @see #setState(int)
178             * @see #setState(int)
179             */
180            public static final int ZOOM_IN = 2;
181    
182            /**
183             * Flag fuer Modus "Heraus zoomen". Nicht fuer Window-Auswahl moeglich!
184             *
185             * @see #setState(int)
186             */
187            public static final int ZOOM_OUT = 3;
188    
189            /**
190           * Flag fuer Modus "SimpleFeature-Auswahl auf allen (sichtbaren) Layern".           * Flag fuer Modus "SimpleFeature-Auswahl auf allen (sichtbaren) Layern".
191           *           *
192           * @see #setState(int)           * @see #setState(int)
# Line 186  public class XMapPane extends JPanel { Line 210  public class XMapPane extends JPanel {
210           */           */
211          public static final int SELECT_TOP = 4;          public static final int SELECT_TOP = 4;
212    
         public static final Cursor WAIT_CURSOR = Cursor  
                         .getPredefinedCursor(Cursor.WAIT_CURSOR);  
   
213          /**          /**
214           * {@link Font} used to paint the wait messages into the map           * {@link Font} used to paint the wait messages into the map
215           *           *
# Line 212  public class XMapPane extends JPanel { Line 233  public class XMapPane extends JPanel {
233          final String waitMsg = SwingUtil.R("WaitMess");          final String waitMsg = SwingUtil.R("WaitMess");
234    
235          /**          /**
          * 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;  
   
         /**  
236           * Konvertiert die Maus-Koordinaten (relativ zum <code>JMapPane</code>) in           * Konvertiert die Maus-Koordinaten (relativ zum <code>JMapPane</code>) in
237           * Karten-Koordinaten.           * Karten-Koordinaten.
238           *           *
# Line 423  public class XMapPane extends JPanel { Line 429  public class XMapPane extends JPanel {
429    
430                  @Override                  @Override
431                  public void layerChanged(final MapLayerEvent event) {                  public void layerChanged(final MapLayerEvent event) {
432                          localRenderer.setContext(getMapContext()); // betters for SLD changes?!                          localRenderer.setContext(getMapContext()); // betters for SLD
433                            // changes?!
434                          requestStartRendering();                          requestStartRendering();
435                  }                  }
436    
# Line 503  public class XMapPane extends JPanel { Line 510  public class XMapPane extends JPanel {
510           * A flag indicating, that the image size has changed and the buffered           * A flag indicating, that the image size has changed and the buffered
511           * images are not big enough any more           * images are not big enough any more
512           **/           **/
513          protected boolean paneResized = false;          protected boolean paneResized = true;
514    
515          private BufferedImage preFinalImage;          private BufferedImage preFinalImage;
516    
517          // if null, no quick preview will be shown          // ** if 0, no quick preview will be shown **/
518          private int quickPreviewHint = 0;          private int quickPreviewHint = 0;
519    
520          private Map<Object, Object> rendererHints = GTUtil          private Map<Object, Object> rendererHints = GTUtil
# Line 554  public class XMapPane extends JPanel { Line 561  public class XMapPane extends JPanel {
561    
562          /** Is set if a renderer has an error **/          /** Is set if a renderer has an error **/
563          protected ArrayList<Exception> renderingErrors = new ArrayList<Exception>();          protected ArrayList<Exception> renderingErrors = new ArrayList<Exception>();
564            
565          /** If <code>true</code>, then rendering exceptions are rendererd into the map pane **/          /**
566          private boolean showExceptions= false;           * If <code>true</code>, then rendering exceptions are rendererd into the
567             * map pane
568          // /** If {@link #getVisibleRect()} of this {@link JPanel} is not yet           **/
569          // defined, but we are **/          private boolean showExceptions = false;
         // private Envelope mapAreaCondidate = null;  
570    
571          public XMapPane() {          public XMapPane() {
572                  this(null, null);                  this(null, null);
# Line 610  public class XMapPane extends JPanel { Line 616  public class XMapPane extends JPanel {
616                                                  if (!isWellDefined())                                                  if (!isWellDefined())
617                                                          return;                                                          return;
618    
619                                                    LOGGER.info("resizeTimer performed");
620    
621                                                  final Rectangle bounds = getVisibleRect();                                                  final Rectangle bounds = getVisibleRect();
622                                                  //                                                  //
623                                                  // System.out.println("\n\ntimer performs with bounds = "                                                  // System.out.println("\n\ntimer performs with bounds = "
# Line 619  public class XMapPane extends JPanel { Line 627  public class XMapPane extends JPanel {
627                                                                  bounds.x, bounds.y, bounds.x + bounds.width,                                                                  bounds.x, bounds.y, bounds.x + bounds.width,
628                                                                  bounds.y + bounds.height);                                                                  bounds.y + bounds.height);
629    
630                                                  if (setMapArea(geoMapArea))                                                  if (setMapArea(geoMapArea)) {
631                                                            LOGGER.info("  maparea changed");
632                                                          paneResized = true;                                                          paneResized = true;
633                                                  // else                                                  } else
634                                                  // syso                                                          LOGGER.info("  maparea NOT changed");
635                                          }                                          }
636                                  });                                  });
637                  resizeTimer.setRepeats(false);                  resizeTimer.setRepeats(false);
638    
639                  this.addComponentListener(new ComponentAdapter() {                  this.addComponentListener(new ComponentAdapter() {
640    
641                            private Rectangle oldVisibleRect;
642    
643                          @Override                          @Override
644                          public void componentResized(final ComponentEvent e) {                          public void componentResized(final ComponentEvent e) {
645    
646                                  // Already cancel the tasks...                                  // Seems to be called twice with the same size..
647                                  if (bgExecuter != null)                                  if (oldVisibleRect != null
648                                          bgExecuter.cancelTask();                                                  && oldVisibleRect.equals(getVisibleRect())){
649                                  if (localExecuter != null)                                          LOGGER.info("skipping resize.");
650                                          localExecuter.cancelTask();                                          return;
651                                    }
652    
653                                    LOGGER.info("resized: " + getVisibleRect());
654                                  resizeTimer.restart();                                  resizeTimer.restart();
655                                    oldVisibleRect = getVisibleRect();
656                          }                          }
657    
658                  });                  });
# Line 650  public class XMapPane extends JPanel { Line 664  public class XMapPane extends JPanel {
664    
665                          @Override                          @Override
666                          public void actionPerformed(final ActionEvent e) {                          public void actionPerformed(final ActionEvent e) {
667                                  if ((localExecuter != null && !localExecuter.isRunning())                                  if ((!localExecuter.isRunning())
668                                                  && (bgExecuter != null && !bgExecuter.isRunning())) {                                                  && (bgExecuter != null && !bgExecuter.isRunning())) {
669                                          repaintTimer.stop();                                          repaintTimer.stop();
670                                  } else {                                  } else {
671                                          updateFinalImage();                                          updateFinalImage();
672                                          XMapPane.this.repaint(100);                                          XMapPane.this.repaint(100);
673    
674                                  }                                  }
675                          }                          }
676                  });                  });
677    
678                  repaintTimer.setInitialDelay(INITIAL_REPAINT_DELAY);                  repaintTimer.setInitialDelay(INITIAL_REPAINT_DELAY);
679                  repaintTimer.setRepeats(true);                  repaintTimer.setRepeats(true);
680    
# Line 676  public class XMapPane extends JPanel { Line 692  public class XMapPane extends JPanel {
692                                                  if (localExecuter.isRunning()) {                                                  if (localExecuter.isRunning()) {
693                                                          localExecuter.cancelTask();                                                          localExecuter.cancelTask();
694                                                  } else {                                                  } else {
   
695                                                          // Stupidly, but we have to recheck the                                                          // Stupidly, but we have to recheck the
696                                                          setMapArea(getMapArea());                                                          setMapArea(getMapArea());
697                                                          requestStartRendering = false;                                                          requestStartRendering = false;
# Line 765  public class XMapPane extends JPanel { Line 780  public class XMapPane extends JPanel {
780                  }                  }
781    
782                  final Envelope maxAllowedExtend = getMaxExtend();                  final Envelope maxAllowedExtend = getMaxExtend();
783                    
784                  while (maxAllowedExtend != null && !maxAllowedExtend.contains(newArea)                  while (maxAllowedExtend != null && !maxAllowedExtend.contains(newArea)
785                                  && newArea != null && !newArea.isNull()                                  && newArea != null && !newArea.isNull()
786                                  && !Double.isNaN(newArea.getMinX())                                  && !Double.isNaN(newArea.getMinX())
# Line 910  public class XMapPane extends JPanel { Line 925  public class XMapPane extends JPanel {
925                          bgExecuter.dispose();                          bgExecuter.dispose();
926                  }                  }
927    
928                  if (localExecuter != null) {                  if (localExecuter.isRunning()) {
929                          int i = 0;                          int i = 0;
930                          localExecuter.cancelTask();                          localExecuter.cancelTask();
931                          while (i++ < 10 && localExecuter.isRunning()) {                          while (i++ < 10 && localExecuter.isRunning()) {
# Line 1161  public class XMapPane extends JPanel { Line 1176  public class XMapPane extends JPanel {
1176          public Envelope getMaxExtend() {          public Envelope getMaxExtend() {
1177                  if (maxExtend == null) {                  if (maxExtend == null) {
1178                          // Commented-out because it takes soo much time!                          // Commented-out because it takes soo much time!
1179  //                          //
1180  //                      long start = System.currentTimeMillis();                          // long start = System.currentTimeMillis();
1181  //                      final ReferencedEnvelope layerBounds = GTUtil                          // final ReferencedEnvelope layerBounds = GTUtil
1182  //                                      .getVisibleLayoutBounds(localContext);                          // .getVisibleLayoutBounds(localContext);
1183  //                                                //                      
1184  //                      LOGGER.info( (System.currentTimeMillis()-start)+"m to get maxExtend");                          // LOGGER.info(
1185  //                                                // (System.currentTimeMillis()-start)+"m to get maxExtend");
1186  //                      if (layerBounds == null) {                          //                      
1187  //                              // TODO Last fallback could be the CRS valid area                          // if (layerBounds == null) {
1188  //                              return null;                          // // TODO Last fallback could be the CRS valid area
1189  //                      }                          // return null;
1190  //                          // }
1191  //                      // Kartenbereich um 10% vergroessern                          //
1192  //                      return JTSUtil.fixAspectRatio(getVisibleRect(), JTSUtil                          // // Kartenbereich um 10% vergroessern
1193  //                                      .expandEnvelope(layerBounds, 0.1), true);                          // return JTSUtil.fixAspectRatio(getVisibleRect(), JTSUtil
1194                            // .expandEnvelope(layerBounds, 0.1), true);
1195                  }                  }
1196                  return maxExtend;                  return maxExtend;
1197          }          }
# Line 1306  public class XMapPane extends JPanel { Line 1322  public class XMapPane extends JPanel {
1322                  return true;                  return true;
1323          }          }
1324    
1325            /**
1326             * Called from the listeners while the mouse is dragging, this method either
1327             * paints a translated (moved/panned) version of the image, or a rectangle.
1328             *
1329             * @param startPos
1330             *            in screen coordinates
1331             * @param lastPos
1332             *            in screen coordinates
1333             * @param event
1334             *            the {@link MouseEvent} to read the mouse buttons from
1335             */
1336          public void mouseDragged(final Point startPos, final Point lastPos,          public void mouseDragged(final Point startPos, final Point lastPos,
1337                          final MouseEvent event) {                          final MouseEvent event) {
1338    
1339                  if ((getState() == XMapPane.PAN)                  if ((getState() == XMapPane.PAN)
1340                                  || ((event.getModifiersEx() & InputEvent.BUTTON3_DOWN_MASK) != 0)) {                                  || ((event.getModifiersEx() & InputEvent.BUTTON3_DOWN_MASK) != 0)) {
1341    
1342                            // Panning needs a panning coursor
1343                          if (getCursor() != SwingUtil.PANNING_CURSOR) {                          if (getCursor() != SwingUtil.PANNING_CURSOR) {
1344                                  setCursor(SwingUtil.PANNING_CURSOR);                                  setCursor(SwingUtil.PANNING_CURSOR);
1345    
1346                                  // While panning, we deactivate the rendering. So the tasts are                                  // While panning, we deactivate the rendering. So the tasks are
1347                                  // ready to start when the panning os done.                                  // ready to start when the panning is finished.
1348                                  if (bgExecuter != null)                                  if (bgExecuter != null && bgExecuter.isRunning())
1349                                          bgExecuter.cancelTask();                                          bgExecuter.cancelTask();
1350                                  if (localExecuter != null)                                  if (localExecuter.isRunning())
1351                                          localExecuter.cancelTask();                                          localExecuter.cancelTask();
1352                          }                          }
1353    
# Line 1366  public class XMapPane extends JPanel { Line 1394  public class XMapPane extends JPanel {
1394                  } else if ((getState() == XMapPane.ZOOM_IN)                  } else if ((getState() == XMapPane.ZOOM_IN)
1395                                  || (getState() == XMapPane.ZOOM_OUT)                                  || (getState() == XMapPane.ZOOM_OUT)
1396                                  || (getState() == XMapPane.SELECT_ALL)                                  || (getState() == XMapPane.SELECT_ALL)
1397                                  || (getState() == XMapPane.SELECT_TOP)                                  || (getState() == XMapPane.SELECT_TOP)) {
                 // || (getState() == XMapPane.SELECT_ONE_FROM_TOP)  
                 ) {  
                         final Graphics graphics = getGraphics();  
1398    
1399                            // Draws a rectangle
1400                            final Graphics graphics = getGraphics();
1401                          drawRectangle(graphics, startPos, event.getPoint());                          drawRectangle(graphics, startPos, event.getPoint());
1402                            if ((lastPos.x > 0) && (lastPos.y > 0))
                         if ((lastPos.x > 0) && (lastPos.y > 0)) {  
1403                                  drawRectangle(graphics, startPos, lastPos);                                  drawRectangle(graphics, startPos, lastPos);
                         }  
   
1404                          graphics.dispose();                          graphics.dispose();
   
1405                  }                  }
   
1406          }          }
1407    
1408          /**          /**
# Line 1396  public class XMapPane extends JPanel { Line 1418  public class XMapPane extends JPanel {
1418           * completed.           * completed.
1419           */           */
1420          public void onRenderingCompleted() {          public void onRenderingCompleted() {
1421                    LOGGER.info("complete");
1422    
1423                  repaintTimer.stop();                  repaintTimer.stop();
1424                  updateFinalImage();  
1425                  repaint();                  // We "forget" about an exception every time we complete a rendering
1426                    // thread successfully
1427                  if (renderingErrors.size() > 0)                  if (renderingErrors.size() > 0)
1428                          renderingErrors.remove(0);                          renderingErrors.remove(0);
1429    
1430                    updateFinalImage();
1431                    repaint();
1432          }          }
1433    
1434          /**          /**
# Line 1416  public class XMapPane extends JPanel { Line 1444  public class XMapPane extends JPanel {
1444          public void onRenderingFailed(final Exception renderingError) {          public void onRenderingFailed(final Exception renderingError) {
1445    
1446                  // Store the exceptions so we can show it to the user:                  // Store the exceptions so we can show it to the user:
1447                  if (!(renderingError instanceof java.lang.IllegalArgumentException                  if (!(renderingError instanceof java.lang.IllegalArgumentException && renderingError
1448                                  && renderingError.getMessage().equals(                                  .getMessage().equals(
1449                                                  "Argument \"sourceCRS\" should not be null.")))                                                  "Argument \"sourceCRS\" should not be null.")))
1450                          this.renderingErrors.add(renderingError);                          this.renderingErrors.add(renderingError);
1451                  if (renderingErrors.size() > 3)                  if (renderingErrors.size() > 3)
1452                          renderingErrors.remove(0);                          renderingErrors.remove(0);
1453                    
1454                  repaintTimer.stop();                  repaintTimer.stop();
1455    
1456                  LOGGER.warn("Rendering failed", renderingError);                  LOGGER.warn("Rendering failed", renderingError);
1457                  updateFinalImage();                  updateFinalImage();
1458                  repaint();                  repaint();
1459    
1460          }          }
1461    
         public void onRenderingPending() {  
                 // LOGGER.debug("Pending rendering updates the preview...");  
                 updateFinalImage();  
                 repaint();  
         }  
   
1462          @Override          @Override
1463          protected void paintComponent(final Graphics g) {          protected void paintComponent(final Graphics g) {
1464    
1465                    // Maybe update the cursor and maybe stop the repainting timer
1466                    updateCursor();
1467    
1468                  if (!acceptsRepaintCalls)                  if (!acceptsRepaintCalls)
1469                          return;                          return;
1470    
1471                  // Maybe update the cursor and maybe stop the repainting timer                  if (!isWellDefined())
1472                  updateCursor();                          return;
1473    
1474                  // super.paintComponent(g); // candidate for removal                  // super.paintComponent(g); // candidate for removal
1475    
# Line 1463  public class XMapPane extends JPanel { Line 1489  public class XMapPane extends JPanel {
1489                                  mapAreaChanged = false;                                  mapAreaChanged = false;
1490    
1491                                  if (getMapArea().covers(oldMapArea)) {                                  if (getMapArea().covers(oldMapArea)) {
1492                                          setQuickPreviewHint(ZOOM_OUT);                                          quickPreviewHint = ZOOM_OUT;
1493                                          paintedSomething = drawScaledPreviewImage_Zoom((Graphics2D) g);                                          paintedSomething = drawScaledPreviewImage_Zoom((Graphics2D) g);
1494                                  } else if (oldMapArea.covers(getMapArea())) {                                  } else if (oldMapArea.covers(getMapArea())) {
1495                                          setQuickPreviewHint(ZOOM_IN);                                          quickPreviewHint = ZOOM_IN;
1496                                          paintedSomething = drawScaledPreviewImage_Zoom((Graphics2D) g);                                          paintedSomething = drawScaledPreviewImage_Zoom((Graphics2D) g);
1497                                  }                                  }
   
1498                          }                          }
   
                         // if (paneResized) {  
                         // paneResized = false;  
                         // disposeImages();  
                         // }  
                         //  
                         // // Start the Threads and Timers to render the image  
                         // requestStartRendering();  
   
1499                  }                  }
1500    
1501                  if (!paintedSomething) {                  if (!paintedSomething) {
# Line 1567  public class XMapPane extends JPanel { Line 1583  public class XMapPane extends JPanel {
1583                          setCursor(SwingUtil.PAN_CURSOR);                          setCursor(SwingUtil.PAN_CURSOR);
1584          }          }
1585    
         //  
         // /**  
         // * 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);  
         // }  
         // }  
   
1586          /**          /**
1587           * Entfernt einen Listener von der Map.           * Entfernt einen Listener von der Map.
1588           *           *
# Line 1607  public class XMapPane extends JPanel { Line 1601  public class XMapPane extends JPanel {
1601          private void requestStartRendering() {          private void requestStartRendering() {
1602                  if (bgExecuter != null)                  if (bgExecuter != null)
1603                          bgExecuter.cancelTask();                          bgExecuter.cancelTask();
1604                  if (localExecuter != null)  
1605                          localExecuter.cancelTask();                  localExecuter.cancelTask();
1606    
1607                  mapImageInvalid = true;                  mapImageInvalid = true;
1608                  if (paneResized) {                  if (paneResized) {
# Line 1728  public class XMapPane extends JPanel { Line 1722  public class XMapPane extends JPanel {
1722           *         has been triggered.           *         has been triggered.
1723           */           */
1724          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;  
                 // }  
1725    
1726                  if (newMapArea == null                  if (newMapArea == null
1727                                  || bestAllowedMapArea(newMapArea).equals(mapArea)) {                                  || bestAllowedMapArea(newMapArea).equals(mapArea)) {
# Line 1793  public class XMapPane extends JPanel { Line 1779  public class XMapPane extends JPanel {
1779    
1780                  mapAreaChanged = true;                  mapAreaChanged = true;
1781    
1782                  repaint(100);                  repaint(200); // Do not remove it!
1783    
1784                  requestStartRendering();                  requestStartRendering();
1785    
# Line 1882  public class XMapPane extends JPanel { Line 1868  public class XMapPane extends JPanel {
1868          }          }
1869    
1870          /**          /**
1871           *           * If <code>true</code>, allow the {@link XMapPane} to process #repaint()
1872           * @param b           * requests. Otherwise the map will not paint anything and not start any
1873             * rendering {@link Thread}s.
1874           */           */
1875          public void setPainting(final boolean b) {          public void setPainting(final boolean b) {
1876                  acceptsRepaintCalls = b;                  acceptsRepaintCalls = b;
1877          }                  if (acceptsRepaintCalls == true)
1878                            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;  
   
1879          }          }
1880    
1881          private void setRendererHints(final Map<Object, Object> rendererHints) {          private void setRendererHints(final Map<Object, Object> rendererHints) {
# Line 1947  public class XMapPane extends JPanel { Line 1921  public class XMapPane extends JPanel {
1921          private void startRendering() {          private void startRendering() {
1922    
1923                  if (!isWellDefined() || !acceptsRepaintCalls) {                  if (!isWellDefined() || !acceptsRepaintCalls) {
1924                            // if we are not ready to start rendering, try it again the next
1925                            // time the timer is chacking the flag.
1926                          requestStartRendering = true;                          requestStartRendering = true;
1927                          return;                          return;
1928                  }                  }
# Line 1956  public class XMapPane extends JPanel { Line 1932  public class XMapPane extends JPanel {
1932                          bgExecuter.cancelTask();                          bgExecuter.cancelTask();
1933                  }                  }
1934    
1935                  if (localExecuter != null) {                  localExecuter.cancelTask();
                         localExecuter.cancelTask();  
                 }  
1936    
1937                  final Rectangle curPaintArea = getVisibleRect();                  final Rectangle curPaintArea = getVisibleRect();
1938    
# Line 1990  public class XMapPane extends JPanel { Line 1964  public class XMapPane extends JPanel {
1964    
1965                          final boolean submitted = localExecuter.submit(getMapArea(),                          final boolean submitted = localExecuter.submit(getMapArea(),
1966                                          curPaintArea, (Graphics2D) getLocalImage().getGraphics(),                                          curPaintArea, (Graphics2D) getLocalImage().getGraphics(),
1967                                          localRenderer                                          localRenderer);
                         // , getWorldToScreenTransform()  
                                         );  
1968                          if (submitted)                          if (submitted)
1969                                  repaintTimer.restart();                                  repaintTimer.restart();
1970                          else                          else
# Line 2067  public class XMapPane extends JPanel { Line 2039  public class XMapPane extends JPanel {
2039                  // if the renderers have stopped, also stop the timer that is updating                  // if the renderers have stopped, also stop the timer that is updating
2040                  // the final image                  // the final image
2041                  if (bgExecuter != null && bgExecuter.isRunning()                  if (bgExecuter != null && bgExecuter.isRunning()
2042                                  || localExecuter != null && localExecuter.isRunning()) {                                  || localExecuter.isRunning()) {
2043                          setCursor(WAIT_CURSOR);                          setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
2044                          return;                          return;
2045                  } else {                  } else {
2046                          // Allow one last rendering                          // Allow one last rendering
# Line 2181  public class XMapPane extends JPanel { Line 2153  public class XMapPane extends JPanel {
2153    
2154                  // If the rendering process is still running, indicate this is the image                  // If the rendering process is still running, indicate this is the image
2155                  if (forceWait || bgExecuter != null && bgExecuter.isRunning()                  if (forceWait || bgExecuter != null && bgExecuter.isRunning()
2156                                  || localExecuter != null && localExecuter.isRunning()) {                                  || localExecuter.isRunning()) {
2157    
2158                          y += 8;                          y += 8;
2159    
# Line 2200  public class XMapPane extends JPanel { Line 2172  public class XMapPane extends JPanel {
2172                          y += 24;                          y += 24;
2173                  }                  }
2174    
2175                  if (renderingErrors != null && isShowExceptions()) {                  if (!renderingErrors.isEmpty() && isShowExceptions()) {
2176    
2177                          final Color c = graphics.getColor();                          final Color c = graphics.getColor();
2178                          graphics.setFont(errorFont);                          graphics.setFont(errorFont);
# Line 2247  public class XMapPane extends JPanel { Line 2219  public class XMapPane extends JPanel {
2219                  ReferencedEnvelope _mapArea;                  ReferencedEnvelope _mapArea;
2220                  if (mapArea == null)                  if (mapArea == null)
2221                          _mapArea = features.getBounds();                          _mapArea = features.getBounds();
2222                  else _mapArea = getMapArea();                  else
2223                            _mapArea = getMapArea();
2224                  double width = _mapArea.getWidth();                  double width = _mapArea.getWidth();
2225                  double height = _mapArea.getHeight();                  double height = _mapArea.getHeight();
2226                  final double ratio = height / width;                  final double ratio = height / width;

Legend:
Removed from v.553  
changed lines
  Added in v.555

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26