当前位置: 首页>>代码示例>>Java>>正文


Java HTMLDocument.getLength方法代码示例

本文整理汇总了Java中javax.swing.text.html.HTMLDocument.getLength方法的典型用法代码示例。如果您正苦于以下问题:Java HTMLDocument.getLength方法的具体用法?Java HTMLDocument.getLength怎么用?Java HTMLDocument.getLength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.text.html.HTMLDocument的用法示例。


在下文中一共展示了HTMLDocument.getLength方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getPlaintextFromEditor

import javax.swing.text.html.HTMLDocument; //导入方法依赖的package包/类
/**
 * Returns plain text from the editor.
 *
 * @param editor
 *            the editor from which to take the text.
 * @param onlySelected
 *            if {@code true} will only return the selected text
 * @return the text of the editor converted to plain text
 * @throws BadLocationException
 * @throws IOException
 */
public static String getPlaintextFromEditor(final JEditorPane editor, final boolean onlySelected) throws IOException,
		BadLocationException {
	if (editor == null) {
		throw new IllegalArgumentException("editor must not be null!");
	}
	HTMLDocument document = (HTMLDocument) editor.getDocument();
	StringWriter writer = new StringWriter();
	int start = 0;
	int length = document.getLength();
	if (onlySelected) {
		start = editor.getSelectionStart();
		length = editor.getSelectionEnd() - start;
	}
	editor.getEditorKit().write(writer, document, start, length);
	String text = writer.toString();
	text = AnnotationDrawUtils.removeStyleFromComment(text);
	// switch <br> and <br/> to actual newline (current system)
	text = text.replaceAll("<br.*?>", System.lineSeparator());
	// kill all other html tags
	text = text.replaceAll("\\<.*?>", "");
	text = StringEscapeUtils.unescapeHtml(text);
	return text;
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:35,代码来源:AnnotationDrawUtils.java

示例2: AltHTMLWriter

import javax.swing.text.html.HTMLDocument; //导入方法依赖的package包/类
public AltHTMLWriter(Writer w, HTMLDocument doc, String enc, boolean nument) {
    this(w, doc, 0, doc.getLength(), enc, nument);
}
 
开发者ID:ser316asu,项目名称:Neukoelln_SER316,代码行数:4,代码来源:AltHTMLWriter.java

示例3: AltHTMLWriter

import javax.swing.text.html.HTMLDocument; //导入方法依赖的package包/类
public AltHTMLWriter(Writer w, HTMLDocument doc, String enc) {
    this(w, doc, 0, doc.getLength(), enc, false);
}
 
开发者ID:ser316asu,项目名称:SER316-Dresden,代码行数:4,代码来源:AltHTMLWriter.java

示例4: AltHTMLWriter

import javax.swing.text.html.HTMLDocument; //导入方法依赖的package包/类
/**
 * Creates a new HTMLWriter.
 *
 * @param w   a Writer
 * @param doc  an HTMLDocument
 *
 */

public AltHTMLWriter(Writer w, HTMLDocument doc) {
    this(w, doc, 0, doc.getLength(), null, false);
}
 
开发者ID:ser316asu,项目名称:Wilmersdorf_SER316,代码行数:12,代码来源:AltHTMLWriter.java


注:本文中的javax.swing.text.html.HTMLDocument.getLength方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。