Search in sources :

Example 56 with SimpleAttributeSet

use of javax.swing.text.SimpleAttributeSet in project omegat by omegat-org.

the class FontFallbackMarker method getAttributes.

private AttributeSet getAttributes(Font font) {
    MutableAttributeSet attrs = new SimpleAttributeSet();
    StyleConstants.setFontFamily(attrs, font.getFamily());
    StyleConstants.setFontSize(attrs, editorFont.getSize());
    return attrs;
}
Also used : SimpleAttributeSet(javax.swing.text.SimpleAttributeSet) MutableAttributeSet(javax.swing.text.MutableAttributeSet)

Example 57 with SimpleAttributeSet

use of javax.swing.text.SimpleAttributeSet in project omegat by omegat-org.

the class DefaultGlossaryRenderer method render.

@Override
public void render(GlossaryEntry entry, IRenderTarget<?> trg) {
    trg.append(entry.getSrcText(), SOURCE_ATTRIBUTES);
    trg.append(" = ");
    String[] targets = entry.getLocTerms(false);
    String[] comments = entry.getComments();
    boolean[] priorities = entry.getPriorities();
    String[] origins = entry.getOrigins(false);
    StringBuilder commentsBuf = new StringBuilder();
    for (int i = 0, commentIndex = 0; i < targets.length; i++) {
        if (i > 0 && targets[i].equals(targets[i - 1])) {
            if (!comments[i].equals("")) {
                commentsBuf.append("\n");
                commentsBuf.append(commentIndex);
                commentsBuf.append(". ");
                commentsBuf.append(comments[i]);
            }
            continue;
        }
        SimpleAttributeSet attrs = new SimpleAttributeSet(TARGET_ATTRIBUTES);
        if (i > 0) {
            trg.append(", ", attrs);
        }
        if (priorities[i]) {
            StyleConstants.setBold(attrs, true);
        }
        attrs.addAttribute(TooltipAttribute.ATTRIBUTE_KEY, new TooltipAttribute(origins[i]));
        trg.append(bracketEntry(targets[i]), attrs);
        commentIndex++;
        if (!comments[i].equals("")) {
            commentsBuf.append("\n");
            commentsBuf.append(commentIndex);
            commentsBuf.append(". ");
            commentsBuf.append(comments[i]);
        }
    }
    trg.append(commentsBuf.toString(), NOTES_ATTRIBUTES);
}
Also used : SimpleAttributeSet(javax.swing.text.SimpleAttributeSet) TooltipAttribute(org.omegat.util.gui.TooltipAttribute)

Aggregations

SimpleAttributeSet (javax.swing.text.SimpleAttributeSet)57 StyledDocument (javax.swing.text.StyledDocument)10 BadLocationException (javax.swing.text.BadLocationException)7 MutableAttributeSet (javax.swing.text.MutableAttributeSet)7 HTMLDocument (javax.swing.text.html.HTMLDocument)5 Color (java.awt.Color)3 AttributeSet (javax.swing.text.AttributeSet)3 View (javax.swing.text.View)3 HTML (javax.swing.text.html.HTML)3 User (lib.pircbot.User)3 Font (java.awt.Font)2 URL (java.net.URL)2 Matcher (java.util.regex.Matcher)2 Pattern (java.util.regex.Pattern)2 Document (javax.swing.text.Document)2 Test (org.junit.Test)2 TaskCallbackStatus (cbit.vcell.mapping.TaskCallbackMessage.TaskCallbackStatus)1 ColorSet (com.android.tools.sherpa.drawing.ColorSet)1 OpenFileDescriptor (com.intellij.openapi.fileEditor.OpenFileDescriptor)1 Project (com.intellij.openapi.project.Project)1