Dave Jarvis' Repositories

git clone https://repo.autonoma.ca/repo/keenwrite.git

Wire up refresh view, re-open preview

AuthorDaveJarvis <email>
Date2020-12-30 15:51:46 GMT-0800
Commitf5db16579d4fccd0fde84cccba82fc794ceef553
Parent38bac31
Delta19 lines added, 12 lines removed, 7-line increase
src/main/java/com/keenwrite/ui/actions/ApplicationActions.java
public void view‿refresh() {
+ getMainPane().viewRefresh();
}
public void view‿preview() {
+ getMainPane().viewPreview();
}
src/main/java/com/keenwrite/preview/HtmlPreview.java
public final class HtmlPreview extends SwingNode {
- private static final ChainedReplacedElementFactory FACTORY;
-
- static {
- FACTORY = new ChainedReplacedElementFactory();
-
- // The order is important: Swing factory will replace SVG images with
- // a blank image, which will cause the chained factory to cache the image
- // and exit. Instead, the SVG must execute first to rasterize the content.
- // Consequently, the chained factory must maintain insertion order.
- FACTORY.addFactory( new SvgReplacedElementFactory() );
- FACTORY.addFactory( new SwingReplacedElementFactory() );
- }
+ // The order is important: Swing factory will replace SVG images with
+ // a blank image, which will cause the chained factory to cache the image
+ // and exit. Instead, the SVG must execute first to rasterize the content.
+ // Consequently, the chained factory must maintain insertion order.
+ private static final ChainedReplacedElementFactory FACTORY
+ = new ChainedReplacedElementFactory(
+ new SvgReplacedElementFactory(),
+ new SwingReplacedElementFactory()
+ );
/**
public void render( final String html ) {
mView.render( decorate( html ), getBaseUri() );
+ }
+
+ /**
+ * Clears the caches then rerenders the content.
+ */
+ public void refresh() {
+ FACTORY.clearCache();
+ rerender();
}