/[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 431 by alfonx, Sun Oct 4 16:55:52 2009 UTC revision 445 by alfonx, Wed Oct 7 13:17:02 2009 UTC
# Line 69  import org.geotools.renderer.shape.Shape Line 69  import org.geotools.renderer.shape.Shape
69  import org.opengis.filter.FilterFactory2;  import org.opengis.filter.FilterFactory2;
70  import org.opengis.referencing.crs.CoordinateReferenceSystem;  import org.opengis.referencing.crs.CoordinateReferenceSystem;
71    
72    import schmitzm.geotools.JTSUtil;
73  import schmitzm.swing.SwingUtil;  import schmitzm.swing.SwingUtil;
74    
75  import com.vividsolutions.jts.geom.Coordinate;  import com.vividsolutions.jts.geom.Coordinate;
# Line 249  public class JMapPane extends JPanel imp Line 250  public class JMapPane extends JPanel imp
250                          renderer.setRendererHints(hints);                          renderer.setRendererHints(hints);
251                  }                  }
252    
                 // this.highlightRenderer = new StreamingRenderer();  
                 // this.selectionRenderer = new StreamingRenderer();  
   
                 // highlightRenderer.setRendererHints(hints);  
                 // selectionRenderer.setRendererHints(hints);  
   
                 // renderer.setRendererHints(hints);  
   
253                  if (this.context != null) {                  if (this.context != null) {
254                          this.renderer.setContext(this.context);                          this.renderer.setContext(this.context);
255                  }                  }
# Line 963  public class JMapPane extends JPanel imp Line 956  public class JMapPane extends JPanel imp
956                  }                  }
957    
958                  Envelope maxAllowedExtend = getMaxExtend();                  Envelope maxAllowedExtend = getMaxExtend();
959                  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()) ) {
960                          /*                          /*
961                           * If a maxExtend is set, we have to honour that...                           * If a maxExtend is set, we have to honour that...
962                           */                           */
# Line 971  public class JMapPane extends JPanel imp Line 964  public class JMapPane extends JPanel imp
964                          // Exceeds top? Move down and maybe cut                          // Exceeds top? Move down and maybe cut
965                          if (newArea.getMaxY() > maxAllowedExtend.getMaxY()) {                          if (newArea.getMaxY() > maxAllowedExtend.getMaxY()) {
966                                  double divY = newArea.getMaxY() - maxAllowedExtend.getMaxY();                                  double divY = newArea.getMaxY() - maxAllowedExtend.getMaxY();
967                                  LOGGER.debug("Moving area down by " + divY);  //                              LOGGER.debug("Moving area down by " + divY);
968    
969                                  newArea = new Envelope(new Coordinate(newArea.getMinX(),                                  newArea = new Envelope(new Coordinate(newArea.getMinX(),
970                                                  newArea.getMinY() - divY), new Coordinate(newArea                                                  newArea.getMinY() - divY), new Coordinate(newArea
971                                                  .getMaxX(), newArea.getMaxY() - divY));                                                  .getMaxX(), newArea.getMaxY() - divY));
972    
973                                  if (newArea.getMinY() < maxAllowedExtend.getMinY()) {                                  if (newArea.getMinY() < maxAllowedExtend.getMinY()) {
974                                          LOGGER.debug("Now it exeeds the bottom border.. cut!");  //                                      LOGGER.debug("Now it exeeds the bottom border.. cut!");
975                                          // And cut the bottom if it moved out of the area                                          // And cut the bottom if it moved out of the area
976                                          newArea = new Envelope(new Coordinate(newArea.getMinX(),                                          newArea = new Envelope(new Coordinate(newArea.getMinX(),
977                                                          maxAllowedExtend.getMinY()), new Coordinate(newArea                                                          maxAllowedExtend.getMinY()), new Coordinate(newArea
978                                                          .getMaxX(), newArea.getMaxY()));                                                          .getMaxX(), newArea.getMaxY()));
979    
980                                          LOGGER.debug("and fix aspect ratio");  //                                      LOGGER.debug("and fix aspect ratio");
981    
982                                          newArea = fixAspectRatio(this.getBounds(), newArea, false);                                          newArea = fixAspectRatio(this.getBounds(), newArea, false);
983                                  }                                  }
# Line 993  public class JMapPane extends JPanel imp Line 986  public class JMapPane extends JPanel imp
986                          // Exceeds bottom? Move up and maybe cut                          // Exceeds bottom? Move up and maybe cut
987                          if (newArea.getMinY() < maxAllowedExtend.getMinY()) {                          if (newArea.getMinY() < maxAllowedExtend.getMinY()) {
988                                  double divY = newArea.getMinY() - maxAllowedExtend.getMinY();                                  double divY = newArea.getMinY() - maxAllowedExtend.getMinY();
989                                  LOGGER.debug("Moving area up by " + divY);  //                              LOGGER.debug("Moving area up by " + divY);
990    
991                                  newArea = new Envelope(new Coordinate(newArea.getMinX(),                                  newArea = new Envelope(new Coordinate(newArea.getMinX(),
992                                                  newArea.getMinY() - divY), new Coordinate(newArea                                                  newArea.getMinY() - divY), new Coordinate(newArea
993                                                  .getMaxX(), newArea.getMaxY() - divY));                                                  .getMaxX(), newArea.getMaxY() - divY));
994    
995                                  if (newArea.getMaxY() > maxAllowedExtend.getMaxY()) {                                  if (newArea.getMaxY() > maxAllowedExtend.getMaxY()) {
996                                          LOGGER.debug("Now it exeeds the top border.. cut!");  //                                      LOGGER.debug("Now it exeeds the top border.. cut!");
997                                          // And cut the bottom if it moved out of the area                                          // And cut the bottom if it moved out of the area
998                                          newArea = new Envelope(new Coordinate(newArea.getMinX(),                                          newArea = new Envelope(new Coordinate(newArea.getMinX(),
999                                                          newArea.getMinY()), new Coordinate(newArea                                                          newArea.getMinY()), new Coordinate(newArea
1000                                                          .getMaxX(), maxAllowedExtend.getMaxY()));                                                          .getMaxX(), maxAllowedExtend.getMaxY()));
1001    
1002                                          LOGGER.debug("and fix aspect ratio");  //                                      LOGGER.debug("and fix aspect ratio");
1003    
1004                                          newArea = fixAspectRatio(this.getBounds(), newArea, false);                                          newArea = fixAspectRatio(this.getBounds(), newArea, false);
1005                                  }                                  }
# Line 1017  public class JMapPane extends JPanel imp Line 1010  public class JMapPane extends JPanel imp
1010    
1011                                  // Move left..                                  // Move left..
1012                                  double divX = newArea.getMaxX() - maxAllowedExtend.getMaxX();                                  double divX = newArea.getMaxX() - maxAllowedExtend.getMaxX();
1013                                  LOGGER.debug("Moving area left by " + divX);  //                              LOGGER.debug("Moving area left by " + divX);
1014    
1015                                  newArea = new Envelope(new Coordinate(newArea.getMinX() - divX,                                  newArea = new Envelope(new Coordinate(newArea.getMinX() - divX,
1016                                                  newArea.getMinY()), new Coordinate(newArea.getMaxX()                                                  newArea.getMinY()), new Coordinate(newArea.getMaxX()
1017                                                  - divX, newArea.getMaxY()));                                                  - divX, newArea.getMaxY()));
1018    
1019                                  if (newArea.getMinX() < maxAllowedExtend.getMinX()) {                                  if (newArea.getMinX() < maxAllowedExtend.getMinX()) {
1020                                          LOGGER.debug("Now it exeeds the left border.. cut!");  //                                      LOGGER.debug("Now it exeeds the left border.. cut!");
1021                                          // And cut the left if it moved out of the area                                          // And cut the left if it moved out of the area
1022                                          newArea = new Envelope(new Coordinate(maxAllowedExtend.getMinX(),                                          newArea = new Envelope(new Coordinate(maxAllowedExtend.getMinX(),
1023                                                          newArea.getMinY()), new Coordinate(newArea                                                          newArea.getMinY()), new Coordinate(newArea
1024                                                          .getMaxX(), newArea.getMaxY()));                                                          .getMaxX(), newArea.getMaxY()));
1025    
1026                                          LOGGER.debug("and fix aspect ratio");  //                                      LOGGER.debug("and fix aspect ratio");
1027    
1028                                          newArea = fixAspectRatio(this.getBounds(), newArea, false);                                          newArea = fixAspectRatio(this.getBounds(), newArea, false);
1029                                  }                                  }
# Line 1041  public class JMapPane extends JPanel imp Line 1034  public class JMapPane extends JPanel imp
1034    
1035                                  // Move right..                                  // Move right..
1036                                  double divX = newArea.getMinX() - maxAllowedExtend.getMinX();                                  double divX = newArea.getMinX() - maxAllowedExtend.getMinX();
1037                                  LOGGER.debug("Moving area right by " + divX);  //                              LOGGER.debug("Moving area right by " + divX);
1038    
1039                                  newArea = new Envelope(new Coordinate(newArea.getMinX() - divX,                                  newArea = new Envelope(new Coordinate(newArea.getMinX() - divX,
1040                                                  newArea.getMinY()), new Coordinate(newArea.getMaxX()                                                  newArea.getMinY()), new Coordinate(newArea.getMaxX()
1041                                                  - divX, newArea.getMaxY()));                                                  - divX, newArea.getMaxY()));
1042    
1043                                  if (newArea.getMaxX() > maxAllowedExtend.getMaxX()) {                                  if (newArea.getMaxX() > maxAllowedExtend.getMaxX()) {
1044                                          LOGGER.debug("Now it exeeds the right border.. cut!");  //                                      LOGGER.debug("Now it exeeds the right border.. cut!");
1045                                          // And cut the left if it moved out of the area                                          // And cut the left if it moved out of the area
1046                                          newArea = new Envelope(new Coordinate(newArea.getMinX(),                                          newArea = new Envelope(new Coordinate(newArea.getMinX(),
1047                                                          newArea.getMinY()), new Coordinate(maxAllowedExtend                                                          newArea.getMinY()), new Coordinate(maxAllowedExtend
1048                                                          .getMaxX(), newArea.getMaxY()));                                                          .getMaxX(), newArea.getMaxY()));
1049    
1050                                          LOGGER.debug("and fix aspect ratio");  //                                      LOGGER.debug("and fix aspect ratio");
1051    
1052                                          newArea = fixAspectRatio(this.getBounds(), newArea, false);                                          newArea = fixAspectRatio(this.getBounds(), newArea, false);
1053                                  }                                  }
# Line 1134  public class JMapPane extends JPanel imp Line 1127  public class JMapPane extends JPanel imp
1127          public Envelope getMaxExtend() {          public Envelope getMaxExtend() {
1128                  if (maxExtend == null) {                  if (maxExtend == null) {
1129                          try {                          try {
1130                                  return fixAspectRatio(this.getBounds(), context.getLayerBounds(), true);                                  return fixAspectRatio(
1131                                        this.getBounds(),
1132                            // Kartenbereich um 10% vergroessern
1133                                        JTSUtil.expandEnvelope(context.getLayerBounds(), 0.1),
1134                                        true
1135                                    );
1136                          } catch (IOException e) {                          } catch (IOException e) {
1137                                  LOGGER                                  LOGGER.warn(
                                                 .warn(  
1138                                                                  "maxExtend == null; faild to getLayerBounds of context",                                                                  "maxExtend == null; faild to getLayerBounds of context",
1139                                                                  e);                                                                  e);
1140                          }                          }

Legend:
Removed from v.431  
changed lines
  Added in v.445

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26