use of javax.swing.text.SimpleAttributeSet in project Botnak by Gocnak.
the class FaceManager method insertFaceMetadata.
private static void insertFaceMetadata(Face f, Map<Integer, Integer> ranges, Map<Integer, SimpleAttributeSet> rangeStyles, String regex, String object) {
boolean isFFZ = f instanceof FrankerFaceZ;
Pattern p = Pattern.compile(isFFZ ? f.getRegex() : regex);
Matcher m = p.matcher(object);
while (m.find() && !GUIMain.shutDown) {
int start = m.start();
int end = m.end() - 1;
if (!Utils.inRanges(start, ranges) && !Utils.inRanges(end, ranges)) {
ranges.put(start, end);
SimpleAttributeSet attrs = new SimpleAttributeSet();
attrs.addAttribute("faceinfo", f);
attrs.addAttribute(isFFZ ? "channel" : "regex", isFFZ ? regex : m.group());
insertFace(attrs, f.getFilePath());
attrs.addAttribute("start", start);
rangeStyles.put(start, attrs);
}
}
}
use of javax.swing.text.SimpleAttributeSet in project antlrworks by antlr.
the class DBInputProcessorToken method createTextAttributes.
public void createTextAttributes() {
attributeNonConsumed = new SimpleAttributeSet();
StyleConstants.setForeground(attributeNonConsumed, AWPrefs.getNonConsumedTokenColor());
attributeConsume = new SimpleAttributeSet();
StyleConstants.setForeground(attributeConsume, AWPrefs.getConsumedTokenColor());
attributeConsumeHidden = new SimpleAttributeSet();
StyleConstants.setForeground(attributeConsumeHidden, AWPrefs.getHiddenTokenColor());
attributeConsumeDead = new SimpleAttributeSet();
StyleConstants.setForeground(attributeConsumeDead, AWPrefs.getDeadTokenColor());
attributeLookahead = new SimpleAttributeSet();
StyleConstants.setForeground(attributeLookahead, AWPrefs.getLookaheadTokenColor());
StyleConstants.setItalic(attributeLookahead, true);
}
use of javax.swing.text.SimpleAttributeSet in project n2a by frothga.
the class TextPaneANSI method append.
public void append(String t) {
int count = t.length();
SimpleAttributeSet attributes = new SimpleAttributeSet();
for (int b = 0; b < count; b++) {
int e = t.indexOf(27, b);
if (e < 0) {
append(t.substring(b), attributes);
break;
}
// There is some text to append.
if (b < e)
append(t.substring(b, e), attributes);
// no more text left
if (e >= count)
break;
// Find end of escape sequence.
e++;
b = t.indexOf('m', e);
// escape sequence cut off by end of string
if (b < 0)
break;
// Does not include initial ESC or ending m.
String sequence = t.substring(e, b);
if (sequence.startsWith("[")) {
String[] codes = sequence.substring(1).split(";");
for (int i = 0; i < codes.length; i++) {
String code = codes[i];
switch(code) {
case "0":
attributes.removeAttributes(attributes);
break;
case "1":
attributes.addAttribute(StyleConstants.Bold, true);
break;
case "3":
attributes.addAttribute(StyleConstants.Italic, true);
break;
case "4":
attributes.addAttribute(StyleConstants.Underline, true);
break;
case "9":
attributes.addAttribute(StyleConstants.StrikeThrough, true);
break;
case "22":
attributes.removeAttribute(StyleConstants.Bold);
break;
case "23":
attributes.removeAttribute(StyleConstants.Italic);
break;
case "24":
attributes.removeAttribute(StyleConstants.Underline);
break;
case "29":
attributes.removeAttribute(StyleConstants.StrikeThrough);
break;
case "30":
attributes.addAttribute(StyleConstants.Foreground, Color.black);
break;
case "31":
attributes.addAttribute(StyleConstants.Foreground, Color.red);
break;
case "32":
attributes.addAttribute(StyleConstants.Foreground, Color.green);
break;
case "33":
attributes.addAttribute(StyleConstants.Foreground, yellow80);
break;
case "34":
attributes.addAttribute(StyleConstants.Foreground, Color.blue);
break;
case "35":
attributes.addAttribute(StyleConstants.Foreground, Color.magenta);
break;
case "36":
attributes.addAttribute(StyleConstants.Foreground, Color.cyan);
break;
case "37":
attributes.addAttribute(StyleConstants.Foreground, Color.white);
break;
case "38":
i++;
if (codes[i] == "2") {
i++;
Color c = interpretRGB(codes, i);
attributes.addAttribute(StyleConstants.Foreground, c);
i += 2;
} else if (codes[i] == "5") {
i++;
Color c = interpret256(codes[i]);
attributes.addAttribute(StyleConstants.Foreground, c);
}
break;
case "39":
attributes.removeAttribute(StyleConstants.Foreground);
break;
case "40":
attributes.addAttribute(StyleConstants.Background, Color.black);
break;
case "41":
attributes.addAttribute(StyleConstants.Background, Color.red);
break;
case "42":
attributes.addAttribute(StyleConstants.Background, Color.green);
break;
case "43":
attributes.addAttribute(StyleConstants.Background, Color.yellow);
break;
case "44":
attributes.addAttribute(StyleConstants.Background, Color.blue);
break;
case "45":
attributes.addAttribute(StyleConstants.Background, Color.magenta);
break;
case "46":
attributes.addAttribute(StyleConstants.Background, Color.cyan);
break;
case "47":
attributes.addAttribute(StyleConstants.Background, Color.white);
break;
case "48":
i++;
if (codes[i] == "2") {
i++;
Color c = interpretRGB(codes, i);
attributes.addAttribute(StyleConstants.Background, c);
i += 2;
} else if (codes[i] == "5") {
i++;
Color c = interpret256(codes[i]);
attributes.addAttribute(StyleConstants.Background, c);
}
break;
case "49":
attributes.removeAttribute(StyleConstants.Background);
break;
}
}
}
}
}
use of javax.swing.text.SimpleAttributeSet in project vcell by virtualcell.
the class SimulationConsolePanel method appendToConsole.
private void appendToConsole(TaskCallbackMessage newCallbackMessage) {
TaskCallbackStatus status = newCallbackMessage.getStatus();
String string = newCallbackMessage.getText();
StyledDocument doc = netGenConsoleText.getStyledDocument();
SimpleAttributeSet keyWord = new SimpleAttributeSet();
try {
switch(status) {
case // clean console, display task initialization message
Clean:
netGenConsoleText.setText("");
break;
case TaskStopped:
StyleConstants.setForeground(keyWord, Color.RED);
StyleConstants.setBold(keyWord, true);
doc.insertString(doc.getLength(), " " + string + "\n", keyWord);
break;
case // normal notification, just display the string
Notification:
doc.insertString(doc.getLength(), string + "\n", null);
break;
case // display this in red, bold
Error:
StyleConstants.setForeground(keyWord, Color.RED);
StyleConstants.setBold(keyWord, true);
doc.insertString(doc.getLength(), string + "\n", keyWord);
break;
case // display this in red
Warning:
StyleConstants.setForeground(keyWord, Color.RED);
doc.insertString(doc.getLength(), string + "\n", keyWord);
break;
default:
break;
}
} catch (Exception e) {
System.out.println(e);
}
}
use of javax.swing.text.SimpleAttributeSet in project omegat by omegat-org.
the class FontFallbackListener method getAttributes.
private AttributeSet getAttributes(Font font) {
MutableAttributeSet attrs = new SimpleAttributeSet();
StyleConstants.setFontFamily(attrs, font.getFamily());
StyleConstants.setFontSize(attrs, defaultFont.getSize());
return attrs;
}
Aggregations