/[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 615 by alfonx, Mon Dec 14 17:31:41 2009 UTC branches/2.0-RC2/src/skrueger/geotools/XMapPane.java revision 639 by alfonx, Thu Jan 28 16:07:22 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            /** A flag indicating whether the {@link XMapPane} is accepting repaints from the EDT. @see {@link XMapPane#setPainting(boolean)) **/
112          private boolean acceptsRepaintCalls = true;          private boolean acceptsRepaintCalls = true;
113    
114          /**          /**
# Line 275  public class XMapPane extends JPanel { Line 277  public class XMapPane extends JPanel {
277                          final AffineTransform at = xMapPane.getScreenToWorld();                          final AffineTransform at = xMapPane.getScreenToWorld();
278                          if (at != null) {                          if (at != null) {
279                                  Point2D transformed = at.transform(e.getPoint(), null);                                  Point2D transformed = at.transform(e.getPoint(), null);
280                                  return new DirectPosition2D(xMapPane.getMapContext().getCoordinateReferenceSystem(), transformed.getX(), transformed.getY());                                  return new DirectPosition2D(xMapPane.getMapContext()
281                                                    .getCoordinateReferenceSystem(), transformed.getX(),
282                                                    transformed.getY());
283                          }                          }
284                          return null;                          return null;
285                  }                  }
286                  throw new IllegalArgumentException(                  throw new IllegalArgumentException(
287                                  "MouseEvent has to be of instance MapMouseEvent or come from an XMapPane");                                  "MouseEvent has to be of instance MapMouseEvent or come from an XMapPane");
288          }          }
           
   
289    
290          /**          /**
291           * Listens to changes of the "background" {@link MapContext} and triggers           * Listens to changes of the "background" {@link MapContext} and triggers
# Line 419  public class XMapPane extends JPanel { Line 421  public class XMapPane extends JPanel {
421    
422                  @Override                  @Override
423                  public void layerChanged(final MapLayerListEvent event) {                  public void layerChanged(final MapLayerListEvent event) {
424  //                      getLocalRenderer().setContext(getMapContext()); geht doch auch ohne?!?!? wow...                          // getLocalRenderer().setContext(getMapContext()); geht doch auch
425                            // ohne?!?!? wow...
426                          requestStartRendering();                          requestStartRendering();
427                  }                  }
428    
# Line 559  public class XMapPane extends JPanel { Line 562  public class XMapPane extends JPanel {
562    
563          /**          /**
564           * The default state is ZOOM_IN, hence by default the           * The default state is ZOOM_IN, hence by default the
565           * {@link #zoomMapPaneMouseListener} is also enabled.           * {@link #xMapPaneMouseListener} is also enabled.
566           **/           **/
567          private int state = ZOOM_IN;          private int state = ZOOM_IN;
568    
# Line 571  public class XMapPane extends JPanel { Line 574  public class XMapPane extends JPanel {
574    
575          private AffineTransform worldToScreen;          private AffineTransform worldToScreen;
576    
577    //      /**
578    //       * This {@link MouseListener} is managing all zoom related tasks
579    //       */
580    //      private final ZoomXMapPaneMouseListener zoomMapPaneMouseListener = new ZoomXMapPaneMouseListener(
581    //                      this);
582            
583          /**          /**
584           * This {@link MouseListener} is managing all zoom related tasks           * This {@link MouseListener} is managing all zoom related tasks
585           */           */
586          public final ZoomXMapPaneMouseListener zoomMapPaneMouseListener = new ZoomXMapPaneMouseListener(          private final XMapPaneMouseListener xMapPaneMouseListener = new XMapPaneMouseListener(this);
587                          this);          
588    
589          /** Is set if a renderer has an error **/          /** Is set if a renderer has an error **/
590          protected ArrayList<Exception> renderingErrors = new ArrayList<Exception>();          protected ArrayList<Exception> renderingErrors = new ArrayList<Exception>();
# Line 616  public class XMapPane extends JPanel { Line 625  public class XMapPane extends JPanel {
625                  /**                  /**
626                   * Adding the #zoomMapPaneMouseListener                   * Adding the #zoomMapPaneMouseListener
627                   */                   */
628                  this.addMouseListener(zoomMapPaneMouseListener);                  this.addMouseListener(xMapPaneMouseListener);
629                  this.addMouseMotionListener(zoomMapPaneMouseListener);                  this.addMouseMotionListener(xMapPaneMouseListener);
630                  this.addMouseWheelListener(zoomMapPaneMouseListener);                  this.addMouseWheelListener(xMapPaneMouseListener);
631    
632                  /*                  /*
633                   * We use a Timer object to avoid rendering delays and flickering when                   * We use a Timer object to avoid rendering delays and flickering when
# Line 973  public class XMapPane extends JPanel { Line 982  public class XMapPane extends JPanel {
982                  // Remove all mapPaneListeners that have registered with us                  // Remove all mapPaneListeners that have registered with us
983                  mapPaneListeners.clear();                  mapPaneListeners.clear();
984    
985                  removeMouseMotionListener(zoomMapPaneMouseListener);                  removeMouseMotionListener(xMapPaneMouseListener);
986                  removeMouseListener(zoomMapPaneMouseListener);                  removeMouseListener(xMapPaneMouseListener);
987    
988                  if (localContext != null)                  if (localContext != null)
989                          getMapContext().clearLayerList();                          getMapContext().clearLayerList();
# Line 983  public class XMapPane extends JPanel { Line 992  public class XMapPane extends JPanel {
992    
993                  removeAll();                  removeAll();
994          }          }
995            
996          /**          /**
997           * Draws a rectangle in XOR mode from the origin at {@link #startPos} to the           * Draws a rectangle in XOR mode from the origin at {@link #startPos} to the
998           * given point. All in screen coordinates.           * given point. All in screen coordinates.
999           */           */
1000          protected void drawRectangle(final Graphics graphics, final Point startPos,          protected void drawRectangle(final Graphics graphics, final Point startPos,
1001                          final Point e) {                          final Point e) {
1002                    drawRectangle(graphics, startPos, e, Color.WHITE);
1003            }
1004    
1005            /**
1006             * Draws a rectangle in XOR mode from the origin at {@link #startPos} to the
1007             * given point. All in screen coordinates.
1008             */
1009            protected void drawRectangle(final Graphics graphics, final Point startPos,
1010                            final Point e, Color color) {
1011    
1012                  if (!isWellDefined())                  if (!isWellDefined())
1013                          return;                          return;
# Line 1005  public class XMapPane extends JPanel { Line 1023  public class XMapPane extends JPanel {
1023                  if (width == 0 && height == 0)                  if (width == 0 && height == 0)
1024                          return;                          return;
1025    
1026                  graphics.setXORMode(Color.WHITE);                  graphics.setXORMode(color);
1027                  graphics.drawRect(left, bottom, width, height);                  graphics.drawRect(left, bottom, width, height);
1028          }          }
1029    
# Line 1131  public class XMapPane extends JPanel { Line 1149  public class XMapPane extends JPanel {
1149                          ReferencedEnvelope mapArea_ = null;                          ReferencedEnvelope mapArea_ = null;
1150                          try {                          try {
1151                                  mapArea_ = localContext.getLayerBounds();                                  mapArea_ = localContext.getLayerBounds();
1152                          } catch (final IOException e) {                          } catch (final Exception e) {
1153                                  LOGGER.warn("localContext.getLayerBounds()", e);                                  LOGGER.warn("localContext.getLayerBounds()", e);
1154                          }                          }
1155    
# Line 1443  public class XMapPane extends JPanel { Line 1461  public class XMapPane extends JPanel {
1461           */           */
1462          public void onRenderingCompleted(final long l) {          public void onRenderingCompleted(final long l) {
1463                  lastRenderingDuration = (lastRenderingDuration + l) / 2;                  lastRenderingDuration = (lastRenderingDuration + l) / 2;
1464  //              LOGGER                  // LOGGER
1465  //                              .debug("complete rendering after " + lastRenderingDuration                  // .debug("complete rendering after " + lastRenderingDuration
1466  //                                              + "ms");                  // + "ms");
1467    
1468                  repaintTimer.stop();                  repaintTimer.stop();
1469    
# Line 1661  public class XMapPane extends JPanel { Line 1679  public class XMapPane extends JPanel {
1679           *            the current map pane extent (screen units)           *            the current map pane extent (screen units)
1680           */           */
1681          private void resetTransforms() {          private void resetTransforms() {
                 final ReferencedEnvelope refMapEnv = new ReferencedEnvelope(mapArea,  
                                 getMapContext().getCoordinateReferenceSystem());  
   
1682                  // System.out                  // System.out
1683                  // .println("paintArea in resetTeansofrms = " + getVisibleRect());                  // .println("paintArea in resetTeansofrms = " + getVisibleRect());
1684                  if (!isWellDefined())                  if (!isWellDefined())
1685                          return;                          return;
1686    
1687                    if (mapArea == null)
1688                            return;
1689                    
1690                    final ReferencedEnvelope refMapEnv = new ReferencedEnvelope(mapArea,
1691                                    getMapContext().getCoordinateReferenceSystem());
1692    
1693                  worldToScreen = RendererUtilities.worldToScreenTransform(refMapEnv,                  worldToScreen = RendererUtilities.worldToScreenTransform(refMapEnv,
1694                                  getVisibleRect());                                  getVisibleRect());
1695    
# Line 1958  public class XMapPane extends JPanel { Line 1979  public class XMapPane extends JPanel {
1979           *           *
1980           * @param state           * @param state
1981           */           */
1982            @Deprecated
1983          public void setState(final int state) {          public void setState(final int state) {
1984                  this.state = state;                  this.state = state;
1985                    
1986                    throw new RuntimeException("Old concept.. migrate to new concept!");
1987    
1988                  zoomMapPaneMouseListener.setEnabled((state == ZOOM_IN  //              xMapPaneMouseListener.setEnabled((state == ZOOM_IN
1989                                  || state == ZOOM_OUT || state == PAN));  //                              || state == ZOOM_OUT || state == PAN));
1990    
1991                  // Je nach Aktion den Cursor umsetzen                  // Je nach Aktion den Cursor umsetzen
1992                  updateCursor();  //              updateCursor();
1993            }
1994            
1995            public void configureMouse(MouseInputType type, XMapPaneAction action){
1996                    
1997          }          }
1998    
1999          /**          /**
# Line 2432  public class XMapPane extends JPanel { Line 2460  public class XMapPane extends JPanel {
2460                  return localRenderer;                  return localRenderer;
2461          }          }
2462    
   
   
2463          /**          /**
2464           * Setzt den Kartenausschnitt auf die Ausdehnung eines bestimmten Layers.           * Setzt den Kartenausschnitt auf die Ausdehnung eines bestimmten Layers.
2465           * Macht nichts, wenn {@code null} uebergeben wird.           * Macht nichts, wenn {@code null} uebergeben wird.
# Line 2563  public class XMapPane extends JPanel { Line 2589  public class XMapPane extends JPanel {
2589                  zoomToLayer(getMapContext().getLayerCount() - 1 - index);                  zoomToLayer(getMapContext().getLayerCount() - 1 - index);
2590          }          }
2591    
           
           
   
   
2592          /**          /**
2593           * Aktiviert oder deaktiviert das AntiAliasing for diese           * Aktiviert oder deaktiviert das AntiAliasing for diese
2594           * {@link SelectableXMapPane}. AntiALiasing ist besonders fuer           * {@link SelectableXMapPane}. AntiALiasing ist besonders fuer
# Line 2581  public class XMapPane extends JPanel { Line 2603  public class XMapPane extends JPanel {
2603                  if (java2DHints == null) {                  if (java2DHints == null) {
2604                          java2DHints = GeoTools.getDefaultHints();                          java2DHints = GeoTools.getDefaultHints();
2605                  }                  }
2606                    
2607                  java2DHints.put(RenderingHints.KEY_ANTIALIASING,                  java2DHints.put(RenderingHints.KEY_ANTIALIASING,
2608                                  aa ? RenderingHints.VALUE_ANTIALIAS_ON                                  aa ? RenderingHints.VALUE_ANTIALIAS_ON
2609                                                  : RenderingHints.VALUE_ANTIALIAS_OFF);                                                  : RenderingHints.VALUE_ANTIALIAS_OFF);
# Line 2591  public class XMapPane extends JPanel { Line 2613  public class XMapPane extends JPanel {
2613                  java2DHints.put(RenderingHints.KEY_RENDERING,                  java2DHints.put(RenderingHints.KEY_RENDERING,
2614                                  aa ? RenderingHints.VALUE_RENDER_QUALITY                                  aa ? RenderingHints.VALUE_RENDER_QUALITY
2615                                                  : RenderingHints.VALUE_RENDER_SPEED);                                                  : RenderingHints.VALUE_RENDER_SPEED);
2616                    
2617          }          }
2618    
2619  }  }

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26