Example usage for javax.swing.text StyleConstants setBold

List of usage examples for javax.swing.text StyleConstants setBold

Introduction

In this page you can find the example usage for javax.swing.text StyleConstants setBold.

Prototype

public static void setBold(MutableAttributeSet a, boolean b) 

Source Link

Document

Sets the bold attribute.

Usage

From source file:org.optaplanner.benchmark.impl.aggregator.swingui.BenchmarkAggregatorFrame.java

private JComponent createNoPlannerFoundTextField() {
    String infoMessage = "No planner benchmarks have been found in the benchmarkDirectory ("
            + benchmarkAggregator.getBenchmarkDirectory() + ").";
    JTextPane textPane = new JTextPane();

    textPane.setEditable(false);/*from   w  w  w  . ja v a 2  s. c o m*/
    textPane.setText(infoMessage);

    // center info message
    StyledDocument styledDocument = textPane.getStyledDocument();
    SimpleAttributeSet center = new SimpleAttributeSet();
    StyleConstants.setAlignment(center, StyleConstants.ALIGN_CENTER);
    StyleConstants.setBold(center, true);
    styledDocument.setParagraphAttributes(0, styledDocument.getLength(), center, false);
    return textPane;
}

From source file:org.quackbot.gui.GUIConsoleAppender.java

public void init() {
    //Init styles
    for (JTextPane curPane : ImmutableList.of(gui.BerrorLog, gui.CerrorLog)) {
        StyledDocument doc = curPane.getStyledDocument();
        doc.addStyle("Normal", null);
        StyleConstants.setForeground(doc.addStyle("Class", null), Color.blue);
        StyleConstants.setForeground(doc.addStyle("Error", null), Color.red);
        //BotSend gets a better shade of orange than Color.organ gives
        StyleConstants.setForeground(doc.addStyle("BotSend", null), new Color(255, 127, 0));
        //BotRecv gets a better shade of green than Color.green gives
        StyleConstants.setForeground(doc.addStyle("BotRecv", null), new Color(0, 159, 107));
        StyleConstants.setBold(doc.addStyle("Server", null), true);
        StyleConstants.setItalic(doc.addStyle("Thread", null), true);
        StyleConstants.setItalic(doc.addStyle("Level", null), true);
    }/*w  w w  .j  ava 2  s. co  m*/

    log.debug("Inited GUILogAppender, processing any saved messages");
    synchronized (initMessageQueue) {
        inited = true;
        while (!initMessageQueue.isEmpty())
            append(initMessageQueue.poll());
    }
}

From source file:org.smart.migrate.ui.ImportThread.java

private void addStylesToDocument(StyledDocument doc) {
    //Initialize some styles.
    Style def = StyleContext.getDefaultStyleContext().getStyle(StyleContext.DEFAULT_STYLE);

    Style regular = doc.addStyle("regular", def);
    StyleConstants.setFontFamily(def, "SansSerif");

    Style s = doc.addStyle("italic", regular);
    StyleConstants.setItalic(s, true);

    s = doc.addStyle("bold", regular);
    StyleConstants.setBold(s, true);

    s = doc.addStyle("small", regular);
    StyleConstants.setFontSize(s, 10);

    s = doc.addStyle("large", regular);
    StyleConstants.setFontSize(s, 16);

    s = doc.addStyle("icon", regular);
    StyleConstants.setAlignment(s, StyleConstants.ALIGN_CENTER);

    s = doc.addStyle("info", regular);
    StyleConstants.setForeground(s, Color.blue);

    s = doc.addStyle("error", regular);
    StyleConstants.setForeground(s, Color.red);

    s = doc.addStyle("warning", regular);
    StyleConstants.setForeground(s, Color.orange);

    s = doc.addStyle("gray", regular);
    StyleConstants.setForeground(s, Color.gray);

    s = doc.addStyle("success", regular);
    StyleConstants.setForeground(s, Color.green);
}

From source file:org.zephyrsoft.sdb2.presenter.SongView.java

private Style addStyle(String styleName, boolean italic, boolean bold, String fontFamily, int fontSize) {
    Style style = document.addStyle(styleName, DEFAULT_STYLE);
    StyleConstants.setItalic(style, italic);
    StyleConstants.setBold(style, bold);
    StyleConstants.setFontFamily(style, fontFamily);
    StyleConstants.setFontSize(style, fontSize);
    return style;
}

From source file:pl.otros.logview.gui.message.pattern.StyleProperties.java

public static Style getStyle(StyleContext styleContext, DataConfiguration styleConfig, String styleName,
        int group) {
    Style style = styleContext.addStyle(styleName, styleContext.getStyle(StyleContext.DEFAULT_STYLE));

    String groupSuffix = "." + group;
    if (group <= 0) {
        groupSuffix = "";
    }/*  w  w  w .ja  v  a  2 s .c  o m*/

    String fontFamily = styleConfig.getString(PROP_FONT_FAMILY + groupSuffix, "");
    if (fontFamily.trim().length() > 0) {
        StyleConstants.setFontFamily(style, styleConfig.getString(PROP_FONT_FAMILY + groupSuffix));
    }

    if (styleConfig.getString(PROP_FONT_SIZE + groupSuffix, "").trim().length() > 0) {
        StyleConstants.setFontSize(style, styleConfig.getInt(PROP_FONT_SIZE + groupSuffix));
    }

    if (styleConfig.getString(PROP_FONT_BOLD + groupSuffix, "").trim().length() > 0) {
        StyleConstants.setBold(style, styleConfig.getBoolean(PROP_FONT_BOLD + groupSuffix));
    }

    if (styleConfig.getString(PROP_FONT_ITALIC + groupSuffix, "").trim().length() > 0) {
        StyleConstants.setItalic(style, styleConfig.getBoolean(PROP_FONT_ITALIC + groupSuffix));
    }

    if (styleConfig.getString(PROP_FONT_UNDERLINE + groupSuffix, "").trim().length() > 0) {
        StyleConstants.setUnderline(style, styleConfig.getBoolean(PROP_FONT_UNDERLINE + groupSuffix));
    }

    if (styleConfig.getString(PROP_BACKGROUND + groupSuffix, "").trim().length() > 0) {
        StyleConstants.setBackground(style, styleConfig.getColor(PROP_BACKGROUND + groupSuffix));
    }

    if (styleConfig.getString(PROP_FOREGROUND + groupSuffix, "").trim().length() > 0) {
        StyleConstants.setForeground(style, styleConfig.getColor(PROP_FOREGROUND + groupSuffix));
    }
    return style;
}

From source file:pl.otros.logview.gui.message.update.LogDataFormatter.java

public LogDataFormatter(LogData logData, //
        DateFormat dateFormat, //
        MessageUpdateUtils messageUtils, //
        PluginableElementsContainer<MessageColorizer> colorizersContainer, //
        PluginableElementsContainer<MessageFormatter> formattersContainer, //
        CancelStatus cancelStatus, int maximumMessageSize) {
    this.ld = logData;
    this.dateFormat = dateFormat;
    this.messageUtils = messageUtils;
    this.colorizersContainer = colorizersContainer;
    this.formattersContainer = formattersContainer;
    this.cancelStatus = cancelStatus;
    this.maximumMessageSize = maximumMessageSize;

    sc = new StyleContext();
    defaultStyle = sc.getStyle(StyleContext.DEFAULT_STYLE);
    mainStyle = sc.addStyle("MainStyle", defaultStyle);
    StyleConstants.setFontSize(mainStyle, 12);
    StyleConstants.setForeground(mainStyle, Color.BLACK);

    classMethodStyle = sc.addStyle("classMethod", null);
    StyleConstants.setFontFamily(classMethodStyle, "monospaced");
    StyleConstants.setForeground(classMethodStyle, Color.BLUE);
    boldArialStyle = sc.addStyle("note", mainStyle);
    StyleConstants.setFontFamily(boldArialStyle, "arial");
    StyleConstants.setBold(boldArialStyle, true);

    propertyNameStyle = sc.addStyle("propertyValue", classMethodStyle);
    StyleConstants.setForeground(propertyNameStyle, new Color(0, 0, 128));

    propertyValueStyle = sc.addStyle("propertyValue", classMethodStyle);
    StyleConstants.setForeground(propertyNameStyle, new Color(0, 128, 0));

}

From source file:pl.otros.logview.gui.MessageDetailListener.java

public MessageDetailListener(JTable table, JTextPane logDetailTextArea, LogDataTableModel dataTableModel,
        SimpleDateFormat dateFormat, PluginableElementsContainer<MessageFormatter> formattersContainer,
        PluginableElementsContainer<MessageColorizer> colorizersContainer) {
    super();/*from ww w.j a va  2s.c om*/
    this.table = table;
    this.logDetailTextArea = logDetailTextArea;
    this.dataTableModel = dataTableModel;
    this.dateFormat = dateFormat;
    this.formattersContainer = formattersContainer;
    this.colorizersContainer = colorizersContainer;

    sc = new StyleContext();
    defaultStyle = sc.getStyle(StyleContext.DEFAULT_STYLE);
    mainStyle = sc.addStyle("MainStyle", defaultStyle);
    StyleConstants.setFontSize(mainStyle, 12);
    StyleConstants.setForeground(mainStyle, Color.BLACK);

    classMethodStyle = sc.addStyle("classMethod", null);
    StyleConstants.setFontFamily(classMethodStyle, "monospaced");
    StyleConstants.setForeground(classMethodStyle, Color.BLUE);
    noteStyle = sc.addStyle("note", mainStyle);
    StyleConstants.setFontFamily(noteStyle, "arial");
    StyleConstants.setBold(noteStyle, true);

    formattersContainer.addListener(new PluginableElementEventListenerImplementation<MessageFormatter>());
    colorizersContainer.addListener(new PluginableElementEventListenerImplementation<MessageColorizer>());
}

From source file:simplealbum.mvc.autocomplete.DController.java

void changeSeeker(Seeker seeker) {
    view.setTitle(seeker.getTitle());/*from  w ww  . j  a va2  s.c  om*/
    //        jTextPane.setText("");  TODO 
    model.emptyList();
    model.setSeeker(seeker);
    request();

    List<String> colors = seeker.getColors();
    styles = new Style[colors.size()];
    StyleContext sc = new StyleContext();
    for (int i = 0; i < colors.size(); i++) {
        styles[i] = sc.addStyle((String) colors.get(i), sc.getStyle(StyleContext.DEFAULT_STYLE));
        StyleConstants.setForeground(styles[i], ColorUtils.getColorByName(colors.get(i)));
        StyleConstants.setBold(styles[i], true);
    }
    colorInputText();

    filter = seeker.getFilter();
}

From source file:simplealbum.mvc.autocomplete.JTextPaneX.java

public JTextPaneX() {

    //Create the style array to show the colors 
    //        List<Object> colorList = CONFIGURATION.getList("ColorWord");
    List<Object> colorList = null;
    styles = new Style[colorList.size()];
    StyleContext sc = new StyleContext();
    for (int i = 0; i < colorList.size(); i++) {
        styles[i] = sc.addStyle((String) colorList.get(i), sc.getStyle(StyleContext.DEFAULT_STYLE));
        StyleConstants.setForeground(styles[i], ColorUtils.getColorByName((String) colorList.get(i)));
        StyleConstants.setBold(styles[i], true);
    }/*from ww w .j a va2 s  .c  o  m*/

    //Get the document for adding a document listener
    dsd = (DefaultStyledDocument) getDocument();
    dsd.addDocumentListener(new DocumentListenerTextPane());

    //...and setting a document filter
    documentFilter = new MyDocumentFilter();
    dsd.setDocumentFilter(documentFilter);
}

From source file:uk.ac.kcl.texthunter.core.AnnotationEditor.java

private void updateProjectSummary() {
    try {/*www. j a  v  a  2  s  . c  om*/
        projectXML.updateProjectSummary(con, targetTableName);
    } catch (java.sql.SQLException ex) {
        updateProjectStatus("Annotation table not ready");
    }
    StyledDocument doc;
    doc = projectSummaryTextPane.getStyledDocument();
    SimpleAttributeSet newString = new SimpleAttributeSet();
    StyleConstants.setForeground(newString, Color.BLACK);
    StyleConstants.setBold(newString, true);

    StringBuilder newText = new StringBuilder("\n");
    DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");
    Date date = new Date();

    newText.append("------ results updated on ").append(dateFormat.format(date)).append(" ------\n\n");
    newText.append("current project annotations:\n");
    newText = newText.append("Gold Standard Positive Annotations = ").append(projectXML.getGsPos())
            .append("\n");
    newText = newText.append("Gold Standard Negative Annotations = ").append(projectXML.getGsneg())
            .append("\n");
    newText = newText.append("Gold Standard Unknown Annotations = ").append(projectXML.getGsunk()).append("\n");
    newText = newText.append("Gold Standard Form Annotations = ").append(projectXML.getGsform()).append("\n");
    newText = newText.append("Seed positive Annotations = ").append(projectXML.getSeedpos()).append("\n");
    newText = newText.append("Seed Negative Annotations = ").append(projectXML.getSeedneg()).append("\n");
    newText = newText.append("Seed Unknown Annotations = ").append(projectXML.getSeedunk()).append("\n");
    newText = newText.append("Seed Form Annotations = ").append(projectXML.getSeedform()).append("\n");
    newText = newText.append("AL Positive Annotations = ").append(projectXML.getAlpos()).append("\n");
    newText = newText.append("AL Negative Annotations = ").append(projectXML.getAlneg()).append("\n");
    newText = newText.append("AL Form Annotations = ").append(projectXML.getAlform()).append("\n");
    newText = newText.append("AL Unknown Annotations = ").append(projectXML.getAlunk()).append("\n\n");

    newText = newText.append("Last Pipeline run results:\n");
    newText = newText.append("P = ").append(projectXML.getPrecision()).append("\n");
    newText = newText.append("R = ").append(projectXML.getRecall()).append("\n");
    newText = newText.append("F1 = ").append(projectXML.getF1()).append("\n");

    try {
        doc.insertString(doc.getLength(), "\n" + newText, newString);
    } catch (Exception e) {
        System.out.println(e);
    }
}