/[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 436 by mojays, Mon Oct 5 11:54:12 2009 UTC revision 493 by mojays, Fri Oct 23 14:09:27 2009 UTC
# Line 58  import java.util.Map; Line 58  import java.util.Map;
58  import javax.swing.JPanel;  import javax.swing.JPanel;
59    
60  import org.apache.log4j.Logger;  import org.apache.log4j.Logger;
 import org.geotools.geometry.jts.ReferencedEnvelope;  
61  import org.geotools.map.MapContext;  import org.geotools.map.MapContext;
62  import org.geotools.map.event.MapLayerListEvent;  import org.geotools.map.event.MapLayerListEvent;
63  import org.geotools.map.event.MapLayerListListener;  import org.geotools.map.event.MapLayerListListener;
# Line 66  import org.geotools.renderer.GTRenderer; Line 65  import org.geotools.renderer.GTRenderer;
65  import org.geotools.renderer.label.LabelCacheImpl;  import org.geotools.renderer.label.LabelCacheImpl;
66  import org.geotools.renderer.lite.LabelCache;  import org.geotools.renderer.lite.LabelCache;
67  import org.geotools.renderer.lite.StreamingRenderer;  import org.geotools.renderer.lite.StreamingRenderer;
 import org.geotools.renderer.shape.ShapefileRenderer;  
68  import org.opengis.filter.FilterFactory2;  import org.opengis.filter.FilterFactory2;
69  import org.opengis.referencing.crs.CoordinateReferenceSystem;  import org.opengis.referencing.crs.CoordinateReferenceSystem;
70    
# Line 79  import com.vividsolutions.jts.geom.Geome Line 77  import com.vividsolutions.jts.geom.Geome
77    
78  public class JMapPane extends JPanel implements MouseListener,  public class JMapPane extends JPanel implements MouseListener,
79                  MouseMotionListener, PropertyChangeListener, MapLayerListListener {                  MouseMotionListener, PropertyChangeListener, MapLayerListListener {
80          private static Logger LOGGER = Logger.getLogger(JMapPane.class.getName());          private static Logger LOGGER = Logger.getLogger(JMapPane.class);
81    
82          private static final long serialVersionUID = -8647971481359690499L;          private static final long serialVersionUID = -8647971481359690499L;
83    
# Line 232  public class JMapPane extends JPanel imp Line 230  public class JMapPane extends JPanel imp
230                  Map<Object, Object> hints = new HashMap<Object, Object>();                  Map<Object, Object> hints = new HashMap<Object, Object>();
231    
232                  this.renderer = renderer;                  this.renderer = renderer;
233    //MS: Apply hint also for ShapeFileRenderer
234                  if (renderer instanceof StreamingRenderer  //              if (renderer instanceof StreamingRenderer) {
                                 || renderer instanceof ShapefileRenderer) {  
235                          hints = renderer.getRendererHints();                          hints = renderer.getRendererHints();
236                          if (hints == null) {                          if (hints == null) {
237                                  hints = new HashMap<Object, Object>();                                  hints = new HashMap<Object, Object>();
# Line 249  public class JMapPane extends JPanel imp Line 246  public class JMapPane extends JPanel imp
246                          hints.put("memoryPreloadingEnabled", Boolean.TRUE);                          hints.put("memoryPreloadingEnabled", Boolean.TRUE);
247    
248                          renderer.setRendererHints(hints);                          renderer.setRendererHints(hints);
249                  }  //              }
   
                 // this.highlightRenderer = new StreamingRenderer();  
                 // this.selectionRenderer = new StreamingRenderer();  
   
                 // highlightRenderer.setRendererHints(hints);  
                 // selectionRenderer.setRendererHints(hints);  
   
                 // renderer.setRendererHints(hints);  
250    
251                  if (this.context != null) {                  if (this.context != null) {
252                          this.renderer.setContext(this.context);                          this.renderer.setContext(this.context);
# Line 381  public class JMapPane extends JPanel imp Line 370  public class JMapPane extends JPanel imp
370                          boolean grow) {                          boolean grow) {
371                                    
372                  if (mapArea == null) {                  if (mapArea == null) {
373                          LOGGER.warn("mapArea has been null in method fixAspectRatio, returning an unmodified ");                          LOGGER.warn("mapArea has been null in method fixAspectRatio, returning also NULL");
374                            return null;
375                    }
376                    if ( r == null || r.width == 0 || r.height == 0 ) {
377              LOGGER.warn("Empty rectangle in method fixAspectRatio, returning an unmodified mapArea!");
378              return mapArea;
379                  }                  }
380    
381                  final double mapWidth = mapArea.getWidth(); /* get the extent of the map */                  final double mapWidth = mapArea.getWidth(); /* get the extent of the map */
# Line 965  public class JMapPane extends JPanel imp Line 959  public class JMapPane extends JPanel imp
959                  }                  }
960    
961                  Envelope maxAllowedExtend = getMaxExtend();                  Envelope maxAllowedExtend = getMaxExtend();
962                  while (maxAllowedExtend != null && !maxAllowedExtend.contains(newArea)) {                  while (maxAllowedExtend != null && !maxAllowedExtend.contains(newArea) && newArea != null && !newArea.isNull() && !Double.isNaN(newArea.getMinX()) && !Double.isNaN(newArea.getMaxX()) && !Double.isNaN(newArea.getMinY()) && !Double.isNaN(newArea.getMaxY()) ) {
963                          /*                          /*
964                           * If a maxExtend is set, we have to honour that...                           * If a maxExtend is set, we have to honour that...
965                           */                           */
# Line 1002  public class JMapPane extends JPanel imp Line 996  public class JMapPane extends JPanel imp
996                                                  .getMaxX(), newArea.getMaxY() - divY));                                                  .getMaxX(), newArea.getMaxY() - divY));
997    
998                                  if (newArea.getMaxY() > maxAllowedExtend.getMaxY()) {                                  if (newArea.getMaxY() > maxAllowedExtend.getMaxY()) {
999                                          LOGGER.debug("Now it exeeds the top border.. cut!");  //                                      LOGGER.debug("Now it exeeds the top border.. cut!");
1000                                          // And cut the bottom if it moved out of the area                                          // And cut the bottom if it moved out of the area
1001                                          newArea = new Envelope(new Coordinate(newArea.getMinX(),                                          newArea = new Envelope(new Coordinate(newArea.getMinX(),
1002                                                          newArea.getMinY()), new Coordinate(newArea                                                          newArea.getMinY()), new Coordinate(newArea
1003                                                          .getMaxX(), maxAllowedExtend.getMaxY()));                                                          .getMaxX(), maxAllowedExtend.getMaxY()));
1004    
1005                                          LOGGER.debug("and fix aspect ratio");  //                                      LOGGER.debug("and fix aspect ratio");
1006    
1007                                          newArea = fixAspectRatio(this.getBounds(), newArea, false);                                          newArea = fixAspectRatio(this.getBounds(), newArea, false);
1008                                  }                                  }
# Line 1026  public class JMapPane extends JPanel imp Line 1020  public class JMapPane extends JPanel imp
1020                                                  - divX, newArea.getMaxY()));                                                  - divX, newArea.getMaxY()));
1021    
1022                                  if (newArea.getMinX() < maxAllowedExtend.getMinX()) {                                  if (newArea.getMinX() < maxAllowedExtend.getMinX()) {
1023                                          LOGGER.debug("Now it exeeds the left border.. cut!");  //                                      LOGGER.debug("Now it exeeds the left border.. cut!");
1024                                          // And cut the left if it moved out of the area                                          // And cut the left if it moved out of the area
1025                                          newArea = new Envelope(new Coordinate(maxAllowedExtend.getMinX(),                                          newArea = new Envelope(new Coordinate(maxAllowedExtend.getMinX(),
1026                                                          newArea.getMinY()), new Coordinate(newArea                                                          newArea.getMinY()), new Coordinate(newArea
1027                                                          .getMaxX(), newArea.getMaxY()));                                                          .getMaxX(), newArea.getMaxY()));
1028    
1029                                          LOGGER.debug("and fix aspect ratio");  //                                      LOGGER.debug("and fix aspect ratio");
1030    
1031                                          newArea = fixAspectRatio(this.getBounds(), newArea, false);                                          newArea = fixAspectRatio(this.getBounds(), newArea, false);
1032                                  }                                  }
# Line 1050  public class JMapPane extends JPanel imp Line 1044  public class JMapPane extends JPanel imp
1044                                                  - divX, newArea.getMaxY()));                                                  - divX, newArea.getMaxY()));
1045    
1046                                  if (newArea.getMaxX() > maxAllowedExtend.getMaxX()) {                                  if (newArea.getMaxX() > maxAllowedExtend.getMaxX()) {
1047                                          LOGGER.debug("Now it exeeds the right border.. cut!");  //                                      LOGGER.debug("Now it exeeds the right border.. cut!");
1048                                          // And cut the left if it moved out of the area                                          // And cut the left if it moved out of the area
1049                                          newArea = new Envelope(new Coordinate(newArea.getMinX(),                                          newArea = new Envelope(new Coordinate(newArea.getMinX(),
1050                                                          newArea.getMinY()), new Coordinate(maxAllowedExtend                                                          newArea.getMinY()), new Coordinate(maxAllowedExtend
1051                                                          .getMaxX(), newArea.getMaxY()));                                                          .getMaxX(), newArea.getMaxY()));
1052    
1053                                          LOGGER.debug("and fix aspect ratio");  //                                      LOGGER.debug("and fix aspect ratio");
1054    
1055                                          newArea = fixAspectRatio(this.getBounds(), newArea, false);                                          newArea = fixAspectRatio(this.getBounds(), newArea, false);
1056                                  }                                  }
# Line 1144  public class JMapPane extends JPanel imp Line 1138  public class JMapPane extends JPanel imp
1138                                  );                                  );
1139                          } catch (IOException e) {                          } catch (IOException e) {
1140                                  LOGGER.warn(                                  LOGGER.warn(
1141                                                                  "maxExtend == null; faild to getLayerBounds of context",                                                                  "maxExtend == null; failed to getLayerBounds of context",
1142                                                                  e);                                                                  e);
1143                          }                          }
1144                  }                  }

Legend:
Removed from v.436  
changed lines
  Added in v.493

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26