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.
|
---|
2 | package org.openstreetmap.josm.gui.widgets;
|
---|
3 |
|
---|
4 | import javax.swing.text.AbstractDocument;
|
---|
5 | import javax.swing.text.AttributeSet;
|
---|
6 | import javax.swing.text.Element;
|
---|
7 | import javax.swing.text.StyleConstants;
|
---|
8 | import javax.swing.text.View;
|
---|
9 | import javax.swing.text.html.HTML;
|
---|
10 | import javax.swing.text.html.HTMLEditorKit.HTMLFactory;
|
---|
11 |
|
---|
12 | import org.openstreetmap.josm.tools.Logging;
|
---|
13 |
|
---|
14 | /**
|
---|
15 | * Specialized HTML Factory allowing to display SVG images.
|
---|
16 | * @since 8933
|
---|
17 | */
|
---|
18 | public 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.