@Override public View asView(Bbox bounds, ZoomOption zoomOption) { double tempResolution = getResolutionForBounds(bounds, zoomOption); Coordinate tempPosition = checkPosition(BboxService.getCenterPoint(bounds), tempResolution); return new View(tempPosition, tempResolution); }
@Override public void applyBounds(Bbox bounds, ZoomOption zoomOption) { double tempResolution = getResolutionForBounds(bounds, zoomOption); Coordinate tempPosition = checkPosition(BboxService.getCenterPoint(bounds), tempResolution); View copy = copy(view, tempPosition, tempResolution); applyViewNoChecks(copy); }
@Override public void applyBounds(Bbox bounds, ZoomOption zoomOption) { double newScale = getScaleForBounds(bounds, zoomOption); Coordinate tempPosition = checkPosition(BboxService.getCenterPoint(bounds), newScale); if (newScale == scale) { if (!position.equals(tempPosition)) { position = tempPosition; if (eventBus != null) { eventBus.fireEvent(new ViewPortTranslatedEvent(this)); } } } else { position = tempPosition; scale = newScale; if (eventBus != null) { eventBus.fireEvent(new ViewPortChangedEvent(this)); } } }
xCenter = BboxService.getCenterPoint(maxBounds).getX(); } else { if ((xCenter - w) < minCoordinate.getX()) { yCenter = BboxService.getCenterPoint(maxBounds).getY(); } else { if ((yCenter - h) < minCoordinate.getY()) {
xCenter = BboxService.getCenterPoint(maxBounds).getX(); } else { if ((xCenter - w) < minCoordinate.getX()) { yCenter = BboxService.getCenterPoint(maxBounds).getY(); } else { if ((yCenter - h) < minCoordinate.getY()) {
private void applyResolution(double newResolution, Coordinate rescalePoint, ZoomOption zoomOption) { double validResolution = checkResolution(newResolution, zoomOption); if (validResolution != getResolution()) { // Calculate theoretical new bounds. First create a BBOX of correct size: Bbox newBbox = new Bbox(0, 0, getMapWidth() * validResolution, getMapHeight() * validResolution); // Calculate translate vector to assure rescalePoint is on the same position as before. double factor = getResolution() / validResolution; double dX = (rescalePoint.getX() - getPosition().getX()) * (1 - 1 / factor); double dY = (rescalePoint.getY() - getPosition().getY()) * (1 - 1 / factor); // Apply translation to set the BBOX on the correct location: newBbox = BboxService.setCenterPoint(newBbox, getPosition()); newBbox = BboxService.translate(newBbox, dX, dY); // Now apply on this view port: Coordinate tempPosition = checkPosition(BboxService.getCenterPoint(newBbox), validResolution); applyViewNoChecks(new View(tempPosition, validResolution)); } }
private void applyScale(double newScale, Coordinate rescalePoint, boolean dragging) { double limitedScale = zoomStrategy.checkScale(newScale, ZoomOption.LEVEL_CLOSEST); if (limitedScale != scale) { // Calculate theoretical new bounds. First create a BBOX of correct size: Bbox newBbox = new Bbox(0, 0, getMapWidth() / limitedScale, getMapHeight() / limitedScale); // Calculate translate vector to assure rescalePoint is on the same position as before. double factor = limitedScale / scale; double dX = (rescalePoint.getX() - position.getX()) * (1 - 1 / factor); double dY = (rescalePoint.getY() - position.getY()) * (1 - 1 / factor); // Apply translation to set the BBOX on the correct location: newBbox = BboxService.setCenterPoint(newBbox, new Coordinate(position.getX(), position.getY())); newBbox = BboxService.translate(newBbox, dX, dY); // Now apply on this view port: scale = limitedScale; position = checkPosition(BboxService.getCenterPoint(newBbox), scale); if (eventBus != null) { if (dX == 0 && dY == 0) { eventBus.fireEvent(dragging ? new ViewPortScalingEvent(this) : new ViewPortScaledEvent(this)); } else { eventBus.fireEvent(dragging ? new ViewPortChangingEvent(this) : new ViewPortChangedEvent(this)); } } } }