本文整理汇总了Java中org.fxmisc.richtext.StyleSpans类的典型用法代码示例。如果您正苦于以下问题:Java StyleSpans类的具体用法?Java StyleSpans怎么用?Java StyleSpans使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
StyleSpans类属于org.fxmisc.richtext包,在下文中一共展示了StyleSpans类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: computeHighlighting
import org.fxmisc.richtext.StyleSpans; //导入依赖的package包/类
public static StyleSpans<Collection<String>> computeHighlighting(final String text) {
final Matcher matcher = UPPAAL.matcher(text);
int lastKwEnd = 0;
final StyleSpansBuilder<Collection<String>> spansBuilder = new StyleSpansBuilder<>();
while (matcher.find()) {
spansBuilder.add(Collections.emptyList(), matcher.start() - lastKwEnd);
if (matcher.group(1) != null) {
spansBuilder.add(Collections.singleton("uppaal-keyword"), matcher.end(1) - matcher.start(1));
} else if (matcher.group(2) != null) {
spansBuilder.add(Collections.singleton("c-keyword"), matcher.end(2) - matcher.start(2));
} else if (matcher.group(3) != null) {
spansBuilder.add(Collections.singleton("comment"), matcher.end(3) - matcher.start(3));
}
lastKwEnd = matcher.end();
}
spansBuilder.add(Collections.emptyList(), text.length() - lastKwEnd);
return spansBuilder.create();
}
示例2: computeHighlighting
import org.fxmisc.richtext.StyleSpans; //导入依赖的package包/类
private StyleSpans<Collection<String>> computeHighlighting(String text) {
Matcher matcher = PATTERN.matcher(text);
int lastKwEnd = 0;
StyleSpansBuilder<Collection<String>> spansBuilder = new StyleSpansBuilder<>();
while (matcher.find()) {
String styleClass = matcher.group("KEYWORD") != null ? "keyword"
: matcher.group("PAREN") != null ? "paren"
: matcher.group("BRACE") != null ? "brace"
: matcher.group("BRACKET") != null ? "bracket"
: matcher.group("SEMICOLON") != null ? "semicolon"
: matcher.group("STRING") != null ? "string"
: matcher.group("COMMENT") != null ? "comment" : null;
/* never happens */ assert styleClass != null;
spansBuilder.add(Collections.emptyList(), matcher.start() - lastKwEnd);
spansBuilder.add(Collections.singleton(styleClass), matcher.end() - matcher.start());
lastKwEnd = matcher.end();
}
spansBuilder.add(Collections.emptyList(), text.length() - lastKwEnd);
return spansBuilder.create();
}
示例3: computeHighlighting
import org.fxmisc.richtext.StyleSpans; //导入依赖的package包/类
private static StyleSpans<Collection<String>> computeHighlighting(String text) {
Matcher matcher = PATTERN.matcher(text);
int lastKwEnd = 0;
StyleSpansBuilder<Collection<String>> spansBuilder = new StyleSpansBuilder<>();
while (matcher.find()) {
String styleClass = matcher.group("KEYWORD") != null ? "keyword"
: matcher.group("PAREN") != null ? "paren"
: matcher.group("BRACE") != null ? "brace"
: matcher.group("BRACKET") != null ? "bracket"
: matcher.group("SEMICOLON") != null ? "semicolon"
: matcher.group("STRING") != null ? "string"
: matcher.group("COMMENT") != null ? "comment" : null;
/* never happens */ assert styleClass != null;
spansBuilder.add(Collections.emptyList(), matcher.start() - lastKwEnd);
spansBuilder.add(Collections.singleton(styleClass), matcher.end() - matcher.start());
lastKwEnd = matcher.end();
}
spansBuilder.add(Collections.emptyList(), text.length() - lastKwEnd);
return spansBuilder.create();
}
示例4: computeHighlighting
import org.fxmisc.richtext.StyleSpans; //导入依赖的package包/类
private static StyleSpans<Collection<String>> computeHighlighting(String text) {
Matcher matcher = PATTERN.matcher(text);
int lastKwEnd = 0;
StyleSpansBuilder<Collection<String>> spansBuilder = new StyleSpansBuilder<>();
while (matcher.find()) {
String styleClass = matcher.group("METHODPAREN") != null ? "method-paren"
: matcher.group("BRACE") != null ? "brace"
: matcher.group("BRACKET") != null ? "bracket"
: matcher.group("SEMICOLON") != null ? "semicolon"
: matcher.group("STRING") != null ? "string"
: matcher.group("COMMENT") != null ? "comment" : null;
/* never happens */ assert styleClass != null;
spansBuilder.add(Collections.emptyList(), matcher.start() - lastKwEnd);
spansBuilder.add(Collections.singleton(styleClass), matcher.end() - matcher.start());
lastKwEnd = matcher.end();
}
spansBuilder.add(Collections.emptyList(), text.length() - lastKwEnd);
return spansBuilder.create();
}
示例5: computeHighlighting
import org.fxmisc.richtext.StyleSpans; //导入依赖的package包/类
private static StyleSpans<Collection<String>> computeHighlighting(String text) {
Matcher matcher = PATTERN.matcher(text);
int lastKwEnd = 0;
StyleSpansBuilder<Collection<String>> spansBuilder = new StyleSpansBuilder<>();
while (matcher.find()) {
String styleClass = matcher.group("KEYWORD") != null ? "keyword"
: matcher.group("PAREN") != null ? "paren"
: matcher.group("BRACE") != null ? "brace"
: matcher.group("BRACKET") != null ? "bracket"
: matcher.group("SEMICOLON") != null ? "semicolon"
: matcher.group("STRING") != null ? "string"
: matcher.group("COMMENT") != null ? "comment" : null; /*
* never
* happens
*/
assert styleClass != null;
spansBuilder.add(Collections.emptyList(), matcher.start() - lastKwEnd);
spansBuilder.add(Collections.singleton(styleClass), matcher.end() - matcher.start());
lastKwEnd = matcher.end();
}
spansBuilder.add(Collections.emptyList(), text.length() - lastKwEnd);
return spansBuilder.create();
}
示例6: groupBackgroundColor
import org.fxmisc.richtext.StyleSpans; //导入依赖的package包/类
private static StyleSpans<Collection<String>> groupBackgroundColor(String text, int point) {
StyleSpansBuilder<Collection<String>> spansBuilder = new StyleSpansBuilder<>();
Pattern pattern = Pattern.compile("\\([^)]+\\)");
Matcher matcher = pattern.matcher(text);
int lastKwEnd = 0;
while (matcher.find()) {
String styleClass = "unGroup";
if (matcher.start() < point && matcher.end() > point) {
styleClass = "inGroup";
}
spansBuilder.add(Collections.emptyList(), matcher.start() - lastKwEnd);
spansBuilder.add(Collections.singleton(styleClass), matcher.end() - matcher.start());
lastKwEnd = matcher.end();
}
spansBuilder.add(Collections.emptyList(), text.length() - lastKwEnd);
return spansBuilder.create();
}
示例7: computeHighlighting
import org.fxmisc.richtext.StyleSpans; //导入依赖的package包/类
private static StyleSpans<Collection<String>> computeHighlighting(String text) {
Matcher matcher = PATTERN.matcher(text);
int lastKwEnd = 0;
StyleSpansBuilder<Collection<String>> spansBuilder
= new StyleSpansBuilder<>();
while(matcher.find()) {
String styleClass =
matcher.group("KEYWORD") != null ? "keyword" :
matcher.group("PAREN") != null ? "paren" :
matcher.group("BRACE") != null ? "brace" :
matcher.group("BRACKET") != null ? "bracket" :
matcher.group("SEMICOLON") != null ? "semicolon" :
matcher.group("STRING") != null ? "string" :
matcher.group("COMMENT") != null ? "comment" :
null; /* never happens */ assert styleClass != null;
spansBuilder.add(Collections.emptyList(), matcher.start() - lastKwEnd);
spansBuilder.add(Collections.singleton(styleClass), matcher.end() - matcher.start());
lastKwEnd = matcher.end();
}
spansBuilder.add(Collections.emptyList(), text.length() - lastKwEnd);
return spansBuilder.create();
}
示例8: computeHighlighting
import org.fxmisc.richtext.StyleSpans; //导入依赖的package包/类
private static StyleSpans<Collection<String>> computeHighlighting(String text) {
Matcher matcher = PATTERN.matcher(text);
int lastKwEnd = 0;
StyleSpansBuilder<Collection<String>> spansBuilder = new StyleSpansBuilder<>();
while (matcher.find()) {
String styleClass = matcher.group("KEYWORD") != null ? "keyword"
: matcher.group("PAREN") != null ? "paren"
: matcher.group("BRACE") != null ? "brace"
: matcher.group("BRACKET") != null ? "bracket"
: matcher.group("SEMICOLON") != null ? "semicolon"
: matcher.group("STRING") != null ? "string"
: matcher.group("ANNOTATION") != null ? "annotation"
: matcher.group("COMMENT") != null ? "comment"
: null;
/* never happens */ assert styleClass != null;
spansBuilder.add(Collections.emptyList(), matcher.start() - lastKwEnd);
spansBuilder.add(Collections.singleton(styleClass), matcher.end() - matcher.start());
lastKwEnd = matcher.end();
}
spansBuilder.add(Collections.emptyList(), text.length() - lastKwEnd);
return spansBuilder.create();
}
示例9: computeHighlighting
import org.fxmisc.richtext.StyleSpans; //导入依赖的package包/类
private static StyleSpans<Collection<String>> computeHighlighting(final String text) {
Matcher matcher = PATTERN.matcher(text);
int lastKwEnd = 0;
StyleSpansBuilder<Collection<String>> spansBuilder = new StyleSpansBuilder<>();
while (matcher.find()) {
String styleClass =
matcher.group("KEYWORD") != null ? "keyword" :
matcher.group("METHOD") != null ? "method" :
matcher.group("PAREN") != null ? "paren" :
matcher.group("BRACE") != null ? "brace" :
matcher.group("BRACKET") != null ? "bracket" :
matcher.group("SEMICOLON") != null ? "semicolon" :
matcher.group("TRIPLEQUOTES") != null ? "string" :
matcher.group("DOUBLEQUOTES") != null ? "string" :
matcher.group("SINGLEQUOTES") != null ? "string" :
matcher.group("COMMENT") != null ? "comment" :
null; /* never happens */
assert styleClass != null;
spansBuilder.add(Collections.emptyList(), matcher.start() - lastKwEnd);
spansBuilder.add(Collections.singleton(styleClass), matcher.end() - matcher.start());
lastKwEnd = matcher.end();
}
spansBuilder.add(Collections.emptyList(), text.length() - lastKwEnd);
return spansBuilder.create();
}
示例10: computeConsoleHighlighting
import org.fxmisc.richtext.StyleSpans; //导入依赖的package包/类
private static StyleSpans<Collection<String>> computeConsoleHighlighting(final String text) {
Matcher matcher = PATTERN_CONSOLE.matcher(text);
int lastKwEnd = 0;
StyleSpansBuilder<Collection<String>> spansBuilder = new StyleSpansBuilder<>();
while (matcher.find()) {
String styleClass =
matcher.group("ERROR") != null ? "error" :
matcher.group("WARN") != null ? "warning" :
null; /* never happens */
assert styleClass != null;
spansBuilder.add(Collections.emptyList(), matcher.start() - lastKwEnd);
spansBuilder.add(Collections.singleton(styleClass), matcher.end() - matcher.start());
lastKwEnd = matcher.end();
}
spansBuilder.add(Collections.emptyList(), text.length() - lastKwEnd);
return spansBuilder.create();
}
示例11: computeHighlighting
import org.fxmisc.richtext.StyleSpans; //导入依赖的package包/类
private static StyleSpans<Collection<String>> computeHighlighting(String text) {
Matcher matcher = PATTERN.matcher(text);
int lastKwEnd = 0;
StyleSpansBuilder<Collection<String>> spansBuilder
= new StyleSpansBuilder<>();
while (matcher.find()) {
String styleClass =
matcher.group("KEYWORD") != null ? "keyword" :
matcher.group("PAREN") != null ? "paren" :
matcher.group("BRACE") != null ? "brace" :
matcher.group("BRACKET") != null ? "bracket" :
matcher.group("SEMICOLON") != null ? "semicolon" :
matcher.group("STRING") != null ? "string" :
matcher.group("COMMENT") != null ? "comment" :
null; /* never happens */
assert styleClass != null;
spansBuilder.add(Collections.emptyList(), matcher.start() - lastKwEnd);
spansBuilder.add(Collections.singleton(styleClass), matcher.end() - matcher.start());
lastKwEnd = matcher.end();
}
spansBuilder.add(Collections.emptyList(), text.length() - lastKwEnd);
return spansBuilder.create();
}
示例12: compute
import org.fxmisc.richtext.StyleSpans; //导入依赖的package包/类
private static StyleSpans<Collection<String>> compute(String text) {
Matcher matcher = PATTERN.matcher(text);
int lastKwEnd = 0;
StyleSpansBuilder<Collection<String>> spansBuilder = new StyleSpansBuilder<>();
while (matcher.find()) {
String styleClass =
matcher.group("KEYWORD") != null ? "keyword" :
matcher.group("PAREN") != null ? "paren" :
matcher.group("BRACE") != null ? "brace" :
matcher.group("BRACKET") != null ? "bracket" :
matcher.group("SEMICOLON") != null ? "semicolon" :
matcher.group("STRING") != null ? "string" :
matcher.group("COMMENT") != null ? "comment" :
null; /* never happens */ assert styleClass != null;
spansBuilder.add(Collections.emptyList(), matcher.start() - lastKwEnd);
spansBuilder.add(Collections.singleton(styleClass), matcher.end() - matcher.start());
lastKwEnd = matcher.end();
}
spansBuilder.add(Collections.emptyList(), text.length() - lastKwEnd);
return spansBuilder.create();
}
示例13: computeHighlighting
import org.fxmisc.richtext.StyleSpans; //导入依赖的package包/类
public static StyleSpans<Collection<String>> computeHighlighting(String text) {
StyleSpansBuilder<Collection<String>> spansBuilder = new StyleSpansBuilder<>();
Matcher matcher = HIGHLIGHT_PATTERN.matcher(text);
int lastMatchEnd = 0;
while(matcher.find()) {
String styleClass =
matcher.group(GROUP_KEYWORD) != null ? CSS_KEYWORD :
matcher.group(GROUP_PAREN) != null ? CSS_PAREN :
matcher.group(GROUP_BRACE) != null ? CSS_BRACE :
matcher.group(GROUP_BRACKET) != null ? CSS_BRACKET :
matcher.group(GROUP_DOT) != null ? CSS_DOT :
matcher.group(GROUP_STRING) != null ? CSS_STRING :
matcher.group(GROUP_COMMENT) != null ? CSS_COMMENT :
null;
spansBuilder.add(new ArrayList<String>(), matcher.start() - lastMatchEnd);
spansBuilder.add(new ArrayList<String>(Arrays.asList(styleClass)), matcher.end() - matcher.start());
lastMatchEnd = matcher.end();
}
spansBuilder.add(new ArrayList<String>(), text.length() - lastMatchEnd);
return spansBuilder.create();
}
示例14: computeHighlighting
import org.fxmisc.richtext.StyleSpans; //导入依赖的package包/类
protected StyleSpans<Collection<String>> computeHighlighting(String text) {
Matcher matcher = PATTERN.matcher(text);
int lastKwEnd = 0;
StyleSpansBuilder<Collection<String>> spansBuilder
= new StyleSpansBuilder<>();
while(matcher.find()) {
String styleClass =
matcher.group("KEYWORD") != null ? "keyword" :
matcher.group("PAREN") != null ? "paren" :
matcher.group("BRACE") != null ? "brace" :
matcher.group("BRACKET") != null ? "bracket" :
matcher.group("SEMICOLON") != null ? "semicolon" :
matcher.group("STRING") != null ? "string" :
null; /* never happens */ assert styleClass != null;
spansBuilder.add(Collections.emptyList(), matcher.start() - lastKwEnd);
spansBuilder.add(Collections.singleton(styleClass), matcher.end() - matcher.start());
lastKwEnd = matcher.end();
}
spansBuilder.add(Collections.emptyList(), text.length() - lastKwEnd);
return spansBuilder.create();
}
示例15: computeHighlighting
import org.fxmisc.richtext.StyleSpans; //导入依赖的package包/类
private static StyleSpans<Collection<String>> computeHighlighting(String text) {
Matcher matcher = CodeAreaFinalValues.getPattern().matcher(text);
int lastKwEnd = 0;
StyleSpansBuilder<Collection<String>> spansBuilder
= new StyleSpansBuilder<>();
while(matcher.find()) {
String styleClass =
matcher.group("KEYWORD") != null ? "keyword" :
matcher.group("PRIMITIVE") != null ? "primitive" :
matcher.group("PAREN") != null ? "paren" :
matcher.group("BRACE") != null ? "brace" :
matcher.group("BRACKET") != null ? "bracket" :
matcher.group("SEMICOLON") != null ? "semicolon" :
matcher.group("STRING") != null ? "string" :
matcher.group("COMMENT") != null ? "comment" :
matcher.group("NUMBERS") != null ? "numbers" :
null; /* never happens */ assert styleClass != null;
spansBuilder.add(Collections.emptyList(), matcher.start() - lastKwEnd);
spansBuilder.add(Collections.singleton(styleClass), matcher.end() - matcher.start());
lastKwEnd = matcher.end();
}
spansBuilder.add(Collections.emptyList(), text.length() - lastKwEnd);
return spansBuilder.create();
}