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


Java LineNumberFactory类代码示例

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


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

示例1: EditorPane

import org.fxmisc.richtext.LineNumberFactory; //导入依赖的package包/类
/**
 * <p>
 * Creates an editable EditorPane with the given code as initial source code text.
 * </p>
 *
 * @param code the string to initialize the {@link CodeArea} to
 * @param syntaxErrors the initial list of {@link SyntaxError}s.
 * @param showLineNumbers whether to show line numbers in the {@link CodeArea}
 */
public EditorPane(String code, ObservableList<SyntaxError> syntaxErrors,
    boolean showLineNumbers) {
  super();
  this.syntaxErrors = syntaxErrors;
  ViewUtils.setupView(this);

  codeArea = new CodeArea(code);
  lineNumberFactory = LineNumberFactory.get(codeArea);
  if (showLineNumbers) {
    codeArea.setParagraphGraphicFactory(this::createLinePrefixForLine);
  }
  this.getItems().addAll(codeArea);
  this.setOrientation(Orientation.VERTICAL);
  this.setDividerPositions(0.8);
}
 
开发者ID:VerifAPS,项目名称:stvs,代码行数:25,代码来源:EditorPane.java

示例2: initialize

import org.fxmisc.richtext.LineNumberFactory; //导入依赖的package包/类
@FXML
public void initialize() {
	findAndReplaceHelper = new CodeAreaFindAndReplaceHelper<>(txtLog);
	txtLog.addEventHandler(KeyEvent.KEY_PRESSED, this::txtLogOnKeyPress);
	this.isStared.addListener((oba, o, n) -> {

		Platform.runLater(() -> {
			if (n) {
				lblStatus.setText("Started");
				btnStart.setDisable(true);
			} else {
				lblStatus.setText("Stopped");
				btnStart.setDisable(false);
			}
		});

	});

	btnStart.setOnAction(ev -> {
		start();
	});

	txtLog.setParagraphGraphicFactory(LineNumberFactory.get(txtLog));

	createContextMenu();
}
 
开发者ID:callakrsos,项目名称:Gargoyle,代码行数:27,代码来源:LogViewController.java

示例3: initialize

import org.fxmisc.richtext.LineNumberFactory; //导入依赖的package包/类
@FXML private void initialize() {
    container.setCenter(vsPane);
    sourceText.getStylesheets().add(MainApp.class.getResource("css/editor.css").toExternalForm());
    sourceText.setStyle("-fx-font-family: \"" + MainApp.getConfig().getEditorFont() + "\";-fx-font-size: " + MainApp.getConfig().getEditorFontsize() + ";");

    if(MainApp.getConfig().isEditorLinenoView())
        sourceText.setParagraphGraphicFactory(LineNumberFactory.get(sourceText));

    if(MainApp.getConfig().isEditorRenderView()) {
        initRenderTask();
    } else {
        splitPane.getItems().remove(1);
    }

    Platform.runLater(sourceText::requestFocus);
}
 
开发者ID:firm1,项目名称:zest-writer,代码行数:17,代码来源:MdConvertController.java

示例4: JavaCodeArea

import org.fxmisc.richtext.LineNumberFactory; //导入依赖的package包/类
public JavaCodeArea() {
	EventHandlerHelper.install(this.onKeyPressedProperty(), tabHandler);
	executor = Executors.newSingleThreadExecutor();
	this.setParagraphGraphicFactory(LineNumberFactory.get(this));
	this.richChanges().filter(ch -> !ch.getInserted().equals(ch.getRemoved())) // XXX
			.successionEnds(Duration.ofMillis(250)).supplyTask(this::computeHighlightingAsync)
			.awaitLatest(this.richChanges()).filterMap(t -> {
				if (t.isSuccess()) {
					return Optional.of(t.get());
				} else {
					t.getFailure().printStackTrace();
					return Optional.empty();
				}
			}).subscribe(this::applyHighlighting);

	this.getStylesheets().add(this.getClass().getResource("java-keywords.css").toExternalForm());
}
 
开发者ID:ProPra16,项目名称:programmierpraktikum-abschlussprojekt-team-2,代码行数:18,代码来源:JavaCodeArea.java

示例5: AbstractRichTextCodeEditor

import org.fxmisc.richtext.LineNumberFactory; //导入依赖的package包/类
AbstractRichTextCodeEditor()
    {
        AnchorPane.setTopAnchor(codeArea, 0.0);
        AnchorPane.setLeftAnchor(codeArea, 0.0);
        AnchorPane.setBottomAnchor(codeArea, 0.0);
        AnchorPane.setRightAnchor(codeArea, 0.0);

        getChildren().add(codeArea);

        IntFunction<String> format = (digits -> " %" + digits + "d ");
/*        String stylesheet = AbstractRichTextCodeEditor.class.getResource("java-keywords.css").toExternalForm();     */
        IntFunction<Node> factory = LineNumberFactory.get(codeArea, format);
        codeArea.setParagraphGraphicFactory(factory);

        codeArea.textProperty().addListener((obs, oldText, newText) -> {
            codeArea.setStyleSpans(0, computeHighlighting(newText));
        });
        Platform.runLater(() -> {
            state.setValue(Worker.State.SUCCEEDED);
        });

        canUndo.bind(codeArea.getUndoManager().undoAvailableProperty());
        canRedo.bind(codeArea.getUndoManager().redoAvailableProperty());
        codeArea.fontProperty().set(Font.font("Source Code Pro", 14));
    }
 
开发者ID:finanzer,项目名称:epubfx,代码行数:26,代码来源:AbstractRichTextCodeEditor.java

示例6: start

import org.fxmisc.richtext.LineNumberFactory; //导入依赖的package包/类
@Override
  public void start(Stage primaryStage) {
      CodeArea codeArea = new CodeArea();
      codeArea.setParagraphGraphicFactory(LineNumberFactory.get(codeArea));

      codeArea.textProperty().addListener((obs, oldText, newText) -> {
          codeArea.setStyleSpans(0, computeHighlighting(newText));
      });
      codeArea.replaceText(0, 0, sampleCode);

Scene scene = new Scene(new StackPane(new VirtualizedScrollPane<>(codeArea)), 600, 400);
      scene.getStylesheets().add(XMLEditor.class.getResource("xml-highlighting.css").toExternalForm());
      primaryStage.setScene(scene);
      primaryStage.setTitle("XML Editor Demo");
      primaryStage.show();
  }
 
开发者ID:FXMisc,项目名称:RichTextFX,代码行数:17,代码来源:XMLEditor.java

示例7: start

import org.fxmisc.richtext.LineNumberFactory; //导入依赖的package包/类
@Override
public void start(Stage primaryStage) {
    CodeArea codeArea = new CodeArea();

    IntFunction<Node> numberFactory = LineNumberFactory.get(codeArea);
    IntFunction<Node> arrowFactory = new ArrowFactory(codeArea.currentParagraphProperty());
    IntFunction<Node> graphicFactory = line -> {
        HBox hbox = new HBox(
                numberFactory.apply(line),
                arrowFactory.apply(line));
        hbox.setAlignment(Pos.CENTER_LEFT);
        return hbox;
    };
    codeArea.setParagraphGraphicFactory(graphicFactory);
    codeArea.replaceText("The green arrow will only be on the line where the caret appears.\n\nTry it.");
    codeArea.moveTo(0, 0);

    primaryStage.setScene(new Scene(new StackPane(codeArea), 600, 400));
    primaryStage.show();
}
 
开发者ID:FXMisc,项目名称:RichTextFX,代码行数:21,代码来源:LineIndicatorDemo.java

示例8: start

import org.fxmisc.richtext.LineNumberFactory; //导入依赖的package包/类
@Override
public void start(Stage primaryStage) {
    CodeArea codeArea = new CodeArea();
    codeArea.setParagraphGraphicFactory(LineNumberFactory.get(codeArea));

    codeArea.richChanges()
            .filter(ch -> !ch.getInserted().equals(ch.getRemoved())) // XXX
            .subscribe(change -> {
                codeArea.setStyleSpans(0, computeHighlighting(codeArea.getText()));
            });
    codeArea.replaceText(0, 0, sampleCode);

    Scene scene = new Scene(new StackPane(new VirtualizedScrollPane<>(codeArea)), 600, 400);
    scene.getStylesheets().add(JavaKeywordsAsync.class.getResource("java-keywords.css").toExternalForm());
    primaryStage.setScene(scene);
    primaryStage.setTitle("Java Keywords Demo");
    primaryStage.show();
}
 
开发者ID:FXMisc,项目名称:RichTextFX,代码行数:19,代码来源:JavaKeywords.java

示例9: initialize

import org.fxmisc.richtext.LineNumberFactory; //导入依赖的package包/类
@Override
public void initialize(URL location, ResourceBundle resources) {
    editor.setParagraphGraphicFactory(LineNumberFactory.get(editor));
    documentManager = new FileManager();
    populateExamples();
    initSyntaxHighlighter();
    initUndoRedo();
    initCopyCutPaste();
    openExample();
    editor.getUndoManager().forgetHistory();
    initializeLibrary();
    Platform.runLater(editor::requestFocus);
}
 
开发者ID:aNNiMON,项目名称:HotaruFX,代码行数:14,代码来源:EditorController.java

示例10: CustomCodeArea

import org.fxmisc.richtext.LineNumberFactory; //导入依赖的package包/类
public CustomCodeArea(String text, Highlight highlight, Syntax syntax, String name) {
    executor = Executors.newSingleThreadExecutor();
    this.highlight = highlight;
    this.syntax = syntax;
    this.lastText = "";
    this.name = name;

    InputMap<Event> prevent = InputMap.consume(
            anyOf(
                    keyPressed(TAB, SHORTCUT_ANY, SHIFT_ANY)
            )
    );
    Nodes.addInputMap(this, prevent);

    this.setOnKeyPressed(event -> {
        if (event.getCode() == KeyCode.TAB) {
            this.insertText(this.getCaretPosition(), "    ");
        }
    });
    caretPosition = CaretPosition.create();
    this.caretPositionProperty().addListener(listener -> caretPosition.compute(this));
    this.setParagraphGraphicFactory(LineNumberFactory.get(this));
    this.richChanges()
            .filter(this::isChangeable)
            .successionEnds(Duration.ofMillis(20))
            .supplyTask(this::computeHighlightingAsync)
            .awaitLatest(this.richChanges())
            .filterMap(this::getOptional)
            .subscribe(this::applyHighlighting);
    this.replaceText(0, 0, text);
}
 
开发者ID:MrChebik,项目名称:Coconut-IDE,代码行数:32,代码来源:CustomCodeArea.java

示例11: CssEditor

import org.fxmisc.richtext.LineNumberFactory; //导入依赖的package包/类
public CssEditor() {
    getStylesheets().add(StyleController.class.getResource("/styles/code_area.css").toExternalForm());
    setParagraphGraphicFactory(LineNumberFactory.get(this));
    richChanges()
            .filter(ch -> !ch.getInserted().equals(ch.getRemoved())) // XXX
            .subscribe(change -> this.setStyleSpans(0, CSSFormatter.computeHighlighting(this.getText())));
}
 
开发者ID:EricCanull,项目名称:fxexperience2,代码行数:8,代码来源:CssEditor.java

示例12: FXMLTextArea

import org.fxmisc.richtext.LineNumberFactory; //导入依赖的package包/类
public FXMLTextArea() {
	codeArea = new CodeArea();
	codeArea.setParagraphGraphicFactory(LineNumberFactory.get(codeArea));

	codeArea.richChanges().subscribe(change -> {
		codeArea.setStyleSpans(0, computeHighlighting(codeArea.getText()));
	});

	codeArea.selectionProperty().addListener((oba, oldval, newval) -> {
		int start = newval.getStart();
		int end = newval.getEnd();
		int caretColumn = codeArea.getCaretColumn();

		String format = String.format("line : %d selectionStart : %d selectionEnd : %d column : %d  anchor : %d",
				codeArea.getCurrentParagraph() + 1, start + 1, end + 1, caretColumn + 1, codeArea.getAnchor());

		lblLineInfo.setText(format);
	});

	codeArea.setOnKeyPressed(this::codeAreaKeyClick);
	lblLineInfo.setPrefHeight(USE_COMPUTED_SIZE);
	lblLineInfo.setMinHeight(USE_COMPUTED_SIZE);
	lblLineInfo.setMaxHeight(USE_COMPUTED_SIZE);
	this.setCenter(codeArea);
	this.setBottom(lblLineInfo);
	// this.getChildren().add(codeArea);
	this.getStylesheets().add(FXMLTextArea.class.getResource("java-keywords.css").toExternalForm());

}
 
开发者ID:callakrsos,项目名称:Gargoyle,代码行数:30,代码来源:FXMLTextArea.java

示例13: tabContents

import org.fxmisc.richtext.LineNumberFactory; //导入依赖的package包/类
@Override
public List<KeyNode> tabContents() {
	CodeArea value = new CodeArea();
	value.setParagraphGraphicFactory(LineNumberFactory.get(value));

	WebView webView = new WebView();
	return Arrays.asList(new KeyNode("Text", value), new KeyNode("WebView", webView));
}
 
开发者ID:callakrsos,项目名称:Gargoyle,代码行数:9,代码来源:DefaultVelocityBinderComposite.java

示例14: TDDCodeArea

import org.fxmisc.richtext.LineNumberFactory; //导入依赖的package包/类
public TDDCodeArea(){
    super();
    this.setParagraphGraphicFactory(LineNumberFactory.get(this));

    this.richChanges()
            .filter(ch -> !ch.getInserted().equals(ch.getRemoved()))
            .subscribe(change -> {
                this.setStyleSpans(0, computeHighlighting(this.getText()));
            });

}
 
开发者ID:ProPra16,项目名称:programmierpraktikum-abschlussprojekt-amigos,代码行数:12,代码来源:TDDCodeArea.java

示例15: ScriptEditorView

import org.fxmisc.richtext.LineNumberFactory; //导入依赖的package包/类
public ScriptEditorView() {
    setParagraphGraphicFactory(LineNumberFactory.get(this));

    richChanges()
            .filter(ch -> !ch.getInserted().equals(ch.getRemoved())) // XXX
            .subscribe(change -> {
                setStyleSpans(0, computeHighlighting(getText()));
            });
}
 
开发者ID:AdrianBZG,项目名称:IEMLS,代码行数:10,代码来源:ScriptEditorView.java


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