public class MyHTMLEditorKit extends HTMLEditorKit {
/**
* serialVersionUID
*/
private static final long serialVersionUID = -6075329078257754709L;
@Override
public ViewFactory getViewFactory() {
return new MyViewFactory();
}
public class MyViewFactory extends HTMLFactory {
/**
* Creates a view from an element.
*
* @param elem
* the element
* @return the view
*/
public View create(Element elem) {
Object o = elem.getAttributes().getAttribute(
StyleConstants.NameAttribute);
if (o instanceof HTML.Tag) {
HTML.Tag kind = (HTML.Tag) o;
if (kind == HTML.Tag.CONTENT) {
return new InlineView(elem);
} else if (kind == HTML.Tag.IMG) {
return new MyImageView(elem);
} else {
return super.create(elem);
}
}
// default to text display
return new LabelView(elem);
}
}
}