| 64 | 64 | public final class HTMLPreviewPane extends SwingNode { |
| 65 | 65 | /** |
| 66 | | * Used to scroll to the top of the preview pane. |
| 67 | | */ |
| 68 | | private static final Point POINT_TOP = new Point( 0, 0 ); |
| 69 | | |
| 70 | | /** |
| 71 | 66 | * Suppresses scrolling to the top on every key press. |
| 72 | 67 | */ |
| ... |
| 261 | 256 | } |
| 262 | 257 | |
| 258 | /** |
| 259 | * Scrolls to the location specified by the {@link Box} that corresponds |
| 260 | * to a point somewhere in the preview pane. If there is no caret, then |
| 261 | * this will not change the scroll position. Changing the scroll position |
| 262 | * to the top if the {@link Box} instance is {@code null} will result in |
| 263 | * jumping around a lot and inconsistent synchronization issues. |
| 264 | * |
| 265 | * @param box The rectangular region containing the caret, or {@code null} |
| 266 | * if the HTML does not have a caret. |
| 267 | */ |
| 263 | 268 | private void scrollTo( final Box box ) { |
| 264 | | scrollTo( box == null ? POINT_TOP : createPoint( box ) ); |
| 269 | if( box != null ) { |
| 270 | scrollTo( createPoint( box ) ); |
| 271 | } |
| 265 | 272 | } |
| 266 | 273 | |
| 267 | 274 | private void scrollTo( final Point point ) { |
| 268 | | invokeLater( () -> mHtmlRenderer.scrollTo( point ) ); |
| 275 | mHtmlRenderer.scrollTo( point ); |
| 269 | 276 | } |
| 270 | 277 | |
| ... |
| 300 | 307 | |
| 301 | 308 | public void repaintScrollPane() { |
| 302 | | invokeLater( () -> getScrollPane().repaint() ); |
| 309 | getScrollPane().repaint(); |
| 303 | 310 | } |
| 304 | 311 | |