Example #1
0
  public void actionPerformed(ActionEvent ae) {
    if (map != null) {
      Proj proj = (Proj) map.getProjection();
      DataBounds bounds = provider.getDataBounds();

      if (bounds != null) {
        java.awt.geom.Point2D center = bounds.getCenter();
        if (center != null) {
          proj.setCenter((float) center.getY(), (float) center.getX());
          LatLonPoint llp1 = new LatLonPoint(bounds.getMax().getY(), bounds.getMin().getX());

          LatLonPoint llp2 = new LatLonPoint(bounds.getMin().getY(), bounds.getMax().getX());

          // 1.1 buffers the edges for viewing a little, a
          // little zommed out.
          proj.setScale(ProjMath.getScale(llp1, llp2, proj) * 1.1f);
          map.setProjection(proj);
        }
      } else {
        String complaint =
            "Can't move map over data: " + provider.getName() + " isn't ready.  Add to map?";
        if (infoDelegator != null) {
          infoDelegator.displayMessage("Go Over Data", complaint);
        } else {
          Debug.error(complaint);
        }
      }
    }
  }