/[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 653 by alfonx, Mon Feb 1 15:09:18 2010 UTC revision 677 by alfonx, Fri Feb 5 15:03:17 2010 UTC
# Line 13  import java.awt.event.ActionEvent; Line 13  import java.awt.event.ActionEvent;
13  import java.awt.event.ActionListener;  import java.awt.event.ActionListener;
14  import java.awt.event.ComponentAdapter;  import java.awt.event.ComponentAdapter;
15  import java.awt.event.ComponentEvent;  import java.awt.event.ComponentEvent;
 import java.awt.event.InputEvent;  
16  import java.awt.event.MouseEvent;  import java.awt.event.MouseEvent;
17  import java.awt.event.MouseListener;  import java.awt.event.MouseListener;
18  import java.awt.geom.AffineTransform;  import java.awt.geom.AffineTransform;
# Line 49  import org.geotools.renderer.label.Label Line 48  import org.geotools.renderer.label.Label
48  import org.geotools.renderer.lite.LabelCache;  import org.geotools.renderer.lite.LabelCache;
49  import org.geotools.renderer.lite.RendererUtilities;  import org.geotools.renderer.lite.RendererUtilities;
50  import org.geotools.renderer.lite.StreamingRenderer;  import org.geotools.renderer.lite.StreamingRenderer;
51    import org.geotools.resources.image.ImageUtilities;
52  import org.geotools.swing.JMapPane;  import org.geotools.swing.JMapPane;
53  import org.geotools.swing.event.MapMouseEvent;  import org.geotools.swing.event.MapMouseEvent;
54  import org.geotools.swing.event.MapPaneEvent;  import org.geotools.swing.event.MapPaneEvent;
# Line 100  import com.vividsolutions.jts.geom.Geome Line 100  import com.vividsolutions.jts.geom.Geome
100   */   */
101  public class XMapPane extends JPanel {  public class XMapPane extends JPanel {
102    
103            /**
104             * If {@link #maxExtend} is <code>null</code> the following rules are used
105             * to create a default maximum.
106             * <ul>
107             * <li>Values &lt; 0 : don't grow to fit the monitors aspect ratio, no
108             * margin</li>
109             * <li>Values 0 : grow to fit the monitors aspect ratio, no margin</li>
110             * <li>Values &gt; 0 : grow to fit the monitors aspect ratio, and add a
111             * relative margin</li>
112             * </ul>
113             * **/
114            private double defaultMaxMapExtendMode = .05;
115    
116          // private static final int IMAGETYPE = BufferedImage.TYPE_INT_RGB;          // private static final int IMAGETYPE = BufferedImage.TYPE_INT_RGB;
117          // private static final int IMAGETYPE_withAlpha =          // private static final int IMAGETYPE_withAlpha =
118          // BufferedImage.TYPE_INT_ARGB;          // BufferedImage.TYPE_INT_ARGB;
119          private static final int IMAGETYPE = BufferedImage.TYPE_3BYTE_BGR;          private static final int IMAGETYPE = BufferedImage.TYPE_3BYTE_BGR;
120    
121            public XMapPaneTool getTool() {
122                    return tool;
123            }
124    
125          private static final int IMAGETYPE_withAlpha = BufferedImage.TYPE_4BYTE_ABGR;          private static final int IMAGETYPE_withAlpha = BufferedImage.TYPE_4BYTE_ABGR;
126    
127          private final static Logger LOGGER = Logger.getLogger(XMapPane.class);          private final static Logger LOGGER = Logger.getLogger(XMapPane.class);
# Line 174  public class XMapPane extends JPanel { Line 192  public class XMapPane extends JPanel {
192           * Flag for no-tool.           * Flag for no-tool.
193           */           */
194          public static final int NONE = -123;          public static final int NONE = -123;
195            //
196          /**          // /**
197           * Flag fuer Modus "Kartenausschnitt bewegen". Nicht fuer Window-Auswahl          // * Flag fuer Modus "Kartenausschnitt bewegen". Nicht fuer Window-Auswahl
198           * moeglich!          // * moeglich!
199           *          // *
200           * @see #setState(int)          // * @see #setState(int)
201           */          // */
202          public static final int PAN = 1;          // public static final int PAN = 1;
203            //
204          /**          // /**
205           * Flag fuer Modus "Heran zoomen".          // * Flag fuer Modus "Heran zoomen".
206           *          // *
207           * @see #setState(int)          // * @see #setState(int)
208           * @see #setState(int)          // * @see #setState(int)
209           */          // */
210          public static final int ZOOM_IN = 2;          // public static final int ZOOM_IN = 2;
211            //
212          /**          // /**
213           * Flag fuer Modus "Heraus zoomen". Nicht fuer Window-Auswahl moeglich!          // * Flag fuer Modus "Heraus zoomen". Nicht fuer Window-Auswahl moeglich!
214           *          // *
215           * @see #setState(int)          // * @see #setState(int)
216           */          // */
217          public static final int ZOOM_OUT = 3;          // public static final int ZOOM_OUT = 3;
   
         /**  
          * Flag fuer Modus "SimpleFeature-Auswahl auf allen (sichtbaren) Layern".  
          *  
          * @see #setState(int)  
          * @see #setState(int)  
          */  
         public static final int SELECT_ALL = 103;  
         /**  
          * Flag fuer Modus  
          * "Auswahl nur eines Features, das erste sichtbare von Oben".  
          *  
          * @see #setState(int)  
          * @see #setState(int)  
          */  
         public static final int SELECT_ONE_FROM_TOP = 104;  
         /**  
          * Flag fuer Modus  
          * "SimpleFeature-Auswahl auf dem obersten (sichtbaren) Layer".  
          *  
          * @see #setState(int)  
          * @see #setState(int)  
          */  
         public static final int SELECT_TOP = 4;  
218    
219          /**          /**
220           * {@link Font} used to paint the wait messages into the map           * {@link Font} used to paint the wait messages into the map
# Line 561  public class XMapPane extends JPanel { Line 555  public class XMapPane extends JPanel {
555           * thread.           * thread.
556           */           */
557          final private Timer startRenderThreadsTimer;          final private Timer startRenderThreadsTimer;
558            //
559          /**          // /**
560           * The default state is ZOOM_IN, hence by default the          // * The default state is ZOOM_IN, hence by default the
561           * {@link #xMapPaneMouseListener} is also enabled.          // * {@link #xMapPaneMouseListener} is also enabled.
562           **/          // **/
563          private int state = ZOOM_IN;          // private int state = ZOOM_IN;
564            //
565          /**          // /**
566           * Manuell gesetzter statischer Cursor, unabhaengig von der aktuellen          // * Manuell gesetzter statischer Cursor, unabhaengig von der aktuellen
567           * MapPane-Funktion          // * MapPane-Funktion
568           */          // */
569          protected Cursor staticCursor = null;          // protected Cursor staticCursor = null;
570    
571          private AffineTransform worldToScreen;          private AffineTransform worldToScreen;
572    
# Line 618  public class XMapPane extends JPanel { Line 612  public class XMapPane extends JPanel {
612                          final Map<Object, Object> rendererHints) {                          final Map<Object, Object> rendererHints) {
613                  super(true);                  super(true);
614    
615                    // A default setting
616                    RenderingHints hintsJava2d = ImageUtilities.NN_INTERPOLATION_HINT;
617                    setJava2dHints(hintsJava2d);
618    
619                  setRendererHints(rendererHints);                  setRendererHints(rendererHints);
620    
621                  setOpaque(true);                  setOpaque(true);
# Line 631  public class XMapPane extends JPanel { Line 629  public class XMapPane extends JPanel {
629                  this.addMouseListener(xMapPaneMouseListener);                  this.addMouseListener(xMapPaneMouseListener);
630                  this.addMouseMotionListener(xMapPaneMouseListener);                  this.addMouseMotionListener(xMapPaneMouseListener);
631                  this.addMouseWheelListener(xMapPaneMouseListener);                  this.addMouseWheelListener(xMapPaneMouseListener);
                 xMapPaneMouseListener.actions.put(MouseInputType.LClick,  
                                 XMapPaneAction.ZOOM_IN);  
                 xMapPaneMouseListener.actions.put(MouseInputType.LDrag,  
                                 XMapPaneAction.ZOOM_IN);  
                 xMapPaneMouseListener.actions.put(MouseInputType.Wheel,  
                                 XMapPaneAction.ZOOM_IN);  
632    
633                  xMapPaneMouseListener.actions.put(MouseInputType.RClick,                  // By default the XMapPAne uses the ZOOM_IN tool.
634                                  XMapPaneAction.SELECT_ALL);                  setTool(XMapPaneTool.ZOOM_IN);
   
                 xMapPaneMouseListener.actions.put(MouseInputType.RDrag,  
                                 XMapPaneAction.PAN);  
635    
636                  /*                  /*
637                   * 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 828  public class XMapPane extends JPanel { Line 817  public class XMapPane extends JPanel {
817    
818                  final Envelope maxAllowedExtend = getMaxExtend();                  final Envelope maxAllowedExtend = getMaxExtend();
819    
820                    /*
821                     * If a maxAllowedExtend is set, we have to honour that...
822                     */
823                    Envelope lastCalculatedArea = null;
824                  while (maxAllowedExtend != null && !maxAllowedExtend.contains(newArea)                  while (maxAllowedExtend != null && !maxAllowedExtend.contains(newArea)
825                                  && newArea != null && !newArea.isNull()                                  && newArea != null && !newArea.isNull()
826                                  && !Double.isNaN(newArea.getMinX())                                  && !Double.isNaN(newArea.getMinX())
827                                  && !Double.isNaN(newArea.getMaxX())                                  && !Double.isNaN(newArea.getMaxX())
828                                  && !Double.isNaN(newArea.getMinY())                                  && !Double.isNaN(newArea.getMinY())
829                                  && !Double.isNaN(newArea.getMaxY())) {                                  && !Double.isNaN(newArea.getMaxY())
830                          /*                                   ) // Due to Double precision problems, this may iterate for ever
831                           * If a maxExtend is set, we have to honour that...                  {
832                           */                          
833                            if (newArea.equals(lastCalculatedArea))
834                                    break;
835                            // Check that we are not iterating for ever due to double precision rounding errors
836                            lastCalculatedArea = newArea;
837                            
838                          // Exceeds top? Move down and maybe cut                          // Exceeds top? Move down and maybe cut
839                          if (newArea.getMaxY() > maxAllowedExtend.getMaxY()) {                          if (newArea.getMaxY() > maxAllowedExtend.getMaxY()) {
840                                  final double divY = newArea.getMaxY()                                  final double divY = newArea.getMaxY()
# Line 941  public class XMapPane extends JPanel { Line 938  public class XMapPane extends JPanel {
938                                                                          .getCoordinateReferenceSystem()), false);                                                                          .getCoordinateReferenceSystem()), false);
939                                  }                                  }
940                          }                          }
941                            
942                            
943                  }                  }
944    
945                  return new ReferencedEnvelope(newArea, env                  return new ReferencedEnvelope(newArea, env
# Line 1014  public class XMapPane extends JPanel { Line 1013  public class XMapPane extends JPanel {
1013           */           */
1014          protected void drawRectangle(final Graphics graphics, final Point startPos,          protected void drawRectangle(final Graphics graphics, final Point startPos,
1015                          final Point e) {                          final Point e) {
1016                  drawRectangle(graphics, startPos, e, Color.WHITE);                  drawRectangle(graphics, startPos, e, Color.WHITE, false);
1017          }          }
1018    
1019          /**          /**
# Line 1022  public class XMapPane extends JPanel { Line 1021  public class XMapPane extends JPanel {
1021           * given point. All in screen coordinates.           * given point. All in screen coordinates.
1022           */           */
1023          protected void drawRectangle(final Graphics graphics, final Point startPos,          protected void drawRectangle(final Graphics graphics, final Point startPos,
1024                          final Point e, Color color) {                          final Point e, Color color, boolean fill) {
1025    
1026                  if (!isWellDefined())                  if (!isWellDefined())
1027                          return;                          return;
# Line 1039  public class XMapPane extends JPanel { Line 1038  public class XMapPane extends JPanel {
1038                          return;                          return;
1039    
1040                  graphics.setXORMode(color);                  graphics.setXORMode(color);
1041    
1042                    if (fill) {
1043                            graphics.fillRect(left, bottom, width, height);
1044                            graphics.setXORMode(Color.WHITE);
1045                    }
1046    
1047                  graphics.drawRect(left, bottom, width, height);                  graphics.drawRect(left, bottom, width, height);
1048          }          }
1049    
# Line 1250  public class XMapPane extends JPanel { Line 1255  public class XMapPane extends JPanel {
1255                                  return null;                                  return null;
1256                          }                          }
1257    
1258                          // Vergrößerung um 10% nochmal rausgenommen                          return JTSUtil
1259                          // // // Kartenbereich um 10% vergroessern                                          .fixAspectRatio(getVisibleRect(), addDefaultMargin(layerBounds), true);
                         // return JTSUtil.fixAspectRatio(getVisibleRect(), JTSUtil  
                         // .expandEnvelope(layerBounds, 0.1), true);  
1260    
                         return JTSUtil.fixAspectRatio(getVisibleRect(), layerBounds, true);  
1261                  }                  }
1262                  return maxExtend;                  return maxExtend;
1263          }          }
# Line 1310  public class XMapPane extends JPanel { Line 1312  public class XMapPane extends JPanel {
1312                  return new AffineTransform(screenToWorld);                  return new AffineTransform(screenToWorld);
1313          }          }
1314    
1315          public int getState() {          // public int getState() {
1316                  return state;          // return state;
1317          }          // }
1318            //
1319          /**          // /**
1320           * Liefert den statisch eingestellten Cursor, der unabhaengig von der          // * Liefert den statisch eingestellten Cursor, der unabhaengig von der
1321           * eingestellten MapPane-Aktion (Zoom, Auswahl, ...) verwendet wird.          // * eingestellten MapPane-Aktion (Zoom, Auswahl, ...) verwendet wird.
1322           *          // *
1323           * @return {@code null}, wenn kein statischer Cursor verwendet, sondern der          // * @return {@code null}, wenn kein statischer Cursor verwendet, sondern
1324           *         Cursor automatisch je nach MapPane-Aktion eingestellt wird.          // der
1325           */          // * Cursor automatisch je nach MapPane-Aktion eingestellt wird.
1326          public Cursor getStaticCursor() {          // */
1327                  return this.staticCursor;          // public Cursor getStaticCursor() {
1328          }          // return this.staticCursor;
1329            // }
1330    
1331          public AffineTransform getWorldToScreenTransform() {          public AffineTransform getWorldToScreenTransform() {
1332                  if (worldToScreen == null) {                  if (worldToScreen == null) {
# Line 1611  public class XMapPane extends JPanel { Line 1614  public class XMapPane extends JPanel {
1614                  }                  }
1615    
1616          }          }
1617  //  
1618  //      /**          //
1619  //       * Performs a {@value #PAN} action. During panning, the displacement is          // /**
1620  //       * stored in {@link #imageOrigin} object. Calling {@link #performPan()} will          // * Performs a {@value #PAN} action. During panning, the displacement is
1621  //       * reset the offset and call {@link #setMapArea(Envelope)}.          // * stored in {@link #imageOrigin} object. Calling {@link #performPan()}
1622  //       */          // will
1623  //      public void performPan() {          // * reset the offset and call {@link #setMapArea(Envelope)}.
1624  //          // */
1625  //              final Rectangle winBounds = getVisibleRect();          // public void performPan() {
1626  //          //
1627  //              winBounds.translate(-imageOrigin.x, -imageOrigin.y);          // final Rectangle winBounds = getVisibleRect();
1628  //              final Envelope newMapArea = tranformWindowToGeo(winBounds.x,          //
1629  //                              winBounds.y, winBounds.x + winBounds.width, winBounds.y          // winBounds.translate(-imageOrigin.x, -imageOrigin.y);
1630  //                                              + winBounds.height);          // final Envelope newMapArea = tranformWindowToGeo(winBounds.x,
1631  //          // winBounds.y, winBounds.x + winBounds.width, winBounds.y
1632  //              imageOrigin.x = 0;          // + winBounds.height);
1633  //              imageOrigin.y = 0;          //
1634  //          // imageOrigin.x = 0;
1635  //              if (!setMapArea(newMapArea)) {          // imageOrigin.y = 0;
1636  //                      /**          //
1637  //                       * If setMapArea returns true, the finalImage is updated anyways.          // if (!setMapArea(newMapArea)) {
1638  //                       * This if-case exists to ensure that we repaint a correct image          // /**
1639  //                       * even if the new panning area has been denied.          // * If setMapArea returns true, the finalImage is updated anyways.
1640  //                       */          // * This if-case exists to ensure that we repaint a correct image
1641  //                      updateFinalImage();          // * even if the new panning area has been denied.
1642  //                      repaint();          // */
1643  //              }          // updateFinalImage();
1644  //          // repaint();
1645  //              if (getCursor() == SwingUtil.PANNING_CURSOR)          // }
1646  //                      setCursor(SwingUtil.PAN_CURSOR);          //
1647  //      }          // if (getCursor() == SwingUtil.PANNING_CURSOR)
1648            // setCursor(SwingUtil.PAN_CURSOR);
1649            // }
1650    
1651          /**          /**
1652           * Entfernt einen Listener von der Map.           * Entfernt einen Listener von der Map.
# Line 1950  public class XMapPane extends JPanel { Line 1955  public class XMapPane extends JPanel {
1955    
1956          // /** Stored the time used for the last real rendering in ms. **/          // /** Stored the time used for the last real rendering in ms. **/
1957          private long lastRenderingDuration = 1000;          private long lastRenderingDuration = 1000;
1958          private XMapPaneTool tool = XMapPaneTool.INFO;          private XMapPaneTool tool = null;
1959    
1960          /**          /**
1961           * 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 1982  public class XMapPane extends JPanel { Line 1987  public class XMapPane extends JPanel {
1987                          this.rendererHints = rendererHints;                          this.rendererHints = rendererHints;
1988          }          }
1989    
1990          /**          // @Deprecated
1991           * Enables/Disables the ZOOM Mouse Listener. Upates the Cursor and stops the          // public void setState(final int state) {
1992           * repaint Timer if          // this.state = state;
1993           *          //
1994           * @param state          // // throw new RuntimeException("Old concept.. migrate to new concept!");
1995           */          //
1996          @Deprecated          // // xMapPaneMouseListener.setEnabled((state == ZOOM_IN
1997          public void setState(final int state) {          // // || state == ZOOM_OUT || state == PAN));
1998                  this.state = state;          //
1999            // // Je nach Aktion den Cursor umsetzen
2000                  // throw new RuntimeException("Old concept.. migrate to new concept!");          // updateCursor();
2001            // }
                 // xMapPaneMouseListener.setEnabled((state == ZOOM_IN  
                 // || state == ZOOM_OUT || state == PAN));  
   
                 // Je nach Aktion den Cursor umsetzen  
                 updateCursor();  
         }  
2002    
2003          public void configureMouse(MouseInputType type, XMapPaneAction action) {          public void configureMouse(MouseInputType type, XMapPaneAction action) {
2004                  xMapPaneMouseListener.actions.put(type, action);                  xMapPaneMouseListener.actions.put(type, action);
2005          }          }
2006            
2007            /**
2008             * Configure the {@link XMapPaneTool} that active on the map. Passing
2009             * <code>null</code> will set the NO_ACTION tool.
2010             */
2011          public void setTool(XMapPaneTool tool) {          public void setTool(XMapPaneTool tool) {
2012                    if (tool == null)
2013                            tool = XMapPaneTool.NO_ACTION;
2014                  this.tool = tool;                  this.tool = tool;
2015                  xMapPaneMouseListener.configure(tool);                  xMapPaneMouseListener.configure(tool);
2016                  setCursor(tool.cursor);                  setCursor(tool.getCursor());
2017          }          }
2018    
2019          /**          // /**
2020           * Standardmaessig wird der Cursor automatisch je nach MapPane-Aktion (Zoom,          // * Standardmaessig wird der Cursor automatisch je nach MapPane-Aktion
2021           * Auswahl, ...) gesetzt. Mit dieser Methode kann ein statischer Cursor          // (Zoom,
2022           * gesetzt werden, der unabhaengig von der aktuellen MapPanes-Aktion          // * Auswahl, ...) gesetzt. Mit dieser Methode kann ein statischer Cursor
2023           * beibehalten wird. Um diesen statischen Cursor wieder zu entfernen, kann          // * gesetzt werden, der unabhaengig von der aktuellen MapPanes-Aktion
2024           * {@code null} als Parameter uebergeben werden          // * beibehalten wird. Um diesen statischen Cursor wieder zu entfernen, kann
2025           *          // * {@code null} als Parameter uebergeben werden
2026           * @param cursor          // *
2027           *            Cursor          // * @param cursor
2028           */          // * Cursor
2029          public void setStaticCursor(final Cursor cursor) {          // */
2030                  this.staticCursor = cursor;          // public void setStaticCursor(final Cursor cursor) {
2031                  if (cursor != null)          // this.staticCursor = cursor;
2032                          super.setCursor(cursor);          // if (cursor != null)
2033          }          // super.setCursor(cursor);
2034            // }
2035    
2036          /**          /**
2037           * Starts rendering on one or two threads           * Starts rendering on one or two threads
# Line 2167  public class XMapPane extends JPanel { Line 2173  public class XMapPane extends JPanel {
2173                                  repaint();                                  repaint();
2174                          }                          }
2175                  }                  }
2176                                    //              
2177  //                  // //
2178                  // wenn manueller Cursor gesetzt ist, dann diesen verwenden (unabhaengig                  // // wenn manueller Cursor gesetzt ist, dann diesen verwenden
2179                  // von der aktuellen Aktion                  // (unabhaengig
2180                  if (this.staticCursor != null) {                  // // von der aktuellen Aktion
2181                          setCursor(staticCursor);                  // if (this.staticCursor != null) {
2182                          return;                  // setCursor(staticCursor);
2183                  }                  // return;
2184                                    // }
2185                    //              
2186                  if (getCursor() == SwingUtil.PANNING_CURSOR) {                  if (getCursor() == SwingUtil.PANNING_CURSOR) {
2187                          // This cursor will reset itself                          // This cursor will reset itself
2188                          return;                          return;
2189                  }                  }
2190                    
2191                  setCursor(tool.cursor);                  setCursor(tool.getCursor());
2192  //  
2193  //              // Set the cursor depending on what tool is in use...                  //
2194  //              switch (state) {                  // // Set the cursor depending on what tool is in use...
2195  //              case SELECT_TOP:                  // switch (state) {
2196  //              case SELECT_ONE_FROM_TOP:                  // case SELECT_TOP:
2197  //              case SELECT_ALL:                  // case SELECT_ONE_FROM_TOP:
2198  //                      setCursor(SwingUtil.CROSSHAIR_CURSOR);                  // case SELECT_ALL:
2199  //                      break;                  // setCursor(SwingUtil.CROSSHAIR_CURSOR);
2200  //              case ZOOM_IN:                  // break;
2201  //                      setCursor(SwingUtil.ZOOMIN_CURSOR);                  // case ZOOM_IN:
2202  //                      break;                  // setCursor(SwingUtil.ZOOMIN_CURSOR);
2203  //              case ZOOM_OUT:                  // break;
2204  //                      setCursor(SwingUtil.ZOOMOUT_CURSOR);                  // case ZOOM_OUT:
2205  //                      break;                  // setCursor(SwingUtil.ZOOMOUT_CURSOR);
2206  //              case PAN:                  // break;
2207  //                      setCursor(SwingUtil.PAN_CURSOR);                  // case PAN:
2208  //                      break;                  // setCursor(SwingUtil.PAN_CURSOR);
2209  //              default:                  // break;
2210  //                      setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));                  // default:
2211  //                      break;                  // setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
2212  //              }                  // break;
2213                    // }
2214          }          }
2215    
2216          /**          /**
# Line 2232  public class XMapPane extends JPanel { Line 2240  public class XMapPane extends JPanel {
2240    
2241                  final Graphics2D finalG = getFinalImage().createGraphics();                  final Graphics2D finalG = getFinalImage().createGraphics();
2242                  finalG.setBackground(getMapBackgroundColor());                  finalG.setBackground(getMapBackgroundColor());
2243                  finalG.drawImage(getPreFinalImage(), getImageOrigin().x, getImageOrigin().y,                  finalG.drawImage(getPreFinalImage(), getImageOrigin().x,
2244                                  getMapBackgroundColor(), null);                                  getImageOrigin().y, getMapBackgroundColor(), null);
2245    
2246                  // When panning, we have to clear the area around the image                  // When panning, we have to clear the area around the image
2247                  final Rectangle painedArea = new Rectangle(getImageOrigin().x,                  final Rectangle painedArea = new Rectangle(getImageOrigin().x,
# Line 2242  public class XMapPane extends JPanel { Line 2250  public class XMapPane extends JPanel {
2250                  SwingUtil.clearAround(finalG, painedArea, getVisibleRect(),                  SwingUtil.clearAround(finalG, painedArea, getVisibleRect(),
2251                                  getMapBackgroundColor());                                  getMapBackgroundColor());
2252    
2253  //              addGadgets(finalG, false);                   addGadgets(finalG, false);
2254    
2255                  finalG.dispose();                  finalG.dispose();
2256    
# Line 2403  public class XMapPane extends JPanel { Line 2411  public class XMapPane extends JPanel {
2411                          // BB umrechnen von Layer-CRS in Map-CRS                          // BB umrechnen von Layer-CRS in Map-CRS
2412    
2413                          // Expand a bit                          // Expand a bit
2414                          bounds.expandBy(bounds.getWidth() / 6., bounds.getHeight() / 6.);                          addDefaultMargin(bounds);
2415    
2416                          setMapArea(bounds);                          setMapArea(bounds);
2417                  }                  }
2418          }          }
2419    
2420            private ReferencedEnvelope addDefaultMargin(ReferencedEnvelope bounds) {
2421                    return JTSUtil.expandEnvelope(bounds, Math.max(0,
2422                                    defaultMaxMapExtendMode));
2423            }
2424    
2425            private Envelope addDefaultMargin(Envelope bounds) {
2426                    return JTSUtil.expandEnvelope(bounds, Math.max(0,
2427                                    defaultMaxMapExtendMode));
2428            }
2429    
2430          /**          /**
2431           * Zooms towards a point.           * Zooms towards a point.
2432           *           *
# Line 2556  public class XMapPane extends JPanel { Line 2574  public class XMapPane extends JPanel {
2574                          // genau auf dem Rand der angezeigten Flaeche)                          // genau auf dem Rand der angezeigten Flaeche)
2575    
2576                          if (mapAreaNew != null) {                          if (mapAreaNew != null) {
2577                                  mapAreaNew.expandBy(mapAreaNew.getWidth() * 0.1, mapAreaNew  
2578                                                  .getHeight() * 0.1);                                  mapAreaNew = addDefaultMargin(mapAreaNew);
2579                                  setMapArea(mapAreaNew);                                  setMapArea(mapAreaNew);
2580                          } else {                          } else {
2581                                  LOGGER                                  LOGGER
# Line 2639  public class XMapPane extends JPanel { Line 2657  public class XMapPane extends JPanel {
2657                  return imageOrigin;                  return imageOrigin;
2658          }          }
2659    
2660            /**
2661             * If {@link #maxExtend} is <code>null</code> the following rules are used
2662             * to create a default maximum.
2663             * <ul>
2664             * <li>Values &lt; 0 : don't grow to fit the monitors aspect ratio, no
2665             * margin</li>
2666             * <li>Values 0 : grow to fit the monitors aspect ratio, no margin</li>
2667             * <li>Values &gt; 0 : grow to fit the monitors aspect ratio, and add a
2668             * relative margin</li>
2669             * </ul>
2670             * **/
2671            public void setDefaultMaxMapExtendMode(double defaultMaxMapExtendMode) {
2672                    this.defaultMaxMapExtendMode = defaultMaxMapExtendMode;
2673            }
2674    
2675            /**
2676             * If {@link #maxExtend} is <code>null</code> the following rules are used
2677             * to create a default maximum.
2678             * <ul>
2679             * <li>Values &lt; 0 : don't grow to fit the monitors aspect ratio, no
2680             * margin</li>
2681             * <li>Values 0 : grow to fit the monitors aspect ratio, no margin</li>
2682             * <li>Values &gt; 0 : grow to fit the monitors aspect ratio, and add a
2683             * relative margin</li>
2684             * </ul>
2685             * **/
2686            public double getDefaultMaxMapExtendMode() {
2687                    return defaultMaxMapExtendMode;
2688            }
2689    
2690  }  }

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26