source: josm/trunk/src/org/openstreetmap/josm/gui/widgets/JosmHTMLEditorKit.java@ 13661

Last change on this file since 13661 was 8933, checked in by Don-vip, 8 years ago

fix #11262 - Images not displayed correctly in Help Browser

  • Property svn:eol-style set to native
File size: 1.7 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.gui.widgets;
3
4import javax.swing.text.ViewFactory;
5import javax.swing.text.html.HTMLEditorKit;
6import javax.swing.text.html.StyleSheet;
7
8/**
9 * A subclass of {@link HTMLEditorKit} that fixes an uncommon design choice that shares the set stylesheet between all instances.
10 * This class stores a single stylesheet per instance, as it should have be done by Sun in the first place.
11 * Moreover it allows to display SVG images.
12 * @since 6040
13 */
14public class JosmHTMLEditorKit extends HTMLEditorKit {
15
16 /** Shared factory for creating HTML Views. */
17 private static final ViewFactory FACTORY = new JosmHTMLFactory();
18
19 private StyleSheet ss = super.getStyleSheet();
20
21 /**
22 * Set the set of styles to be used to render the various HTML elements.
23 * These styles are specified in terms of CSS specifications.
24 * Each document produced by the kit will have a copy of the sheet which
25 * it can add the document specific styles to.
26 *
27 * Unlike the base implementation, the StyleSheet specified is NOT shared
28 * by all HTMLEditorKit instances, to provide a finer granularity.
29
30 * @see #getStyleSheet
31 */
32 @Override
33 public void setStyleSheet(StyleSheet s) {
34 ss = s;
35 }
36
37 /**
38 * Get the set of styles currently being used to render the HTML elements.
39 *
40 * Unlike the base implementation, the StyleSheet specified is NOT shared
41 * by all HTMLEditorKit instances, to provide a finer granularity.
42 *
43 * @see #setStyleSheet
44 */
45 @Override
46 public StyleSheet getStyleSheet() {
47 return ss;
48 }
49
50 @Override
51 public ViewFactory getViewFactory() {
52 return FACTORY;
53 }
54}
Note: See TracBrowser for help on using the repository browser.