当前位置: 首页>>代码示例>>Java>>正文


Java StyleSpansBuilder.create方法代码示例

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


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

示例1: computeHighlighting

import org.fxmisc.richtext.StyleSpansBuilder; //导入方法依赖的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();
}
 
开发者ID:ulriknyman,项目名称:H-Uppaal,代码行数:23,代码来源:ComponentPresentation.java

示例2: groupBackgroundColor

import org.fxmisc.richtext.StyleSpansBuilder; //导入方法依赖的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();
	}
 
开发者ID:callakrsos,项目名称:Gargoyle,代码行数:22,代码来源:SqlKeywords.java

示例3: computeHighlighting

import org.fxmisc.richtext.StyleSpansBuilder; //导入方法依赖的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();
}
 
开发者ID:gaste,项目名称:dwasp-gui,代码行数:26,代码来源:AspCore2Highlight.java

示例4: computeHighlighting

import org.fxmisc.richtext.StyleSpansBuilder; //导入方法依赖的package包/类
private static StyleSpans<Collection<String>> computeHighlighting(Grammar g, Map<String, String> styles, String text){
    System.out.println("Starting to compute highlighting");
    StyleSpansBuilder<Collection<String>> spansBuilder = new StyleSpansBuilder<>();

    if(text.length() > 0){
        LexerInterpreter lex = g.createLexerInterpreter(new ANTLRInputStream(text));
        CommonTokenStream tokenStream = new CommonTokenStream(lex);

        // parse
        int lastEnd = 0;
        for(Token t: lex.getAllTokens()){
            int spacer = t.getStartIndex() - lastEnd;
            if(spacer > 0) {
                spansBuilder.add(Collections.emptyList(), spacer);

                int gap = t.getText().length();
                spansBuilder.add(Collections.singleton(getStyleClass(lex,styles,t)), gap);
                lastEnd = t.getStopIndex() + 1;
            }
        }
    }else{
        spansBuilder.add(Collections.emptyList(), 0);
    }
    return spansBuilder.create();
}
 
开发者ID:jeffreyguenther,项目名称:Xanthic,代码行数:26,代码来源:SyntaxArea.java

示例5: computeHighlighting

import org.fxmisc.richtext.StyleSpansBuilder; //导入方法依赖的package包/类
private StyleSpans<Collection<String>> computeHighlighting(
        String sourcecode) {
    List<Token> tokens = new ArrayList<>();
    List<SyntaxError> syntaxErrors = new ArrayList<>();

    // Short-circuit setting parsed code properties on code, since we're in another thread.
    ParsedCode.parseCode(sourcecode, newTokens -> {
        tokens.addAll(newTokens);
        Platform.runLater(() -> code.tokensProperty().setAll(newTokens));
    }, synErrs -> {
        syntaxErrors.addAll(synErrs);
        Platform.runLater(
                () -> code.syntaxErrorsProperty().setAll(synErrs));
    }, parsedCode -> Platform
            .runLater(() -> code.parsedCodeProperty().set(parsedCode)));

    StyleSpansBuilder<Collection<String>> spansBuilder = new StyleSpansBuilder<>();

    if (tokens.isEmpty()) {
        spansBuilder.add(Collections.emptyList(), 0);
        return spansBuilder.create();
    }

    tokens.forEach(token ->
            // replaceAll is a work-around for a bug when ANTLR has a
            // different character count than this CodeArea.
            spansBuilder.add(getStyleClassesFor(token, syntaxErrors),
                    token.getText().replaceAll("\\r", "").length()));
    return spansBuilder.create();
}
 
开发者ID:VerifAPS,项目名称:stvs,代码行数:31,代码来源:EditorPaneController.java

示例6: computeHighlighting

import org.fxmisc.richtext.StyleSpansBuilder; //导入方法依赖的package包/类
private static StyleSpans<Collection<String>> computeHighlighting(String text) {
	StyleSpansBuilder<Collection<String>> spansBuilder = new StyleSpansBuilder<>();
	int lastTokenEnd = 0;
	ANTLRInputStream input = new ANTLRInputStream(text);
	HOGMLexer lexer = new HOGMLexer(input);
	CommonTokenStream tokens = new CommonTokenStream(lexer);
	tokens.fill();	
	for (int i = 0; i < tokens.size(); i++) {
		Token t = tokens.get(i);
		if (t.getType() == Token.EOF) {
			break;
		}			
		String styleClass;
		if (t.getType() == HOGMLexer.COMMENT || t.getType() == HOGMLexer.LINE_COMMENT) {
			styleClass = "hogmCodeComment";
		}
		else if (HOGMTerminalSymbols.isTerminalSymbol(t.getText())) {
			styleClass = "hogmCodeKeyword";
		}
		else {
			styleClass = "hogmCodeOther";
		}
		int spacing = t.getStartIndex() - lastTokenEnd;
		if (spacing > 0) {			
			spansBuilder.add(Collections.emptyList(), spacing);
		}
		int stylesize = (t.getStopIndex() - t.getStartIndex()) +1;			
		spansBuilder.add(Collections.singleton(styleClass), stylesize);
		lastTokenEnd = t.getStopIndex()+1;
	}
	
	return spansBuilder.create();
}
 
开发者ID:aic-sri-international,项目名称:aic-praise,代码行数:34,代码来源:HOGMCodeArea.java

示例7: computeHighlighting

import org.fxmisc.richtext.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:callakrsos,项目名称:Gargoyle,代码行数:47,代码来源:XMLEditor.java


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