001// License: GPL. For details, see LICENSE file. 002package org.openstreetmap.josm.gui.widgets; 003 004import javax.swing.text.html.HTMLEditorKit; 005import javax.swing.text.html.StyleSheet; 006 007/** 008 * A subclass of {@link HTMLEditorKit} that fixes an uncommon design choice that shares the set stylesheet between all instances. 009 * This class stores a single stylesheet per instance, as it should have be done by Sun in the first place. 010 * @since 6040 011 */ 012public class JosmHTMLEditorKit extends HTMLEditorKit { 013 014 /** 015 * Constructs a new {@code JosmHTMLEditorKit} 016 */ 017 public JosmHTMLEditorKit() { 018 } 019 020 protected StyleSheet ss = super.getStyleSheet(); 021 022 /** 023 * Set the set of styles to be used to render the various HTML elements. 024 * These styles are specified in terms of CSS specifications. 025 * Each document produced by the kit will have a copy of the sheet which 026 * it can add the document specific styles to. 027 * 028 * Unlike the base implementation, the StyleSheet specified is NOT shared 029 * by all HTMLEditorKit instances, to provide a finer granularity. 030 031 * @see #getStyleSheet 032 */ 033 @Override 034 public void setStyleSheet(StyleSheet s) { 035 ss = s; 036 } 037 038 /** 039 * Get the set of styles currently being used to render the HTML elements. 040 * 041 * Unlike the base implementation, the StyleSheet specified is NOT shared 042 * by all HTMLEditorKit instances, to provide a finer granularity. 043 * 044 * @see #setStyleSheet 045 */ 046 @Override 047 public StyleSheet getStyleSheet() { 048 return ss; 049 } 050}