Example usage for javax.swing.text.html StyleSheet loadRules

List of usage examples for javax.swing.text.html StyleSheet loadRules

Introduction

In this page you can find the example usage for javax.swing.text.html StyleSheet loadRules.

Prototype

public void loadRules(Reader in, URL ref) throws IOException 

Source Link

Document

Loads a set of rules that have been specified in terms of CSS1 grammar.

Usage

From source file:net.ftb.util.OSUtils.java

public static StyleSheet makeStyleSheet(String name) {
    try {/*from w  w w  . j a  v a2s .com*/
        StyleSheet sheet = new StyleSheet();
        Reader reader = new InputStreamReader(System.class.getResourceAsStream("/css/" + name + ".css"));
        sheet.loadRules(reader, null);
        reader.close();

        return sheet;
    } catch (Exception ex) {
        ex.printStackTrace();
        return null;
    }
}

From source file:com.vladsch.idea.multimarkdown.editor.MultiMarkdownPreviewEditor.java

public static void setStyleSheet(JEditorPane jEditorPane) {
    HTMLEditorKit htmlKit = new HTMLEditorKit();

    final StyleSheet style = new StyleSheet();

    if (!MultiMarkdownGlobalSettings.getInstance().useCustomCss(false)) {
        style.importStyleSheet(MultiMarkdownGlobalSettings.getInstance().getCssFileURL(false));
    } else {// ww w  .  ja v  a2 s. com
        try {
            style.loadRules(new StringReader(MultiMarkdownGlobalSettings.getInstance().getCssText(false)),
                    null);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    htmlKit.setStyleSheet(style);
    jEditorPane.setEditorKit(htmlKit);
}

From source file:ja.lingo.application.JaLingo.java

private void applyJEditorPaneStyleHack(int fontSize, String fontFace) {
    StyleSheet ss = new StyleSheet();
    try {/*from  w ww. j  a  va2  s  .  c o m*/
        ss.loadRules(new StringReader(new CssHelper(fontSize, fontFace).asString()), null);
    } catch (IOException e) {
        States.shouldNeverReachHere(e);
    }
    // set static style, so all JEditorPanes wil have new style
    new HTMLEditorKit().getStyleSheet().addStyleSheet(ss);
}

From source file:com.hexidec.ekit.component.ExtendedHTMLEditorKit.java

public StyleSheet getStyleSheet() {
    try {//from   w w  w  .java 2 s .  c om
        StyleSheet defaultStyles = new StyleSheet();
        InputStream is = getClass().getResourceAsStream("/ekit.css");
        Reader r = new BufferedReader(new InputStreamReader(is, "ISO-8859-1"));
        defaultStyles.loadRules(r, null);
        r.close();

        return defaultStyles;
    } catch (Throwable e) {
        log.error("Falha ao ler ekit.css. Utilizando estilos padro.", e);
        return super.getStyleSheet();
    }
}

From source file:EditorPaneExample14.java

public StyleSheet loadStyleSheet(InputStream is) throws IOException {
    StyleSheet s = new StyleSheet();
    BufferedReader reader = new BufferedReader(new InputStreamReader(is));
    s.loadRules(reader, null);
    reader.close();/*from  w w  w.j a  v  a 2s. c  o  m*/

    return s;
}

From source file:EditorPaneExample14.java

public void addToStyleSheet(StyleSheet s, InputStream is) throws IOException {
    BufferedReader reader = new BufferedReader(new InputStreamReader(is));
    s.loadRules(reader, null);
    reader.close();/*from  ww w. j  av a2 s  .  c o m*/
}

From source file:com.vladsch.idea.multimarkdown.editor.MultiMarkdownPreviewEditor.java

protected void setStyleSheet() {
    if (isRawHtml)
        return;//from ww w .  j  a  va 2 s.  c om

    MultiMarkdownEditorKit htmlKit = new MultiMarkdownEditorKit();

    final StyleSheet style = new MultiMarkdownStyleSheet();

    if (!MultiMarkdownGlobalSettings.getInstance().useCustomCss(false)) {
        style.importStyleSheet(MultiMarkdownGlobalSettings.getInstance().getCssFileURL(false));
    } else {
        try {
            style.loadRules(new StringReader(MultiMarkdownGlobalSettings.getInstance().getCssText(false)),
                    null);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    htmlKit.setStyleSheet(style);

    jEditorPane.setEditorKit(htmlKit);
}