• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java StyleSpansBuilder类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.fxmisc.richtext.model.StyleSpansBuilder的典型用法代码示例。如果您正苦于以下问题:Java StyleSpansBuilder类的具体用法?Java StyleSpansBuilder怎么用?Java StyleSpansBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



StyleSpansBuilder类属于org.fxmisc.richtext.model包,在下文中一共展示了StyleSpansBuilder类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: highlight

import org.fxmisc.richtext.model.StyleSpansBuilder; //导入依赖的package包/类
public StyleSpans<Collection<String>> highlight(String text) {
    Matcher matcher = PATTERN.matcher(text);
    int lastKeywordEnd = 0;
    StyleSpansBuilder<Collection<String>> spansBuilder = new StyleSpansBuilder<>();
    while(matcher.find()) {
        String styleClass
                = matcher.group("KEYWORD") != null ? "keyword"
                : matcher.group("STRING") != null ? "string"
                : matcher.group("COMMENT") != null ? "comment"
                : matcher.group("LABEL") != null ? "label"
                : null;
        spansBuilder.add(Collections.emptyList(), matcher.start() - lastKeywordEnd);
        spansBuilder.add(Collections.singleton(styleClass), matcher.end() - matcher.start());
        lastKeywordEnd = matcher.end();
    }
    if(lastKeywordEnd == 0) {
        return highlightMisspelled(text);
    }
    spansBuilder.add(Collections.emptyList(), text.length() - lastKeywordEnd);
    return spansBuilder.create();
}
 
开发者ID:kasirgalabs,项目名称:ETUmulator,代码行数:22,代码来源:SyntaxHighlighter.java


示例2: highlightMisspelled

import org.fxmisc.richtext.model.StyleSpansBuilder; //导入依赖的package包/类
private StyleSpans<Collection<String>> highlightMisspelled(String text) {
    StyleSpansBuilder<Collection<String>> spansBuilder = new StyleSpansBuilder<>();
    BreakIterator wb = BreakIterator.getWordInstance();
    wb.setText(text);
    int lastIndex = wb.first();
    int lastKeywordEnd = 0;
    while(lastIndex != BreakIterator.DONE) {
        int firstIndex = lastIndex;
        lastIndex = wb.next();
        if(lastIndex != BreakIterator.DONE
                && Character.isLetterOrDigit(text.charAt(firstIndex))) {
            String word = text.substring(firstIndex, lastIndex).toLowerCase();
            if(!dictionary.contains(word)) {
                spansBuilder.add(Collections.emptyList(), firstIndex - lastKeywordEnd);
                spansBuilder.add(Collections.singleton("underlined"), lastIndex - firstIndex);
                lastKeywordEnd = lastIndex;
            }
        }
    }
    spansBuilder.add(Collections.emptyList(), text.length() - lastKeywordEnd);
    return spansBuilder.create();
}
 
开发者ID:kasirgalabs,项目名称:ETUmulator,代码行数:23,代码来源:SyntaxHighlighter.java


示例3: computeHighlighting

import org.fxmisc.richtext.model.StyleSpansBuilder; //导入依赖的package包/类
public static StyleSpans<Collection<String>> computeHighlighting(String text, Pattern pattern) {
    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("DIGIT") != null ? "digit" :
                                                                matcher.group("STRING") != null ? "string" :
                                                                        matcher.group("COMMENT") != null ? "comment" :
                                                                                null; /* never happens */
        spansBuilder.add(Collections.emptyList(), matcher.start() - lastKwEnd);
        spansBuilder.add(Collections.singletonList(styleClass), matcher.end() - matcher.start());
        lastKwEnd = matcher.end();
    }
    spansBuilder.add(Collections.emptyList(), text.length() - lastKwEnd);
    return spansBuilder.create();
}
 
开发者ID:iazarny,项目名称:gitember,代码行数:24,代码来源:HighlightProvider.java


示例4: computeHighlighting

import org.fxmisc.richtext.model.StyleSpansBuilder; //导入依赖的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 = null;
		String s;
		if ((s = matcher.group("IDENTIFIER")) != null) {
			for (String command : ExpressionInterpreter.getSupportedCommands()) {
				if (s.equalsIgnoreCase(command)) {
					styleClass = "command";
					break;
				}
			}
			if (s.equals("_x")) {
				styleClass = "magic-var";
			}
		} else if (matcher.group("NUMBER") != null) {
			styleClass = "number";
		} else if (matcher.group("STRING") != null) {
			styleClass = "string";
		} else if (matcher.group("COMMENT") != null) {
			styleClass = "comment";
		}

		if (styleClass == null) {
			continue;
		}

		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();
}
 
开发者ID:kayler-renslow,项目名称:arma-dialog-creator,代码行数:38,代码来源:ExpressionEvaluatorPopup.java


示例5: computeHighlighting

import org.fxmisc.richtext.model.StyleSpansBuilder; //导入依赖的package包/类
private static StyleSpans<Collection<String>> computeHighlighting(String text) {
	text = text.replaceAll("%%", "__");//prevent matching %%1 or %%%%1. We can't remove the %% however because that would mess with the indexes
	Matcher matcher = PATTERN.matcher(text);
	int lastKwEnd = 0;
	StyleSpansBuilder<Collection<String>> spansBuilder = new StyleSpansBuilder<>();
	while (matcher.find()) {
		spansBuilder.add(Collections.emptyList(), matcher.start() - lastKwEnd);
		spansBuilder.add(Collections.singleton("param"), matcher.end() - matcher.start());
		lastKwEnd = matcher.end();
	}
	spansBuilder.add(Collections.emptyList(), text.length() - lastKwEnd);
	return spansBuilder.create();
}
 
开发者ID:kayler-renslow,项目名称:arma-dialog-creator,代码行数:14,代码来源:StringTableLanguageTokenEditor.java


示例6: computeHighlighting

import org.fxmisc.richtext.model.StyleSpansBuilder; //导入依赖的package包/类
private static StyleSpans<Collection<String>> computeHighlighting(String text) {
	StyleSpansBuilder<Collection<String>> spansBuilder = new StyleSpansBuilder<>();
	SyntaxHighlighter.highlight(text, "html", (length, style) -> {
		spansBuilder.add(toSpanStyle(style), length);
	});
	return spansBuilder.create();
}
 
开发者ID:JFormDesigner,项目名称:markdown-writer-fx,代码行数:8,代码来源:HtmlSourcePreview.java


示例7: computeHighlighting

import org.fxmisc.richtext.model.StyleSpansBuilder; //导入依赖的package包/类
private static StyleSpans<Collection<String>> computeHighlighting(String text) {
    Matcher matcher = XML_TAG.matcher(text);
    int lastKwEnd = 0;
    StyleSpansBuilder<Collection<String>> spansBuilder = new StyleSpansBuilder<>();
    while (matcher.find()) {
        spansBuilder.add(Collections.<String>emptyList(), matcher.start() - lastKwEnd);
        if (matcher.group("COMMENT") != null) {
            spansBuilder.add(Collections.singleton("comment"), matcher.end() - matcher.start());
        } else {
            if (matcher.group("ELEMENT") != null) {
                String attributesText = matcher.group(GROUP_ATTRIBUTES_SECTION);

                spansBuilder.add(Collections.singleton("tagmark"), matcher.end(GROUP_OPEN_BRACKET) - matcher.start(GROUP_OPEN_BRACKET));
                spansBuilder.add(Collections.singleton("anytag"), matcher.end(GROUP_ELEMENT_NAME) - matcher.end(GROUP_OPEN_BRACKET));

                if (!attributesText.isEmpty()) {
                    lastKwEnd = 0;

                    Matcher amatcher = ATTRIBUTES.matcher(attributesText);
                    while (amatcher.find()) {
                        spansBuilder.add(Collections.<String>emptyList(), amatcher.start() - lastKwEnd);
                        spansBuilder.add(Collections.singleton("attribute"), amatcher.end(GROUP_ATTRIBUTE_NAME) - amatcher.start(GROUP_ATTRIBUTE_NAME));
                        spansBuilder.add(Collections.singleton("tagmark"), amatcher.end(GROUP_EQUAL_SYMBOL) - amatcher.end(GROUP_ATTRIBUTE_NAME));
                        spansBuilder.add(Collections.singleton("avalue"), amatcher.end(GROUP_ATTRIBUTE_VALUE) - amatcher.end(GROUP_EQUAL_SYMBOL));
                        lastKwEnd = amatcher.end();
                    }
                    if (attributesText.length() > lastKwEnd)
                        spansBuilder.add(Collections.<String>emptyList(), attributesText.length() - lastKwEnd);
                }

                lastKwEnd = matcher.end(GROUP_ATTRIBUTES_SECTION);

                spansBuilder.add(Collections.singleton("tagmark"), matcher.end(GROUP_CLOSE_BRACKET) - lastKwEnd);
            }
        }
        lastKwEnd = matcher.end();
    }
    spansBuilder.add(Collections.<String>emptyList(), text.length() - lastKwEnd);
    return spansBuilder.create();
}
 
开发者ID:aalmiray,项目名称:bootstrapfx,代码行数:41,代码来源:XMLEditor.java


示例8: computeHighlighting

import org.fxmisc.richtext.model.StyleSpansBuilder; //导入依赖的package包/类
private static StyleSpans<Collection<String>> computeHighlighting(String text) {
    
    StyleSpansBuilder<Collection<String>> spansBuilder = new StyleSpansBuilder<>();
    
    BreakIterator wb = BreakIterator.getWordInstance();
    wb.setText(text);

    int lastIndex = wb.first();
    int lastKwEnd = 0;
    while(lastIndex != BreakIterator.DONE) {
        int firstIndex = lastIndex;
        lastIndex = wb.next();

        if (lastIndex != BreakIterator.DONE
            && Character.isLetterOrDigit(text.charAt(firstIndex))) {
            String word = text.substring(firstIndex, lastIndex).toLowerCase();
            if (!dictionary.contains(word)) {
                spansBuilder.add(Collections.emptyList(), firstIndex - lastKwEnd);
                spansBuilder.add(Collections.singleton("underlined"), lastIndex - firstIndex);
                lastKwEnd = lastIndex;
            }
            System.err.println();
        }
    }
    spansBuilder.add(Collections.emptyList(), text.length() - lastKwEnd);

    return spansBuilder.create();
}
 
开发者ID:FXMisc,项目名称:RichTextFX,代码行数:29,代码来源:SpellChecking.java


示例9: computeHighlightingByRegex

import org.fxmisc.richtext.model.StyleSpansBuilder; //导入依赖的package包/类
public static StyleSpans<Collection<String>> computeHighlightingByRegex(String text) {
  StyleSpansBuilder<Collection<String>> spansBuilder = new StyleSpansBuilder<Collection<String>>();
  Matcher cssMatcher = CSS_PATTERN.matcher(text);
  int lastKwEnd = 0;
  while (cssMatcher.find()) {
    spansBuilder.add(Collections.emptyList(), cssMatcher.start() - lastKwEnd);
    if (cssMatcher.group(Element.MUTI_COMMENT) != null) {
      spansBuilder.add(Collections.singleton(Element.MUTI_COMMENT), cssMatcher.end() - cssMatcher.start());
    } else {
      if (cssMatcher.group(Element.CSS) != null) {
        String selectorText = cssMatcher.group(GROUP_SELECTOR);
        if (!selectorText.isEmpty()) {
          lastKwEnd = 0;
          Matcher selectorMatcher = SELECTOR_PATTERN.matcher(selectorText);
          while (selectorMatcher.find()) {
            spansBuilder.add(Collections.emptyList(), selectorMatcher.start() - lastKwEnd);
            spansBuilder.add(Collections.emptyList(), selectorMatcher.end(1) - selectorMatcher.start(1));
            String prefix = selectorMatcher.group(1);
            List<String> list = new ArrayList<>();
            switch (prefix) {
            case "#":
              list.add(Element.SELECTOR_ID);
              break;
            case ".":
              list.add(Element.SELECTOR_CLASS);
              break;
            case ":":
              list.add(Element.SELECTOR_STATE);
              break;
            case " ":
            case "\n":
              list.add(Element.SELECTOR_JAVACLASS);
              break;
            }
            spansBuilder.add(list, selectorMatcher.end(2) - selectorMatcher.start(2));
            lastKwEnd = selectorMatcher.end();
          }
          if (selectorText.length() > lastKwEnd) {
            spansBuilder.add(Collections.emptyList(), selectorText.length() - lastKwEnd);
          }
        }
        spansBuilder.add(Collections.singleton(Element.LEFT_BRACE),
            cssMatcher.end(GROUP_LEFT_BRACE) - cssMatcher.start(GROUP_LEFT_BRACE));
        String entriesText = cssMatcher.group(GROUP_VALUES);
        if (!entriesText.isEmpty()) {
          lastKwEnd = 0;
          Matcher entryMatcher = ENTRY_PATTERN.matcher(entriesText);
          while (entryMatcher.find()) {
            spansBuilder.add(Collections.emptyList(), entryMatcher.start() - lastKwEnd);
            if (entryMatcher.group(Element.MUTI_COMMENT) != null) {
              spansBuilder
                  .add(Collections.singleton(Element.MUTI_COMMENT), entryMatcher.end() - entryMatcher.start());
            } else {
              if (entryMatcher.group(Element.ENTRY) != null) {
                spansBuilder.add(Collections.singleton(Element.KEY),
                    entryMatcher.end(GROUP_KEY) - entryMatcher.start(GROUP_KEY));
                spansBuilder.add(Collections.singleton(Element.COLON),
                    entryMatcher.end(GROPU_COLON) - entryMatcher.start(GROPU_COLON));
                spansBuilder.add(Collections.singleton(Element.VALUE),
                    entryMatcher.end(GROUP_VALUE) - entryMatcher.start(GROUP_VALUE));
                spansBuilder.add(Collections.singleton(Element.SEMICOLON),
                    entryMatcher.end(GROUP_SEMICOLON) - entryMatcher.start(GROUP_SEMICOLON));
              }
            }
            lastKwEnd = entryMatcher.end();
          }
          if (entriesText.length() > lastKwEnd) {
            spansBuilder.add(Collections.emptyList(), entriesText.length() - lastKwEnd);
          }
        }

        lastKwEnd = cssMatcher.end(GROUP_VALUES);

        spansBuilder.add(Collections.singleton(Element.RIGHT_BRACE), cssMatcher.end(GROUP_RIGHT_BRACE) - lastKwEnd);
      }
    }
    lastKwEnd = cssMatcher.end();
  }
  spansBuilder.add(Collections.emptyList(), text.length() - lastKwEnd);
  return spansBuilder.create();
}
 
开发者ID:XDean,项目名称:CSS-Editor-FX,代码行数:82,代码来源:CSSHighLight.java


示例10: computeHighlighting

import org.fxmisc.richtext.model.StyleSpansBuilder; //导入依赖的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()) {
		spansBuilder.add(Collections.emptyList(), matcher.start(GROUP_NODE_NAME) - lastKwEnd);
		spansBuilder.add(STYLE_NODE, groupLength(matcher, GROUP_NODE_NAME));

		String attributesText = matcher.group(GROUP_ATTRS);
		if(!attributesText.isEmpty()) {
			lastKwEnd = 0;

			Matcher amatcher = ATTRIBUTES.matcher(attributesText);
			while(amatcher.find()) {
				if (amatcher.start() > lastKwEnd)
					spansBuilder.add(Collections.emptyList(), amatcher.start() - lastKwEnd);

				Collection<String> style = null;
				int length = amatcher.end() - amatcher.start();
				if (amatcher.group(GROUP_ATTR_NAME) != null) {
					style = STYLE_ATTR_NAME;
					length--;
				} else if (amatcher.group(GROUP_ATTR_STRING) != null)
					style = STYLE_ATTR_VALUE;
				else if (amatcher.group(GROUP_ATTR_NUMBER) != null)
					style = STYLE_ATTR_VALUE;
				else if (amatcher.group(GROUP_ATTR_PUNCTATION) != null)
					style = STYLE_PUNCTATION;
				else
					style = Collections.emptyList();
				spansBuilder.add(style, length);
				if (style == STYLE_ATTR_NAME)
					spansBuilder.add(STYLE_PUNCTATION, 1);

				lastKwEnd = amatcher.end();
			}
			if(attributesText.length() > lastKwEnd)
				spansBuilder.add(Collections.emptyList(), attributesText.length() - lastKwEnd);
		}
		lastKwEnd = matcher.end();
	}
	spansBuilder.add(Collections.emptyList(), text.length() - lastKwEnd);
	return spansBuilder.create();
}
 
开发者ID:JFormDesigner,项目名称:markdown-writer-fx,代码行数:45,代码来源:ASTPreview.java


示例11: computeHighlighting

import org.fxmisc.richtext.model.StyleSpansBuilder; //导入依赖的package包/类
/**
 * Highlights tag marks, tags, comments and attributes of the XML text
 * 
 * @param text
 *          The XML text to be highlighted
 * @return A StyleSpans with the highlighted text.
 */
public static StyleSpans<Collection<String>> computeHighlighting(String text) {
  Matcher matcher = XML_TAG.matcher(text);
  int lastKwEnd = 0;
  StyleSpansBuilder<Collection<String>> spansBuilder = new StyleSpansBuilder<>();
  while (matcher.find()) {

    spansBuilder.add(Collections.emptyList(), matcher.start() - lastKwEnd);
    if (matcher.group("COMMENT") != null) {
      spansBuilder.add(Collections.singleton("comment"), matcher.end() - matcher.start());
    } else {
      if (matcher.group("ELEMENT") != null) {
        String attributesText = matcher.group(GROUP_ATTRIBUTES_SECTION);

        spansBuilder.add(Collections.singleton("tagmark"),
          matcher.end(GROUP_OPEN_BRACKET) - matcher.start(GROUP_OPEN_BRACKET));
        if (matcher.start(GROUP_NAMESPACE) != -1 && matcher.end(GROUP_NAMESPACE) != -1) {
          spansBuilder.add(Collections.singleton("namespace"),
            matcher.end(GROUP_NAMESPACE) - matcher.end(GROUP_OPEN_BRACKET));
          spansBuilder.add(Collections.singleton("anytag"),
            matcher.end(GROUP_ELEMENT_NAME) - matcher.end(GROUP_NAMESPACE));
        } else {
          spansBuilder.add(Collections.singleton("anytag"),
            matcher.end(GROUP_ELEMENT_NAME) - matcher.end(GROUP_OPEN_BRACKET));
        }

        if (!attributesText.isEmpty()) {

          lastKwEnd = 0;

          Matcher amatcher = ATTRIBUTES.matcher(attributesText);
          while (amatcher.find()) {
            spansBuilder.add(Collections.emptyList(), amatcher.start() - lastKwEnd);
            spansBuilder.add(Collections.singleton("attribute"),
              amatcher.end(GROUP_ATTRIBUTE_NAME) - amatcher.start(GROUP_ATTRIBUTE_NAME));
            spansBuilder.add(Collections.singleton("tagmark"),
              amatcher.end(GROUP_EQUAL_SYMBOL) - amatcher.end(GROUP_ATTRIBUTE_NAME));
            spansBuilder.add(Collections.singleton("avalue"),
              amatcher.end(GROUP_ATTRIBUTE_VALUE) - amatcher.end(GROUP_EQUAL_SYMBOL));
            lastKwEnd = amatcher.end();
          }
          if (attributesText.length() > lastKwEnd)
            spansBuilder.add(Collections.emptyList(), attributesText.length() - lastKwEnd);
        }

        lastKwEnd = matcher.end(GROUP_ATTRIBUTES_SECTION);

        spansBuilder.add(Collections.singleton("tagmark"), matcher.end(GROUP_CLOSE_BRACKET) - lastKwEnd);
      }
    }
    lastKwEnd = matcher.end();
  }
  spansBuilder.add(Collections.emptyList(), text.length() - lastKwEnd);
  return spansBuilder.create();
}
 
开发者ID:keeps,项目名称:roda-in,代码行数:62,代码来源:XMLEditor.java


示例12: computeHighlighting

import org.fxmisc.richtext.model.StyleSpansBuilder; //导入依赖的package包/类
private static StyleSpans<Collection<String>> computeHighlighting(String text) {
	
    Matcher matcher = XML_TAG.matcher(text);
    int lastKwEnd = 0;
    StyleSpansBuilder<Collection<String>> spansBuilder = new StyleSpansBuilder<>();
    while(matcher.find()) {
    	
    	spansBuilder.add(Collections.emptyList(), matcher.start() - lastKwEnd);
    	if(matcher.group("COMMENT") != null) {
    		spansBuilder.add(Collections.singleton("comment"), matcher.end() - matcher.start());
    	}
    	else {
    		if(matcher.group("ELEMENT") != null) {
    			String attributesText = matcher.group(GROUP_ATTRIBUTES_SECTION);
    			
    			spansBuilder.add(Collections.singleton("tagmark"), matcher.end(GROUP_OPEN_BRACKET) - matcher.start(GROUP_OPEN_BRACKET));
    			spansBuilder.add(Collections.singleton("anytag"), matcher.end(GROUP_ELEMENT_NAME) - matcher.end(GROUP_OPEN_BRACKET));

    			if(!attributesText.isEmpty()) {
    				
    				lastKwEnd = 0;
    				
    				Matcher amatcher = ATTRIBUTES.matcher(attributesText);
    				while(amatcher.find()) {
    					spansBuilder.add(Collections.emptyList(), amatcher.start() - lastKwEnd);
    					spansBuilder.add(Collections.singleton("attribute"), amatcher.end(GROUP_ATTRIBUTE_NAME) - amatcher.start(GROUP_ATTRIBUTE_NAME));
    					spansBuilder.add(Collections.singleton("tagmark"), amatcher.end(GROUP_EQUAL_SYMBOL) - amatcher.end(GROUP_ATTRIBUTE_NAME));
    					spansBuilder.add(Collections.singleton("avalue"), amatcher.end(GROUP_ATTRIBUTE_VALUE) - amatcher.end(GROUP_EQUAL_SYMBOL));
    					lastKwEnd = amatcher.end();
    				}
    				if(attributesText.length() > lastKwEnd)
    					spansBuilder.add(Collections.emptyList(), attributesText.length() - lastKwEnd);
    			}

    			lastKwEnd = matcher.end(GROUP_ATTRIBUTES_SECTION);
    			
    			spansBuilder.add(Collections.singleton("tagmark"), matcher.end(GROUP_CLOSE_BRACKET) - lastKwEnd);
    		}
    	}
        lastKwEnd = matcher.end();
    }
    spansBuilder.add(Collections.emptyList(), text.length() - lastKwEnd);
    return spansBuilder.create();
}
 
开发者ID:FXMisc,项目名称:RichTextFX,代码行数:45,代码来源:XMLEditor.java


示例13: computeHighlighting

import org.fxmisc.richtext.model.StyleSpansBuilder; //导入依赖的package包/类
@NotNull
private static StyleSpans<Collection<String>> computeHighlighting(@NotNull final String text) {

    final Matcher matcher = PATTERN.matcher(text);
    final StyleSpansBuilder<Collection<String>> spansBuilder = new StyleSpansBuilder<>();

    int lastKwEnd = 0;

    while (matcher.find()) {

        String styleClass = matcher.group("SEVERITY") != null ? "log-severity" : null;

        if (styleClass == null) {
            styleClass = matcher.group("FRAMEWORK") != null ? "log-framework" : null;
        }

        if (styleClass == null) {
            styleClass = matcher.group("CLASS") != null ? "log-class" : null;
        }

        spansBuilder.add(singleton("plain-code"), matcher.start() - lastKwEnd);
        spansBuilder.add(singleton(styleClass), matcher.end() - matcher.start());

        lastKwEnd = matcher.end();
    }

    spansBuilder.add(singleton("plain-code"), text.length() - lastKwEnd);

    return spansBuilder.create();
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:31,代码来源:LogView.java



注:本文中的org.fxmisc.richtext.model.StyleSpansBuilder类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ShuffleConsumerPlugin类代码示例发布时间:2022-05-22
下一篇:
Java OnMyLocationChangeListener类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap