コード例 #1
0
ファイル: CustomMapView.java プロジェクト: juanje/gofleet
 /**
  * @param newCenter {@link EastNorth} of the new center
  * @param zoomFactor The OSM zoom facto to zoom to
  */
 public void zoomToFactor(EastNorth newCenter, int zoomFactor) {
   if (zoomFactor < getMinZoom() || zoomFactor > getMaxZoom()) {
     return;
   }
   this.zoomFactor = zoomFactor;
   super.zoomTo(newCenter, zoom2Scale(zoomFactor));
 }
コード例 #2
0
  public void setProjectionBounds(ProjectionBounds bounds) {
    view_bounds = bounds;

    if (bounds.maxEast - bounds.minEast > max_east_west) {
      max_east_west = bounds.maxEast - bounds.minEast;

      /* We need to set the parent MapView's bounds (i.e.
       * zoom level) to the same as ours max possible
       * bounds to avoid WMSLayer thinking we're zoomed
       * out more than we are or it'll pop up an annoying
       * "requested area is too large" popup.
       */
      EastNorth parent_center = parent.getCenter();
      parent.zoomTo(
          new ProjectionBounds(
              new EastNorth(parent_center.east() - max_east_west / 2, parent_center.north()),
              new EastNorth(parent_center.east() + max_east_west / 2, parent_center.north())));

      /* Request again because NavigatableContent adds
       * a border just to be sure.
       */
      ProjectionBounds new_bounds = parent.getProjectionBounds();
      max_east_west = new_bounds.maxEast - new_bounds.minEast;
    }

    Point vmin = getPoint(bounds.getMin());
    Point vmax = getPoint(bounds.getMax());
    int w = vmax.x + 1;
    int h = vmin.y + 1;

    if (w <= ground_width && h <= ground_height) {
      graphics.setClip(0, 0, w, h);
      return;
    }

    if (w > ground_width) ground_width = w;
    if (h > ground_height) ground_height = h;

    ground_image = new BufferedImage(ground_width, ground_height, BufferedImage.TYPE_INT_RGB);
    graphics = ground_image.createGraphics();
    graphics.setClip(0, 0, w, h);
  }