use of javax.swing.text.Document in project LauncherV3 by TechnicPack.
the class LimitLinesDocumentListener method removeLines.
private void removeLines(DocumentEvent e) {
// The root Element of the Document will tell us the total number
// of line in the Document.
Document document = e.getDocument();
Element root = document.getDefaultRootElement();
while (root.getElementCount() > maximumLines) {
if (isRemoveFromStart) {
removeFromStart(document, root);
} else {
removeFromEnd(document, root);
}
}
}
use of javax.swing.text.Document in project openj9 by eclipse.
the class Rtf method convert.
public static String convert(String rtf) throws Exception {
DefaultStyledDocument styledDoc = new DefaultStyledDocument();
RTFEditorKit rtfKit = new RTFEditorKit();
StringReader reader = null;
reader = new StringReader(rtf);
rtfKit.read(reader, styledDoc, 0);
Document doc = styledDoc.getDefaultRootElement().getDocument();
String txt = doc.getText(0, doc.getLength());
return txt;
}
use of javax.swing.text.Document in project freeplane by freeplane.
the class ScaledHTML method createHTMLView.
/**
* Create an html renderer for the given component and
* string of html.
*/
public static View createHTMLView(JComponent c, String html) {
ScaledEditorKit kit = ScaledEditorKit.create();
Document doc = kit.createDefaultDocument(c.getFont(), c.getForeground());
Object base = c.getClientProperty(documentBaseKey);
if (base instanceof URL) {
((HTMLDocument) doc).setBase((URL) base);
}
Reader r = new StringReader(html);
try {
kit.read(r, doc, 0);
} catch (Throwable e) {
}
ViewFactory f = kit.getViewFactory();
View hview = f.create(doc.getDefaultRootElement());
View v = new Renderer(c, f, hview);
return v;
}
use of javax.swing.text.Document in project freeplane by freeplane.
the class XHTMLWriter method html2xhtml.
/**
* Read HTML from the Reader, and send XHTML to the writer. Common mistakes
* in the HTML code will also be corrected. The result is pretty-printed.
*
* @param reader
* HTML source
* @param writer
* XHTML target
*/
public static void html2xhtml(final Reader reader, final Writer writer) throws IOException, BadLocationException {
final HTMLEditorKit kit = new HTMLEditorKit();
final Document doc = kit.createDefaultDocument();
kit.read(reader, doc, doc.getLength());
final XHTMLWriter xhw = new XHTMLWriter(writer, (HTMLDocument) doc);
xhw.write();
}
use of javax.swing.text.Document in project openj9 by eclipse.
the class RtfChild method convert.
public static String convert(String rtf) throws Exception {
DefaultStyledDocument styledDoc = new DefaultStyledDocument();
RTFEditorKit rtfKit = new RTFEditorKit();
StringReader reader = null;
reader = new StringReader(rtf);
rtfKit.read(reader, styledDoc, 0);
Document doc = styledDoc.getDefaultRootElement().getDocument();
String txt = doc.getText(0, doc.getLength());
return txt;
}
Aggregations