Point (double scale, Point at) { Point locationBefore = imageComponent.getLocation(); ImageZoomModel model = editor != null ? editor.getZoomModel() : getZoomModel(); double factor = model.getZoomFactor(); model.setZoomFactor(scale * factor); return new Point(((int)((at.x - Math.max(scale > 1.0 ? locationBefore.x : 0, 0)) * scale)), ((int)((at.y - Math.max(scale > 1.0 ? locationBefore.y : 0, 0)) * scale))); }