source: josm/trunk/src/org/openstreetmap/josm/gui/widgets/JosmHTMLFactory.java@ 12620

Last change on this file since 12620 was 12620, checked in by Don-vip, 7 years ago

see #15182 - deprecate all Main logging methods and introduce suitable replacements in Logging for most of them

File size: 1.2 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.gui.widgets;
3
4import javax.swing.text.AbstractDocument;
5import javax.swing.text.AttributeSet;
6import javax.swing.text.Element;
7import javax.swing.text.StyleConstants;
8import javax.swing.text.View;
9import javax.swing.text.html.HTML;
10import javax.swing.text.html.HTMLEditorKit.HTMLFactory;
11
12import org.openstreetmap.josm.tools.Logging;
13
14/**
15 * Specialized HTML Factory allowing to display SVG images.
16 * @since 8933
17 */
18public class JosmHTMLFactory extends HTMLFactory {
19
20 @Override
21 public View create(Element elem) {
22 AttributeSet attrs = elem.getAttributes();
23 Object elementName = attrs.getAttribute(AbstractDocument.ElementNameAttribute);
24 Object o = (elementName != null) ? null : attrs.getAttribute(StyleConstants.NameAttribute);
25 if (o instanceof HTML.Tag) {
26 HTML.Tag kind = (HTML.Tag) o;
27 if (kind == HTML.Tag.IMG) {
28 try {
29 return new JosmImageView(elem);
30 } catch (NoSuchFieldException | SecurityException e) {
31 Logging.error(e);
32 }
33 }
34 }
35 return super.create(elem);
36 }
37}
Note: See TracBrowser for help on using the repository browser.