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

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

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

branches/2.0-RC1/src/skrueger/geotools/XMapPane.java revision 612 by alfonx, Sat Dec 12 17:14:17 2009 UTC branches/2.0-RC2/src/skrueger/geotools/XMapPane.java revision 653 by alfonx, Mon Feb 1 15:09:18 2010 UTC
# Line 69  import schmitzm.geotools.map.event.MapLa Line 69  import schmitzm.geotools.map.event.MapLa
69  import schmitzm.lang.LangUtil;  import schmitzm.lang.LangUtil;
70  import schmitzm.swing.JPanel;  import schmitzm.swing.JPanel;
71  import schmitzm.swing.SwingUtil;  import schmitzm.swing.SwingUtil;
72    import schmitzm.swing.event.MouseInputType;
73    
74  import com.vividsolutions.jts.geom.Coordinate;  import com.vividsolutions.jts.geom.Coordinate;
75  import com.vividsolutions.jts.geom.Envelope;  import com.vividsolutions.jts.geom.Envelope;
# Line 107  public class XMapPane extends JPanel { Line 108  public class XMapPane extends JPanel {
108    
109          private final static Logger LOGGER = Logger.getLogger(XMapPane.class);          private final static Logger LOGGER = Logger.getLogger(XMapPane.class);
110    
111            /**
112             * A flag indicating whether the {@link XMapPane} is accepting repaints from
113             * the EDT. @see {@link XMapPane#setPainting(boolean))
114             **/
115          private boolean acceptsRepaintCalls = true;          private boolean acceptsRepaintCalls = true;
116    
117          /**          /**
# Line 275  public class XMapPane extends JPanel { Line 280  public class XMapPane extends JPanel {
280                          final AffineTransform at = xMapPane.getScreenToWorld();                          final AffineTransform at = xMapPane.getScreenToWorld();
281                          if (at != null) {                          if (at != null) {
282                                  Point2D transformed = at.transform(e.getPoint(), null);                                  Point2D transformed = at.transform(e.getPoint(), null);
283                                  return new DirectPosition2D(xMapPane.getMapContext().getCoordinateReferenceSystem(), transformed.getX(), transformed.getY());                                  return new DirectPosition2D(xMapPane.getMapContext()
284                                                    .getCoordinateReferenceSystem(), transformed.getX(),
285                                                    transformed.getY());
286                          }                          }
287                          return null;                          return null;
288                  }                  }
289                  throw new IllegalArgumentException(                  throw new IllegalArgumentException(
290                                  "MouseEvent has to be of instance MapMouseEvent or come from an XMapPane");                                  "MouseEvent has to be of instance MapMouseEvent or come from an XMapPane");
291          }          }
           
   
292    
293          /**          /**
294           * Listens to changes of the "background" {@link MapContext} and triggers           * Listens to changes of the "background" {@link MapContext} and triggers
# Line 296  public class XMapPane extends JPanel { Line 301  public class XMapPane extends JPanel {
301                          final MapLayer layer = event.getLayer();                          final MapLayer layer = event.getLayer();
302                          layer.addMapLayerListener(bgMapLayerListener);                          layer.addMapLayerListener(bgMapLayerListener);
303                          requestStartRendering();                          requestStartRendering();
   
304                  }                  }
305    
306                  @Override                  @Override
# Line 390  public class XMapPane extends JPanel { Line 394  public class XMapPane extends JPanel {
394           * While dragging, the {@link #updateFinalImage()} method is translating the           * While dragging, the {@link #updateFinalImage()} method is translating the
395           * cached images while setting it together.           * cached images while setting it together.
396           **/           **/
397          Point imageOrigin = new Point(0, 0);          private final Point imageOrigin = new Point(0, 0);
398          /**          /**
399           * For every rendering thread started,           * For every rendering thread started,
400           * {@link GTUtil#createGTRenderer(MapContext)} is called to create a new           * {@link GTUtil#createGTRenderer(MapContext)} is called to create a new
# Line 419  public class XMapPane extends JPanel { Line 423  public class XMapPane extends JPanel {
423    
424                  @Override                  @Override
425                  public void layerChanged(final MapLayerListEvent event) {                  public void layerChanged(final MapLayerListEvent event) {
426  //                      getLocalRenderer().setContext(getMapContext()); geht doch auch ohne?!?!? wow...                          // getLocalRenderer().setContext(getMapContext()); geht doch auch
427                            // ohne?!?!? wow...
428                          requestStartRendering();                          requestStartRendering();
429                  }                  }
430    
# Line 559  public class XMapPane extends JPanel { Line 564  public class XMapPane extends JPanel {
564    
565          /**          /**
566           * The default state is ZOOM_IN, hence by default the           * The default state is ZOOM_IN, hence by default the
567           * {@link #zoomMapPaneMouseListener} is also enabled.           * {@link #xMapPaneMouseListener} is also enabled.
568           **/           **/
569          private int state = ZOOM_IN;          private int state = ZOOM_IN;
570    
# Line 571  public class XMapPane extends JPanel { Line 576  public class XMapPane extends JPanel {
576    
577          private AffineTransform worldToScreen;          private AffineTransform worldToScreen;
578    
579            // /**
580            // * This {@link MouseListener} is managing all zoom related tasks
581            // */
582            // private final ZoomXMapPaneMouseListener zoomMapPaneMouseListener = new
583            // ZoomXMapPaneMouseListener(
584            // this);
585    
586          /**          /**
587           * This {@link MouseListener} is managing all zoom related tasks           * This {@link MouseListener} is managing all zoom related tasks
588           */           */
589          public final ZoomXMapPaneMouseListener zoomMapPaneMouseListener = new ZoomXMapPaneMouseListener(          private final XMapPaneMouseListener xMapPaneMouseListener = new XMapPaneMouseListener(
590                          this);                          this);
591    
592          /** Is set if a renderer has an error **/          /** Is set if a renderer has an error **/
# Line 616  public class XMapPane extends JPanel { Line 628  public class XMapPane extends JPanel {
628                  /**                  /**
629                   * Adding the #zoomMapPaneMouseListener                   * Adding the #zoomMapPaneMouseListener
630                   */                   */
631                  this.addMouseListener(zoomMapPaneMouseListener);                  this.addMouseListener(xMapPaneMouseListener);
632                  this.addMouseMotionListener(zoomMapPaneMouseListener);                  this.addMouseMotionListener(xMapPaneMouseListener);
633                  this.addMouseWheelListener(zoomMapPaneMouseListener);                  this.addMouseWheelListener(xMapPaneMouseListener);
634                    xMapPaneMouseListener.actions.put(MouseInputType.LClick,
635                                    XMapPaneAction.ZOOM_IN);
636                    xMapPaneMouseListener.actions.put(MouseInputType.LDrag,
637                                    XMapPaneAction.ZOOM_IN);
638                    xMapPaneMouseListener.actions.put(MouseInputType.Wheel,
639                                    XMapPaneAction.ZOOM_IN);
640    
641                    xMapPaneMouseListener.actions.put(MouseInputType.RClick,
642                                    XMapPaneAction.SELECT_ALL);
643    
644                    xMapPaneMouseListener.actions.put(MouseInputType.RDrag,
645                                    XMapPaneAction.PAN);
646    
647                  /*                  /*
648                   * We use a Timer object to avoid rendering delays and flickering when                   * We use a Timer object to avoid rendering delays and flickering when
# Line 973  public class XMapPane extends JPanel { Line 997  public class XMapPane extends JPanel {
997                  // Remove all mapPaneListeners that have registered with us                  // Remove all mapPaneListeners that have registered with us
998                  mapPaneListeners.clear();                  mapPaneListeners.clear();
999    
1000                  removeMouseMotionListener(zoomMapPaneMouseListener);                  removeMouseMotionListener(xMapPaneMouseListener);
1001                  removeMouseListener(zoomMapPaneMouseListener);                  removeMouseListener(xMapPaneMouseListener);
1002    
1003                  if (localContext != null)                  if (localContext != null)
1004                          getMapContext().clearLayerList();                          getMapContext().clearLayerList();
# Line 990  public class XMapPane extends JPanel { Line 1014  public class XMapPane extends JPanel {
1014           */           */
1015          protected void drawRectangle(final Graphics graphics, final Point startPos,          protected void drawRectangle(final Graphics graphics, final Point startPos,
1016                          final Point e) {                          final Point e) {
1017                    drawRectangle(graphics, startPos, e, Color.WHITE);
1018            }
1019    
1020            /**
1021             * Draws a rectangle in XOR mode from the origin at {@link #startPos} to the
1022             * given point. All in screen coordinates.
1023             */
1024            protected void drawRectangle(final Graphics graphics, final Point startPos,
1025                            final Point e, Color color) {
1026    
1027                  if (!isWellDefined())                  if (!isWellDefined())
1028                          return;                          return;
# Line 1005  public class XMapPane extends JPanel { Line 1038  public class XMapPane extends JPanel {
1038                  if (width == 0 && height == 0)                  if (width == 0 && height == 0)
1039                          return;                          return;
1040    
1041                  graphics.setXORMode(Color.WHITE);                  graphics.setXORMode(color);
1042                  graphics.drawRect(left, bottom, width, height);                  graphics.drawRect(left, bottom, width, height);
1043          }          }
1044    
# Line 1131  public class XMapPane extends JPanel { Line 1164  public class XMapPane extends JPanel {
1164                          ReferencedEnvelope mapArea_ = null;                          ReferencedEnvelope mapArea_ = null;
1165                          try {                          try {
1166                                  mapArea_ = localContext.getLayerBounds();                                  mapArea_ = localContext.getLayerBounds();
1167                          } catch (final IOException e) {                          } catch (final Exception e) {
1168                                  LOGGER.warn("localContext.getLayerBounds()", e);                                  LOGGER.warn("localContext.getLayerBounds()", e);
1169                          }                          }
1170    
# Line 1344  public class XMapPane extends JPanel { Line 1377  public class XMapPane extends JPanel {
1377          }          }
1378    
1379          /**          /**
1380           * Called from the listeners while the mouse is dragging, this method either           * Usually called from {@link XMapPaneAction_Pan} to pan the image.
          * paints a translated (moved/panned) version of the image, or a rectangle.  
1381           *           *
1382           * @param startPos           * @param startPos
1383           *            in screen coordinates           *            in screen coordinates
1384           * @param lastPos           * @param lastPos
1385           *            in screen coordinates           *            in screen coordinates
          * @param event  
          *            the {@link MouseEvent} to read the mouse buttons from  
1386           */           */
1387          public void mouseDragged(final Point startPos, final Point lastPos,          public void pan(final int dX, final int dY) {
                         final MouseEvent event) {  
1388    
1389                  if ((getState() == XMapPane.PAN)                  // Panning needs a panning coursor
1390                                  || ((event.getModifiersEx() & InputEvent.BUTTON3_DOWN_MASK) != 0)) {                  if (getCursor() != SwingUtil.PANNING_CURSOR) {
1391                            setCursor(SwingUtil.PANNING_CURSOR);
1392                          // Panning needs a panning coursor  
1393                          if (getCursor() != SwingUtil.PANNING_CURSOR) {                          // While panning, we deactivate the rendering. So the tasks are
1394                                  setCursor(SwingUtil.PANNING_CURSOR);                          // ready to start when the panning is finished.
1395                            if (bgExecuter != null && bgExecuter.isRunning())
1396                                  // While panning, we deactivate the rendering. So the tasks are                                  bgExecuter.cancelTask();
1397                                  // ready to start when the panning is finished.                          if (localExecuter.isRunning())
1398                                  if (bgExecuter != null && bgExecuter.isRunning())                                  localExecuter.cancelTask();
1399                                          bgExecuter.cancelTask();                  }
1400                                  if (localExecuter.isRunning())                  //
1401                                          localExecuter.cancelTask();                  // if (lastPos.x > 0 && lastPos.y > 0) {
1402                          }                  // final int dx = event.getX() - lastPos.x;
1403                    // final int dy = event.getY() - lastPos.y;
1404                          if (lastPos.x > 0 && lastPos.y > 0) {  
1405                                  final int dx = event.getX() - lastPos.x;                  // TODO Stop dragging when the drag would not be valid...
1406                                  final int dy = event.getY() - lastPos.y;                  // boolean dragValid = true;
1407                    // // check if this panning results in a valid mapArea
1408                                  // TODO Stop dragging when the drag would not be valid...                  // {
1409                                  // boolean dragValid = true;                  // Rectangle winBounds = xMapPane.getBounds();
1410                                  // // check if this panning results in a valid mapArea                  // winBounds.translate(xMapPane.imageOrigin.x,
1411                                  // {                  // -xMapPane.imageOrigin.y);
1412                                  // Rectangle winBounds = xMapPane.getBounds();                  // Envelope newMapAreaBefore = xMapPane.tranformWindowToGeo(
1413                                  // winBounds.translate(xMapPane.imageOrigin.x,                  // winBounds.x, winBounds.y, winBounds.x
1414                                  // -xMapPane.imageOrigin.y);                  // + winBounds.width, winBounds.y
1415                                  // Envelope newMapAreaBefore = xMapPane.tranformWindowToGeo(                  // + winBounds.height);
1416                                  // winBounds.x, winBounds.y, winBounds.x                  //                                      
1417                                  // + winBounds.width, winBounds.y                  //
1418                                  // + winBounds.height);                  // winBounds = xMapPane.getBounds();
1419                                  //                                                        // Point testIng = new Point(xMapPane.imageOrigin);
1420                                  //                  // testIng.translate(dx, dy);
1421                                  // winBounds = xMapPane.getBounds();                  // winBounds.translate(testIng.x, -testIng.y);
1422                                  // Point testIng = new Point(xMapPane.imageOrigin);                  // Envelope newMapAreaAfter = xMapPane.tranformWindowToGeo(
1423                                  // testIng.translate(dx, dy);                  // winBounds.x, winBounds.y, winBounds.x
1424                                  // winBounds.translate(testIng.x, -testIng.y);                  // + winBounds.width, winBounds.y
1425                                  // Envelope newMapAreaAfter = xMapPane.tranformWindowToGeo(                  // + winBounds.height);
1426                                  // winBounds.x, winBounds.y, winBounds.x                  //
1427                                  // + winBounds.width, winBounds.y                  // // If the last drag doesn't change the MapArea anymore cancel
1428                                  // + winBounds.height);                  // it.
1429                                  //                  // if (xMapPane.bestAllowedMapArea(newMapAreaAfter).equals(
1430                                  // // If the last drag doesn't change the MapArea anymore cancel                  // xMapPane.bestAllowedMapArea(newMapAreaBefore))){
1431                                  // it.                  // dragValid = false;
1432                                  // if (xMapPane.bestAllowedMapArea(newMapAreaAfter).equals(                  // return;
1433                                  // xMapPane.bestAllowedMapArea(newMapAreaBefore))){                  // }
1434                                  // dragValid = false;                  // }
                                 // return;  
                                 // }  
                                 // }  
1435    
1436                                  imageOrigin.translate(dx, dy);                  getImageOrigin().translate(dX, dY);
1437                                  updateFinalImage();                  updateFinalImage();
1438                                  repaint();                  repaint();
1439                          }                  // }
1440    
1441                  } else if ((getState() == XMapPane.ZOOM_IN)                  // } else if ((getState() == XMapPane.ZOOM_IN)
1442                                  || (getState() == XMapPane.ZOOM_OUT)                  // || (getState() == XMapPane.ZOOM_OUT)
1443                                  || (getState() == XMapPane.SELECT_ALL)                  // || (getState() == XMapPane.SELECT_ALL)
1444                                  || (getState() == XMapPane.SELECT_TOP)) {                  // || (getState() == XMapPane.SELECT_TOP)) {
1445                    //
1446                          // Draws a rectangle                  // // Draws a rectangle
1447                          final Graphics2D graphics = (Graphics2D) getGraphics();                  // final Graphics2D graphics = (Graphics2D) getGraphics();
1448                          drawRectangle(graphics, startPos, event.getPoint());                  // drawRectangle(graphics, startPos, event.getPoint());
1449                          if ((lastPos.x > 0) && (lastPos.y > 0))                  // if ((lastPos.x > 0) && (lastPos.y > 0))
1450                                  drawRectangle(graphics, startPos, lastPos);                  // drawRectangle(graphics, startPos, lastPos);
1451                          graphics.dispose();                  // graphics.dispose();
1452                  }                  // }
1453          }          }
1454    
1455          /**          /**
# Line 1443  public class XMapPane extends JPanel { Line 1469  public class XMapPane extends JPanel {
1469           */           */
1470          public void onRenderingCompleted(final long l) {          public void onRenderingCompleted(final long l) {
1471                  lastRenderingDuration = (lastRenderingDuration + l) / 2;                  lastRenderingDuration = (lastRenderingDuration + l) / 2;
1472                  LOGGER                  // LOGGER
1473                                  .debug("complete rendering after " + lastRenderingDuration                  // .debug("complete rendering after " + lastRenderingDuration
1474                                                  + "ms");                  // + "ms");
1475    
1476                  repaintTimer.stop();                  repaintTimer.stop();
1477    
# Line 1585  public class XMapPane extends JPanel { Line 1611  public class XMapPane extends JPanel {
1611                  }                  }
1612    
1613          }          }
1614    //
1615          /**  //      /**
1616           * Performs a {@value #PAN} action. During panning, the displacement is  //       * Performs a {@value #PAN} action. During panning, the displacement is
1617           * stored in {@link #imageOrigin} object. Calling {@link #performPan()} will  //       * stored in {@link #imageOrigin} object. Calling {@link #performPan()} will
1618           * reset the offset and call {@link #setMapArea(Envelope)}.  //       * reset the offset and call {@link #setMapArea(Envelope)}.
1619           */  //       */
1620          public void performPan() {  //      public void performPan() {
1621    //
1622                  final Rectangle winBounds = getVisibleRect();  //              final Rectangle winBounds = getVisibleRect();
1623    //
1624                  winBounds.translate(-imageOrigin.x, -imageOrigin.y);  //              winBounds.translate(-imageOrigin.x, -imageOrigin.y);
1625                  final Envelope newMapArea = tranformWindowToGeo(winBounds.x,  //              final Envelope newMapArea = tranformWindowToGeo(winBounds.x,
1626                                  winBounds.y, winBounds.x + winBounds.width, winBounds.y  //                              winBounds.y, winBounds.x + winBounds.width, winBounds.y
1627                                                  + winBounds.height);  //                                              + winBounds.height);
1628    //
1629                  imageOrigin.x = 0;  //              imageOrigin.x = 0;
1630                  imageOrigin.y = 0;  //              imageOrigin.y = 0;
1631    //
1632                  if (!setMapArea(newMapArea)) {  //              if (!setMapArea(newMapArea)) {
1633                          /**  //                      /**
1634                           * If setMapArea returns true, the finalImage is updated anyways.  //                       * If setMapArea returns true, the finalImage is updated anyways.
1635                           * This if-case exists to ensure that we repaint a correct image  //                       * This if-case exists to ensure that we repaint a correct image
1636                           * even if the new panning area has been denied.  //                       * even if the new panning area has been denied.
1637                           */  //                       */
1638                          updateFinalImage();  //                      updateFinalImage();
1639                          repaint();  //                      repaint();
1640                  }  //              }
1641    //
1642                  if (getCursor() == SwingUtil.PANNING_CURSOR)  //              if (getCursor() == SwingUtil.PANNING_CURSOR)
1643                          setCursor(SwingUtil.PAN_CURSOR);  //                      setCursor(SwingUtil.PAN_CURSOR);
1644          }  //      }
1645    
1646          /**          /**
1647           * Entfernt einen Listener von der Map.           * Entfernt einen Listener von der Map.
# Line 1661  public class XMapPane extends JPanel { Line 1687  public class XMapPane extends JPanel {
1687           *            the current map pane extent (screen units)           *            the current map pane extent (screen units)
1688           */           */
1689          private void resetTransforms() {          private void resetTransforms() {
                 final ReferencedEnvelope refMapEnv = new ReferencedEnvelope(mapArea,  
                                 getMapContext().getCoordinateReferenceSystem());  
   
1690                  // System.out                  // System.out
1691                  // .println("paintArea in resetTeansofrms = " + getVisibleRect());                  // .println("paintArea in resetTeansofrms = " + getVisibleRect());
1692                  if (!isWellDefined())                  if (!isWellDefined())
1693                          return;                          return;
1694    
1695                    if (mapArea == null)
1696                            return;
1697    
1698                    final ReferencedEnvelope refMapEnv = new ReferencedEnvelope(mapArea,
1699                                    getMapContext().getCoordinateReferenceSystem());
1700    
1701                  worldToScreen = RendererUtilities.worldToScreenTransform(refMapEnv,                  worldToScreen = RendererUtilities.worldToScreenTransform(refMapEnv,
1702                                  getVisibleRect());                                  getVisibleRect());
1703    
# Line 1921  public class XMapPane extends JPanel { Line 1950  public class XMapPane extends JPanel {
1950    
1951          // /** Stored the time used for the last real rendering in ms. **/          // /** Stored the time used for the last real rendering in ms. **/
1952          private long lastRenderingDuration = 1000;          private long lastRenderingDuration = 1000;
1953            private XMapPaneTool tool = XMapPaneTool.INFO;
1954    
1955          /**          /**
1956           * Set the minimum (nearest) allowed zoom scale. This is the bigger number           * Set the minimum (nearest) allowed zoom scale. This is the bigger number
# Line 1958  public class XMapPane extends JPanel { Line 1988  public class XMapPane extends JPanel {
1988           *           *
1989           * @param state           * @param state
1990           */           */
1991            @Deprecated
1992          public void setState(final int state) {          public void setState(final int state) {
1993                  this.state = state;                  this.state = state;
1994    
1995                  zoomMapPaneMouseListener.setEnabled((state == ZOOM_IN                  // throw new RuntimeException("Old concept.. migrate to new concept!");
1996                                  || state == ZOOM_OUT || state == PAN));  
1997                    // xMapPaneMouseListener.setEnabled((state == ZOOM_IN
1998                    // || state == ZOOM_OUT || state == PAN));
1999    
2000                  // Je nach Aktion den Cursor umsetzen                  // Je nach Aktion den Cursor umsetzen
2001                  updateCursor();                  updateCursor();
2002          }          }
2003    
2004            public void configureMouse(MouseInputType type, XMapPaneAction action) {
2005                    xMapPaneMouseListener.actions.put(type, action);
2006            }
2007            
2008            public void setTool(XMapPaneTool tool) {
2009                    this.tool = tool;
2010                    xMapPaneMouseListener.configure(tool);
2011                    setCursor(tool.cursor);
2012            }
2013    
2014          /**          /**
2015           * Standardmaessig wird der Cursor automatisch je nach MapPane-Aktion (Zoom,           * Standardmaessig wird der Cursor automatisch je nach MapPane-Aktion (Zoom,
2016           * Auswahl, ...) gesetzt. Mit dieser Methode kann ein statischer Cursor           * Auswahl, ...) gesetzt. Mit dieser Methode kann ein statischer Cursor
# Line 2124  public class XMapPane extends JPanel { Line 2167  public class XMapPane extends JPanel {
2167                                  repaint();                                  repaint();
2168                          }                          }
2169                  }                  }
2170                    
2171    //
2172                  // wenn manueller Cursor gesetzt ist, dann diesen verwenden (unabhaengig                  // wenn manueller Cursor gesetzt ist, dann diesen verwenden (unabhaengig
2173                  // von der aktuellen Aktion                  // von der aktuellen Aktion
2174                  if (this.staticCursor != null) {                  if (this.staticCursor != null) {
2175                          setCursor(staticCursor);                          setCursor(staticCursor);
2176                          return;                          return;
2177                  }                  }
2178                    
2179                  if (getCursor() == SwingUtil.PANNING_CURSOR) {                  if (getCursor() == SwingUtil.PANNING_CURSOR) {
2180                          // This cursor will reset itself                          // This cursor will reset itself
2181                          return;                          return;
2182                  }                  }
2183                    
2184                  // Set the cursor depending on what tool is in use...                  setCursor(tool.cursor);
2185                  switch (state) {  //
2186                  case SELECT_TOP:  //              // Set the cursor depending on what tool is in use...
2187                  case SELECT_ONE_FROM_TOP:  //              switch (state) {
2188                  case SELECT_ALL:  //              case SELECT_TOP:
2189                          setCursor(SwingUtil.CROSSHAIR_CURSOR);  //              case SELECT_ONE_FROM_TOP:
2190                          break;  //              case SELECT_ALL:
2191                  case ZOOM_IN:  //                      setCursor(SwingUtil.CROSSHAIR_CURSOR);
2192                          setCursor(SwingUtil.ZOOMIN_CURSOR);  //                      break;
2193                          break;  //              case ZOOM_IN:
2194                  case ZOOM_OUT:  //                      setCursor(SwingUtil.ZOOMIN_CURSOR);
2195                          setCursor(SwingUtil.ZOOMOUT_CURSOR);  //                      break;
2196                          break;  //              case ZOOM_OUT:
2197                  case PAN:  //                      setCursor(SwingUtil.ZOOMOUT_CURSOR);
2198                          setCursor(SwingUtil.PAN_CURSOR);  //                      break;
2199                          break;  //              case PAN:
2200                  default:  //                      setCursor(SwingUtil.PAN_CURSOR);
2201                          setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));  //                      break;
2202                          break;  //              default:
2203                  }  //                      setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
2204    //                      break;
2205    //              }
2206          }          }
2207    
2208          /**          /**
# Line 2185  public class XMapPane extends JPanel { Line 2232  public class XMapPane extends JPanel {
2232    
2233                  final Graphics2D finalG = getFinalImage().createGraphics();                  final Graphics2D finalG = getFinalImage().createGraphics();
2234                  finalG.setBackground(getMapBackgroundColor());                  finalG.setBackground(getMapBackgroundColor());
2235                  finalG.drawImage(getPreFinalImage(), imageOrigin.x, imageOrigin.y,                  finalG.drawImage(getPreFinalImage(), getImageOrigin().x, getImageOrigin().y,
2236                                  getMapBackgroundColor(), null);                                  getMapBackgroundColor(), null);
2237    
2238                  // When panning, we have to clear the area around the image                  // When panning, we have to clear the area around the image
2239                  final Rectangle painedArea = new Rectangle(imageOrigin.x,                  final Rectangle painedArea = new Rectangle(getImageOrigin().x,
2240                                  imageOrigin.y, getFinalImage().getWidth(), getFinalImage()                                  getImageOrigin().y, getFinalImage().getWidth(), getFinalImage()
2241                                                  .getHeight());                                                  .getHeight());
2242                  SwingUtil.clearAround(finalG, painedArea, getVisibleRect(),                  SwingUtil.clearAround(finalG, painedArea, getVisibleRect(),
2243                                  getMapBackgroundColor());                                  getMapBackgroundColor());
2244    
2245                  addGadgets(finalG, false);  //              addGadgets(finalG, false);
2246    
2247                  finalG.dispose();                  finalG.dispose();
2248    
# Line 2380  public class XMapPane extends JPanel { Line 2427  public class XMapPane extends JPanel {
2427           * @param center           * @param center
2428           *            position in window coordinates           *            position in window coordinates
2429           * @param zoomFaktor           * @param zoomFaktor
2430           *            > 1 for zoom in, < 1 for zoom out. Default is 1.33.           *            > 1 for zoom out, < 1 for zoom in. Default is .5
2431           */           */
2432          public void zoomTo(Point center, Double zoomFaktor) {          public void zoomTo(Point center, Double zoomFaktor) {
2433                  if (zoomFaktor == null || zoomFaktor == 0.)                  if (zoomFaktor == null || zoomFaktor == 0.)
2434                          zoomFaktor = 2.;                          zoomFaktor = .5;
2435    
2436                  final Point2D gcenter = getScreenToWorld().transform(center, null);                  final Point2D gcenter = getScreenToWorld().transform(center, null);
2437                  center = null;                  center = null;
# Line 2406  public class XMapPane extends JPanel { Line 2453  public class XMapPane extends JPanel {
2453                                  .getHeight()) / 2.);                                  .getHeight()) / 2.);
2454    
2455                  // // Move the newMapArea above the new center if we zoom in:                  // // Move the newMapArea above the new center if we zoom in:
2456                  if (zoomFaktor >= 1) {                  newMapArea.translate(gcenter.getX() - mapArea.centre().x, gcenter
2457                          newMapArea.translate(gcenter.getX() - mapArea.centre().x, gcenter                                  .getY()
2458                                          .getY()                                  - mapArea.centre().y);
                                         - mapArea.centre().y);  
                 }  
2459    
2460                  setMapArea(newMapArea);                  setMapArea(newMapArea);
2461          }          }
# Line 2434  public class XMapPane extends JPanel { Line 2479  public class XMapPane extends JPanel {
2479                  return localRenderer;                  return localRenderer;
2480          }          }
2481    
   
   
2482          /**          /**
2483           * Setzt den Kartenausschnitt auf die Ausdehnung eines bestimmten Layers.           * Setzt den Kartenausschnitt auf die Ausdehnung eines bestimmten Layers.
2484           * Macht nichts, wenn {@code null} uebergeben wird.           * Macht nichts, wenn {@code null} uebergeben wird.
# Line 2565  public class XMapPane extends JPanel { Line 2608  public class XMapPane extends JPanel {
2608                  zoomToLayer(getMapContext().getLayerCount() - 1 - index);                  zoomToLayer(getMapContext().getLayerCount() - 1 - index);
2609          }          }
2610    
           
           
   
   
2611          /**          /**
2612           * Aktiviert oder deaktiviert das AntiAliasing for diese           * Aktiviert oder deaktiviert das AntiAliasing for diese
2613           * {@link SelectableXMapPane}. AntiALiasing ist besonders fuer           * {@link SelectableXMapPane}. AntiALiasing ist besonders fuer
# Line 2583  public class XMapPane extends JPanel { Line 2622  public class XMapPane extends JPanel {
2622                  if (java2DHints == null) {                  if (java2DHints == null) {
2623                          java2DHints = GeoTools.getDefaultHints();                          java2DHints = GeoTools.getDefaultHints();
2624                  }                  }
2625                    
2626                  java2DHints.put(RenderingHints.KEY_ANTIALIASING,                  java2DHints.put(RenderingHints.KEY_ANTIALIASING,
2627                                  aa ? RenderingHints.VALUE_ANTIALIAS_ON                                  aa ? RenderingHints.VALUE_ANTIALIAS_ON
2628                                                  : RenderingHints.VALUE_ANTIALIAS_OFF);                                                  : RenderingHints.VALUE_ANTIALIAS_OFF);
# Line 2593  public class XMapPane extends JPanel { Line 2632  public class XMapPane extends JPanel {
2632                  java2DHints.put(RenderingHints.KEY_RENDERING,                  java2DHints.put(RenderingHints.KEY_RENDERING,
2633                                  aa ? RenderingHints.VALUE_RENDER_QUALITY                                  aa ? RenderingHints.VALUE_RENDER_QUALITY
2634                                                  : RenderingHints.VALUE_RENDER_SPEED);                                                  : RenderingHints.VALUE_RENDER_SPEED);
2635                    
2636            }
2637    
2638            public Point getImageOrigin() {
2639                    return imageOrigin;
2640          }          }
2641    
2642  }  }

Legend:
Removed from v.612  
changed lines
  Added in v.653

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26