本文整理汇总了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);
}
示例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();
}
示例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);
}
示例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());
}
示例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));
}
示例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();
}
示例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();
}
示例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();
}
示例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);
}
示例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);
}
示例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())));
}
示例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());
}
示例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));
}
示例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()));
});
}
示例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()));
});
}