Search in sources :

Example 1 with ViewFactory

use of javax.swing.text.ViewFactory in project adempiere by adempiere.

the class HTMLRenderer method get.

/**
	 * 	Get View from HTML String
	 *	@param html html string
	 *	@return renderer view
	 */
public static HTMLRenderer get(String html) {
    HTMLEditorKit kit = new HTMLEditorKit();
    HTMLDocument doc = (HTMLDocument) kit.createDefaultDocument();
    try {
        doc.remove(0, doc.getLength());
        Reader r = new StringReader(html);
        kit.read(r, doc, 0);
    } catch (Exception e) {
        log.log(Level.SEVERE, "", e);
    }
    //	Create Renderer
    Element element = doc.getDefaultRootElement();
    ViewFactory factory = kit.getViewFactory();
    //	Y_AXIS is main
    View view = factory.create(element);
    HTMLRenderer renderer = new HTMLRenderer(factory, view);
    renderer.preferenceChanged(null, true, true);
    return renderer;
}
Also used : HTMLDocument(javax.swing.text.html.HTMLDocument) Element(javax.swing.text.Element) ViewFactory(javax.swing.text.ViewFactory) StringReader(java.io.StringReader) Reader(java.io.Reader) StringReader(java.io.StringReader) HTMLEditorKit(javax.swing.text.html.HTMLEditorKit) View(javax.swing.text.View) BadLocationException(javax.swing.text.BadLocationException)

Aggregations

Reader (java.io.Reader)1 StringReader (java.io.StringReader)1 BadLocationException (javax.swing.text.BadLocationException)1 Element (javax.swing.text.Element)1 View (javax.swing.text.View)1 ViewFactory (javax.swing.text.ViewFactory)1 HTMLDocument (javax.swing.text.html.HTMLDocument)1 HTMLEditorKit (javax.swing.text.html.HTMLEditorKit)1