Example #1
0
  /**
   * Check if the envelope corresponds to full extent. It will probably not equal the full extent
   * envelope because of slack space in the display area, so we check that at least one pair of
   * opposite edges are equal to the full extent envelope, allowing for slack space on the other two
   * sides.
   *
   * <p>Note: this method returns {@code false} if the full extent envelope is wholly within the
   * requested envelope (e.g. user has zoomed out from full extent), only touches one edge, or
   * touches two adjacent edges. In all these cases we assume that the user wants to maintain the
   * slack space in the display.
   *
   * <p>This method is part of the work-around that the map pane needs because of the differences in
   * how raster and vector layers are treated by the renderer classes.
   *
   * @param envelope a pending display envelope to compare to the full extent envelope
   * @return true if the envelope is coincident with the full extent evenlope on at least two edges;
   *     false otherwise
   * @todo My logic here seems overly complex - I'm sure there must be a simpler way for the map
   *     pane to handle this.
   */
  private boolean equalsFullExtent(final Envelope envelope) {
    if (fullExtent == null || envelope == null) {
      return false;
    }

    final double TOL = 1.0e-6d * (fullExtent.getWidth() + fullExtent.getHeight());

    boolean touch = false;
    if (Math.abs(envelope.getMinimum(0) - fullExtent.getMinimum(0)) < TOL) {
      touch = true;
    }
    if (Math.abs(envelope.getMaximum(0) - fullExtent.getMaximum(0)) < TOL) {
      if (touch) {
        return true;
      }
    }
    if (Math.abs(envelope.getMinimum(1) - fullExtent.getMinimum(1)) < TOL) {
      touch = true;
    }
    if (Math.abs(envelope.getMaximum(1) - fullExtent.getMaximum(1)) < TOL) {
      if (touch) {
        return true;
      }
    }

    return false;
  }
Example #2
0
  /**
   * Called after the base image has been dragged. Sets the new map area and transforms
   *
   * @param env the display area (world coordinates) prior to the image being moved
   * @param paintArea the current drawing area (screen units)
   */
  private void afterImageMove() {
    final ReferencedEnvelope env = content.getViewport().getBounds();
    if (env == null) return;
    int dx = imageOrigin.x;
    int dy = imageOrigin.y;
    DirectPosition2D newPos = new DirectPosition2D(dx, dy);
    screenToWorld.transform(newPos, newPos);

    env.translate(env.getMinimum(0) - newPos.x, env.getMaximum(1) - newPos.y);
    doSetDisplayArea(env);
    imageOrigin.setLocation(0, 0);
    redrawBaseImage = true;
  }