Java 8 HTMLDocument - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 HTMLDocument class.

This code example shows how to use the following methods:setAsynchronousLoadPriority, setParser, setTokenThreshold
	@Override 
	public Document createDefaultDocument() {
		StyleSheet styles = getStyleSheet();
		StyleSheet ss = new ScaledStyleSheet();
		ss.addStyleSheet(styles);
		HTMLDocument doc = new HTMLDocument(ss);
		doc.setParser(getParser());
		doc.setAsynchronousLoadPriority(4);
		doc.setTokenThreshold(100);
		return doc;
	} 
 
	/** 
	 * Sets the async policy to flush everything in one chunk, and 
	 * to not display unknown tags. 
	 */ 
	Document createDefaultDocument(Font defaultFont, Color foreground) {
		StyleSheet styles = getStyleSheet();
		StyleSheet ss = new ScaledStyleSheet();
		ss.addStyleSheet(styles);
6
CodeRank
This code example shows how to use the following methods:addStyle, getStyle, setBase
        tfText.setText(StringUtils.excerpt(aText, EXCERPT_SENTENCES, EXCERPT_MIN_CHARS, EXCERPT_MAX_CHARS));
        tfText.setEditable(false);
        tfText.setToolTipText("<html>" + aText);
 
        HTMLDocument doc = (HTMLDocument)tfText.getDocument();
        doc.setBase(article.getLink());
        Style def = doc.getStyle("default");
        doc.addStyle(TEXT_STYLE_NAME, def);
        UifUtilities.setFontAttributes(doc, TEXT_STYLE_NAME, articleConfig.getTextFont());
 
        setViewMode(config.getViewMode());
 
        layout = new FormLayout("5px, center:pref, 5px", "5px, pref, 5px, pref, 5px, pref, 5px");
        setLayout(layout);
 
        aImageURL = aImageURL == null ? config.getNoImageURL() : aImageURL;
        Dimension dim = modeToDimension(config.getViewMode());
        lbImage = new AsyncImagePanel(aImageURL, dim.width, dim.height,
            new ShadowBorder(COLOR_SHADOW_BORDER), article.isRead());
        setTextComponentsWidth(); 
6
CodeRank
This code example shows how to use the following methods:getDocumentProperties, setBase
		} 
	} 
 
	public void initImageLoader(HTMLDocument document) {
		try { 
			document.setBase(new URL(ImageLoaderCache.IMAGE_URL_PREFIX));
		} catch (MalformedURLException e) {
			log.error(e.getMessage());
		} 
		setContextResource(navigator.getCurrentResource());
		document.getDocumentProperties().put("imageCache", this);
	} 
 
 
	private String getResourceHref(String requestUrl) {
		String resourceHref = requestUrl.toString().substring(IMAGE_URL_PREFIX.length());
		resourceHref = currentFolder + resourceHref;
		resourceHref = FilenameUtils.normalize(resourceHref);
		// normalize uses the SYSTEM_SEPARATOR, which on windows is a '\' 
		// replace with '/' to make it href '/' 
6
CodeRank
This code example shows how to use the following methods:addDocumentListener, removeDocumentListener, setBase
		final SHTMLPanel noteViewerComponent = noteController.getNoteViewerComponent();
		if (noteViewerComponent == null) {
			return; 
		} 
		final HTMLDocument document = noteViewerComponent.getDocument();
		document.removeDocumentListener(mNoteDocumentListener);
		try { 
			final URL url = node.getMap().getURL();
			if (url != null) {
				document.setBase(url);
			} 
			else { 
				document.setBase(new URL("file: "));
			} 
		} 
		catch (final Exception e) {
		} 
		noteController.setDefaultFont();
		final String note = node != null ? NoteModel.getNoteText(node) : null;
		if (note != null) {

5
CodeRank
This code example shows how to use the following methods:setAsynchronousLoadPriority, setParser, setTokenThreshold
        StyleSheet ss = new StyleSheet();
 
        ss.addStyleSheet(styles);
 
        HTMLDocument doc = new CustomHTMLDocument(ss);
        doc.setParser(getParser());
        doc.setAsynchronousLoadPriority(4);
        doc.setTokenThreshold(100);
        return doc;
    } 
 
    /** 
     * Gets the set of styles to be used to render HTML elements. 
     * 
     * @return A <code>StyleSheet</code> containing the default HTML element styles. 
     */ 
    public StyleSheet getStyleSheet()
    { 
        StyleSheet style;
 
5
CodeRank
This code example shows how to use the following methods:removeDocumentListener, addDocumentListener, setBase
		final SHTMLPanel noteViewerComponent = noteController.getNoteViewerComponent();
		if (noteViewerComponent == null) {
			return; 
		} 
		final HTMLDocument document = noteViewerComponent.getDocument();
		document.removeDocumentListener(mNoteDocumentListener);
		try { 
			final URL url = node.getMap().getURL();
			if (url != null) {
				document.setBase(url);
			} 
			else { 
				document.setBase(new URL("file: "));
			} 
		} 
		catch (final Exception e) {
		} 
		noteController.setDefaultFont();
		final String note = node != null ? NoteModel.getNoteText(node) : null;
		if (note != null) {

5
CodeRank
This code example shows how to use the following methods:insertString
    String content = IOUtils.toString(getClass().getResourceAsStream("/" + filename));
    return createDocument(content);
  } 
 
  public StyledDocument createDocument(String content) throws BadLocationException {
    StyledDocument doc = new HTMLDocument();
    doc.insertString(0, content, null);
    return doc;
  } 
 
} 
4
CodeRank
This code example shows how to use the following methods:
 * @author nantuko 
 */ 
public class ColorPane extends JEditorPane {
 
    HTMLEditorKit kit = new HTMLEditorKit();
    HTMLDocument doc =  new HTMLDocument();
     
    public ColorPane() { 
        this.setEditorKit(kit);
        this.setDocument(doc);
    } 
    /** 
     * This method solves the known issue with Nimbus LAF background transparency and background color. 
     * @param color 
     */ 
    public void setExtBackgroundColor(Color color) {
        setBackground(new Color(0,0,0,0));
        JPanel jPanel = new JPanel();
        jPanel.setBackground(color);
        setLayout(new BorderLayout());
4
CodeRank
This code example shows how to use the following methods:processHTMLFrameHyperlinkEvent
This code example shows how to use the following methods:getLength
	 *            Writer to write to 
	 * @param doc 
	 *            Source document 
	 */ 
	public XHTMLWriter(final Writer writer, final HTMLDocument doc) {
		this(writer, doc, 0, doc.getLength());
	} 
 
	/** 
	 * Create a new XHTMLWriter that will write a part of a HTMLDocument. 
	 *  
	 * @param writer 
	 *            Writer to write to 
	 * @param doc 
	 *            Source document 
	 * @param pos 
	 *            Starting position 
	 * @param len 
	 *            Length 
	 */ 
4
CodeRank
See Code Examples for Java 8 HTMLDocument Methods: