void (MouseWheelEvent e) { Options options = OptionsManager.getInstance().getOptions(); EditorOptions editorOptions = options.getEditorOptions(); ZoomOptions zoomOptions = editorOptions.getZoomOptions(); if (zoomOptions.isWheelZooming() && e.isControlDown()) { int rotation = e.getWheelRotation(); double oldZoomFactor = zoomModel.getZoomFactor(); Point oldPosition = myScrollPane.getViewport().getViewPosition(); if (rotation > 0) { zoomModel.zoomOut(); } else if (rotation < 0) { zoomModel.zoomIn(); } // reset view, otherwise view size is not obtained correctly sometimes Component view = myScrollPane.getViewport().getView(); myScrollPane.setViewport(null); myScrollPane.setViewportView(view); if (oldZoomFactor > 0 && rotation != 0) { Point mousePoint = e.getPoint(); double zoomChange = zoomModel.getZoomFactor() / oldZoomFactor; Point newPosition = new Point((int)Math.max(0, (oldPosition.getX() + mousePoint.getX()) * zoomChange - mousePoint.getX()), (int)Math.max(0, (oldPosition.getY() + mousePoint.getY()) * zoomChange - mousePoint.getY())); myScrollPane.getViewport().setViewPosition(newPosition); } e.consume(); } }