package sample;import javafx.application.Application;import javafx.collections.ListChangeListener;import javafx.scene.Scene;import javafx.scene.control.TextArea;import javafx.scene.layout.BorderPane;import javafx.scene.layout.HBox;import javafx.stage.Stage;import java.util.ArrayList;public class Main extends Application {public static String getCurrentString(DfaState currentState) {String tempString = "";DfaState tempState = currentState;while (tempState.getParentState() != null) {tempString = (char) tempState.getParentInput() + tempString;tempState = tempState.getParentState();}return tempString;}@Overridepublic void start(Stage primaryStage) throws Exception {primaryStage.setTitle("Fuck Writing!!!");BorderPane borderPane = new BorderPane();HBox box = new HBox();DfaBuilder builder = new DfaBuilder();builder.setDfaCallBack((current, states) -> {System.out.println("current list " + getCurrentString(current));System.out.println("预测文本 =》");ArrayList<DfaState> list = new ArrayList<>();for (Integer key : states.keySet()) {states.get(key).returnEndList(list);}for (DfaState state : list) {System.out.println("prediction list " + getCurrentString(state));}});TextArea field = new TextArea();field.setPrefSize(500, 500);field.getParagraphs().addListener((ListChangeListener<CharSequence>) c -> {while (c.next()) {int size = c.getAddedSubList().get(0).length();// System.out.println(size);// System.out.println(c);if (size >= 1) {System.out.println(c.getAddedSubList().get(0).charAt(size - 1));builder.input(c.getAddedSubList().get(0).charAt(size - 1));}}});box.getChildren().addAll(field);borderPane.setCenter(box);Scene scene = new Scene(borderPane);primaryStage.setScene(scene);primaryStage.show();}public static void main(String[] args) {launch(args);}}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。