/[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 435 by alfonx, Sun Oct 4 16:55:52 2009 UTC revision 436 by mojays, Mon Oct 5 11:54:12 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;
61    import org.geotools.geometry.jts.ReferencedEnvelope;
62  import org.geotools.map.MapContext;  import org.geotools.map.MapContext;
63  import org.geotools.map.event.MapLayerListEvent;  import org.geotools.map.event.MapLayerListEvent;
64  import org.geotools.map.event.MapLayerListListener;  import org.geotools.map.event.MapLayerListListener;
# Line 69  import org.geotools.renderer.shape.Shape Line 70  import org.geotools.renderer.shape.Shape
70  import org.opengis.filter.FilterFactory2;  import org.opengis.filter.FilterFactory2;
71  import org.opengis.referencing.crs.CoordinateReferenceSystem;  import org.opengis.referencing.crs.CoordinateReferenceSystem;
72    
73    import schmitzm.geotools.JTSUtil;
74  import schmitzm.swing.SwingUtil;  import schmitzm.swing.SwingUtil;
75    
76  import com.vividsolutions.jts.geom.Coordinate;  import com.vividsolutions.jts.geom.Coordinate;
# Line 971  public class JMapPane extends JPanel imp Line 973  public class JMapPane extends JPanel imp
973                          // Exceeds top? Move down and maybe cut                          // Exceeds top? Move down and maybe cut
974                          if (newArea.getMaxY() > maxAllowedExtend.getMaxY()) {                          if (newArea.getMaxY() > maxAllowedExtend.getMaxY()) {
975                                  double divY = newArea.getMaxY() - maxAllowedExtend.getMaxY();                                  double divY = newArea.getMaxY() - maxAllowedExtend.getMaxY();
976                                  LOGGER.debug("Moving area down by " + divY);  //                              LOGGER.debug("Moving area down by " + divY);
977    
978                                  newArea = new Envelope(new Coordinate(newArea.getMinX(),                                  newArea = new Envelope(new Coordinate(newArea.getMinX(),
979                                                  newArea.getMinY() - divY), new Coordinate(newArea                                                  newArea.getMinY() - divY), new Coordinate(newArea
980                                                  .getMaxX(), newArea.getMaxY() - divY));                                                  .getMaxX(), newArea.getMaxY() - divY));
981    
982                                  if (newArea.getMinY() < maxAllowedExtend.getMinY()) {                                  if (newArea.getMinY() < maxAllowedExtend.getMinY()) {
983                                          LOGGER.debug("Now it exeeds the bottom border.. cut!");  //                                      LOGGER.debug("Now it exeeds the bottom border.. cut!");
984                                          // And cut the bottom if it moved out of the area                                          // And cut the bottom if it moved out of the area
985                                          newArea = new Envelope(new Coordinate(newArea.getMinX(),                                          newArea = new Envelope(new Coordinate(newArea.getMinX(),
986                                                          maxAllowedExtend.getMinY()), new Coordinate(newArea                                                          maxAllowedExtend.getMinY()), new Coordinate(newArea
987                                                          .getMaxX(), newArea.getMaxY()));                                                          .getMaxX(), newArea.getMaxY()));
988    
989                                          LOGGER.debug("and fix aspect ratio");  //                                      LOGGER.debug("and fix aspect ratio");
990    
991                                          newArea = fixAspectRatio(this.getBounds(), newArea, false);                                          newArea = fixAspectRatio(this.getBounds(), newArea, false);
992                                  }                                  }
# Line 993  public class JMapPane extends JPanel imp Line 995  public class JMapPane extends JPanel imp
995                          // Exceeds bottom? Move up and maybe cut                          // Exceeds bottom? Move up and maybe cut
996                          if (newArea.getMinY() < maxAllowedExtend.getMinY()) {                          if (newArea.getMinY() < maxAllowedExtend.getMinY()) {
997                                  double divY = newArea.getMinY() - maxAllowedExtend.getMinY();                                  double divY = newArea.getMinY() - maxAllowedExtend.getMinY();
998                                  LOGGER.debug("Moving area up by " + divY);  //                              LOGGER.debug("Moving area up by " + divY);
999    
1000                                  newArea = new Envelope(new Coordinate(newArea.getMinX(),                                  newArea = new Envelope(new Coordinate(newArea.getMinX(),
1001                                                  newArea.getMinY() - divY), new Coordinate(newArea                                                  newArea.getMinY() - divY), new Coordinate(newArea
# Line 1017  public class JMapPane extends JPanel imp Line 1019  public class JMapPane extends JPanel imp
1019    
1020                                  // Move left..                                  // Move left..
1021                                  double divX = newArea.getMaxX() - maxAllowedExtend.getMaxX();                                  double divX = newArea.getMaxX() - maxAllowedExtend.getMaxX();
1022                                  LOGGER.debug("Moving area left by " + divX);  //                              LOGGER.debug("Moving area left by " + divX);
1023    
1024                                  newArea = new Envelope(new Coordinate(newArea.getMinX() - divX,                                  newArea = new Envelope(new Coordinate(newArea.getMinX() - divX,
1025                                                  newArea.getMinY()), new Coordinate(newArea.getMaxX()                                                  newArea.getMinY()), new Coordinate(newArea.getMaxX()
# Line 1041  public class JMapPane extends JPanel imp Line 1043  public class JMapPane extends JPanel imp
1043    
1044                                  // Move right..                                  // Move right..
1045                                  double divX = newArea.getMinX() - maxAllowedExtend.getMinX();                                  double divX = newArea.getMinX() - maxAllowedExtend.getMinX();
1046                                  LOGGER.debug("Moving area right by " + divX);  //                              LOGGER.debug("Moving area right by " + divX);
1047    
1048                                  newArea = new Envelope(new Coordinate(newArea.getMinX() - divX,                                  newArea = new Envelope(new Coordinate(newArea.getMinX() - divX,
1049                                                  newArea.getMinY()), new Coordinate(newArea.getMaxX()                                                  newArea.getMinY()), new Coordinate(newArea.getMaxX()
# Line 1134  public class JMapPane extends JPanel imp Line 1136  public class JMapPane extends JPanel imp
1136          public Envelope getMaxExtend() {          public Envelope getMaxExtend() {
1137                  if (maxExtend == null) {                  if (maxExtend == null) {
1138                          try {                          try {
1139                                  return fixAspectRatio(this.getBounds(), context.getLayerBounds(), true);                                  return fixAspectRatio(
1140                                        this.getBounds(),
1141                            // Kartenbereich um 10% vergroessern
1142                                        JTSUtil.expandEnvelope(context.getLayerBounds(), 0.1),
1143                                        true
1144                                    );
1145                          } catch (IOException e) {                          } catch (IOException e) {
1146                                  LOGGER                                  LOGGER.warn(
                                                 .warn(  
1147                                                                  "maxExtend == null; faild to getLayerBounds of context",                                                                  "maxExtend == null; faild to getLayerBounds of context",
1148                                                                  e);                                                                  e);
1149                          }                          }

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26