/**
  * Align given bounds with square size and expand by given fraction
  *
  * @param bounds
  * @param size
  * @return
  */
 private ReferencedEnvelope align(ReferencedEnvelope bounds, double size, double expand) {
   bounds = new ReferencedEnvelope(bounds);
   bounds.expandBy(expand * size);
   double x = offset(bounds.getLowerCorner(), 0, size);
   double y = offset(bounds.getLowerCorner(), 1, size);
   bounds.translate(-x, -y);
   return bounds;
 }
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;
  }