/
Shalva
/
Lab4_DataPipeline
Обзор
Документация
Войти
/
Shalva
/
Lab4_DataPipeline
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
src/main/java/gui/WindowApp.java
81 строка
3 KB
Kvaratskheliia Shalva
Исходный код к проекту Lab4_DataPipeline
14 июн 2026, 18:57
14 июн 2026, 18:57
ac72959
Код
Авторство
О чём код?
package gui; import core.DataProcessor; import javafx.application.Application; import javafx.geometry.Insets; import javafx.scene.Scene; import javafx.scene.control.*; import javafx.scene.layout.VBox; import javafx.stage.Stage; import java.util.Arrays; public class WindowApp extends Application { @Override public void start(Stage primaryStage) { primaryStage.setTitle("Лабораторная 4: Циклический сдвиг"); Label inputLabel = new Label("Введите числа через пробел или запятую:"); TextArea inputTextArea = new TextArea(" "); inputTextArea.setPrefHeight(80); inputTextArea.setWrapText(true); Label kLabel = new Label("Величина сдвига k:"); TextField kTextField = new TextField("3"); kTextField.setMaxWidth(80); Button processButton = new Button("Выполнить сдвиг"); processButton.setMaxWidth(Double.MAX_VALUE); Label outputLabel = new Label("Результат обработки (ListView):"); ListView<String> outputListView = new ListView<>(); processButton.setOnAction(event -> { outputListView.getItems().clear(); String rawText = inputTextArea.getText().trim(); String kText = kTextField.getText().trim(); if (rawText.isEmpty() || kText.isEmpty()) { outputListView.getItems().add("Ошибка: Поля ввода не должны быть пустыми!"); return; } String[] tokens = rawText.split("[\\s,;]+"); String[] pipelineInput = new String[tokens.length + 1]; System.arraycopy(tokens, 0, pipelineInput, 0, tokens.length); pipelineInput[pipelineInput.length - 1] = kText; try { String[] pipelineResult = DataProcessor.processPipeline(pipelineInput); if (pipelineResult.length == 0) { outputListView.getItems().add("Предупреждение: Конвейер вернул пустой результат. Проверьте корректность чисел."); } else { outputListView.getItems().addAll(Arrays.asList(pipelineResult)); } } catch (Exception e) { outputListView.getItems().add("Произошла непредвиденная ошибка: " + e.getMessage()); } }); VBox root = new VBox(10); root.setPadding(new Insets(15)); root.getChildren().addAll( inputLabel, inputTextArea, kLabel, kTextField, processButton, outputLabel, outputListView ); Scene scene = new Scene(root, 400, 450); primaryStage.setScene(scene); primaryStage.show(); } public static void main(String[] args) { launch(args); } }